From owner-svn-src-all@FreeBSD.ORG Wed Jan 28 17:57:17 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F24A3106566C; Wed, 28 Jan 2009 17:57:16 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DDA428FC0A; Wed, 28 Jan 2009 17:57:16 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0SHvGlb027889; Wed, 28 Jan 2009 17:57:16 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0SHvGt8027878; Wed, 28 Jan 2009 17:57:16 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200901281757.n0SHvGt8027878@svn.freebsd.org> From: Ed Schouten Date: Wed, 28 Jan 2009 17:57:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187830 - in head/sys: cddl/contrib/opensolaris/uts/common/fs/zfs compat/linux compat/svr4 dev/xen/blkback fs/cd9660 nfs4client nfsclient nfsserver sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Jan 2009 17:57:17 -0000 Author: ed Date: Wed Jan 28 17:57:16 2009 New Revision: 187830 URL: http://svn.freebsd.org/changeset/base/187830 Log: 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. Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c head/sys/compat/linux/linux_stats.c head/sys/compat/svr4/svr4_types.h head/sys/dev/xen/blkback/blkback.c head/sys/fs/cd9660/cd9660_rrip.c head/sys/nfs4client/nfs4_subs.c head/sys/nfsclient/nfs_vnops.c head/sys/nfsserver/nfs_srvsubs.c head/sys/sys/conf.h head/sys/sys/param.h head/sys/sys/types.h Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c Wed Jan 28 16:37:49 2009 (r187829) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c Wed Jan 28 17:57:16 2009 (r187830) @@ -494,7 +494,7 @@ zfs_init_fs(zfsvfs_t *zfsvfs, znode_t ** 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. Modified: head/sys/compat/linux/linux_stats.c ============================================================================== --- head/sys/compat/linux/linux_stats.c Wed Jan 28 16:37:49 2009 (r187829) +++ head/sys/compat/linux/linux_stats.c Wed Jan 28 17:57:16 2009 (r187830) @@ -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 * 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 *u 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; Modified: head/sys/compat/svr4/svr4_types.h ============================================================================== --- head/sys/compat/svr4/svr4_types.h Wed Jan 28 16:37:49 2009 (r187829) +++ head/sys/compat/svr4/svr4_types.h Wed Jan 28 17:57:16 2009 (r187830) @@ -69,13 +69,13 @@ typedef struct timespec svr4_timestruc_ (((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_ */ Modified: head/sys/dev/xen/blkback/blkback.c ============================================================================== --- head/sys/dev/xen/blkback/blkback.c Wed Jan 28 16:37:49 2009 (r187829) +++ head/sys/dev/xen/blkback/blkback.c Wed Jan 28 17:57:16 2009 (r187830) @@ -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); Modified: head/sys/fs/cd9660/cd9660_rrip.c ============================================================================== --- head/sys/fs/cd9660/cd9660_rrip.c Wed Jan 28 16:37:49 2009 (r187829) +++ head/sys/fs/cd9660/cd9660_rrip.c Wed Jan 28 17:57:16 2009 (r187830) @@ -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; } Modified: head/sys/nfs4client/nfs4_subs.c ============================================================================== --- head/sys/nfs4client/nfs4_subs.c Wed Jan 28 16:37:49 2009 (r187829) +++ head/sys/nfs4client/nfs4_subs.c Wed Jan 28 17:57:16 2009 (r187830) @@ -668,7 +668,7 @@ nfsm_v4build_create_xx(struct nfs4_compo 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); Modified: head/sys/nfsclient/nfs_vnops.c ============================================================================== --- head/sys/nfsclient/nfs_vnops.c Wed Jan 28 16:37:49 2009 (r187829) +++ head/sys/nfsclient/nfs_vnops.c Wed Jan 28 17:57:16 2009 (r187830) @@ -1314,8 +1314,8 @@ nfs_mknodrpc(struct vnode *dvp, struct v 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); Modified: head/sys/nfsserver/nfs_srvsubs.c ============================================================================== --- head/sys/nfsserver/nfs_srvsubs.c Wed Jan 28 16:37:49 2009 (r187829) +++ head/sys/nfsserver/nfs_srvsubs.c Wed Jan 28 17:57:16 2009 (r187830) @@ -1057,8 +1057,8 @@ nfsm_srvfattr(struct nfsrv_descript *nfs 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; Modified: head/sys/sys/conf.h ============================================================================== --- head/sys/sys/conf.h Wed Jan 28 16:37:49 2009 (r187829) +++ head/sys/sys/conf.h Wed Jan 28 17:57:16 2009 (r187830) @@ -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); Modified: head/sys/sys/param.h ============================================================================== --- head/sys/sys/param.h Wed Jan 28 16:37:49 2009 (r187829) +++ head/sys/sys/param.h Wed Jan 28 17:57:16 2009 (r187830) @@ -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 Modified: head/sys/sys/types.h ============================================================================== --- head/sys/sys/types.h Wed Jan 28 16:37:49 2009 (r187829) +++ head/sys/sys/types.h Wed Jan 28 17:57:16 2009 (r187830) @@ -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 . */ -#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 */ /*