123400Smckusick /* 250264Skarels * Copyright (c) 1989, 1991 The Regents of the University of California. 337737Smckusick * All rights reserved. 423400Smckusick * 544539Sbostic * %sccs.include.redist.c% 637737Smckusick * 7*52175Smckusick * @(#)lfs_vfsops.c 7.71 (Berkeley) 01/10/92 823400Smckusick */ 912795Ssam 1051483Sbostic #include <sys/param.h> 1151483Sbostic #include <sys/systm.h> 1251483Sbostic #include <sys/namei.h> 1351483Sbostic #include <sys/proc.h> 1451483Sbostic #include <sys/kernel.h> 1551483Sbostic #include <sys/vnode.h> 1651483Sbostic #include <sys/specdev.h> 1751483Sbostic #include <sys/mount.h> 1851483Sbostic #include <sys/buf.h> 1951483Sbostic #include <sys/file.h> 2051483Sbostic #include <sys/disklabel.h> 2151483Sbostic #include <sys/ioctl.h> 2251483Sbostic #include <sys/errno.h> 2351483Sbostic #include <sys/malloc.h> 2412795Ssam 2551501Sbostic #include <ufs/ufs/quota.h> 2651501Sbostic #include <ufs/ufs/inode.h> 2751501Sbostic #include <ufs/ufs/ufsmount.h> 2851501Sbostic #include <ufs/ufs/ufs_extern.h> 2947571Skarels 3051501Sbostic #include <ufs/lfs/lfs.h> 3151501Sbostic #include <ufs/lfs/lfs_extern.h> 3251155Sbostic 3351991Sbostic int lfs_mountfs __P((struct vnode *, struct mount *, struct proc *)); 3451215Sbostic 3551155Sbostic struct vfsops lfs_vfsops = { 3651155Sbostic lfs_mount, 3739043Smckusick ufs_start, 3851155Sbostic lfs_unmount, 3951559Smckusick lfs_root, 4041314Smckusick ufs_quotactl, 4151155Sbostic lfs_statfs, 4251155Sbostic lfs_sync, 4351559Smckusick lfs_fhtovp, 4451559Smckusick lfs_vptofh, 4551483Sbostic lfs_init, 4637737Smckusick }; 4737737Smckusick 4851483Sbostic int 4951155Sbostic lfs_mountroot() 5012795Ssam { 5151483Sbostic panic("lfs_mountroot"); /* XXX -- implement */ 5237737Smckusick } 5337737Smckusick 5437737Smckusick /* 5537737Smckusick * VFS Operations. 5637737Smckusick * 5737737Smckusick * mount system call 5837737Smckusick */ 5951155Sbostic lfs_mount(mp, path, data, ndp, p) 6040346Smckusick register struct mount *mp; 6137737Smckusick char *path; 6237737Smckusick caddr_t data; 6337737Smckusick struct nameidata *ndp; 6448036Smckusick struct proc *p; 6537737Smckusick { 6637737Smckusick struct vnode *devvp; 6737737Smckusick struct ufs_args args; 6837737Smckusick struct ufsmount *ump; 6951501Sbostic register struct lfs *fs; /* LFS */ 7037737Smckusick u_int size; 7137737Smckusick int error; 7237737Smckusick 7337737Smckusick if (error = copyin(data, (caddr_t)&args, sizeof (struct ufs_args))) 7437737Smckusick return (error); 7551483Sbostic 7651483Sbostic /* Until LFS can do NFS right. XXX */ 7751483Sbostic if (args.exflags & MNT_EXPORTED) 7851483Sbostic return (EINVAL); 7940371Smckusick /* 8050264Skarels * If updating, check whether changing from read-only to 8150264Skarels * read/write; if there is no device name, that's all we do. 8250264Skarels */ 8350264Skarels if (mp->mnt_flag & MNT_UPDATE) { 8439336Smckusick ump = VFSTOUFS(mp); 8551155Sbostic #ifdef NOTLFS /* LFS */ 8639336Smckusick fs = ump->um_fs; 8741397Smckusick if (fs->fs_ronly && (mp->mnt_flag & MNT_RDONLY) == 0) 8839336Smckusick fs->fs_ronly = 0; 8951155Sbostic #else 9051155Sbostic fs = ump->um_lfs; 9151155Sbostic if (fs->lfs_ronly && (mp->mnt_flag & MNT_RDONLY) == 0) 9251155Sbostic fs->lfs_ronly = 0; 9351155Sbostic #endif 94*52175Smckusick if (args.fspec == 0) { 95*52175Smckusick /* 96*52175Smckusick * Process export requests. 97*52175Smckusick */ 98*52175Smckusick if (args.exflags & MNT_EXPORTED) { 99*52175Smckusick if (error = hang_addrlist(mp, &args)) 100*52175Smckusick return (error); 101*52175Smckusick mp->mnt_flag |= MNT_EXPORTED; 102*52175Smckusick } 103*52175Smckusick if (args.exflags & MNT_DELEXPORT) { 104*52175Smckusick free_addrlist(ump); 105*52175Smckusick mp->mnt_flag &= 106*52175Smckusick ~(MNT_EXPORTED | MNT_DEFEXPORTED); 107*52175Smckusick } 10840371Smckusick return (0); 109*52175Smckusick } 11050264Skarels } 11150264Skarels /* 11250264Skarels * Not an update, or updating the name: look up the name 11350264Skarels * and verify that it refers to a sensible block device. 11450264Skarels */ 11550264Skarels ndp->ni_nameiop = LOOKUP | FOLLOW; 11650264Skarels ndp->ni_segflg = UIO_USERSPACE; 11750264Skarels ndp->ni_dirp = args.fspec; 11850264Skarels if (error = namei(ndp, p)) 11950264Skarels return (error); 12050264Skarels devvp = ndp->ni_vp; 12150264Skarels if (devvp->v_type != VBLK) { 12250264Skarels vrele(devvp); 12350264Skarels return (ENOTBLK); 12450264Skarels } 12550264Skarels if (major(devvp->v_rdev) >= nblkdev) { 12650264Skarels vrele(devvp); 12750264Skarels return (ENXIO); 12850264Skarels } 12950264Skarels if ((mp->mnt_flag & MNT_UPDATE) == 0) 13051155Sbostic error = lfs_mountfs(devvp, mp, p); /* LFS */ 13150264Skarels else { 13239336Smckusick if (devvp != ump->um_devvp) 13339336Smckusick error = EINVAL; /* needs translation */ 13442858Smckusick else 13542858Smckusick vrele(devvp); 13639336Smckusick } 13737737Smckusick if (error) { 13837737Smckusick vrele(devvp); 13937737Smckusick return (error); 14032721Smckusick } 14137737Smckusick ump = VFSTOUFS(mp); 14251155Sbostic fs = ump->um_lfs; /* LFS */ 14351155Sbostic #ifdef NOTLFS /* LFS */ 14437737Smckusick (void) copyinstr(path, fs->fs_fsmnt, sizeof(fs->fs_fsmnt) - 1, &size); 14537737Smckusick bzero(fs->fs_fsmnt + size, sizeof(fs->fs_fsmnt) - size); 14641397Smckusick bcopy((caddr_t)fs->fs_fsmnt, (caddr_t)mp->mnt_stat.f_mntonname, 14741397Smckusick MNAMELEN); 14851991Sbostic (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, 14941397Smckusick &size); 15041397Smckusick bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); 15148036Smckusick (void) ufs_statfs(mp, &mp->mnt_stat, p); 15251155Sbostic #else 15351155Sbostic (void)copyinstr(path, fs->lfs_fsmnt, sizeof(fs->lfs_fsmnt) - 1, &size); 15451155Sbostic bzero(fs->lfs_fsmnt + size, sizeof(fs->lfs_fsmnt) - size); 15551155Sbostic bcopy((caddr_t)fs->lfs_fsmnt, (caddr_t)mp->mnt_stat.f_mntonname, 15651155Sbostic MNAMELEN); 15751991Sbostic (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, 15851155Sbostic &size); 15951155Sbostic bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); 16051155Sbostic (void) lfs_statfs(mp, &mp->mnt_stat, p); 16151155Sbostic #endif 16237737Smckusick return (0); 16312795Ssam } 16412795Ssam 16537737Smckusick /* 16637737Smckusick * Common code for mount and mountroot 16751155Sbostic * LFS specific 16837737Smckusick */ 16951991Sbostic int 17051155Sbostic lfs_mountfs(devvp, mp, p) 17140376Smckusick register struct vnode *devvp; 17237737Smckusick struct mount *mp; 17348036Smckusick struct proc *p; 17412795Ssam { 17551155Sbostic extern struct vnode *rootvp; 17651501Sbostic register struct lfs *fs; 17751155Sbostic register struct ufsmount *ump; 17851155Sbostic struct inode *ip; 17951155Sbostic struct vnode *vp; 18051155Sbostic struct buf *bp; 18130749Skarels struct partinfo dpart; 18251155Sbostic daddr_t seg_addr; 18351155Sbostic dev_t dev; 18451155Sbostic int error, i, ronly, size; 18512795Ssam 18640376Smckusick /* 18740376Smckusick * Disallow multiple mounts of the same device. 18845652Smckusick * Disallow mounting of a device that is currently in use 18945652Smckusick * (except for root, which might share swap device for miniroot). 19040376Smckusick * Flush out any old buffers remaining from a previous use. 19140376Smckusick */ 19251483Sbostic if (error = ufs_mountedon(devvp)) 19340376Smckusick return (error); 19445652Smckusick if (vcount(devvp) > 1 && devvp != rootvp) 19540376Smckusick return (EBUSY); 19640376Smckusick vinvalbuf(devvp, 1); 19751155Sbostic 19851155Sbostic ronly = (mp->mnt_flag & MNT_RDONLY) != 0; 19948036Smckusick if (error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p)) 20037737Smckusick return (error); 20151155Sbostic 20248036Smckusick if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, p) != 0) 20337737Smckusick size = DEV_BSIZE; 20448036Smckusick else { 20530749Skarels size = dpart.disklab->d_secsize; 20651155Sbostic #ifdef NEVER_USED 20751155Sbostic dpart.part->p_fstype = FS_LFS; 20851155Sbostic dpart.part->p_fsize = fs->lfs_fsize; /* frag size */ 20951155Sbostic dpart.part->p_frag = fs->lfs_frag; /* frags per block */ 21051155Sbostic dpart.part->p_cpg = fs->lfs_segshift; /* segment shift */ 21151155Sbostic #endif 21237737Smckusick } 21351155Sbostic 21451155Sbostic /* Don't free random space on error. */ 21551155Sbostic bp = NULL; 21651155Sbostic ump = NULL; 21751155Sbostic 21851155Sbostic /* Read in the superblock. */ 21951155Sbostic if (error = bread(devvp, LFS_LABELPAD / size, LFS_SBPAD, NOCRED, &bp)) 22012795Ssam goto out; 22151155Sbostic fs = bp->b_un.b_lfs; 22251155Sbostic 22351155Sbostic /* Check the basics. */ 22451155Sbostic if (fs->lfs_magic != LFS_MAGIC || fs->lfs_bsize > MAXBSIZE || 22551501Sbostic fs->lfs_bsize < sizeof(struct lfs)) { 22641314Smckusick error = EINVAL; /* XXX needs translation */ 22716639Skarels goto out; 22816639Skarels } 22951155Sbostic #ifdef DEBUG 23051483Sbostic lfs_dump_super(fs); 23151155Sbostic #endif 23251155Sbostic 23351155Sbostic /* Allocate the mount structure, copy the superblock into it. */ 23441314Smckusick ump = (struct ufsmount *)malloc(sizeof *ump, M_UFSMNT, M_WAITOK); 23551989Smckusick ump->um_lfs = malloc(sizeof(struct lfs), M_UFSMNT, M_WAITOK); 23651501Sbostic bcopy(bp->b_un.b_addr, ump->um_lfs, sizeof(struct lfs)); 23751501Sbostic if (sizeof(struct lfs) < LFS_SBPAD) /* XXX why? */ 23839675Smckusick bp->b_flags |= B_INVAL; 23934421Skarels brelse(bp); 24034421Skarels bp = NULL; 24151155Sbostic 24251183Sbostic /* Set up the I/O information */ 24351183Sbostic fs->lfs_iocount = 0; 24451853Sbostic /* XXX NOTUSED: fs->lfs_seglist = NULL; */ 24551183Sbostic 24651155Sbostic /* Set the file system readonly/modify bits. */ 24751155Sbostic fs = ump->um_lfs; 24851155Sbostic fs->lfs_ronly = ronly; 24912795Ssam if (ronly == 0) 25051155Sbostic fs->lfs_fmod = 1; 25151155Sbostic 25251155Sbostic /* Initialize the mount structure. */ 25351155Sbostic dev = devvp->v_rdev; 25441397Smckusick mp->mnt_data = (qaddr_t)ump; 25541397Smckusick mp->mnt_stat.f_fsid.val[0] = (long)dev; 25651991Sbostic mp->mnt_stat.f_fsid.val[1] = MOUNT_LFS; 25741397Smckusick mp->mnt_flag |= MNT_LOCAL; 25837737Smckusick ump->um_mountp = mp; 25937737Smckusick ump->um_dev = dev; 26037737Smckusick ump->um_devvp = devvp; 26141314Smckusick for (i = 0; i < MAXQUOTAS; i++) 26241314Smckusick ump->um_quotas[i] = NULLVP; 26351155Sbostic 26451155Sbostic /* Read the ifile disk inode and store it in a vnode. */ 26551559Smckusick if (error = bread(devvp, fs->lfs_idaddr, fs->lfs_bsize, NOCRED, &bp)) 26651155Sbostic goto out; 26751559Smckusick if (error = lfs_vcreate(mp, LFS_IFILE_INUM, &vp)) 26851155Sbostic goto out; 26951155Sbostic ip = VTOI(vp); 27051559Smckusick VREF(ip->i_devvp); 27151155Sbostic 27251155Sbostic /* The ifile inode is stored in the superblock. */ 27351155Sbostic fs->lfs_ivnode = vp; 27451155Sbostic 27551155Sbostic /* Copy the on-disk inode into place. */ 27651155Sbostic ip->i_din = *lfs_ifind(fs, LFS_IFILE_INUM, bp->b_un.b_dino); 27751155Sbostic brelse(bp); 27851155Sbostic 27951155Sbostic /* Initialize the associated vnode */ 28051155Sbostic vp->v_type = IFTOVT(ip->i_mode); 28151155Sbostic 28240653Smckusick devvp->v_specflags |= SI_MOUNTEDON; 28351155Sbostic VREF(ip->i_devvp); 28437737Smckusick return (0); 28512795Ssam out: 28640872Smckusick if (bp) 28740872Smckusick brelse(bp); 28851155Sbostic (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p); 28941314Smckusick if (ump) { 29051989Smckusick free(ump->um_lfs, M_UFSMNT); 29151501Sbostic free(ump, M_UFSMNT); 29241397Smckusick mp->mnt_data = (qaddr_t)0; 29332721Smckusick } 29437737Smckusick return (error); 29512795Ssam } 29612795Ssam 29739043Smckusick /* 29837737Smckusick * unmount system call 29937737Smckusick */ 30051155Sbostic lfs_unmount(mp, mntflags, p) 30137737Smckusick struct mount *mp; 30241314Smckusick int mntflags; 30348036Smckusick struct proc *p; 30412795Ssam { 30551501Sbostic extern int doforce; 30637737Smckusick register struct ufsmount *ump; 30751501Sbostic register struct lfs *fs; /* LFS */ 30841314Smckusick int i, error, ronly, flags = 0; 30951215Sbostic int ndirty; /* LFS */ 31012795Ssam 31151853Sbostic #ifdef VERBOSE 31251853Sbostic printf("lfs_unmount\n"); 31351853Sbostic #endif 31448065Smckusick if (mntflags & MNT_FORCE) { 31548359Smckusick if (!doforce || mp == rootfs) 31648065Smckusick return (EINVAL); 31741314Smckusick flags |= FORCECLOSE; 31848065Smckusick } 31951215Sbostic if (error = lfs_segwrite(mp, 1)) 32051215Sbostic return(error); 32151215Sbostic 32251215Sbostic ndirty = lfs_umountdebug(mp); 32351215Sbostic printf("lfs_umountdebug: returned %d dirty\n", ndirty); 32451215Sbostic return(0); 32539675Smckusick if (mntinvalbuf(mp)) 32639675Smckusick return (EBUSY); 32737737Smckusick ump = VFSTOUFS(mp); 32812795Ssam #ifdef QUOTA 32941397Smckusick if (mp->mnt_flag & MNT_QUOTA) { 33041314Smckusick if (error = vflush(mp, NULLVP, SKIPSYSTEM|flags)) 33139898Smckusick return (error); 33241314Smckusick for (i = 0; i < MAXQUOTAS; i++) { 33341314Smckusick if (ump->um_quotas[i] == NULLVP) 33441314Smckusick continue; 33550114Smckusick quotaoff(p, mp, i); 33641314Smckusick } 33739898Smckusick /* 33841314Smckusick * Here we fall through to vflush again to ensure 33941314Smckusick * that we have gotten rid of all the system vnodes. 34039898Smckusick */ 34141314Smckusick } 34212795Ssam #endif 34341314Smckusick if (error = vflush(mp, NULLVP, flags)) 34439898Smckusick return (error); 34551155Sbostic #ifdef NOTLFS /* LFS */ 34637737Smckusick fs = ump->um_fs; 34737737Smckusick ronly = !fs->fs_ronly; 34851155Sbostic #else 34951155Sbostic fs = ump->um_lfs; 35051155Sbostic ronly = !fs->lfs_ronly; 35151155Sbostic #endif 35240653Smckusick ump->um_devvp->v_specflags &= ~SI_MOUNTEDON; 35348036Smckusick error = VOP_CLOSE(ump->um_devvp, ronly ? FREAD : FREAD|FWRITE, 35448036Smckusick NOCRED, p); 35537737Smckusick vrele(ump->um_devvp); 35651155Sbostic #ifdef NOTLFS /* LFS */ 35751989Smckusick free((caddr_t)fs->fs_csp[0], M_UFSMNT); 35851155Sbostic #else 35951155Sbostic iput(VTOI(fs->lfs_ivnode)); 36051155Sbostic #endif 36151989Smckusick free(fs, M_UFSMNT); 36251501Sbostic free(ump, M_UFSMNT); 36341397Smckusick mp->mnt_data = (qaddr_t)0; 36441397Smckusick mp->mnt_flag &= ~MNT_LOCAL; 36530749Skarels return (error); 36612795Ssam } 36712795Ssam 36837737Smckusick /* 36951559Smckusick * Return root of a filesystem 37051559Smckusick */ 37151559Smckusick int 37251559Smckusick lfs_root(mp, vpp) 37351559Smckusick struct mount *mp; 37451559Smckusick struct vnode **vpp; 37551559Smckusick { 37651559Smckusick struct vnode *nvp; 37751559Smckusick int error; 37851559Smckusick 37951853Sbostic #ifdef VERBOSE 38051853Sbostic printf("lfs_root\n"); 38151853Sbostic #endif 38251559Smckusick if (error = lfs_vget(mp, (ino_t)ROOTINO, &nvp)) 38351559Smckusick return (error); 38451559Smckusick *vpp = nvp; 38551559Smckusick return (0); 38651559Smckusick } 38751559Smckusick 38851559Smckusick /* 38937737Smckusick * Get file system statistics. 39037737Smckusick */ 39151155Sbostic lfs_statfs(mp, sbp, p) 39237737Smckusick struct mount *mp; 39337737Smckusick register struct statfs *sbp; 39448036Smckusick struct proc *p; 39537737Smckusick { 39651501Sbostic register struct lfs *fs; 39737737Smckusick register struct ufsmount *ump; 39837737Smckusick 39937737Smckusick ump = VFSTOUFS(mp); 40051155Sbostic fs = ump->um_lfs; 40151155Sbostic if (fs->lfs_magic != LFS_MAGIC) 40251155Sbostic panic("lfs_statfs: magic"); 40351155Sbostic sbp->f_type = MOUNT_LFS; 40451155Sbostic sbp->f_bsize = fs->lfs_bsize; 40551943Smckusick sbp->f_iosize = fs->lfs_bsize; 40651155Sbostic sbp->f_blocks = fs->lfs_dsize; 40751155Sbostic sbp->f_bfree = fs->lfs_bfree; 40851155Sbostic sbp->f_bavail = (fs->lfs_dsize * (100 - fs->lfs_minfree) / 100) - 40951155Sbostic (fs->lfs_dsize - sbp->f_bfree); 41051155Sbostic sbp->f_files = fs->lfs_nfiles; 41151155Sbostic sbp->f_ffree = fs->lfs_bfree * INOPB(fs); 41241397Smckusick if (sbp != &mp->mnt_stat) { 41341397Smckusick bcopy((caddr_t)mp->mnt_stat.f_mntonname, 41440346Smckusick (caddr_t)&sbp->f_mntonname[0], MNAMELEN); 41541397Smckusick bcopy((caddr_t)mp->mnt_stat.f_mntfromname, 41640346Smckusick (caddr_t)&sbp->f_mntfromname[0], MNAMELEN); 41740346Smckusick } 41837737Smckusick return (0); 41937737Smckusick } 42037737Smckusick 42137737Smckusick /* 42237737Smckusick * Go through the disk queues to initiate sandbagged IO; 42337737Smckusick * go through the inodes to write those that have been modified; 42437737Smckusick * initiate the writing of the super block if it has been modified. 42541314Smckusick * 42641314Smckusick * Note: we are always called with the filesystem marked `MPBUSY'. 42737737Smckusick */ 42851155Sbostic lfs_sync(mp, waitfor) 42937737Smckusick struct mount *mp; 43037737Smckusick int waitfor; 43137737Smckusick { 43251914Sbostic extern int crashandburn, syncprt; 43351215Sbostic int error; 43437737Smckusick 43551853Sbostic #ifdef VERBOSE 43651853Sbostic printf("lfs_sync\n"); 43751853Sbostic #endif 43851215Sbostic 43951914Sbostic #ifdef DIAGNOSTIC 44051914Sbostic if (crashandburn) 44151914Sbostic return (0); 44251914Sbostic #endif 44337737Smckusick if (syncprt) 44451483Sbostic ufs_bufstats(); 44551310Sbostic 44651310Sbostic /* All syncs must be checkpoints until roll-forward is implemented. */ 44751991Sbostic error = lfs_segwrite(mp, 1); 44841314Smckusick #ifdef QUOTA 44941314Smckusick qsync(mp); 45041314Smckusick #endif 45151215Sbostic return (error); 45237737Smckusick } 45351559Smckusick 45451559Smckusick /* 45551559Smckusick * File handle to vnode 45651559Smckusick * 45751559Smckusick * Have to be really careful about stale file handles: 45851559Smckusick * - check that the inode number is valid 45951559Smckusick * - call lfs_vget() to get the locked inode 46051559Smckusick * - check for an unallocated inode (i_mode == 0) 46151559Smckusick * - check that the generation number matches 46251559Smckusick * 46351559Smckusick * XXX 46451559Smckusick * use ifile to see if inode is allocated instead of reading off disk 46551559Smckusick * what is the relationship between my generational number and the NFS 46651559Smckusick * generational number. 46751559Smckusick */ 46851559Smckusick int 469*52175Smckusick lfs_fhtovp(mp, fhp, setgen, vpp) 47051559Smckusick register struct mount *mp; 47151559Smckusick struct fid *fhp; 472*52175Smckusick int setgen; 47351559Smckusick struct vnode **vpp; 47451559Smckusick { 47551559Smckusick register struct inode *ip; 47651559Smckusick register struct ufid *ufhp; 47751559Smckusick struct vnode *nvp; 47851559Smckusick int error; 47951559Smckusick 48051559Smckusick ufhp = (struct ufid *)fhp; 48151559Smckusick if (ufhp->ufid_ino < ROOTINO) 48251559Smckusick return (EINVAL); 48351559Smckusick if (error = lfs_vget(mp, ufhp->ufid_ino, &nvp)) { 48451559Smckusick *vpp = NULLVP; 48551559Smckusick return (error); 48651559Smckusick } 48751559Smckusick ip = VTOI(nvp); 48851559Smckusick if (ip->i_mode == 0) { 48951559Smckusick ufs_iput(ip); 49051559Smckusick *vpp = NULLVP; 49151559Smckusick return (EINVAL); 49251559Smckusick } 49351559Smckusick if (ip->i_gen != ufhp->ufid_gen) { 494*52175Smckusick if (setgen) 495*52175Smckusick ufhp->ufid_gen = ip->i_gen; 496*52175Smckusick else { 497*52175Smckusick ufs_iput(ip); 498*52175Smckusick *vpp = NULLVP; 499*52175Smckusick return (EINVAL); 500*52175Smckusick } 50151559Smckusick } 50251559Smckusick *vpp = nvp; 50351559Smckusick return (0); 50451559Smckusick } 50551559Smckusick 50651559Smckusick /* 50751559Smckusick * Vnode pointer to File handle 50851559Smckusick */ 50951559Smckusick /* ARGSUSED */ 51051559Smckusick lfs_vptofh(vp, fhp) 51151559Smckusick struct vnode *vp; 51251559Smckusick struct fid *fhp; 51351559Smckusick { 51451559Smckusick register struct inode *ip; 51551559Smckusick register struct ufid *ufhp; 51651559Smckusick 51751559Smckusick ip = VTOI(vp); 51851559Smckusick ufhp = (struct ufid *)fhp; 51951559Smckusick ufhp->ufid_len = sizeof(struct ufid); 52051559Smckusick ufhp->ufid_ino = ip->i_number; 52151559Smckusick ufhp->ufid_gen = ip->i_gen; 52251559Smckusick return (0); 52351559Smckusick } 524