Module Name: src Committed By: dholland Date: Mon Jun 20 02:31:47 UTC 2016
Modified Files: src/sys/ufs/lfs: lfs_vnops.c ulfs_extern.h ulfs_vnops.c Log Message: Merge (effectively) -r1.78 of ufs_extern.h: shift ulfs_makeinode to lfs_vnops.c and make it file-static there, as that's the only place it's used. To generate a diff of this commit: cvs rdiff -u -r1.298 -r1.299 src/sys/ufs/lfs/lfs_vnops.c cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/lfs/ulfs_extern.h cvs rdiff -u -r1.41 -r1.42 src/sys/ufs/lfs/ulfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/ufs/lfs/lfs_vnops.c diff -u src/sys/ufs/lfs/lfs_vnops.c:1.298 src/sys/ufs/lfs/lfs_vnops.c:1.299 --- src/sys/ufs/lfs/lfs_vnops.c:1.298 Mon Jun 20 02:25:03 2016 +++ src/sys/ufs/lfs/lfs_vnops.c Mon Jun 20 02:31:47 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_vnops.c,v 1.298 2016/06/20 02:25:03 dholland Exp $ */ +/* $NetBSD: lfs_vnops.c,v 1.299 2016/06/20 02:31:47 dholland Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -125,7 +125,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.298 2016/06/20 02:25:03 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.299 2016/06/20 02:31:47 dholland Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -178,6 +178,10 @@ static int lfs_setextattr(void *v); static int lfs_listextattr(void *v); static int lfs_deleteextattr(void *v); +static int ulfs_makeinode(struct vattr *vap, struct vnode *, + const struct ulfs_lookup_results *, + struct vnode **, struct componentname *); + /* Global vfs data structures for lfs. */ int (**lfs_vnodeop_p)(void *); const struct vnodeopv_entry_desc lfs_vnodeop_entries[] = { @@ -352,6 +356,75 @@ const struct vnodeopv_desc lfs_fifoop_op #undef LFS_READWRITE /* + * Allocate a new inode. + */ +static int +ulfs_makeinode(struct vattr *vap, struct vnode *dvp, + const struct ulfs_lookup_results *ulr, + struct vnode **vpp, struct componentname *cnp) +{ + struct inode *ip; + struct vnode *tvp; + int error; + + error = vcache_new(dvp->v_mount, dvp, vap, cnp->cn_cred, &tvp); + if (error) + return error; + error = vn_lock(tvp, LK_EXCLUSIVE); + if (error) { + vrele(tvp); + return error; + } + lfs_mark_vnode(tvp); + *vpp = tvp; + ip = VTOI(tvp); + ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE; + ip->i_nlink = 1; + DIP_ASSIGN(ip, nlink, 1); + + /* Authorize setting SGID if needed. */ + if (ip->i_mode & ISGID) { + error = kauth_authorize_vnode(cnp->cn_cred, KAUTH_VNODE_WRITE_SECURITY, + tvp, NULL, genfs_can_chmod(tvp->v_type, cnp->cn_cred, ip->i_uid, + ip->i_gid, MAKEIMODE(vap->va_type, vap->va_mode))); + if (error) { + ip->i_mode &= ~ISGID; + DIP_ASSIGN(ip, mode, ip->i_mode); + } + } + + if (cnp->cn_flags & ISWHITEOUT) { + ip->i_flags |= UF_OPAQUE; + DIP_ASSIGN(ip, flags, ip->i_flags); + } + + /* + * Make sure inode goes to disk before directory entry. + */ + if ((error = lfs_update(tvp, NULL, NULL, UPDATE_DIROP)) != 0) + goto bad; + error = ulfs_direnter(dvp, ulr, tvp, + cnp, ip->i_number, LFS_IFTODT(ip->i_mode), NULL); + if (error) + goto bad; + *vpp = tvp; + return (0); + + bad: + /* + * Write error occurred trying to update the inode + * or the directory so must deallocate the inode. + */ + ip->i_nlink = 0; + DIP_ASSIGN(ip, nlink, 0); + ip->i_flag |= IN_CHANGE; + /* If IN_ADIROP, account for it */ + lfs_unmark_vnode(tvp); + vput(tvp); + return (error); +} + +/* * Synch an open file. */ /* ARGSUSED */ @@ -2297,3 +2370,4 @@ lfs_deleteextattr(void *v) /* XXX Not implemented for ULFS2 file systems. */ return (EOPNOTSUPP); } + Index: src/sys/ufs/lfs/ulfs_extern.h diff -u src/sys/ufs/lfs/ulfs_extern.h:1.22 src/sys/ufs/lfs/ulfs_extern.h:1.23 --- src/sys/ufs/lfs/ulfs_extern.h:1.22 Mon Jun 20 02:25:03 2016 +++ src/sys/ufs/lfs/ulfs_extern.h Mon Jun 20 02:31:47 2016 @@ -1,5 +1,5 @@ -/* $NetBSD: ulfs_extern.h,v 1.22 2016/06/20 02:25:03 dholland Exp $ */ -/* from NetBSD: ufs_extern.h,v 1.77 2014/10/29 01:13:28 christos Exp */ +/* $NetBSD: ulfs_extern.h,v 1.23 2016/06/20 02:31:47 dholland Exp $ */ +/* from NetBSD: ufs_extern.h,v 1.78 2015/03/17 09:39:29 hannken Exp */ /*- * Copyright (c) 1991, 1993, 1994 @@ -154,9 +154,6 @@ int ulfs_fhtovp(struct mount *, struct u /* ulfs_vnops.c */ void ulfs_vinit(struct mount *, int (**)(void *), int (**)(void *), struct vnode **); -int ulfs_makeinode(struct vattr *vap, struct vnode *, - const struct ulfs_lookup_results *, - struct vnode **, struct componentname *); int ulfs_gop_alloc(struct vnode *, off_t, off_t, int, kauth_cred_t); void ulfs_gop_markupdate(struct vnode *, int); int ulfs_bufio(enum uio_rw, struct vnode *, void *, size_t, off_t, int, Index: src/sys/ufs/lfs/ulfs_vnops.c diff -u src/sys/ufs/lfs/ulfs_vnops.c:1.41 src/sys/ufs/lfs/ulfs_vnops.c:1.42 --- src/sys/ufs/lfs/ulfs_vnops.c:1.41 Mon Jun 20 02:25:03 2016 +++ src/sys/ufs/lfs/ulfs_vnops.c Mon Jun 20 02:31:47 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ulfs_vnops.c,v 1.41 2016/06/20 02:25:03 dholland Exp $ */ +/* $NetBSD: ulfs_vnops.c,v 1.42 2016/06/20 02:31:47 dholland Exp $ */ /* from NetBSD: ufs_vnops.c,v 1.224 2014/10/29 01:13:28 christos Exp */ /*- @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.41 2016/06/20 02:25:03 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.42 2016/06/20 02:31:47 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_lfs.h" @@ -1159,75 +1159,6 @@ ulfs_vinit(struct mount *mntp, int (**sp } /* - * Allocate a new inode. - */ -int -ulfs_makeinode(struct vattr *vap, struct vnode *dvp, - const struct ulfs_lookup_results *ulr, - struct vnode **vpp, struct componentname *cnp) -{ - struct inode *ip; - struct vnode *tvp; - int error; - - error = vcache_new(dvp->v_mount, dvp, vap, cnp->cn_cred, &tvp); - if (error) - return error; - error = vn_lock(tvp, LK_EXCLUSIVE); - if (error) { - vrele(tvp); - return error; - } - lfs_mark_vnode(tvp); - *vpp = tvp; - ip = VTOI(tvp); - ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE; - ip->i_nlink = 1; - DIP_ASSIGN(ip, nlink, 1); - - /* Authorize setting SGID if needed. */ - if (ip->i_mode & ISGID) { - error = kauth_authorize_vnode(cnp->cn_cred, KAUTH_VNODE_WRITE_SECURITY, - tvp, NULL, genfs_can_chmod(tvp->v_type, cnp->cn_cred, ip->i_uid, - ip->i_gid, MAKEIMODE(vap->va_type, vap->va_mode))); - if (error) { - ip->i_mode &= ~ISGID; - DIP_ASSIGN(ip, mode, ip->i_mode); - } - } - - if (cnp->cn_flags & ISWHITEOUT) { - ip->i_flags |= UF_OPAQUE; - DIP_ASSIGN(ip, flags, ip->i_flags); - } - - /* - * Make sure inode goes to disk before directory entry. - */ - if ((error = lfs_update(tvp, NULL, NULL, UPDATE_DIROP)) != 0) - goto bad; - error = ulfs_direnter(dvp, ulr, tvp, - cnp, ip->i_number, LFS_IFTODT(ip->i_mode), NULL); - if (error) - goto bad; - *vpp = tvp; - return (0); - - bad: - /* - * Write error occurred trying to update the inode - * or the directory so must deallocate the inode. - */ - ip->i_nlink = 0; - DIP_ASSIGN(ip, nlink, 0); - ip->i_flag |= IN_CHANGE; - /* If IN_ADIROP, account for it */ - lfs_unmark_vnode(tvp); - vput(tvp); - return (error); -} - -/* * Allocate len bytes at offset off. */ int