NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: lib/39215: getdevmajor()/major() types don't match
The following reply was made to PR lib/39215; it has been noted by GNATS.
From: Matthias Drochner <M.Drochner%fz-juelich.de@localhost>
To: M.Drochner%fz-juelich.de@localhost
Cc: christos%zoulas.com@localhost (Christos Zoulas),
gnats-bugs%NetBSD.org@localhost,
lib-bug-people%NetBSD.org@localhost, gnats-admin%NetBSD.org@localhost,
netbsd-bugs%NetBSD.org@localhost, dholland%eecs.harvard.edu@localhost
Subject: Re: lib/39215: getdevmajor()/major() types don't match
Date: Tue, 12 Aug 2008 21:25:37 +0200
This is a multipart MIME message.
--==_Exmh_35676715813600
Content-Type: text/plain; charset=us-ascii
Here is the the current state. I've tried to remove assumptions
about signedness as I've found them, but did not test yet with
eg. unsigned devmajor_t.
M.Drochner%fz-juelich.de@localhost said:
> I just found that devmajor_t etc can't be typedefs but must be macros
> so that they can be #undef'd away in config(1) bootstrap
Alternatively, we could use "nbdevmajor_t" etc in config(1).
(Would help for the unlikely case that another OS typedefs
devmajor_t.)
best regards
Matthias
-------------------------------------------------------------------
-------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr. Harald Bolt,
Dr. Sebastian M. Schmidt
-------------------------------------------------------------------
-------------------------------------------------------------------
--==_Exmh_35676715813600
Content-Type: text/plain ; name="major.txt"; charset=us-ascii
Content-Description: major.txt
Content-Disposition: attachment; filename="major.txt"
============================================================
--- include/stdlib.h 88c992035e9fc9a987d6bbd51ed517126c84252c
+++ include/stdlib.h fd62f316416514ef631c061192e7564d189d1064
@@ -278,7 +278,7 @@ int dehumanize_number(const char *, int
int humanize_number(char *, size_t, int64_t, const char *, int, int);
int dehumanize_number(const char *, int64_t *);
-dev_t getdevmajor(const char *, mode_t);
+devmajor_t getdevmajor(const char *, mode_t);
int getloadavg(double [], int);
int getenv_r(const char *, char *, size_t);
============================================================
--- lib/libc/gen/devname.c fc188811536b897bb2cfaeefea452b85edef7fd4
+++ lib/libc/gen/devname.c 6715a1d6ed5a3bd178926defb34f3be414bfa31d
@@ -113,7 +113,8 @@ devname(dev, type)
DBT data, key;
DEVC *ptr, **pptr;
static DEVC **devtb = NULL;
- static dev_t pts = (dev_t)~1;
+ static devmajor_t pts;
+ static int pts_valid = 0;
if (!db && !failure &&
!(db = dbopen(_PATH_DEVDB, O_RDONLY, 0, DB_HASH, NULL))) {
@@ -165,9 +166,11 @@ devname(dev, type)
return (NULL);
ptr->valid = INVALID;
if (type == S_IFCHR) {
- if (pts == (dev_t)~1)
+ if (!pts_valid) {
pts = getdevmajor("pts", S_IFCHR);
- if (pts != (dev_t)~0 && major(dev) == pts) {
+ pts_valid = 1;
+ }
+ if (pts != NODEVMAJOR && major(dev) == pts) {
(void)snprintf(ptr->name, sizeof(ptr->name),
"%s%d", _PATH_DEV_PTS +
sizeof(_PATH_DEV) - 1, minor(dev));
============================================================
--- lib/libc/gen/getdevmajor.c 8d741a93bb4ddb0f918f7da5ef4c54b8c9d10141
+++ lib/libc/gen/getdevmajor.c 0c4e97f74e067d924f7aedd5ec379807c5e8d04f
@@ -51,13 +51,13 @@ __weak_alias(getdevmajor,_getdevmajor)
__weak_alias(getdevmajor,_getdevmajor)
#endif
-dev_t
+devmajor_t
getdevmajor(const char *name, mode_t type)
{
struct kinfo_drivers kd[200], *kdp = &kd[0];
int rc, i;
size_t sz = sizeof(kd);
- dev_t n = (dev_t)~0;
+ devmajor_t n = NODEVMAJOR;
if (type != S_IFCHR && type != S_IFBLK) {
errno = EINVAL;
============================================================
--- sys/dev/drm/drm_drv.c ab4a9f3002c65e5f69fa4c8426d4bcd26f09e2d1
+++ sys/dev/drm/drm_drv.c 836390e88fd8e0a1a288a20604f04f04a2b255c7
@@ -816,7 +816,7 @@ drm_modcmd(modcmd_t cmd, void *arg)
drm_modcmd(modcmd_t cmd, void *arg)
{
#ifdef _MODULE
- int bmajor = -1, cmajor = -1;
+ devmajor_t bmajor = NODEVMAJOR, cmajor = NODEVMAJOR;
switch (cmd) {
case MODULE_CMD_INIT:
============================================================
--- sys/dev/pud/pud.c 328c391308b125e7120a8232288d80eb3abad88d
+++ sys/dev/pud/pud.c 4d02d5dafa17888f9336fc5a5f32411232c1474f
@@ -175,7 +175,8 @@ pudconf_reg(struct pud_dev *pd, struct p
pudconf_reg(struct pud_dev *pd, struct pud_conf_reg *pcr)
{
struct bdevsw *bsw;
- int cmajor, bmajor, error;
+ devmajor_t cmajor, bmajor;
+ int error;
if (pcr->pm_version != (PUD_DEVELVERSION | PUD_VERSION)) {
printf("pud version mismatch %d vs %d\n",
@@ -189,7 +190,7 @@ pudconf_reg(struct pud_dev *pd, struct p
bmajor = cmajor;
} else {
bsw = NULL;
- bmajor = -1;
+ bmajor = NODEVMAJOR;
}
pcr->pm_devname[PUD_DEVNAME_MAX] = '\0';
============================================================
--- sys/dev/putter/putter.c 27da452f36a5019160196532d2fe25a0190fd7e2
+++ sys/dev/putter/putter.c ec16969417cbc2140e07e34bb6cb8662b0348de8
@@ -619,7 +619,7 @@ putter_modcmd(modcmd_t cmd, void *arg)
putter_modcmd(modcmd_t cmd, void *arg)
{
#ifdef _MODULE
- int bmajor = -1, cmajor = -1;
+ devmajor_t bmajor = NODEVMAJOR, cmajor = NODEVMAJOR;
switch (cmd) {
case MODULE_CMD_INIT:
============================================================
--- sys/kern/kern_lkm.c 7da372c15e3e54b03c8ce3e833d0bad896c8e5da
+++ sys/kern/kern_lkm.c 51e7ef76e4b60ae88d703f72e676cd8339c9b42c
@@ -815,8 +815,8 @@ _lkm_dev(struct lkm_table *lkmtp, int cm
case LKM_E_UNLOAD:
devsw_detach(args->lkm_bdev, args->lkm_cdev);
- args->lkm_bdevmaj = -1;
- args->lkm_cdevmaj = -1;
+ args->lkm_bdevmaj = NODEVMAJOR;
+ args->lkm_cdevmaj = NODEVMAJOR;
break;
case LKM_E_STAT: /* no special handling... */
============================================================
--- sys/kern/subr_devsw.c 46fe7b32c25f0587ee7703dcdb7dd8871a61ad9e
+++ sys/kern/subr_devsw.c 5c253b626e14162e48e4162002065a07bf555838
@@ -99,8 +99,8 @@ extern int max_bdevsws, max_cdevsws, max
extern const int sys_bdevsws, sys_cdevsws;
extern int max_bdevsws, max_cdevsws, max_devsw_convs;
-static int bdevsw_attach(const struct bdevsw *, int *);
-static int cdevsw_attach(const struct cdevsw *, int *);
+static int bdevsw_attach(const struct bdevsw *, devmajor_t *);
+static int cdevsw_attach(const struct cdevsw *, devmajor_t *);
static void devsw_detach_locked(const struct bdevsw *, const struct cdevsw *);
void
@@ -112,8 +112,9 @@ int
}
int
-devsw_attach(const char *devname, const struct bdevsw *bdev, int *bmajor,
- const struct cdevsw *cdev, int *cmajor)
+devsw_attach(const char *devname,
+ const struct bdevsw *bdev, devmajor_t *bmajor,
+ const struct cdevsw *cdev, devmajor_t *cmajor)
{
struct devsw_conv *conv;
char *name;
@@ -213,10 +214,11 @@ static int
}
static int
-bdevsw_attach(const struct bdevsw *devsw, int *devmajor)
+bdevsw_attach(const struct bdevsw *devsw, devmajor_t *devmajor)
{
const struct bdevsw **newptr;
- int bmajor, i;
+ devmajor_t bmajor;
+ int i;
KASSERT(mutex_owned(&specfs_lock));
@@ -262,10 +264,11 @@ static int
}
static int
-cdevsw_attach(const struct cdevsw *devsw, int *devmajor)
+cdevsw_attach(const struct cdevsw *devsw, devmajor_t *devmajor)
{
const struct cdevsw **newptr;
- int cmajor, i;
+ devmajor_t cmajor;
+ int i;
KASSERT(mutex_owned(&specfs_lock));
@@ -350,7 +353,7 @@ bdevsw_lookup(dev_t dev)
const struct bdevsw *
bdevsw_lookup(dev_t dev)
{
- int bmajor;
+ devmajor_t bmajor;
if (dev == NODEV)
return (NULL);
@@ -369,7 +372,7 @@ cdevsw_lookup(dev_t dev)
const struct cdevsw *
cdevsw_lookup(dev_t dev)
{
- int cmajor;
+ devmajor_t cmajor;
if (dev == NODEV)
return (NULL);
@@ -386,17 +389,17 @@ cdevsw_lookup(dev_t dev)
* => Caller must ensure that the device is not detached, and therefore
* that the returned major is still valid when dereferenced.
*/
-int
+devmajor_t
bdevsw_lookup_major(const struct bdevsw *bdev)
{
- int bmajor;
+ devmajor_t bmajor;
for (bmajor = 0 ; bmajor < max_bdevsws ; bmajor++) {
if (bdevsw[bmajor] == bdev)
return (bmajor);
}
- return (-1);
+ return (NODEVMAJOR);
}
/*
@@ -405,17 +408,17 @@ bdevsw_lookup_major(const struct bdevsw
* => Caller must ensure that the device is not detached, and therefore
* that the returned major is still valid when dereferenced.
*/
-int
+devmajor_t
cdevsw_lookup_major(const struct cdevsw *cdev)
{
- int cmajor;
+ devmajor_t cmajor;
for (cmajor = 0 ; cmajor < max_cdevsws ; cmajor++) {
if (cdevsw[cmajor] == cdev)
return (cmajor);
}
- return (-1);
+ return (NODEVMAJOR);
}
/*
@@ -425,10 +428,11 @@ const char *
* that the name pointer is still valid when dereferenced.
*/
const char *
-devsw_blk2name(int bmajor)
+devsw_blk2name(devmajor_t bmajor)
{
const char *name;
- int cmajor, i;
+ devmajor_t cmajor;
+ int i;
name = NULL;
cmajor = -1;
@@ -457,14 +461,15 @@ devsw_blk2name(int bmajor)
* => Caller must ensure that the device is not detached, and therefore
* that the major number is still valid when dereferenced.
*/
-int
+devmajor_t
devsw_name2blk(const char *name, char *devname, size_t devnamelen)
{
struct devsw_conv *conv;
- int bmajor, i;
+ devmajor_t bmajor;
+ int i;
if (name == NULL)
- return (-1);
+ return (NODEVMAJOR);
mutex_enter(&specfs_lock);
for (i = 0 ; i < max_devsw_convs ; i++) {
@@ -495,7 +500,7 @@ devsw_name2blk(const char *name, char *d
}
mutex_exit(&specfs_lock);
- return (-1);
+ return (NODEVMAJOR);
}
/*
@@ -504,14 +509,15 @@ devsw_name2blk(const char *name, char *d
* => Caller must ensure that the device is not detached, and therefore
* that the major number is still valid when dereferenced.
*/
-int
+devmajor_t
devsw_name2chr(const char *name, char *devname, size_t devnamelen)
{
struct devsw_conv *conv;
- int cmajor, i;
+ devmajor_t cmajor;
+ int i;
if (name == NULL)
- return (-1);
+ return (NODEVMAJOR);
mutex_enter(&specfs_lock);
for (i = 0 ; i < max_devsw_convs ; i++) {
@@ -542,7 +548,7 @@ devsw_name2chr(const char *name, char *d
}
mutex_exit(&specfs_lock);
- return (-1);
+ return (NODEVMAJOR);
}
/*
@@ -554,11 +560,12 @@ devsw_chr2blk(dev_t cdev)
dev_t
devsw_chr2blk(dev_t cdev)
{
- int bmajor, cmajor, i;
+ devmajor_t bmajor, cmajor;
+ int i;
dev_t rv;
cmajor = major(cdev);
- bmajor = -1;
+ bmajor = NODEVMAJOR;
rv = NODEV;
mutex_enter(&specfs_lock);
@@ -588,11 +595,12 @@ devsw_blk2chr(dev_t bdev)
dev_t
devsw_blk2chr(dev_t bdev)
{
- int bmajor, cmajor, i;
+ devmajor_t bmajor, cmajor;
+ int i;
dev_t rv;
bmajor = major(bdev);
- cmajor = -1;
+ cmajor = NODEVMAJOR;
rv = NODEV;
mutex_enter(&specfs_lock);
============================================================
--- sys/rump/librump/rumpkern/emul.c 118414bfe2ea421ef3558f8d555595c4d684d7b6
+++ sys/rump/librump/rumpkern/emul.c abb62a4bc7d5d28c67fd3ff14fb9fd0c6430d700
@@ -606,8 +606,9 @@ int
}
int
-devsw_attach(const char *devname, const struct bdevsw *bdev, int *bmajor,
- const struct cdevsw *cdev, int *cmajor)
+devsw_attach(const char *devname,
+ const struct bdevsw *bdev, devmajor_t *bmajor,
+ const struct cdevsw *cdev, devmajor_t *cmajor)
{
panic("%s: not implemented", __func__);
============================================================
--- sys/sys/conf.h 9f05263f4a8dca129073ed13d7ec642ca0282bd4
+++ sys/sys/conf.h ef42f81b6f1a9e31c85343075490e854ed5d4cb2
@@ -94,13 +94,13 @@ struct cdevsw {
#ifdef _KERNEL
-int devsw_attach(const char *, const struct bdevsw *, int *,
- const struct cdevsw *, int *);
+int devsw_attach(const char *, const struct bdevsw *, devmajor_t *,
+ const struct cdevsw *, devmajor_t *);
int devsw_detach(const struct bdevsw *, const struct cdevsw *);
const struct bdevsw *bdevsw_lookup(dev_t);
const struct cdevsw *cdevsw_lookup(dev_t);
-int bdevsw_lookup_major(const struct bdevsw *);
-int cdevsw_lookup_major(const struct cdevsw *);
+devmajor_t bdevsw_lookup_major(const struct bdevsw *);
+devmajor_t cdevsw_lookup_major(const struct cdevsw *);
#define dev_type_open(n) int n (dev_t, int, int, struct lwp *)
#define dev_type_close(n) int n (dev_t, int, int, struct lwp *)
@@ -228,15 +228,15 @@ struct devsw_conv {
struct devsw_conv {
const char *d_name;
- int d_bmajor;
- int d_cmajor;
+ devmajor_t d_bmajor;
+ devmajor_t d_cmajor;
};
#ifdef _KERNEL
void devsw_init(void);
-const char *devsw_blk2name(int);
-int devsw_name2blk(const char *, char *, size_t);
-int devsw_name2chr(const char *, char *, size_t);
+const char *devsw_blk2name(devmajor_t);
+devmajor_t devsw_name2blk(const char *, char *, size_t);
+devmajor_t devsw_name2chr(const char *, char *, size_t);
dev_t devsw_chr2blk(dev_t);
dev_t devsw_blk2chr(dev_t);
#endif /* _KERNEL */
============================================================
--- sys/sys/lkm.h 6597d155f42f6c77319327957b06a3bbaace2ecb
+++ sys/sys/lkm.h a1fcead5171777292c5375bf24fe169b0c56b7c2
@@ -116,9 +116,9 @@ struct lkm_dev {
struct lkm_any mod;
const char *lkm_devname;
const struct bdevsw *lkm_bdev;
- int lkm_bdevmaj;
+ devmajor_t lkm_bdevmaj;
const struct cdevsw *lkm_cdev;
- int lkm_cdevmaj;
+ devmajor_t lkm_cdevmaj;
};
#ifdef STREAMS
============================================================
--- sys/sys/sysctl.h 70cfbed5be95f2268ab2be24dcb86c4304733797
+++ sys/sys/sysctl.h 12c5dd129939eeec3eb419d3dccd8072c2792911
@@ -711,8 +711,8 @@ struct kinfo_drivers {
*/
struct kinfo_drivers {
- int32_t d_cmajor;
- int32_t d_bmajor;
+ devmajor_t d_cmajor;
+ devmajor_t d_bmajor;
char d_name[24];
};
============================================================
--- sys/sys/types.h 503eb280f263bd5991da2f1e0ce5b8461173217c
+++ sys/sys/types.h 44a3ae84df879360a78cf769ea9b203d94c7526a
@@ -258,8 +258,12 @@ __END_DECLS
#if defined(_NETBSD_SOURCE)
/* Major, minor numbers, dev_t's. */
-#define major(x) ((int32_t)((((x) & 0x000fff00) >> 8)))
-#define minor(x) ((int32_t)((((x) & 0xfff00000) >> 12) | \
+typedef int32_t __devmajor_t, __devminor_t;
+#define devmajor_t __devmajor_t
+#define devminor_t __devminor_t
+#define NODEVMAJOR (-1)
+#define major(x) ((devmajor_t)((((x) & 0x000fff00) >> 8)))
+#define minor(x) ((devminor_t)((((x) & 0xfff00000) >> 12) | \
(((x) & 0x000000ff) >> 0)))
#define makedev(x,y) ((dev_t)((((x) << 8) & 0x000fff00) | \
(((y) << 12) & 0xfff00000) | \
============================================================
--- usr.bin/config/defs.h 5f055d676d1a7aa0d94facb2adbd28a9342961d4
+++ usr.bin/config/defs.h 18cfb7554250021bdb9c567f47cc57fc8fc86658
@@ -71,14 +71,20 @@
#ifdef MAKE_BOOTSTRAP
#undef dev_t
+#undef devmajor_t
+#undef devminor_t
#undef NODEV
+#undef NODEVMAJOR
#undef major
#undef minor
#undef makedev
-#define dev_t int /* XXX: assumes int is 32 bits
*/
+#define dev_t unsigned int /* XXX: assumes int is 32 bits
*/
#define NODEV ((dev_t)-1)
-#define major(x) ((int)((((x) & 0x000fff00) >> 8)))
-#define minor(x) ((int)((((x) & 0xfff00000) >> 12) | \
+#define devmajor_t int
+#define devminor_t int
+#define NODEVMAJOR (-1)
+#define major(x) ((devmajor_t)((((x) & 0x000fff00) >> 8)))
+#define minor(x) ((devminor_t)((((x) & 0xfff00000) >> 12) | \
(((x) & 0x000000ff) >> 0)))
#define makedev(x,y) ((dev_t)((((x) << 8) & 0x000fff00) | \
(((y) << 12) & 0xfff00000) | \
@@ -200,7 +206,7 @@ struct devbase {
TAILQ_ENTRY(devbase) d_next;
int d_isdef; /* set once properly defined */
int d_ispseudo; /* is a pseudo-device */
- int d_major; /* used for "root on sd0", e.g. */
+ devmajor_t d_major; /* used for "root on sd0", e.g. */
struct nvlist *d_attrs; /* attributes, if any */
int d_umax; /* highest unit number + 1 */
struct devi *d_ihead; /* first instance, if any */
@@ -361,8 +367,8 @@ struct devm {
const char *dm_srcfile; /* the name of the "majors" file */
u_short dm_srcline; /* the line number */
const char *dm_name; /* [bc]devsw name */
- int dm_cmajor; /* character major */
- int dm_bmajor; /* block major */
+ devmajor_t dm_cmajor; /* character major */
+ devmajor_t dm_bmajor; /* block major */
struct nvlist *dm_opts; /* options */
};
@@ -425,8 +431,8 @@ int npspecs; /* number of
parent specs
TAILQ_HEAD(, pspec) allpspecs; /* list of all parent specs */
int ndevi; /* number of devi's (before packing) */
int npspecs; /* number of parent specs */
-int maxbdevm; /* max number of block major */
-int maxcdevm; /* max number of character major */
+devmajor_t maxbdevm; /* max number of block major */
+devmajor_t maxcdevm; /* max number of character major */
int do_devsw; /* 0 if pre-devsw config */
int oktopackage; /* 0 before setmachine() */
int devilevel; /* used for devi->i_level */
============================================================
--- usr.bin/config/files.c bd7434eaff97e08a66183cfab434a6350bdcb729
+++ usr.bin/config/files.c 13f2bceb2d23c9b6c4841a4cbee76f392a350561
@@ -382,7 +382,7 @@ fixdevsw(void)
!expr_eval(dm->dm_opts, fixsel, NULL))
continue;
- if (dm->dm_cmajor != -1) {
+ if (dm->dm_cmajor != NODEVMAJOR) {
if (ht_lookup(cdevmtab, intern(dm->dm_name)) != NULL) {
cfgxerror(dm->dm_srcfile, dm->dm_srcline,
"device-major of character device '%s' "
@@ -404,7 +404,7 @@ fixdevsw(void)
dm->dm_name, dm->dm_cmajor);
}
}
- if (dm->dm_bmajor != -1) {
+ if (dm->dm_bmajor != NODEVMAJOR) {
if (ht_lookup(bdevmtab, intern(dm->dm_name)) != NULL) {
cfgxerror(dm->dm_srcfile, dm->dm_srcline,
"device-major of block device '%s' "
============================================================
--- usr.bin/config/mkdevsw.c 5eda55ccebd2f1ae8bd8e728841d25cd73f54bea
+++ usr.bin/config/mkdevsw.c 925b3718076f6bb396f794ba547284377d844d23
@@ -96,7 +96,7 @@ emitdevm(FILE *fp)
{
struct devm *dm;
char mstr[16];
- int i;
+ devmajor_t i;
fputs("\n/* device switch table for block device */\n", fp);
============================================================
--- usr.bin/config/mkioconf.c 9baee5cfb7fe232afde814522db329707fdef78a
+++ usr.bin/config/mkioconf.c 85ca469e14e845a26a0875112556e819a4cd2e04
@@ -486,7 +486,7 @@ emitname2blk(FILE *fp)
fprintf(fp, "struct devnametobdevmaj dev_name2blk[] = {\n");
TAILQ_FOREACH(dev, &allbases, d_next) {
- if (dev->d_major == NODEV)
+ if (dev->d_major == NODEVMAJOR)
continue;
fprintf(fp, "\t{ \"%s\", %d },\n",
============================================================
--- usr.bin/config/sem.c b5726e2cd90dade9a42096cfbff203fdb2e1ee1c
+++ usr.bin/config/sem.c 23d1f09910d86bf4b0eeff668d4622ac92cc79b5
@@ -84,8 +84,8 @@ static const char *makedevstr(int, int);
static void selectbase(struct devbase *, struct deva *);
static const char **fixloc(const char *, struct attr *, struct nvlist *);
static const char *makedevstr(int, int);
-static const char *major2name(int);
-static int dev2major(struct devbase *);
+static const char *major2name(devmajor_t);
+static devmajor_t dev2major(struct devbase *);
extern const char *yyfile;
extern int vflag;
@@ -436,7 +436,7 @@ getdevbase(const char *name)
dev = ecalloc(1, sizeof *dev);
dev->d_name = name;
dev->d_isdef = 0;
- dev->d_major = NODEV;
+ dev->d_major = NODEVMAJOR;
dev->d_attrs = NULL;
dev->d_ihead = NULL;
dev->d_ipp = &dev->d_ihead;
@@ -631,10 +631,10 @@ void
* as a root/dumps "on" device in a configuration.
*/
void
-setmajor(struct devbase *d, int n)
+setmajor(struct devbase *d, devmajor_t n)
{
- if (d != &errdev && d->d_major != NODEV)
+ if (d != &errdev && d->d_major != NODEVMAJOR)
cfgerror("device `%s' is already major %d",
d->d_name, d->d_major);
else
@@ -642,7 +642,7 @@ const char *
}
const char *
-major2name(int maj)
+major2name(devmajor_t maj)
{
struct devbase *dev;
struct devm *dm;
@@ -661,7 +661,7 @@ major2name(int maj)
return (NULL);
}
-int
+devmajor_t
dev2major(struct devbase *dev)
{
struct devm *dm;
@@ -680,7 +680,7 @@ static const char *
* Make a string description of the device at maj/min.
*/
static const char *
-makedevstr(int maj, int min)
+makedevstr(devmajor_t maj, devmajor_t min)
{
const char *devicename;
char buf[32];
@@ -707,7 +707,9 @@ resolve(struct nvlist **nvp, const char
struct nvlist *nv;
struct devbase *dev;
const char *cp;
- int maj, min, i, l;
+ devmajor_t maj;
+ devminor_t min;
+ int i, l;
int unit;
char buf[NAMESIZE];
@@ -1461,22 +1463,23 @@ void
}
void
-adddevm(const char *name, int cmajor, int bmajor, struct nvlist *options)
+adddevm(const char *name, devmajor_t cmajor, devmajor_t bmajor,
+ struct nvlist *options)
{
struct devm *dm;
- if (cmajor < -1 || cmajor >= 4096) {
+ if (cmajor != NODEVMAJOR && (cmajor < 0 || cmajor >= 4096)) {
cfgerror("character major %d is invalid", cmajor);
nvfreel(options);
return;
}
- if (bmajor < -1 || bmajor >= 4096) {
+ if (bmajor != NODEVMAJOR && (bmajor < 0 || bmajor >= 4096)) {
cfgerror("block major %d is invalid", bmajor);
nvfreel(options);
return;
}
- if (cmajor == -1 && bmajor == -1) {
+ if (cmajor == NODEVMAJOR && bmajor == NODEVMAJOR) {
cfgerror("both character/block majors are not specified");
nvfreel(options);
return;
============================================================
--==_Exmh_35676715813600--
Home |
Main Index |
Thread Index |
Old Index