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.
This commit is contained in:
parent
0261ff7039
commit
b08ea0376c
@ -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[] = {
|
||||
@ -351,6 +355,75 @@ const struct vnodeopv_desc lfs_fifoop_opv_desc =
|
||||
#include <ufs/lfs/ulfs_readwrite.c>
|
||||
#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.
|
||||
*/
|
||||
@ -2297,3 +2370,4 @@ lfs_deleteextattr(void *v)
|
||||
/* XXX Not implemented for ULFS2 file systems. */
|
||||
return (EOPNOTSUPP);
|
||||
}
|
||||
|
||||
|
@ -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 ulfs_ufid *, struct vnode **);
|
||||
/* 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,
|
||||
|
@ -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"
|
||||
@ -1158,75 +1158,6 @@ ulfs_vinit(struct mount *mntp, int (**specops)(void *), int (**fifoops)(void *),
|
||||
*vpp = vp;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user