Commit 41901585 authored by Nathan Scott's avatar Nathan Scott Committed by Stephen Lord

[XFS] Remove unneeded initialisations to zero, formatting cleanups, remove

a no-longer-correct-comment, fix up symlink error path code, several
minor changes to help keep this code more in sync with 2.4.

SGI Modid: 2.5.x-xfs:slinx:141838a
parent b7f81d36
/* /*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as * under the terms of version 2 of the GNU General Public License as
...@@ -154,20 +154,18 @@ linvfs_mkdir( ...@@ -154,20 +154,18 @@ linvfs_mkdir(
return linvfs_mknod(dir, dentry, mode|S_IFDIR, 0); return linvfs_mknod(dir, dentry, mode|S_IFDIR, 0);
} }
STATIC struct dentry * STATIC struct dentry *
linvfs_lookup( linvfs_lookup(
struct inode *dir, struct inode *dir,
struct dentry *dentry) struct dentry *dentry)
{ {
int error;
vnode_t *vp, *cvp;
struct inode *ip = NULL; struct inode *ip = NULL;
vnode_t *vp, *cvp = NULL;
int error;
if (dentry->d_name.len >= MAXNAMELEN) if (dentry->d_name.len >= MAXNAMELEN)
return ERR_PTR(-ENAMETOOLONG); return ERR_PTR(-ENAMETOOLONG);
cvp = NULL;
vp = LINVFS_GET_VP(dir); vp = LINVFS_GET_VP(dir);
VOP_LOOKUP(vp, dentry, &cvp, 0, NULL, NULL, error); VOP_LOOKUP(vp, dentry, &cvp, 0, NULL, NULL, error);
if (!error) { if (!error) {
...@@ -189,10 +187,10 @@ linvfs_link( ...@@ -189,10 +187,10 @@ linvfs_link(
struct inode *dir, struct inode *dir,
struct dentry *dentry) struct dentry *dentry)
{ {
int error;
vnode_t *tdvp; /* Target directory for new name/link */
vnode_t *vp; /* vp of name being linked */
struct inode *ip; /* inode of guy being linked to */ struct inode *ip; /* inode of guy being linked to */
vnode_t *tdvp; /* target directory for new name/link */
vnode_t *vp; /* vp of name being linked */
int error;
ip = old_dentry->d_inode; /* inode being linked to */ ip = old_dentry->d_inode; /* inode being linked to */
if (S_ISDIR(ip->i_mode)) if (S_ISDIR(ip->i_mode))
...@@ -201,7 +199,6 @@ linvfs_link( ...@@ -201,7 +199,6 @@ linvfs_link(
tdvp = LINVFS_GET_VP(dir); tdvp = LINVFS_GET_VP(dir);
vp = LINVFS_GET_VP(ip); vp = LINVFS_GET_VP(ip);
error = 0;
VOP_LINK(tdvp, vp, dentry, NULL, error); VOP_LINK(tdvp, vp, dentry, NULL, error);
if (!error) { if (!error) {
VMODIFY(tdvp); VMODIFY(tdvp);
...@@ -218,16 +215,14 @@ linvfs_unlink( ...@@ -218,16 +215,14 @@ linvfs_unlink(
struct inode *dir, struct inode *dir,
struct dentry *dentry) struct dentry *dentry)
{ {
int error = 0;
struct inode *inode; struct inode *inode;
vnode_t *dvp; /* directory containing name to remove */ vnode_t *dvp; /* directory containing name to remove */
int error;
inode = dentry->d_inode; inode = dentry->d_inode;
dvp = LINVFS_GET_VP(dir); dvp = LINVFS_GET_VP(dir);
VOP_REMOVE(dvp, dentry, NULL, error); VOP_REMOVE(dvp, dentry, NULL, error);
if (!error) { if (!error) {
validate_fields(dir); /* For size only */ validate_fields(dir); /* For size only */
validate_fields(inode); validate_fields(inode);
...@@ -244,13 +239,14 @@ linvfs_symlink( ...@@ -244,13 +239,14 @@ linvfs_symlink(
struct dentry *dentry, struct dentry *dentry,
const char *symname) const char *symname)
{ {
int error; struct inode *ip;
vattr_t va;
vnode_t *dvp; /* directory containing name to remove */ vnode_t *dvp; /* directory containing name to remove */
vnode_t *cvp; /* used to lookup symlink to put in dentry */ vnode_t *cvp; /* used to lookup symlink to put in dentry */
vattr_t va; int error;
struct inode *ip = NULL;
dvp = LINVFS_GET_VP(dir); dvp = LINVFS_GET_VP(dir);
cvp = NULL;
memset(&va, 0, sizeof(va)); memset(&va, 0, sizeof(va));
va.va_type = VLNK; va.va_type = VLNK;
...@@ -259,20 +255,14 @@ linvfs_symlink( ...@@ -259,20 +255,14 @@ linvfs_symlink(
error = 0; error = 0;
VOP_SYMLINK(dvp, dentry, &va, (char *)symname, &cvp, NULL, error); VOP_SYMLINK(dvp, dentry, &va, (char *)symname, &cvp, NULL, error);
if (!error) { if (!error && cvp) {
ASSERT(cvp);
ASSERT(cvp->v_type == VLNK); ASSERT(cvp->v_type == VLNK);
ip = LINVFS_GET_IP(cvp); ip = LINVFS_GET_IP(cvp);
if (!ip) { d_instantiate(dentry, ip);
error = ENOMEM; validate_fields(dir);
VN_RELE(cvp); validate_fields(ip); /* size needs update */
} else { mark_inode_dirty_sync(ip);
d_instantiate(dentry, ip); mark_inode_dirty_sync(dir);
validate_fields(dir);
validate_fields(ip); /* size needs update */
mark_inode_dirty_sync(ip);
mark_inode_dirty_sync(dir);
}
} }
return -error; return -error;
} }
...@@ -303,23 +293,20 @@ linvfs_rename( ...@@ -303,23 +293,20 @@ linvfs_rename(
struct inode *ndir, struct inode *ndir,
struct dentry *ndentry) struct dentry *ndentry)
{ {
int error; struct inode *new_inode = ndentry->d_inode;
vnode_t *fvp; /* from directory */ vnode_t *fvp; /* from directory */
vnode_t *tvp; /* target directory */ vnode_t *tvp; /* target directory */
struct inode *new_inode = NULL; int error;
fvp = LINVFS_GET_VP(odir); fvp = LINVFS_GET_VP(odir);
tvp = LINVFS_GET_VP(ndir); tvp = LINVFS_GET_VP(ndir);
new_inode = ndentry->d_inode;
VOP_RENAME(fvp, odentry, tvp, ndentry, NULL, error); VOP_RENAME(fvp, odentry, tvp, ndentry, NULL, error);
if (error) if (error)
return -error; return -error;
if (new_inode) { if (new_inode)
validate_fields(new_inode); validate_fields(new_inode);
}
validate_fields(odir); validate_fields(odir);
if (ndir != odir) if (ndir != odir)
...@@ -334,13 +321,11 @@ linvfs_readlink( ...@@ -334,13 +321,11 @@ linvfs_readlink(
char *buf, char *buf,
int size) int size)
{ {
vnode_t *vp; vnode_t *vp = LINVFS_GET_VP(dentry->d_inode);
uio_t uio; uio_t uio;
iovec_t iov; iovec_t iov;
int error; int error;
vp = LINVFS_GET_VP(dentry->d_inode);
iov.iov_base = buf; iov.iov_base = buf;
iov.iov_len = size; iov.iov_len = size;
...@@ -427,11 +412,6 @@ linvfs_permission( ...@@ -427,11 +412,6 @@ linvfs_permission(
return -error; return -error;
} }
/* Brute force approach for now - copy data into linux inode
* from the results of a getattr. This gets called out of things
* like stat.
*/
STATIC int STATIC int
linvfs_getattr( linvfs_getattr(
struct vfsmount *mnt, struct vfsmount *mnt,
...@@ -442,9 +422,8 @@ linvfs_getattr( ...@@ -442,9 +422,8 @@ linvfs_getattr(
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
int error = 0; int error = 0;
if (unlikely(vp->v_flag & VMODIFIED)) { if (unlikely(vp->v_flag & VMODIFIED))
error = vn_revalidate(vp); error = vn_revalidate(vp);
}
if (!error) if (!error)
generic_fillattr(inode, stat); generic_fillattr(inode, stat);
return 0; return 0;
...@@ -456,11 +435,11 @@ linvfs_setattr( ...@@ -456,11 +435,11 @@ linvfs_setattr(
struct iattr *attr) struct iattr *attr)
{ {
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
unsigned int ia_valid = attr->ia_valid;
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
vattr_t vattr; vattr_t vattr;
unsigned int ia_valid = attr->ia_valid;
int error;
int flags = 0; int flags = 0;
int error;
memset(&vattr, 0, sizeof(vattr_t)); memset(&vattr, 0, sizeof(vattr_t));
if (ia_valid & ATTR_UID) { if (ia_valid & ATTR_UID) {
...@@ -513,7 +492,7 @@ linvfs_setattr( ...@@ -513,7 +492,7 @@ linvfs_setattr(
STATIC void STATIC void
linvfs_truncate( linvfs_truncate(
struct inode *inode) struct inode *inode)
{ {
block_truncate_page(inode->i_mapping, inode->i_size, linvfs_get_block); block_truncate_page(inode->i_mapping, inode->i_size, linvfs_get_block);
} }
...@@ -581,11 +560,11 @@ linvfs_setxattr( ...@@ -581,11 +560,11 @@ linvfs_setxattr(
size_t size, size_t size,
int flags) int flags)
{ {
int error;
int xflags = 0;
char *p = (char *)name;
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
char *p = (char *)name;
int xflags = 0;
int error;
if (strncmp(name, xfs_namespaces[SYSTEM_NAMES].name, if (strncmp(name, xfs_namespaces[SYSTEM_NAMES].name,
xfs_namespaces[SYSTEM_NAMES].namelen) == 0) { xfs_namespaces[SYSTEM_NAMES].namelen) == 0) {
...@@ -594,20 +573,16 @@ linvfs_setxattr( ...@@ -594,20 +573,16 @@ linvfs_setxattr(
return error; return error;
error = -EOPNOTSUPP; error = -EOPNOTSUPP;
p += xfs_namespaces[SYSTEM_NAMES].namelen; p += xfs_namespaces[SYSTEM_NAMES].namelen;
if (strcmp(p, POSIXACL_ACCESS) == 0) { if (strcmp(p, POSIXACL_ACCESS) == 0)
error = xfs_acl_vset(vp, (void *) data, size, error = xfs_acl_vset(vp, (void *) data, size,
_ACL_TYPE_ACCESS); _ACL_TYPE_ACCESS);
} else if (strcmp(p, POSIXACL_DEFAULT) == 0)
else if (strcmp(p, POSIXACL_DEFAULT) == 0) {
error = xfs_acl_vset(vp, (void *) data, size, error = xfs_acl_vset(vp, (void *) data, size,
_ACL_TYPE_DEFAULT); _ACL_TYPE_DEFAULT);
} else if (strcmp(p, POSIXCAP) == 0)
else if (strcmp(p, POSIXCAP) == 0) {
error = xfs_cap_vset(vp, (void *) data, size); error = xfs_cap_vset(vp, (void *) data, size);
} if (!error)
if (!error) {
error = vn_revalidate(vp); error = vn_revalidate(vp);
}
return error; return error;
} }
...@@ -644,25 +619,22 @@ linvfs_getxattr( ...@@ -644,25 +619,22 @@ linvfs_getxattr(
void *data, void *data,
size_t size) size_t size)
{ {
ssize_t error;
int xflags = 0;
char *p = (char *)name;
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
char *p = (char *)name;
int xflags = 0;
ssize_t error;
if (strncmp(name, xfs_namespaces[SYSTEM_NAMES].name, if (strncmp(name, xfs_namespaces[SYSTEM_NAMES].name,
xfs_namespaces[SYSTEM_NAMES].namelen) == 0) { xfs_namespaces[SYSTEM_NAMES].namelen) == 0) {
error = -EOPNOTSUPP; error = -EOPNOTSUPP;
p += xfs_namespaces[SYSTEM_NAMES].namelen; p += xfs_namespaces[SYSTEM_NAMES].namelen;
if (strcmp(p, POSIXACL_ACCESS) == 0) { if (strcmp(p, POSIXACL_ACCESS) == 0)
error = xfs_acl_vget(vp, data, size, _ACL_TYPE_ACCESS); error = xfs_acl_vget(vp, data, size, _ACL_TYPE_ACCESS);
} else if (strcmp(p, POSIXACL_DEFAULT) == 0)
else if (strcmp(p, POSIXACL_DEFAULT) == 0) {
error = xfs_acl_vget(vp, data, size, _ACL_TYPE_DEFAULT); error = xfs_acl_vget(vp, data, size, _ACL_TYPE_DEFAULT);
} else if (strcmp(p, POSIXCAP) == 0)
else if (strcmp(p, POSIXCAP) == 0) {
error = xfs_cap_vget(vp, data, size); error = xfs_cap_vget(vp, data, size);
}
return error; return error;
} }
...@@ -701,15 +673,13 @@ linvfs_listxattr( ...@@ -701,15 +673,13 @@ linvfs_listxattr(
char *data, char *data,
size_t size) size_t size)
{ {
ssize_t error;
int result = 0;
int xflags = ATTR_KERNAMELS;
char *k = data;
attrlist_cursor_kern_t cursor; attrlist_cursor_kern_t cursor;
xattr_namespace_t *sys; xattr_namespace_t *sys;
vnode_t *vp; vnode_t *vp = LINVFS_GET_VP(dentry->d_inode);
char *k = data;
vp = LINVFS_GET_VP(dentry->d_inode); int xflags = ATTR_KERNAMELS;
int result = 0;
ssize_t error;
if (!size) if (!size)
xflags |= ATTR_KERNOVAL; xflags |= ATTR_KERNOVAL;
...@@ -745,11 +715,11 @@ linvfs_removexattr( ...@@ -745,11 +715,11 @@ linvfs_removexattr(
struct dentry *dentry, struct dentry *dentry,
const char *name) const char *name)
{ {
int error;
int xflags = 0;
char *p = (char *)name;
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
char *p = (char *)name;
int xflags = 0;
int error;
if (strncmp(name, xfs_namespaces[SYSTEM_NAMES].name, if (strncmp(name, xfs_namespaces[SYSTEM_NAMES].name,
xfs_namespaces[SYSTEM_NAMES].namelen) == 0) { xfs_namespaces[SYSTEM_NAMES].namelen) == 0) {
...@@ -788,8 +758,8 @@ linvfs_removexattr( ...@@ -788,8 +758,8 @@ linvfs_removexattr(
struct inode_operations linvfs_file_inode_operations = struct inode_operations linvfs_file_inode_operations =
{ {
.permission = linvfs_permission, .permission = linvfs_permission,
.getattr = linvfs_getattr,
.truncate = linvfs_truncate, .truncate = linvfs_truncate,
.getattr = linvfs_getattr,
.setattr = linvfs_setattr, .setattr = linvfs_setattr,
.setxattr = linvfs_setxattr, .setxattr = linvfs_setxattr,
.getxattr = linvfs_getxattr, .getxattr = linvfs_getxattr,
......
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