diff options
Diffstat (limited to 'sys/ufs/ffs')
-rw-r--r-- | sys/ufs/ffs/ffs_extern.h | 9 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_subr.c | 67 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 5 |
3 files changed, 70 insertions, 11 deletions
diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h index ecb37e464ff..45de5724f2f 100644 --- a/sys/ufs/ffs/ffs_extern.h +++ b/sys/ufs/ffs/ffs_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_extern.h,v 1.42 2016/05/23 09:31:28 natano Exp $ */ +/* $OpenBSD: ffs_extern.h,v 1.43 2016/08/10 08:04:57 natano Exp $ */ /* $NetBSD: ffs_extern.h,v 1.4 1996/02/09 22:22:22 christos Exp $ */ /* @@ -132,6 +132,7 @@ int ffs_isfreeblock(struct fs *, u_char *, daddr_t); int ffs_isblock(struct fs *, u_char *, daddr_t); void ffs_clrblock(struct fs *, u_char *, daddr_t); void ffs_setblock(struct fs *, u_char *, daddr_t); +int ffs_vinit(struct mount *, struct vnode **); /* ffs_vfsops.c */ int ffs_mountroot(void); @@ -188,12 +189,6 @@ void softdep_fsync_mountdev(struct vnode *, int); int softdep_sync_metadata(struct vop_fsync_args *); int softdep_fsync(struct vnode *); -#ifdef FIFO -#define FFS_FIFOOPS &ffs_fifovops -#else -#define FFS_FIFOOPS NULL -#endif - extern struct pool ffs_ino_pool; /* memory pool for inodes */ extern struct pool ffs_dinode1_pool; /* memory pool for UFS1 dinodes */ #ifdef FFS2 diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c index 3da51515e37..d2455d45ef7 100644 --- a/sys/ufs/ffs/ffs_subr.c +++ b/sys/ufs/ffs/ffs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_subr.c,v 1.30 2015/11/28 21:52:02 beck Exp $ */ +/* $OpenBSD: ffs_subr.c,v 1.31 2016/08/10 08:04:57 natano Exp $ */ /* $NetBSD: ffs_subr.c,v 1.6 1996/03/17 02:16:23 christos Exp $ */ /* @@ -244,3 +244,68 @@ ffs_isfreeblock(struct fs *fs, u_char *cp, daddr_t h) return ((cp[h >> 3] & (0x01 << (h & 0x7))) == 0); } } + +/* + * Initialize the vnode associated with a new inode, handle aliased + * vnodes. + */ +int +ffs_vinit(struct mount *mntp, struct vnode **vpp) +{ + struct inode *ip; + struct vnode *vp, *nvp; + struct timeval mtv; + + vp = *vpp; + ip = VTOI(vp); + switch(vp->v_type = IFTOVT(DIP(ip, mode))) { + case VCHR: + case VBLK: + vp->v_op = &ffs_specvops; + if ((nvp = checkalias(vp, DIP(ip, rdev), mntp)) != NULL) { + /* + * Discard unneeded vnode, but save its inode. + * Note that the lock is carried over in the inode + * to the replacement vnode. + */ + nvp->v_data = vp->v_data; + vp->v_data = NULL; + vp->v_op = &spec_vops; +#ifdef VFSLCKDEBUG + vp->v_flag &= ~VLOCKSWORK; +#endif + vrele(vp); + vgone(vp); + /* + * Reinitialize aliased inode. + */ + vp = nvp; + ip->i_vnode = vp; + } + break; + case VFIFO: +#ifdef FIFO + vp->v_op = &ffs_fifovops; + break; +#else + return (EOPNOTSUPP); +#endif + case VNON: + case VBAD: + case VSOCK: + case VLNK: + case VDIR: + case VREG: + break; + } + if (ip->i_number == ROOTINO) + vp->v_flag |= VROOT; + /* + * Initialize modrev times + */ + getmicrouptime(&mtv); + ip->i_modrev = (u_quad_t)mtv.tv_sec << 32; + ip->i_modrev |= (u_quad_t)mtv.tv_usec * 4294; + *vpp = vp; + return (0); +} diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 20fee3d9773..5249344fc0a 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_vfsops.c,v 1.160 2016/06/19 11:54:34 natano Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.161 2016/08/10 08:04:57 natano Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -1367,8 +1367,7 @@ retry: * Initialize the vnode from the inode, check for aliases. * Note that the underlying vnode may have changed. */ - error = ufs_vinit(mp, &ffs_specvops, FFS_FIFOOPS, &vp); - if (error) { + if ((error = ffs_vinit(mp, &vp)) != 0) { vput(vp); *vpp = NULL; return (error); |