4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
37 #include <sys/devpolicy.h>
38 #include <sys/modctl.h>
39 #include <sys/vnode.h>
42 static char *progname
;
44 static const priv_impl_info_t
*pi
;
48 fatalerr(const char *s
)
50 (void) fprintf(stderr
, "%s: %s: %s\n", progname
, s
, strerror(errno
));
58 (void) fprintf(stderr
, "%s: %s\n", progname
, s
);
64 printpolicy(const devplcysys_t
*ds
)
68 ss
= priv_set_to_str(DEVPLCYSYS_RDP(ds
, pi
), ',', PRIV_STR_SHORT
);
69 (void) printf("\t"DEVPLCY_TKN_RDP
"=%s\n", ss
);
71 ss
= priv_set_to_str(DEVPLCYSYS_WRP(ds
, pi
), ',', PRIV_STR_SHORT
);
72 (void) printf("\t"DEVPLCY_TKN_WRP
"=%s\n", ss
);
85 if (modctl(MODGETDEVPOLICY
, &nitems
, sz
, mem
) == 0 || errno
!= ENOMEM
)
86 fatalerr("modctl(MODGETDEVPOLICY)");
88 mem
= malloc(nitems
* sz
);
90 fatal("Out of memory");
92 if (modctl(MODGETDEVPOLICY
, &nitems
, sz
, mem
) != 0)
95 for (i
= 0; i
< nitems
; i
++) {
96 /* LINTED: alignment */
97 ds
= (devplcysys_t
*)(mem
+ i
* sz
);
99 (void) printf("DEFAULT");
101 if (modctl(MODGETNAME
, major
, sizeof (major
),
104 (void) printf("%s:", major
);
105 if (ds
->dps_minornm
[0] != '\0') {
106 (void) printf("%s", ds
->dps_minornm
);
108 /* (minor[-minor]) */
109 (void) printf("(%u", (uint_t
)ds
->dps_lomin
);
110 if (ds
->dps_lomin
!= ds
->dps_himin
)
112 (uint_t
)ds
->dps_himin
);
120 (void) putchar('\n');
126 getdevpolicy(const char *dev
)
133 fatal("Out of memory");
135 if (modctl(MODGETDEVPOLICYBYNAME
, sz
, ds
, dev
) != 0)
138 (void) printf("%s\n", dev
);
144 main(int argc
, char **argv
)
146 progname
= basename(argv
[0]);
148 if ((pi
= getprivimplinfo()) == NULL
)
149 fatalerr("getprivimplinfo");
151 sz
= DEVPLCYSYS_SZ(pi
);
158 while (*++argv
!= NULL
)