diff options
author | phk <phk@FreeBSD.org> | 1999-08-25 12:24:39 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1999-08-25 12:24:39 +0000 |
commit | ea55d634757e3bbadb6525c31e5cb18f4f05ad53 (patch) | |
tree | bf5db0228b3f8aba1534aff880eed69f71082a05 /sys | |
parent | 8bfe025139b1ec3d8cbe77369f343a2dbd6e5702 (diff) | |
download | FreeBSD-src-ea55d634757e3bbadb6525c31e5cb18f4f05ad53.zip FreeBSD-src-ea55d634757e3bbadb6525c31e5cb18f4f05ad53.tar.gz |
Introduce vn_isdisk(struct vnode *vp) function, and use it to test for diskness.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/fs/cd9660/cd9660_vfsops.c | 8 | ||||
-rw-r--r-- | sys/fs/msdosfs/msdosfs_vfsops.c | 8 | ||||
-rw-r--r-- | sys/fs/ntfs/ntfs_vfsops.c | 8 | ||||
-rw-r--r-- | sys/gnu/ext2fs/ext2_vfsops.c | 6 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_vfsops.c | 6 | ||||
-rw-r--r-- | sys/isofs/cd9660/cd9660_vfsops.c | 8 | ||||
-rw-r--r-- | sys/kern/vfs_export.c | 29 | ||||
-rw-r--r-- | sys/kern/vfs_subr.c | 29 | ||||
-rw-r--r-- | sys/msdosfs/msdosfs_vfsops.c | 8 | ||||
-rw-r--r-- | sys/ntfs/ntfs_vfsops.c | 8 | ||||
-rw-r--r-- | sys/sys/vnode.h | 3 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 8 |
12 files changed, 58 insertions, 71 deletions
diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c index 2e007db..1dc080d 100644 --- a/sys/fs/cd9660/cd9660_vfsops.c +++ b/sys/fs/cd9660/cd9660_vfsops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)cd9660_vfsops.c 8.18 (Berkeley) 5/22/95 - * $Id: cd9660_vfsops.c,v 1.58 1999/08/13 10:29:18 phk Exp $ + * $Id: cd9660_vfsops.c,v 1.59 1999/08/23 21:07:12 bde Exp $ */ #include <sys/param.h> @@ -220,14 +220,10 @@ cd9660_mount(mp, path, data, ndp, p) return (error); devvp = ndp->ni_vp; - if (devvp->v_type != VBLK) { + if (!vn_isdisk(devvp)) { vrele(devvp); return ENOTBLK; } - if (devsw(devvp->v_rdev) == NULL) { - vrele(devvp); - return ENXIO; - } /* * Verify that user has necessary permissions on the device, diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c index f8c7392..adb5b5a 100644 --- a/sys/fs/msdosfs/msdosfs_vfsops.c +++ b/sys/fs/msdosfs/msdosfs_vfsops.c @@ -1,4 +1,4 @@ -/* $Id: msdosfs_vfsops.c,v 1.47 1999/08/13 10:29:26 phk Exp $ */ +/* $Id: msdosfs_vfsops.c,v 1.48 1999/08/23 21:07:13 bde Exp $ */ /* $NetBSD: msdosfs_vfsops.c,v 1.51 1997/11/17 15:36:58 ws Exp $ */ /*- @@ -293,14 +293,10 @@ msdosfs_mount(mp, path, data, ndp, p) return (error); devvp = ndp->ni_vp; - if (devvp->v_type != VBLK) { + if (!vn_isdisk(devvp)) { vrele(devvp); return (ENOTBLK); } - if (devsw(devvp->v_rdev) == NULL) { - vrele(devvp); - return (ENXIO); - } /* * If mount by non-root, then verify that user has necessary * permissions on the device. diff --git a/sys/fs/ntfs/ntfs_vfsops.c b/sys/fs/ntfs/ntfs_vfsops.c index 172460d..44877bd 100644 --- a/sys/fs/ntfs/ntfs_vfsops.c +++ b/sys/fs/ntfs/ntfs_vfsops.c @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ntfs_vfsops.c,v 1.8 1999/08/08 18:42:58 phk Exp $ + * $Id: ntfs_vfsops.c,v 1.9 1999/08/13 10:29:29 phk Exp $ */ @@ -290,14 +290,10 @@ ntfs_mount ( devvp = ndp->ni_vp; - if (devvp->v_type != VBLK) { + if (vn_isdisk(devvp)) { err = ENOTBLK; goto error_2; } - if (devsw(devvp->v_rdev) == NULL) { - err = ENXIO; - goto error_2; - } if (mp->mnt_flag & MNT_UPDATE) { #if 0 /* diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c index ed772f6..1bf97d5 100644 --- a/sys/gnu/ext2fs/ext2_vfsops.c +++ b/sys/gnu/ext2fs/ext2_vfsops.c @@ -270,14 +270,10 @@ ext2_mount(mp, path, data, ndp, p) return (error); devvp = ndp->ni_vp; - if (devvp->v_type != VBLK) { + if (!vn_isdisk(devvp)) { vrele(devvp); return (ENOTBLK); } - if (devsw(devvp->v_rdev) == NULL) { - vrele(devvp); - return (ENXIO); - } /* * If mount by non-root, then verify that user has necessary diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c index ed772f6..1bf97d5 100644 --- a/sys/gnu/fs/ext2fs/ext2_vfsops.c +++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c @@ -270,14 +270,10 @@ ext2_mount(mp, path, data, ndp, p) return (error); devvp = ndp->ni_vp; - if (devvp->v_type != VBLK) { + if (!vn_isdisk(devvp)) { vrele(devvp); return (ENOTBLK); } - if (devsw(devvp->v_rdev) == NULL) { - vrele(devvp); - return (ENXIO); - } /* * If mount by non-root, then verify that user has necessary diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c index 2e007db..1dc080d 100644 --- a/sys/isofs/cd9660/cd9660_vfsops.c +++ b/sys/isofs/cd9660/cd9660_vfsops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)cd9660_vfsops.c 8.18 (Berkeley) 5/22/95 - * $Id: cd9660_vfsops.c,v 1.58 1999/08/13 10:29:18 phk Exp $ + * $Id: cd9660_vfsops.c,v 1.59 1999/08/23 21:07:12 bde Exp $ */ #include <sys/param.h> @@ -220,14 +220,10 @@ cd9660_mount(mp, path, data, ndp, p) return (error); devvp = ndp->ni_vp; - if (devvp->v_type != VBLK) { + if (!vn_isdisk(devvp)) { vrele(devvp); return ENOTBLK; } - if (devsw(devvp->v_rdev) == NULL) { - vrele(devvp); - return ENXIO; - } /* * Verify that user has necessary permissions on the device, diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c index 5357297..46d31fc 100644 --- a/sys/kern/vfs_export.c +++ b/sys/kern/vfs_export.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 - * $Id: vfs_subr.c,v 1.218 1999/08/22 00:15:04 jdp Exp $ + * $Id: vfs_subr.c,v 1.219 1999/08/25 04:55:17 julian Exp $ */ /* @@ -860,10 +860,7 @@ bgetvp(vp, bp) vhold(vp); bp->b_vp = vp; - if (vp->v_type == VBLK || vp->v_type == VCHR) - bp->b_dev = vp->v_rdev; - else - bp->b_dev = NODEV; + bp->b_dev = vn_todev(vp); /* * Insert onto list for new vnode. */ @@ -1095,10 +1092,7 @@ pbgetvp(vp, bp) bp->b_vp = vp; bp->b_flags |= B_PAGING; - if (vp->v_type == VBLK || vp->v_type == VCHR) - bp->b_dev = vp->v_rdev; - else - bp->b_dev = NODEV; + bp->b_dev = vn_todev(vp); } /* @@ -3015,3 +3009,20 @@ vn_todev(vp) return (NODEV); return (vp->v_rdev); } + +/* + * Check if vnode represents a disk device + */ +int +vn_isdisk(vp) + struct vnode *vp; +{ + if (vp->v_type != VBLK) + return (0); + if (!devsw(vp->v_rdev)) + return (0); + if (!(devsw(vp->v_rdev)->d_flags & D_DISK)) + return (0); + return (1); +} + diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 5357297..46d31fc 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 - * $Id: vfs_subr.c,v 1.218 1999/08/22 00:15:04 jdp Exp $ + * $Id: vfs_subr.c,v 1.219 1999/08/25 04:55:17 julian Exp $ */ /* @@ -860,10 +860,7 @@ bgetvp(vp, bp) vhold(vp); bp->b_vp = vp; - if (vp->v_type == VBLK || vp->v_type == VCHR) - bp->b_dev = vp->v_rdev; - else - bp->b_dev = NODEV; + bp->b_dev = vn_todev(vp); /* * Insert onto list for new vnode. */ @@ -1095,10 +1092,7 @@ pbgetvp(vp, bp) bp->b_vp = vp; bp->b_flags |= B_PAGING; - if (vp->v_type == VBLK || vp->v_type == VCHR) - bp->b_dev = vp->v_rdev; - else - bp->b_dev = NODEV; + bp->b_dev = vn_todev(vp); } /* @@ -3015,3 +3009,20 @@ vn_todev(vp) return (NODEV); return (vp->v_rdev); } + +/* + * Check if vnode represents a disk device + */ +int +vn_isdisk(vp) + struct vnode *vp; +{ + if (vp->v_type != VBLK) + return (0); + if (!devsw(vp->v_rdev)) + return (0); + if (!(devsw(vp->v_rdev)->d_flags & D_DISK)) + return (0); + return (1); +} + diff --git a/sys/msdosfs/msdosfs_vfsops.c b/sys/msdosfs/msdosfs_vfsops.c index f8c7392..adb5b5a 100644 --- a/sys/msdosfs/msdosfs_vfsops.c +++ b/sys/msdosfs/msdosfs_vfsops.c @@ -1,4 +1,4 @@ -/* $Id: msdosfs_vfsops.c,v 1.47 1999/08/13 10:29:26 phk Exp $ */ +/* $Id: msdosfs_vfsops.c,v 1.48 1999/08/23 21:07:13 bde Exp $ */ /* $NetBSD: msdosfs_vfsops.c,v 1.51 1997/11/17 15:36:58 ws Exp $ */ /*- @@ -293,14 +293,10 @@ msdosfs_mount(mp, path, data, ndp, p) return (error); devvp = ndp->ni_vp; - if (devvp->v_type != VBLK) { + if (!vn_isdisk(devvp)) { vrele(devvp); return (ENOTBLK); } - if (devsw(devvp->v_rdev) == NULL) { - vrele(devvp); - return (ENXIO); - } /* * If mount by non-root, then verify that user has necessary * permissions on the device. diff --git a/sys/ntfs/ntfs_vfsops.c b/sys/ntfs/ntfs_vfsops.c index 172460d..44877bd 100644 --- a/sys/ntfs/ntfs_vfsops.c +++ b/sys/ntfs/ntfs_vfsops.c @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ntfs_vfsops.c,v 1.8 1999/08/08 18:42:58 phk Exp $ + * $Id: ntfs_vfsops.c,v 1.9 1999/08/13 10:29:29 phk Exp $ */ @@ -290,14 +290,10 @@ ntfs_mount ( devvp = ndp->ni_vp; - if (devvp->v_type != VBLK) { + if (vn_isdisk(devvp)) { err = ENOTBLK; goto error_2; } - if (devsw(devvp->v_rdev) == NULL) { - err = ENXIO; - goto error_2; - } if (mp->mnt_flag & MNT_UPDATE) { #if 0 /* diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index b3ed24a..ee3a325 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)vnode.h 8.7 (Berkeley) 2/4/94 - * $Id: vnode.h,v 1.95 1999/08/22 00:15:15 jdp Exp $ + * $Id: vnode.h,v 1.96 1999/08/25 04:55:20 julian Exp $ */ #ifndef _SYS_VNODE_H_ @@ -526,6 +526,7 @@ int vrecycle __P((struct vnode *vp, struct simplelock *inter_lkp, struct proc *p)); int vn_close __P((struct vnode *vp, int flags, struct ucred *cred, struct proc *p)); +int vn_isdisk __P((struct vnode *vp)); int vn_lock __P((struct vnode *vp, int flags, struct proc *p)); #ifdef DEBUG_LOCKS int debug_vn_lock __P((struct vnode *vp, int flags, struct proc *p, diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 0f249e4..37c82cc 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_vfsops.c 8.31 (Berkeley) 5/20/95 - * $Id: ffs_vfsops.c,v 1.101 1999/08/08 18:43:01 phk Exp $ + * $Id: ffs_vfsops.c,v 1.102 1999/08/13 10:29:33 phk Exp $ */ #include "opt_quota.h" @@ -284,14 +284,10 @@ ffs_mount( mp, path, data, ndp, p) devvp = ndp->ni_vp; - if (devvp->v_type != VBLK) { + if (!vn_isdisk(devvp)) { err = ENOTBLK; goto error_2; } - if (devsw(devvp->v_rdev) == NULL) { - err = ENXIO; - goto error_2; - } /* * If mount by non-root, then verify that user has necessary |