1 /* $NetBSD: lint.c,v 1.7 2008/12/28 01:23:46 christos Exp $ */
4 * Copyright (c) 2007 The NetBSD Foundation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
29 #if HAVE_NBTOOL_CONFIG_H
30 #include "nbtool_config.h"
41 printf("version\t%d\n", CONFIG_VERSION
);
42 printf("ident\t\"LINT_%s\"\n", conffile
);
43 printf("maxusers\t%d\n", defmaxusers
);
44 printf("config netbsdlint root on ?\n");
54 static struct opt_type
{
55 enum opt_types ot_type
;
57 struct hashtab
**ot_ht
;
59 { OT_FLAG
, "options", &opttab
},
60 { OT_PARAM
, "options", &opttab
},
61 { OT_FS
, "file-system", &fsopttab
},
65 do_emit_option(const char *name
, void *value
, void *v
)
67 struct nvlist
*nv
= value
;
68 const struct opt_type
*ot
= v
;
70 if (nv
->nv_flags
& NV_OBSOLETE
)
73 if (ht_lookup(*(ot
->ot_ht
), name
))
76 printf("%s\t%s", ot
->ot_name
, nv
->nv_name
);
77 if (ot
->ot_type
== OT_PARAM
) {
78 struct nvlist
*nv2
= ht_lookup(defoptlint
, nv
->nv_name
);
81 printf("=\"%s\"", nv2
->nv_str
? nv2
->nv_str
: "1");
93 (void)ht_enumerate(defflagtab
, do_emit_option
, &opt_types
[0]);
95 (void)ht_enumerate(defparamtab
, do_emit_option
, &opt_types
[1]);
97 (void)ht_enumerate(deffstab
, do_emit_option
, &opt_types
[2]);
102 do_emit_instances(struct devbase
*d
, struct attr
*at
)
104 struct nvlist
*nv
, *nv1
;
109 * d_isdef is used to check whether a deva has been seen or not,
110 * for there are devices that can be their own ancestor (e.g.
115 for (da
= d
->d_ahead
; da
!= NULL
; da
= da
->d_bsame
)
116 if (onlist(da
->d_atlist
, at
))
119 panic("do_emit_instances: no deva found for %s at %s",
120 d
->d_name
, at
->a_name
);
127 if (at
== NULL
&& !d
->d_ispseudo
&& d
->d_ihead
== NULL
)
128 printf("%s0\tat\troot\n", d
->d_name
);
129 else if (at
!= NULL
&& !d
->d_ispseudo
&& da
->d_ihead
== NULL
) {
130 printf("%s0\tat\t%s?", d
->d_name
, at
->a_name
);
132 for (nv
= at
->a_locs
; nv
!= NULL
; nv
= nv
->nv_next
) {
134 printf(" %s %c", nv
->nv_name
,
135 nv
->nv_str
? '?' : '0');
142 * Children attachments are found the same way as in the orphan
143 * detection code in main.c.
145 for (nv
= d
->d_attrs
; nv
!= NULL
; nv
= nv
->nv_next
) {
147 for (nv1
= a
->a_devs
; nv1
!= NULL
; nv1
= nv1
->nv_next
)
148 do_emit_instances(nv1
->nv_ptr
, a
);
154 emit_root_instance(const char *name
, void *value
, void *v
)
157 do_emit_instances((struct devbase
*)value
, NULL
);
164 emit_pseudo_instance(const char *name
, void *value
, void *v
)
166 struct devbase
*d
= value
;
168 if (d
->d_ispseudo
&& d
->d_ihead
== NULL
)
169 printf("pseudo-device\t%s\n", d
->d_name
);
177 (void)ht_enumerate(devroottab
, emit_root_instance
, NULL
);
179 (void)ht_enumerate(devbasetab
, emit_pseudo_instance
, NULL
);