summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-01-28 17:57:16 +0000
committered <ed@FreeBSD.org>2009-01-28 17:57:16 +0000
commita964306db9f5f3dcada77a81a5f3af448d146fc4 (patch)
treea4d8791bcffe7b700a58d406674efaab2d6f59ee
parent5cbdce783bd4925f5a830d13c274b2c77fe993a3 (diff)
downloadFreeBSD-src-a964306db9f5f3dcada77a81a5f3af448d146fc4.zip
FreeBSD-src-a964306db9f5f3dcada77a81a5f3af448d146fc4.tar.gz
Last step of splitting up minor and unit numbers: remove minor().
Inside the kernel, the minor() function was responsible for obtaining the device minor number of a character device. Because we made device numbers dynamically allocated and independent of the unit number passed to make_dev() a long time ago, it was actually a misnomer. If you really want to obtain the device number, you should use dev2udev(). We already converted all the drivers to use dev2unit() to obtain the device unit number, which is still used by a lot of drivers. I've noticed not a single driver passes NULL to dev2unit(). Even if they would, its behaviour would make little sense. This is why I've removed the NULL check. Ths commit removes minor(), minor2unit() and unit2minor() from the kernel. Because there was a naming collision with uminor(), we can rename umajor() and uminor() back to major() and minor(). This means that the makedev(3) manual page also applies to kernel space code now. I suspect umajor() and uminor() isn't used that often in external code, but to make it easier for other parties to port their code, I've increased __FreeBSD_version to 800062.
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c2
-rw-r--r--sys/compat/linux/linux_stats.c6
-rw-r--r--sys/compat/svr4/svr4_types.h4
-rw-r--r--sys/dev/xen/blkback/blkback.c4
-rw-r--r--sys/fs/cd9660/cd9660_rrip.c4
-rw-r--r--sys/nfs4client/nfs4_subs.c2
-rw-r--r--sys/nfsclient/nfs_vnops.c4
-rw-r--r--sys/nfsserver/nfs_srvsubs.c4
-rw-r--r--sys/sys/conf.h5
-rw-r--r--sys/sys/param.h2
-rw-r--r--sys/sys/types.h10
11 files changed, 18 insertions, 29 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
index 86838df..5687522 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
@@ -494,7 +494,7 @@ zfs_init_fs(zfsvfs_t *zfsvfs, znode_t **zpp)
static uint64_t
zfs_expldev(dev_t dev)
{
- return (((uint64_t)umajor(dev) << NBITSMINOR64) | uminor(dev));
+ return (((uint64_t)major(dev) << NBITSMINOR64) | minor(dev));
}
/*
* Special cmpldev for ZFS private use.
diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c
index c5f10af..5f1ce53 100644
--- a/sys/compat/linux/linux_stats.c
+++ b/sys/compat/linux/linux_stats.c
@@ -88,7 +88,7 @@ disk_foo(struct somestat *tbuf)
/* XXX this may not be quite right */
/* Map major number to 0 */
- tbuf.st_dev = uminor(buf->st_dev) & 0xf;
+ tbuf.st_dev = minor(buf->st_dev) & 0xf;
tbuf.st_rdev = buf->st_rdev & 0xff;
}
dev_relthread(dev);
@@ -156,7 +156,7 @@ newstat_copyout(struct stat *buf, void *ubuf)
struct l_newstat tbuf;
bzero(&tbuf, sizeof(tbuf));
- tbuf.st_dev = uminor(buf->st_dev) | (umajor(buf->st_dev) << 8);
+ tbuf.st_dev = minor(buf->st_dev) | (major(buf->st_dev) << 8);
tbuf.st_ino = buf->st_ino;
tbuf.st_mode = buf->st_mode;
tbuf.st_nlink = buf->st_nlink;
@@ -487,7 +487,7 @@ stat64_copyout(struct stat *buf, void *ubuf)
struct l_stat64 lbuf;
bzero(&lbuf, sizeof(lbuf));
- lbuf.st_dev = uminor(buf->st_dev) | (umajor(buf->st_dev) << 8);
+ lbuf.st_dev = minor(buf->st_dev) | (major(buf->st_dev) << 8);
lbuf.st_ino = buf->st_ino;
lbuf.st_mode = buf->st_mode;
lbuf.st_nlink = buf->st_nlink;
diff --git a/sys/compat/svr4/svr4_types.h b/sys/compat/svr4/svr4_types.h
index af801d8..e4f51b5 100644
--- a/sys/compat/svr4/svr4_types.h
+++ b/sys/compat/svr4/svr4_types.h
@@ -69,13 +69,13 @@ typedef struct timespec svr4_timestruc_t;
(((y) << 0) & 0x00ff)))
#define svr4_to_bsd_odev_t(d) makedev(svr4_omajor(d), svr4_ominor(d))
-#define bsd_to_svr4_odev_t(d) svr4_omakedev(umajor(d), uminor(d))
+#define bsd_to_svr4_odev_t(d) svr4_omakedev(major(d), minor(d))
#define svr4_major(x) ((int32_t)((((x) & 0xfffc0000) >> 18)))
#define svr4_minor(x) ((int32_t)((((x) & 0x0003ffff) >> 0)))
#define svr4_makedev(x,y) ((svr4_dev_t)((((x) << 18) & 0xfffc0000) | \
(((y) << 0) & 0x0003ffff)))
#define svr4_to_bsd_dev_t(d) makedev(svr4_major(d), svr4_minor(d))
-#define bsd_to_svr4_dev_t(d) svr4_makedev(umajor(d), uminor(d))
+#define bsd_to_svr4_dev_t(d) svr4_makedev(major(d), minor(d))
#endif /* !_SVR4_TYPES_H_ */
diff --git a/sys/dev/xen/blkback/blkback.c b/sys/dev/xen/blkback/blkback.c
index a418c6d..259f2f6 100644
--- a/sys/dev/xen/blkback/blkback.c
+++ b/sys/dev/xen/blkback/blkback.c
@@ -1135,8 +1135,8 @@ open_device(blkif_t *blkif)
}
blkif->media_num_sectors = blkif->media_size >> blkif->sector_size_shift;
- blkif->major = umajor(vattr.va_rdev);
- blkif->minor = uminor(vattr.va_rdev);
+ blkif->major = major(vattr.va_rdev);
+ blkif->minor = minor(vattr.va_rdev);
DPRINTF("opened dev=%s major=%d minor=%d sector_size=%u media_size=%lld\n",
blkif->dev_name, blkif->major, blkif->minor, blkif->sector_size, blkif->media_size);
diff --git a/sys/fs/cd9660/cd9660_rrip.c b/sys/fs/cd9660/cd9660_rrip.c
index 739972b..9a32e9b 100644
--- a/sys/fs/cd9660/cd9660_rrip.c
+++ b/sys/fs/cd9660/cd9660_rrip.c
@@ -416,9 +416,9 @@ cd9660_rrip_device(p,ana)
low = isonum_733(p->dev_t_low);
if (high == 0)
- ana->inop->inode.iso_rdev = makedev(umajor(low), uminor(low));
+ ana->inop->inode.iso_rdev = makedev(major(low), minor(low));
else
- ana->inop->inode.iso_rdev = makedev(high, uminor(low));
+ ana->inop->inode.iso_rdev = makedev(high, minor(low));
ana->fields &= ~ISO_SUSP_DEVICE;
return ISO_SUSP_DEVICE;
}
diff --git a/sys/nfs4client/nfs4_subs.c b/sys/nfs4client/nfs4_subs.c
index a08240a..21c89c9 100644
--- a/sys/nfs4client/nfs4_subs.c
+++ b/sys/nfs4client/nfs4_subs.c
@@ -668,7 +668,7 @@ nfsm_v4build_create_xx(struct nfs4_compound *cp, struct nfs4_oparg_create *c,
nfsm_buildf_xx(mb, bpos, "s", strlen(c->linktext), c->linktext);
else if (c->type == NFCHR || c->type == NFBLK)
nfsm_buildf_xx(mb, bpos, "uu",
- umajor(c->vap->va_rdev), uminor(c->vap->va_rdev));
+ major(c->vap->va_rdev), minor(c->vap->va_rdev));
/* Name */
nfsm_buildf_xx(mb, bpos, "s", c->namelen, c->name);
diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c
index 7f8ab18..e56e4eb 100644
--- a/sys/nfsclient/nfs_vnops.c
+++ b/sys/nfsclient/nfs_vnops.c
@@ -1314,8 +1314,8 @@ nfs_mknodrpc(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp,
nfsm_v3attrbuild(vap, FALSE);
if (vap->va_type == VCHR || vap->va_type == VBLK) {
tl = nfsm_build(u_int32_t *, 2 * NFSX_UNSIGNED);
- *tl++ = txdr_unsigned(umajor(vap->va_rdev));
- *tl = txdr_unsigned(uminor(vap->va_rdev));
+ *tl++ = txdr_unsigned(major(vap->va_rdev));
+ *tl = txdr_unsigned(minor(vap->va_rdev));
}
} else {
sp = nfsm_build(struct nfsv2_sattr *, NFSX_V2SATTR);
diff --git a/sys/nfsserver/nfs_srvsubs.c b/sys/nfsserver/nfs_srvsubs.c
index 49c6c16..00e5216 100644
--- a/sys/nfsserver/nfs_srvsubs.c
+++ b/sys/nfsserver/nfs_srvsubs.c
@@ -1057,8 +1057,8 @@ nfsm_srvfattr(struct nfsrv_descript *nfsd, struct vattr *vap,
fp->fa_mode = vtonfsv3_mode(vap->va_mode);
txdr_hyper(vap->va_size, &fp->fa3_size);
txdr_hyper(vap->va_bytes, &fp->fa3_used);
- fp->fa3_rdev.specdata1 = txdr_unsigned(umajor(vap->va_rdev));
- fp->fa3_rdev.specdata2 = txdr_unsigned(uminor(vap->va_rdev));
+ fp->fa3_rdev.specdata1 = txdr_unsigned(major(vap->va_rdev));
+ fp->fa3_rdev.specdata2 = txdr_unsigned(minor(vap->va_rdev));
fp->fa3_fsid.nfsuquad[0] = 0;
fp->fa3_fsid.nfsuquad[1] = txdr_unsigned(vap->va_fsid);
fp->fa3_fileid.nfsuquad[0] = 0;
diff --git a/sys/sys/conf.h b/sys/sys/conf.h
index 3fc0777..043c9df 100644
--- a/sys/sys/conf.h
+++ b/sys/sys/conf.h
@@ -274,10 +274,7 @@ void dev_lock(void);
void dev_unlock(void);
void setconf(void);
-#define dev2unit(d) ((d) ? (d)->si_drv0 : NODEV)
-#define minor(d) ((d) ? (d)->si_drv0 : NODEV)
-#define unit2minor(u) (u)
-#define minor2unit(m) (m)
+#define dev2unit(d) ((d)->si_drv0)
typedef void (*cdevpriv_dtr_t)(void *data);
int devfs_get_cdevpriv(void **datap);
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 770067e..6a8e4b0 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -57,7 +57,7 @@
* is created, otherwise 1.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 800061 /* Master, propagated to newvers */
+#define __FreeBSD_version 800062 /* Master, propagated to newvers */
#ifndef LOCORE
#include <sys/types.h>
diff --git a/sys/sys/types.h b/sys/sys/types.h
index cf9264a..66be699 100644
--- a/sys/sys/types.h
+++ b/sys/sys/types.h
@@ -317,17 +317,9 @@ typedef struct vm_page *vm_page_t;
* minor() gives a cookie instead of an index since we don't want to
* change the meanings of bits 0-15 or waste time and space shifting
* bits 16-31 for devices that don't use them.
- *
- * XXX: In the kernel we must name it umajor() and uminor(), because
- * minor() is still in use by <sys/conf.h>.
*/
-#ifdef _KERNEL
-#define umajor(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
-#define uminor(x) ((int)((x)&0xffff00ff)) /* minor number */
-#else /* !_KERNEL */
-#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
+#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
#define minor(x) ((int)((x)&0xffff00ff)) /* minor number */
-#endif /* _KERNEL */
#define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */
/*
OpenPOWER on IntegriCloud