Commit 3e5daf05 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Tim Shimmin

[XFS] simplify xfs_create/mknod/symlink prototype

Simplify the prototype for xfs_create/xfs_mkdir/xfs_symlink by not passing
down a bhv_vattr_t that just hogs stack space. Instead pass down the mode
in a mode_t and in case of xfs_create the rdev as a scalar type as well.

SGI-PV: 968563
SGI-Modid: xfs-linux-melb:xfs-kern:29794a
Signed-off-by: default avatarChristoph Hellwig <hch@infradead.org>
Signed-off-by: default avatarLachlan McIlroy <lachlan@sgi.com>
Signed-off-by: default avatarTim Shimmin <tes@sgi.com>
parent c83bfab1
...@@ -271,7 +271,6 @@ xfs_vn_mknod( ...@@ -271,7 +271,6 @@ xfs_vn_mknod(
dev_t rdev) dev_t rdev)
{ {
struct inode *ip; struct inode *ip;
bhv_vattr_t vattr = { 0 };
bhv_vnode_t *vp = NULL, *dvp = vn_from_inode(dir); bhv_vnode_t *vp = NULL, *dvp = vn_from_inode(dir);
xfs_acl_t *default_acl = NULL; xfs_acl_t *default_acl = NULL;
attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS; attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS;
...@@ -297,19 +296,14 @@ xfs_vn_mknod( ...@@ -297,19 +296,14 @@ xfs_vn_mknod(
if (IS_POSIXACL(dir) && !default_acl && xfs_has_fs_struct(current)) if (IS_POSIXACL(dir) && !default_acl && xfs_has_fs_struct(current))
mode &= ~current->fs->umask; mode &= ~current->fs->umask;
vattr.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
vattr.va_mode = mode;
switch (mode & S_IFMT) { switch (mode & S_IFMT) {
case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK: case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK:
vattr.va_rdev = sysv_encode_dev(rdev); rdev = sysv_encode_dev(rdev);
vattr.va_mask |= XFS_AT_RDEV;
/*FALLTHROUGH*/
case S_IFREG: case S_IFREG:
error = xfs_create(XFS_I(dir), dentry, &vattr, &vp, NULL); error = xfs_create(XFS_I(dir), dentry, mode, rdev, &vp, NULL);
break; break;
case S_IFDIR: case S_IFDIR:
error = xfs_mkdir(XFS_I(dir), dentry, &vattr, &vp, NULL); error = xfs_mkdir(XFS_I(dir), dentry, mode, &vp, NULL);
break; break;
default: default:
error = EINVAL; error = EINVAL;
...@@ -324,7 +318,7 @@ xfs_vn_mknod( ...@@ -324,7 +318,7 @@ xfs_vn_mknod(
if (unlikely(default_acl)) { if (unlikely(default_acl)) {
if (!error) { if (!error) {
error = _ACL_INHERIT(vp, &vattr, default_acl); error = _ACL_INHERIT(vp, mode, default_acl);
if (!error) if (!error)
xfs_iflags_set(XFS_I(vp), XFS_IMODIFIED); xfs_iflags_set(XFS_I(vp), XFS_IMODIFIED);
else else
...@@ -441,18 +435,17 @@ xfs_vn_symlink( ...@@ -441,18 +435,17 @@ xfs_vn_symlink(
const char *symname) const char *symname)
{ {
struct inode *ip; struct inode *ip;
bhv_vattr_t va = { 0 };
bhv_vnode_t *cvp; /* used to lookup symlink to put in dentry */ bhv_vnode_t *cvp; /* used to lookup symlink to put in dentry */
int error; int error;
mode_t mode;
cvp = NULL; cvp = NULL;
va.va_mode = S_IFLNK | mode = S_IFLNK |
(irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO); (irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO);
va.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
error = xfs_symlink(XFS_I(dir), dentry, &va, error = xfs_symlink(XFS_I(dir), dentry, (char *)symname, mode,
(char *)symname, &cvp, NULL); &cvp, NULL);
if (likely(!error && cvp)) { if (likely(!error && cvp)) {
error = xfs_init_security(cvp, dir); error = xfs_init_security(cvp, dir);
if (likely(!error)) { if (likely(!error)) {
......
...@@ -704,7 +704,7 @@ xfs_acl_vtoacl( ...@@ -704,7 +704,7 @@ xfs_acl_vtoacl(
int int
xfs_acl_inherit( xfs_acl_inherit(
bhv_vnode_t *vp, bhv_vnode_t *vp,
bhv_vattr_t *vap, mode_t mode,
xfs_acl_t *pdaclp) xfs_acl_t *pdaclp)
{ {
xfs_acl_t *cacl; xfs_acl_t *cacl;
...@@ -732,7 +732,7 @@ xfs_acl_inherit( ...@@ -732,7 +732,7 @@ xfs_acl_inherit(
return ENOMEM; return ENOMEM;
memcpy(cacl, pdaclp, sizeof(xfs_acl_t)); memcpy(cacl, pdaclp, sizeof(xfs_acl_t));
xfs_acl_filter_mode(vap->va_mode, cacl); xfs_acl_filter_mode(mode, cacl);
xfs_acl_setmode(vp, cacl, &basicperms); xfs_acl_setmode(vp, cacl, &basicperms);
/* /*
......
...@@ -57,7 +57,7 @@ extern struct kmem_zone *xfs_acl_zone; ...@@ -57,7 +57,7 @@ extern struct kmem_zone *xfs_acl_zone;
(zone) = kmem_zone_init(sizeof(xfs_acl_t), (name)) (zone) = kmem_zone_init(sizeof(xfs_acl_t), (name))
#define xfs_acl_zone_destroy(zone) kmem_zone_destroy(zone) #define xfs_acl_zone_destroy(zone) kmem_zone_destroy(zone)
extern int xfs_acl_inherit(bhv_vnode_t *, struct bhv_vattr *, xfs_acl_t *); extern int xfs_acl_inherit(bhv_vnode_t *, mode_t mode, xfs_acl_t *);
extern int xfs_acl_iaccess(struct xfs_inode *, mode_t, cred_t *); extern int xfs_acl_iaccess(struct xfs_inode *, mode_t, cred_t *);
extern int xfs_acl_vtoacl(bhv_vnode_t *, xfs_acl_t *, xfs_acl_t *); extern int xfs_acl_vtoacl(bhv_vnode_t *, xfs_acl_t *, xfs_acl_t *);
extern int xfs_acl_vhasacl_access(bhv_vnode_t *); extern int xfs_acl_vhasacl_access(bhv_vnode_t *);
...@@ -70,7 +70,7 @@ extern int xfs_acl_vremove(bhv_vnode_t *, int); ...@@ -70,7 +70,7 @@ extern int xfs_acl_vremove(bhv_vnode_t *, int);
#define _ACL_TYPE_DEFAULT 2 #define _ACL_TYPE_DEFAULT 2
#define _ACL_PERM_INVALID(perm) ((perm) & ~(ACL_READ|ACL_WRITE|ACL_EXECUTE)) #define _ACL_PERM_INVALID(perm) ((perm) & ~(ACL_READ|ACL_WRITE|ACL_EXECUTE))
#define _ACL_INHERIT(c,v,d) (xfs_acl_inherit(c,v,d)) #define _ACL_INHERIT(c,m,d) (xfs_acl_inherit(c,m,d))
#define _ACL_GET_ACCESS(pv,pa) (xfs_acl_vtoacl(pv,pa,NULL) == 0) #define _ACL_GET_ACCESS(pv,pa) (xfs_acl_vtoacl(pv,pa,NULL) == 0)
#define _ACL_GET_DEFAULT(pv,pd) (xfs_acl_vtoacl(pv,NULL,pd) == 0) #define _ACL_GET_DEFAULT(pv,pd) (xfs_acl_vtoacl(pv,NULL,pd) == 0)
#define _ACL_ACCESS_EXISTS xfs_acl_vhasacl_access #define _ACL_ACCESS_EXISTS xfs_acl_vhasacl_access
...@@ -90,7 +90,7 @@ extern int xfs_acl_vremove(bhv_vnode_t *, int); ...@@ -90,7 +90,7 @@ extern int xfs_acl_vremove(bhv_vnode_t *, int);
#define xfs_acl_vhasacl_default(v) (0) #define xfs_acl_vhasacl_default(v) (0)
#define _ACL_ALLOC(a) (1) /* successfully allocate nothing */ #define _ACL_ALLOC(a) (1) /* successfully allocate nothing */
#define _ACL_FREE(a) ((void)0) #define _ACL_FREE(a) ((void)0)
#define _ACL_INHERIT(c,v,d) (0) #define _ACL_INHERIT(c,m,d) (0)
#define _ACL_GET_ACCESS(pv,pa) (0) #define _ACL_GET_ACCESS(pv,pa) (0)
#define _ACL_GET_DEFAULT(pv,pd) (0) #define _ACL_GET_DEFAULT(pv,pd) (0)
#define _ACL_ACCESS_EXISTS (NULL) #define _ACL_ACCESS_EXISTS (NULL)
......
...@@ -1824,7 +1824,8 @@ int ...@@ -1824,7 +1824,8 @@ int
xfs_create( xfs_create(
xfs_inode_t *dp, xfs_inode_t *dp,
bhv_vname_t *dentry, bhv_vname_t *dentry,
bhv_vattr_t *vap, mode_t mode,
xfs_dev_t rdev,
bhv_vnode_t **vpp, bhv_vnode_t **vpp,
cred_t *credp) cred_t *credp)
{ {
...@@ -1834,7 +1835,6 @@ xfs_create( ...@@ -1834,7 +1835,6 @@ xfs_create(
xfs_inode_t *ip; xfs_inode_t *ip;
bhv_vnode_t *vp = NULL; bhv_vnode_t *vp = NULL;
xfs_trans_t *tp; xfs_trans_t *tp;
xfs_dev_t rdev;
int error; int error;
xfs_bmap_free_t free_list; xfs_bmap_free_t free_list;
xfs_fsblock_t first_block; xfs_fsblock_t first_block;
...@@ -1845,20 +1845,18 @@ xfs_create( ...@@ -1845,20 +1845,18 @@ xfs_create(
xfs_prid_t prid; xfs_prid_t prid;
struct xfs_dquot *udqp, *gdqp; struct xfs_dquot *udqp, *gdqp;
uint resblks; uint resblks;
int dm_di_mode;
int namelen; int namelen;
ASSERT(!*vpp); ASSERT(!*vpp);
vn_trace_entry(dp, __FUNCTION__, (inst_t *)__return_address); vn_trace_entry(dp, __FUNCTION__, (inst_t *)__return_address);
dm_di_mode = vap->va_mode;
namelen = VNAMELEN(dentry); namelen = VNAMELEN(dentry);
if (DM_EVENT_ENABLED(dp, DM_EVENT_CREATE)) { if (DM_EVENT_ENABLED(dp, DM_EVENT_CREATE)) {
error = XFS_SEND_NAMESP(mp, DM_EVENT_CREATE, error = XFS_SEND_NAMESP(mp, DM_EVENT_CREATE,
dir_vp, DM_RIGHT_NULL, NULL, dir_vp, DM_RIGHT_NULL, NULL,
DM_RIGHT_NULL, name, NULL, DM_RIGHT_NULL, name, NULL,
dm_di_mode, 0, 0); mode, 0, 0);
if (error) if (error)
return error; return error;
...@@ -1873,8 +1871,6 @@ xfs_create( ...@@ -1873,8 +1871,6 @@ xfs_create(
udqp = gdqp = NULL; udqp = gdqp = NULL;
if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
prid = dp->i_d.di_projid; prid = dp->i_d.di_projid;
else if (vap->va_mask & XFS_AT_PROJID)
prid = (xfs_prid_t)vap->va_projid;
else else
prid = (xfs_prid_t)dfltprid; prid = (xfs_prid_t)dfltprid;
...@@ -1926,8 +1922,7 @@ xfs_create( ...@@ -1926,8 +1922,7 @@ xfs_create(
if (resblks == 0 && (error = xfs_dir_canenter(tp, dp, name, namelen))) if (resblks == 0 && (error = xfs_dir_canenter(tp, dp, name, namelen)))
goto error_return; goto error_return;
rdev = (vap->va_mask & XFS_AT_RDEV) ? vap->va_rdev : 0; error = xfs_dir_ialloc(&tp, dp, mode, 1,
error = xfs_dir_ialloc(&tp, dp, vap->va_mode, 1,
rdev, credp, prid, resblks > 0, rdev, credp, prid, resblks > 0,
&ip, &committed); &ip, &committed);
if (error) { if (error) {
...@@ -2018,7 +2013,7 @@ xfs_create( ...@@ -2018,7 +2013,7 @@ xfs_create(
dir_vp, DM_RIGHT_NULL, dir_vp, DM_RIGHT_NULL,
*vpp ? vp:NULL, *vpp ? vp:NULL,
DM_RIGHT_NULL, name, NULL, DM_RIGHT_NULL, name, NULL,
dm_di_mode, error, 0); mode, error, 0);
} }
return error; return error;
...@@ -2709,7 +2704,7 @@ int ...@@ -2709,7 +2704,7 @@ int
xfs_mkdir( xfs_mkdir(
xfs_inode_t *dp, xfs_inode_t *dp,
bhv_vname_t *dentry, bhv_vname_t *dentry,
bhv_vattr_t *vap, mode_t mode,
bhv_vnode_t **vpp, bhv_vnode_t **vpp,
cred_t *credp) cred_t *credp)
{ {
...@@ -2731,19 +2726,17 @@ xfs_mkdir( ...@@ -2731,19 +2726,17 @@ xfs_mkdir(
xfs_prid_t prid; xfs_prid_t prid;
struct xfs_dquot *udqp, *gdqp; struct xfs_dquot *udqp, *gdqp;
uint resblks; uint resblks;
int dm_di_mode;
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO); return XFS_ERROR(EIO);
tp = NULL; tp = NULL;
dm_di_mode = vap->va_mode;
if (DM_EVENT_ENABLED(dp, DM_EVENT_CREATE)) { if (DM_EVENT_ENABLED(dp, DM_EVENT_CREATE)) {
error = XFS_SEND_NAMESP(mp, DM_EVENT_CREATE, error = XFS_SEND_NAMESP(mp, DM_EVENT_CREATE,
dir_vp, DM_RIGHT_NULL, NULL, dir_vp, DM_RIGHT_NULL, NULL,
DM_RIGHT_NULL, dir_name, NULL, DM_RIGHT_NULL, dir_name, NULL,
dm_di_mode, 0, 0); mode, 0, 0);
if (error) if (error)
return error; return error;
dm_event_sent = 1; dm_event_sent = 1;
...@@ -2757,8 +2750,6 @@ xfs_mkdir( ...@@ -2757,8 +2750,6 @@ xfs_mkdir(
udqp = gdqp = NULL; udqp = gdqp = NULL;
if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
prid = dp->i_d.di_projid; prid = dp->i_d.di_projid;
else if (vap->va_mask & XFS_AT_PROJID)
prid = (xfs_prid_t)vap->va_projid;
else else
prid = (xfs_prid_t)dfltprid; prid = (xfs_prid_t)dfltprid;
...@@ -2811,7 +2802,7 @@ xfs_mkdir( ...@@ -2811,7 +2802,7 @@ xfs_mkdir(
/* /*
* create the directory inode. * create the directory inode.
*/ */
error = xfs_dir_ialloc(&tp, dp, vap->va_mode, 2, error = xfs_dir_ialloc(&tp, dp, mode, 2,
0, credp, prid, resblks > 0, 0, credp, prid, resblks > 0,
&cdp, NULL); &cdp, NULL);
if (error) { if (error) {
...@@ -2905,7 +2896,7 @@ xfs_mkdir( ...@@ -2905,7 +2896,7 @@ xfs_mkdir(
created ? XFS_ITOV(cdp):NULL, created ? XFS_ITOV(cdp):NULL,
DM_RIGHT_NULL, DM_RIGHT_NULL,
dir_name, NULL, dir_name, NULL,
dm_di_mode, error, 0); mode, error, 0);
} }
return error; return error;
...@@ -3162,8 +3153,8 @@ int ...@@ -3162,8 +3153,8 @@ int
xfs_symlink( xfs_symlink(
xfs_inode_t *dp, xfs_inode_t *dp,
bhv_vname_t *dentry, bhv_vname_t *dentry,
bhv_vattr_t *vap,
char *target_path, char *target_path,
mode_t mode,
bhv_vnode_t **vpp, bhv_vnode_t **vpp,
cred_t *credp) cred_t *credp)
{ {
...@@ -3251,8 +3242,6 @@ xfs_symlink( ...@@ -3251,8 +3242,6 @@ xfs_symlink(
udqp = gdqp = NULL; udqp = gdqp = NULL;
if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
prid = dp->i_d.di_projid; prid = dp->i_d.di_projid;
else if (vap->va_mask & XFS_AT_PROJID)
prid = (xfs_prid_t)vap->va_projid;
else else
prid = (xfs_prid_t)dfltprid; prid = (xfs_prid_t)dfltprid;
...@@ -3321,7 +3310,7 @@ xfs_symlink( ...@@ -3321,7 +3310,7 @@ xfs_symlink(
/* /*
* Allocate an inode for the symlink. * Allocate an inode for the symlink.
*/ */
error = xfs_dir_ialloc(&tp, dp, S_IFLNK | (vap->va_mode&~S_IFMT), error = xfs_dir_ialloc(&tp, dp, S_IFLNK | (mode & ~S_IFMT),
1, 0, credp, prid, resblks > 0, &ip, NULL); 1, 0, credp, prid, resblks > 0, &ip, NULL);
if (error) { if (error) {
if (error == ENOSPC) if (error == ENOSPC)
......
...@@ -26,19 +26,19 @@ int xfs_release(struct xfs_inode *ip); ...@@ -26,19 +26,19 @@ int xfs_release(struct xfs_inode *ip);
int xfs_inactive(struct xfs_inode *ip); int xfs_inactive(struct xfs_inode *ip);
int xfs_lookup(struct xfs_inode *dp, bhv_vname_t *dentry, int xfs_lookup(struct xfs_inode *dp, bhv_vname_t *dentry,
bhv_vnode_t **vpp); bhv_vnode_t **vpp);
int xfs_create(struct xfs_inode *dp, bhv_vname_t *dentry, int xfs_create(struct xfs_inode *dp, bhv_vname_t *dentry, mode_t mode,
struct bhv_vattr *vap, bhv_vnode_t **vpp, struct cred *credp); xfs_dev_t rdev, bhv_vnode_t **vpp, struct cred *credp);
int xfs_remove(struct xfs_inode *dp, bhv_vname_t *dentry); int xfs_remove(struct xfs_inode *dp, bhv_vname_t *dentry);
int xfs_link(struct xfs_inode *tdp, bhv_vnode_t *src_vp, int xfs_link(struct xfs_inode *tdp, bhv_vnode_t *src_vp,
bhv_vname_t *dentry); bhv_vname_t *dentry);
int xfs_mkdir(struct xfs_inode *dp, bhv_vname_t *dentry, int xfs_mkdir(struct xfs_inode *dp, bhv_vname_t *dentry,
struct bhv_vattr *vap, bhv_vnode_t **vpp, struct cred *credp); mode_t mode, bhv_vnode_t **vpp, struct cred *credp);
int xfs_rmdir(struct xfs_inode *dp, bhv_vname_t *dentry); int xfs_rmdir(struct xfs_inode *dp, bhv_vname_t *dentry);
int xfs_readdir(struct xfs_inode *dp, void *dirent, size_t bufsize, int xfs_readdir(struct xfs_inode *dp, void *dirent, size_t bufsize,
xfs_off_t *offset, filldir_t filldir); xfs_off_t *offset, filldir_t filldir);
int xfs_symlink(struct xfs_inode *dp, bhv_vname_t *dentry, int xfs_symlink(struct xfs_inode *dp, bhv_vname_t *dentry,
struct bhv_vattr *vap, char *target_path, char *target_path, mode_t mode, bhv_vnode_t **vpp,
bhv_vnode_t **vpp, struct cred *credp); struct cred *credp);
int xfs_fid2(struct xfs_inode *ip, fid_t *fidp); int xfs_fid2(struct xfs_inode *ip, fid_t *fidp);
int xfs_rwlock(struct xfs_inode *ip, bhv_vrwlock_t locktype); int xfs_rwlock(struct xfs_inode *ip, bhv_vrwlock_t locktype);
void xfs_rwunlock(struct xfs_inode *ip, bhv_vrwlock_t locktype); void xfs_rwunlock(struct xfs_inode *ip, bhv_vrwlock_t locktype);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment