提交 520c8534 编写于 作者: L Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6:
  inotify: fix type errors in interfaces
  fix breakage in reiserfs_new_inode()
  fix the treatment of jfs special inodes
  vfs: remove duplicate code in get_fs_type()
  add a vfs_fsync helper
  sys_execve and sys_uselib do not call into fsnotify
  zero i_uid/i_gid on inode allocation
  inode->i_op is never NULL
  ntfs: don't NULL i_op
  isofs check for NULL ->i_op in root directory is dead code
  affs: do not zero ->i_op
  kill suid bit only for regular files
  vfs: lseek(fd, 0, SEEK_CUR) race condition
...@@ -97,7 +97,6 @@ spufs_new_inode(struct super_block *sb, int mode) ...@@ -97,7 +97,6 @@ spufs_new_inode(struct super_block *sb, int mode)
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = current_fsuid(); inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid(); inode->i_gid = current_fsgid();
inode->i_blocks = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
out: out:
return inode; return inode;
......
...@@ -106,7 +106,6 @@ static struct inode *hypfs_make_inode(struct super_block *sb, int mode) ...@@ -106,7 +106,6 @@ static struct inode *hypfs_make_inode(struct super_block *sb, int mode)
ret->i_mode = mode; ret->i_mode = mode;
ret->i_uid = hypfs_info->uid; ret->i_uid = hypfs_info->uid;
ret->i_gid = hypfs_info->gid; ret->i_gid = hypfs_info->gid;
ret->i_blocks = 0;
ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
if (mode & S_IFDIR) if (mode & S_IFDIR)
ret->i_nlink = 2; ret->i_nlink = 2;
......
...@@ -57,9 +57,6 @@ static int ipathfs_mknod(struct inode *dir, struct dentry *dentry, ...@@ -57,9 +57,6 @@ static int ipathfs_mknod(struct inode *dir, struct dentry *dentry,
} }
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = 0;
inode->i_gid = 0;
inode->i_blocks = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_private = data; inode->i_private = data;
if ((mode & S_IFMT) == S_IFDIR) { if ((mode & S_IFMT) == S_IFDIR) {
......
...@@ -111,8 +111,6 @@ capifs_fill_super(struct super_block *s, void *data, int silent) ...@@ -111,8 +111,6 @@ capifs_fill_super(struct super_block *s, void *data, int silent)
goto fail; goto fail;
inode->i_ino = 1; inode->i_ino = 1;
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
inode->i_blocks = 0;
inode->i_uid = inode->i_gid = 0;
inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR; inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
inode->i_op = &simple_dir_inode_operations; inode->i_op = &simple_dir_inode_operations;
inode->i_fop = &simple_dir_operations; inode->i_fop = &simple_dir_operations;
......
...@@ -146,8 +146,6 @@ static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode) ...@@ -146,8 +146,6 @@ static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode)
if (ret) { if (ret) {
ret->i_mode = mode; ret->i_mode = mode;
ret->i_uid = ret->i_gid = 0;
ret->i_blocks = 0;
ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
} }
return ret; return ret;
......
...@@ -29,9 +29,6 @@ static struct inode *oprofilefs_get_inode(struct super_block *sb, int mode) ...@@ -29,9 +29,6 @@ static struct inode *oprofilefs_get_inode(struct super_block *sb, int mode)
if (inode) { if (inode) {
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = 0;
inode->i_gid = 0;
inode->i_blocks = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
} }
return inode; return inode;
......
...@@ -279,7 +279,6 @@ static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t de ...@@ -279,7 +279,6 @@ static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t de
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = current_fsuid(); inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid(); inode->i_gid = current_fsgid();
inode->i_blocks = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
switch (mode & S_IFMT) { switch (mode & S_IFMT) {
default: default:
......
...@@ -1863,26 +1863,10 @@ static int do_write(struct fsg_dev *fsg) ...@@ -1863,26 +1863,10 @@ static int do_write(struct fsg_dev *fsg)
static int fsync_sub(struct lun *curlun) static int fsync_sub(struct lun *curlun)
{ {
struct file *filp = curlun->filp; struct file *filp = curlun->filp;
struct inode *inode;
int rc, err;
if (curlun->ro || !filp) if (curlun->ro || !filp)
return 0; return 0;
if (!filp->f_op->fsync) return vfs_fsync(filp, filp->f_path.dentry, 1);
return -EINVAL;
inode = filp->f_path.dentry->d_inode;
mutex_lock(&inode->i_mutex);
rc = filemap_fdatawrite(inode->i_mapping);
err = filp->f_op->fsync(filp, filp->f_path.dentry, 1);
if (!rc)
rc = err;
err = filemap_fdatawait(inode->i_mapping);
if (!rc)
rc = err;
mutex_unlock(&inode->i_mutex);
VLDBG(curlun, "fdatasync -> %d\n", rc);
return rc;
} }
static void fsync_all(struct fsg_dev *fsg) static void fsync_all(struct fsg_dev *fsg)
......
...@@ -2001,7 +2001,6 @@ gadgetfs_make_inode (struct super_block *sb, ...@@ -2001,7 +2001,6 @@ gadgetfs_make_inode (struct super_block *sb,
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = default_uid; inode->i_uid = default_uid;
inode->i_gid = default_gid; inode->i_gid = default_gid;
inode->i_blocks = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime inode->i_atime = inode->i_mtime = inode->i_ctime
= CURRENT_TIME; = CURRENT_TIME;
inode->i_private = data; inode->i_private = data;
......
...@@ -119,8 +119,7 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino) ...@@ -119,8 +119,7 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)
goto bad_inode; goto bad_inode;
#else #else
inode->i_mode |= S_IFDIR; inode->i_mode |= S_IFDIR;
inode->i_op = NULL; /* ... and leave ->i_op and ->i_fop pointing to empty */
inode->i_fop = NULL;
break; break;
#endif #endif
case ST_LINKFILE: case ST_LINKFILE:
......
...@@ -251,13 +251,11 @@ struct inode *autofs_iget(struct super_block *sb, unsigned long ino) ...@@ -251,13 +251,11 @@ struct inode *autofs_iget(struct super_block *sb, unsigned long ino)
inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO; inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
inode->i_nlink = 2; inode->i_nlink = 2;
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
inode->i_blocks = 0;
if (ino == AUTOFS_ROOT_INO) { if (ino == AUTOFS_ROOT_INO) {
inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR; inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
inode->i_op = &autofs_root_inode_operations; inode->i_op = &autofs_root_inode_operations;
inode->i_fop = &autofs_root_operations; inode->i_fop = &autofs_root_operations;
inode->i_uid = inode->i_gid = 0; /* Changed in read_super */
goto done; goto done;
} }
......
...@@ -455,11 +455,7 @@ struct inode *autofs4_get_inode(struct super_block *sb, ...@@ -455,11 +455,7 @@ struct inode *autofs4_get_inode(struct super_block *sb,
if (sb->s_root) { if (sb->s_root) {
inode->i_uid = sb->s_root->d_inode->i_uid; inode->i_uid = sb->s_root->d_inode->i_uid;
inode->i_gid = sb->s_root->d_inode->i_gid; inode->i_gid = sb->s_root->d_inode->i_gid;
} else {
inode->i_uid = 0;
inode->i_gid = 0;
} }
inode->i_blocks = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
if (S_ISDIR(inf->mode)) { if (S_ISDIR(inf->mode)) {
......
...@@ -496,9 +496,6 @@ static struct inode *bm_get_inode(struct super_block *sb, int mode) ...@@ -496,9 +496,6 @@ static struct inode *bm_get_inode(struct super_block *sb, int mode)
if (inode) { if (inode) {
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = 0;
inode->i_gid = 0;
inode->i_blocks = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime = inode->i_atime = inode->i_mtime = inode->i_ctime =
current_fs_time(inode->i_sb); current_fs_time(inode->i_sb);
} }
......
...@@ -1641,7 +1641,7 @@ static int cifs_vmtruncate(struct inode *inode, loff_t offset) ...@@ -1641,7 +1641,7 @@ static int cifs_vmtruncate(struct inode *inode, loff_t offset)
i_size_write(inode, offset); i_size_write(inode, offset);
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
out_truncate: out_truncate:
if (inode->i_op && inode->i_op->truncate) if (inode->i_op->truncate)
inode->i_op->truncate(inode); inode->i_op->truncate(inode);
return 0; return 0;
out_sig: out_sig:
......
...@@ -201,8 +201,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file) ...@@ -201,8 +201,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file)
int coda_fsync(struct file *coda_file, struct dentry *coda_dentry, int datasync) int coda_fsync(struct file *coda_file, struct dentry *coda_dentry, int datasync)
{ {
struct file *host_file; struct file *host_file;
struct dentry *host_dentry; struct inode *coda_inode = coda_dentry->d_inode;
struct inode *host_inode, *coda_inode = coda_dentry->d_inode;
struct coda_file_info *cfi; struct coda_file_info *cfi;
int err = 0; int err = 0;
...@@ -214,14 +213,7 @@ int coda_fsync(struct file *coda_file, struct dentry *coda_dentry, int datasync) ...@@ -214,14 +213,7 @@ int coda_fsync(struct file *coda_file, struct dentry *coda_dentry, int datasync)
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
host_file = cfi->cfi_container; host_file = cfi->cfi_container;
if (host_file->f_op && host_file->f_op->fsync) { err = vfs_fsync(host_file, host_file->f_path.dentry, datasync);
host_dentry = host_file->f_path.dentry;
host_inode = host_dentry->d_inode;
mutex_lock(&host_inode->i_mutex);
err = host_file->f_op->fsync(host_file, host_dentry, datasync);
mutex_unlock(&host_inode->i_mutex);
}
if ( !err && !datasync ) { if ( !err && !datasync ) {
lock_kernel(); lock_kernel();
err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode)); err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode));
......
...@@ -117,8 +117,6 @@ int configfs_setattr(struct dentry * dentry, struct iattr * iattr) ...@@ -117,8 +117,6 @@ int configfs_setattr(struct dentry * dentry, struct iattr * iattr)
static inline void set_default_inode_attr(struct inode * inode, mode_t mode) static inline void set_default_inode_attr(struct inode * inode, mode_t mode)
{ {
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = 0;
inode->i_gid = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
} }
...@@ -136,7 +134,6 @@ struct inode * configfs_new_inode(mode_t mode, struct configfs_dirent * sd) ...@@ -136,7 +134,6 @@ struct inode * configfs_new_inode(mode_t mode, struct configfs_dirent * sd)
{ {
struct inode * inode = new_inode(configfs_sb); struct inode * inode = new_inode(configfs_sb);
if (inode) { if (inode) {
inode->i_blocks = 0;
inode->i_mapping->a_ops = &configfs_aops; inode->i_mapping->a_ops = &configfs_aops;
inode->i_mapping->backing_dev_info = &configfs_backing_dev_info; inode->i_mapping->backing_dev_info = &configfs_backing_dev_info;
inode->i_op = &configfs_inode_operations; inode->i_op = &configfs_inode_operations;
......
...@@ -83,8 +83,6 @@ static struct inode *get_cramfs_inode(struct super_block *sb, ...@@ -83,8 +83,6 @@ static struct inode *get_cramfs_inode(struct super_block *sb,
inode->i_op = &page_symlink_inode_operations; inode->i_op = &page_symlink_inode_operations;
inode->i_data.a_ops = &cramfs_aops; inode->i_data.a_ops = &cramfs_aops;
} else { } else {
inode->i_size = 0;
inode->i_blocks = 0;
init_special_inode(inode, inode->i_mode, init_special_inode(inode, inode->i_mode,
old_decode_dev(cramfs_inode->size)); old_decode_dev(cramfs_inode->size));
} }
......
...@@ -37,9 +37,6 @@ static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t d ...@@ -37,9 +37,6 @@ static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t d
if (inode) { if (inode) {
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = 0;
inode->i_gid = 0;
inode->i_blocks = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
switch (mode & S_IFMT) { switch (mode & S_IFMT) {
default: default:
......
...@@ -189,8 +189,6 @@ static int mknod_ptmx(struct super_block *sb) ...@@ -189,8 +189,6 @@ static int mknod_ptmx(struct super_block *sb)
} }
inode->i_ino = 2; inode->i_ino = 2;
inode->i_uid = inode->i_gid = 0;
inode->i_blocks = 0;
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
mode = S_IFCHR|opts->ptmxmode; mode = S_IFCHR|opts->ptmxmode;
...@@ -300,8 +298,6 @@ devpts_fill_super(struct super_block *s, void *data, int silent) ...@@ -300,8 +298,6 @@ devpts_fill_super(struct super_block *s, void *data, int silent)
goto free_fsi; goto free_fsi;
inode->i_ino = 1; inode->i_ino = 1;
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
inode->i_blocks = 0;
inode->i_uid = inode->i_gid = 0;
inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR; inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
inode->i_op = &simple_dir_inode_operations; inode->i_op = &simple_dir_inode_operations;
inode->i_fop = &simple_dir_operations; inode->i_fop = &simple_dir_operations;
......
...@@ -275,18 +275,9 @@ static int ecryptfs_release(struct inode *inode, struct file *file) ...@@ -275,18 +275,9 @@ static int ecryptfs_release(struct inode *inode, struct file *file)
static int static int
ecryptfs_fsync(struct file *file, struct dentry *dentry, int datasync) ecryptfs_fsync(struct file *file, struct dentry *dentry, int datasync)
{ {
struct file *lower_file = ecryptfs_file_to_lower(file); return vfs_fsync(ecryptfs_file_to_lower(file),
struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); ecryptfs_dentry_to_lower(dentry),
struct inode *lower_inode = lower_dentry->d_inode; datasync);
int rc = -EINVAL;
if (lower_inode->i_fop->fsync) {
mutex_lock(&lower_inode->i_mutex);
rc = lower_inode->i_fop->fsync(lower_file, lower_dentry,
datasync);
mutex_unlock(&lower_inode->i_mutex);
}
return rc;
} }
static int ecryptfs_fasync(int fd, struct file *file, int flag) static int ecryptfs_fasync(int fd, struct file *file, int flag)
......
...@@ -612,8 +612,7 @@ ecryptfs_readlink(struct dentry *dentry, char __user * buf, int bufsiz) ...@@ -612,8 +612,7 @@ ecryptfs_readlink(struct dentry *dentry, char __user * buf, int bufsiz)
struct ecryptfs_crypt_stat *crypt_stat; struct ecryptfs_crypt_stat *crypt_stat;
lower_dentry = ecryptfs_dentry_to_lower(dentry); lower_dentry = ecryptfs_dentry_to_lower(dentry);
if (!lower_dentry->d_inode->i_op || if (!lower_dentry->d_inode->i_op->readlink) {
!lower_dentry->d_inode->i_op->readlink) {
rc = -EINVAL; rc = -EINVAL;
goto out; goto out;
} }
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include <linux/audit.h> #include <linux/audit.h>
#include <linux/tracehook.h> #include <linux/tracehook.h>
#include <linux/kmod.h> #include <linux/kmod.h>
#include <linux/fsnotify.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/mmu_context.h> #include <asm/mmu_context.h>
...@@ -132,6 +133,8 @@ asmlinkage long sys_uselib(const char __user * library) ...@@ -132,6 +133,8 @@ asmlinkage long sys_uselib(const char __user * library)
if (IS_ERR(file)) if (IS_ERR(file))
goto out; goto out;
fsnotify_open(file->f_path.dentry);
error = -ENOEXEC; error = -ENOEXEC;
if(file->f_op) { if(file->f_op) {
struct linux_binfmt * fmt; struct linux_binfmt * fmt;
...@@ -684,6 +687,8 @@ struct file *open_exec(const char *name) ...@@ -684,6 +687,8 @@ struct file *open_exec(const char *name)
if (IS_ERR(file)) if (IS_ERR(file))
return file; return file;
fsnotify_open(file->f_path.dentry);
err = deny_write_access(file); err = deny_write_access(file);
if (err) { if (err) {
fput(file); fput(file);
......
...@@ -253,24 +253,27 @@ static int __init proc_filesystems_init(void) ...@@ -253,24 +253,27 @@ static int __init proc_filesystems_init(void)
module_init(proc_filesystems_init); module_init(proc_filesystems_init);
#endif #endif
struct file_system_type *get_fs_type(const char *name) static struct file_system_type *__get_fs_type(const char *name, int len)
{ {
struct file_system_type *fs; struct file_system_type *fs;
const char *dot = strchr(name, '.');
unsigned len = dot ? dot - name : strlen(name);
read_lock(&file_systems_lock); read_lock(&file_systems_lock);
fs = *(find_filesystem(name, len)); fs = *(find_filesystem(name, len));
if (fs && !try_module_get(fs->owner)) if (fs && !try_module_get(fs->owner))
fs = NULL; fs = NULL;
read_unlock(&file_systems_lock); read_unlock(&file_systems_lock);
if (!fs && (request_module("%.*s", len, name) == 0)) { return fs;
read_lock(&file_systems_lock); }
fs = *(find_filesystem(name, len));
if (fs && !try_module_get(fs->owner)) struct file_system_type *get_fs_type(const char *name)
fs = NULL; {
read_unlock(&file_systems_lock); struct file_system_type *fs;
} const char *dot = strchr(name, '.');
int len = dot ? dot - name : strlen(name);
fs = __get_fs_type(name, len);
if (!fs && (request_module("%.*s", len, name) == 0))
fs = __get_fs_type(name, len);
if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) { if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
put_filesystem(fs); put_filesystem(fs);
......
...@@ -506,7 +506,6 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid, ...@@ -506,7 +506,6 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid,
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = uid; inode->i_uid = uid;
inode->i_gid = gid; inode->i_gid = gid;
inode->i_blocks = 0;
inode->i_mapping->a_ops = &hugetlbfs_aops; inode->i_mapping->a_ops = &hugetlbfs_aops;
inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info; inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
......
...@@ -131,6 +131,8 @@ struct inode *inode_init_always(struct super_block *sb, struct inode *inode) ...@@ -131,6 +131,8 @@ struct inode *inode_init_always(struct super_block *sb, struct inode *inode)
inode->i_op = &empty_iops; inode->i_op = &empty_iops;
inode->i_fop = &empty_fops; inode->i_fop = &empty_fops;
inode->i_nlink = 1; inode->i_nlink = 1;
inode->i_uid = 0;
inode->i_gid = 0;
atomic_set(&inode->i_writecount, 0); atomic_set(&inode->i_writecount, 0);
inode->i_size = 0; inode->i_size = 0;
inode->i_blocks = 0; inode->i_blocks = 0;
......
...@@ -855,10 +855,6 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) ...@@ -855,10 +855,6 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
} }
sbi->s_joliet_level = joliet_level; sbi->s_joliet_level = joliet_level;
/* check the root inode */
if (!inode->i_op)
goto out_bad_root;
/* Make sure the root inode is a directory */ /* Make sure the root inode is a directory */
if (!S_ISDIR(inode->i_mode)) { if (!S_ISDIR(inode->i_mode)) {
printk(KERN_WARNING printk(KERN_WARNING
...@@ -886,8 +882,6 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) ...@@ -886,8 +882,6 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
/* /*
* Display error messages and free resources. * Display error messages and free resources.
*/ */
out_bad_root:
printk(KERN_WARNING "%s: root inode not initialized\n", __func__);
out_iput: out_iput:
iput(inode); iput(inode);
goto out_no_inode; goto out_no_inode;
......
...@@ -58,9 +58,9 @@ ...@@ -58,9 +58,9 @@
/* /*
* __mark_inode_dirty expects inodes to be hashed. Since we don't want * __mark_inode_dirty expects inodes to be hashed. Since we don't want
* special inodes in the fileset inode space, we hash them to a dummy head * special inodes in the fileset inode space, we make them appear hashed,
* but do not put on any lists.
*/ */
static HLIST_HEAD(aggregate_hash);
/* /*
* imap locks * imap locks
...@@ -496,7 +496,11 @@ struct inode *diReadSpecial(struct super_block *sb, ino_t inum, int secondary) ...@@ -496,7 +496,11 @@ struct inode *diReadSpecial(struct super_block *sb, ino_t inum, int secondary)
/* release the page */ /* release the page */
release_metapage(mp); release_metapage(mp);
hlist_add_head(&ip->i_hash, &aggregate_hash); /*
* that will look hashed, but won't be on any list; hlist_del()
* will work fine and require no locking.
*/
ip->i_hash.pprev = &ip->i_hash.next;
return (ip); return (ip);
} }
......
...@@ -231,7 +231,6 @@ int get_sb_pseudo(struct file_system_type *fs_type, char *name, ...@@ -231,7 +231,6 @@ int get_sb_pseudo(struct file_system_type *fs_type, char *name,
*/ */
root->i_ino = 1; root->i_ino = 1;
root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR; root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
root->i_uid = root->i_gid = 0;
root->i_atime = root->i_mtime = root->i_ctime = CURRENT_TIME; root->i_atime = root->i_mtime = root->i_ctime = CURRENT_TIME;
dentry = d_alloc(NULL, &d_name); dentry = d_alloc(NULL, &d_name);
if (!dentry) { if (!dentry) {
...@@ -436,8 +435,6 @@ int simple_fill_super(struct super_block *s, int magic, struct tree_descr *files ...@@ -436,8 +435,6 @@ int simple_fill_super(struct super_block *s, int magic, struct tree_descr *files
*/ */
inode->i_ino = 1; inode->i_ino = 1;
inode->i_mode = S_IFDIR | 0755; inode->i_mode = S_IFDIR | 0755;
inode->i_uid = inode->i_gid = 0;
inode->i_blocks = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_op = &simple_dir_inode_operations; inode->i_op = &simple_dir_inode_operations;
inode->i_fop = &simple_dir_operations; inode->i_fop = &simple_dir_operations;
...@@ -464,8 +461,6 @@ int simple_fill_super(struct super_block *s, int magic, struct tree_descr *files ...@@ -464,8 +461,6 @@ int simple_fill_super(struct super_block *s, int magic, struct tree_descr *files
if (!inode) if (!inode)
goto out; goto out;
inode->i_mode = S_IFREG | files->mode; inode->i_mode = S_IFREG | files->mode;
inode->i_uid = inode->i_gid = 0;
inode->i_blocks = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_fop = files->ops; inode->i_fop = files->ops;
inode->i_ino = i; inode->i_ino = i;
......
...@@ -257,7 +257,7 @@ int inode_permission(struct inode *inode, int mask) ...@@ -257,7 +257,7 @@ int inode_permission(struct inode *inode, int mask)
return -EACCES; return -EACCES;
} }
if (inode->i_op && inode->i_op->permission) if (inode->i_op->permission)
retval = inode->i_op->permission(inode, mask); retval = inode->i_op->permission(inode, mask);
else else
retval = generic_permission(inode, mask, NULL); retval = generic_permission(inode, mask, NULL);
...@@ -432,7 +432,7 @@ static int exec_permission_lite(struct inode *inode) ...@@ -432,7 +432,7 @@ static int exec_permission_lite(struct inode *inode)
{ {
umode_t mode = inode->i_mode; umode_t mode = inode->i_mode;
if (inode->i_op && inode->i_op->permission) if (inode->i_op->permission)
return -EAGAIN; return -EAGAIN;
if (current_fsuid() == inode->i_uid) if (current_fsuid() == inode->i_uid)
...@@ -908,9 +908,6 @@ static int __link_path_walk(const char *name, struct nameidata *nd) ...@@ -908,9 +908,6 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
inode = next.dentry->d_inode; inode = next.dentry->d_inode;
if (!inode) if (!inode)
goto out_dput; goto out_dput;
err = -ENOTDIR;
if (!inode->i_op)
goto out_dput;
if (inode->i_op->follow_link) { if (inode->i_op->follow_link) {
err = do_follow_link(&next, nd); err = do_follow_link(&next, nd);
...@@ -920,9 +917,6 @@ static int __link_path_walk(const char *name, struct nameidata *nd) ...@@ -920,9 +917,6 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
inode = nd->path.dentry->d_inode; inode = nd->path.dentry->d_inode;
if (!inode) if (!inode)
break; break;
err = -ENOTDIR;
if (!inode->i_op)
break;
} else } else
path_to_nameidata(&next, nd); path_to_nameidata(&next, nd);
err = -ENOTDIR; err = -ENOTDIR;
...@@ -961,7 +955,7 @@ static int __link_path_walk(const char *name, struct nameidata *nd) ...@@ -961,7 +955,7 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
break; break;
inode = next.dentry->d_inode; inode = next.dentry->d_inode;
if ((lookup_flags & LOOKUP_FOLLOW) if ((lookup_flags & LOOKUP_FOLLOW)
&& inode && inode->i_op && inode->i_op->follow_link) { && inode && inode->i_op->follow_link) {
err = do_follow_link(&next, nd); err = do_follow_link(&next, nd);
if (err) if (err)
goto return_err; goto return_err;
...@@ -973,7 +967,7 @@ static int __link_path_walk(const char *name, struct nameidata *nd) ...@@ -973,7 +967,7 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
break; break;
if (lookup_flags & LOOKUP_DIRECTORY) { if (lookup_flags & LOOKUP_DIRECTORY) {
err = -ENOTDIR; err = -ENOTDIR;
if (!inode->i_op || !inode->i_op->lookup) if (!inode->i_op->lookup)
break; break;
} }
goto return_base; goto return_base;
...@@ -1469,7 +1463,7 @@ int vfs_create(struct inode *dir, struct dentry *dentry, int mode, ...@@ -1469,7 +1463,7 @@ int vfs_create(struct inode *dir, struct dentry *dentry, int mode,
if (error) if (error)
return error; return error;
if (!dir->i_op || !dir->i_op->create) if (!dir->i_op->create)
return -EACCES; /* shouldn't it be ENOSYS? */ return -EACCES; /* shouldn't it be ENOSYS? */
mode &= S_IALLUGO; mode &= S_IALLUGO;
mode |= S_IFREG; mode |= S_IFREG;
...@@ -1752,7 +1746,7 @@ struct file *do_filp_open(int dfd, const char *pathname, ...@@ -1752,7 +1746,7 @@ struct file *do_filp_open(int dfd, const char *pathname,
error = -ENOENT; error = -ENOENT;
if (!path.dentry->d_inode) if (!path.dentry->d_inode)
goto exit_dput; goto exit_dput;
if (path.dentry->d_inode->i_op && path.dentry->d_inode->i_op->follow_link) if (path.dentry->d_inode->i_op->follow_link)
goto do_link; goto do_link;
path_to_nameidata(&path, &nd); path_to_nameidata(&path, &nd);
...@@ -1933,7 +1927,7 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) ...@@ -1933,7 +1927,7 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD)) if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
return -EPERM; return -EPERM;
if (!dir->i_op || !dir->i_op->mknod) if (!dir->i_op->mknod)
return -EPERM; return -EPERM;
error = devcgroup_inode_mknod(mode, dev); error = devcgroup_inode_mknod(mode, dev);
...@@ -2035,7 +2029,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -2035,7 +2029,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
if (error) if (error)
return error; return error;
if (!dir->i_op || !dir->i_op->mkdir) if (!dir->i_op->mkdir)
return -EPERM; return -EPERM;
mode &= (S_IRWXUGO|S_ISVTX); mode &= (S_IRWXUGO|S_ISVTX);
...@@ -2126,7 +2120,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -2126,7 +2120,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
if (error) if (error)
return error; return error;
if (!dir->i_op || !dir->i_op->rmdir) if (!dir->i_op->rmdir)
return -EPERM; return -EPERM;
DQUOT_INIT(dir); DQUOT_INIT(dir);
...@@ -2213,7 +2207,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -2213,7 +2207,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry)
if (error) if (error)
return error; return error;
if (!dir->i_op || !dir->i_op->unlink) if (!dir->i_op->unlink)
return -EPERM; return -EPERM;
DQUOT_INIT(dir); DQUOT_INIT(dir);
...@@ -2320,7 +2314,7 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname) ...@@ -2320,7 +2314,7 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
if (error) if (error)
return error; return error;
if (!dir->i_op || !dir->i_op->symlink) if (!dir->i_op->symlink)
return -EPERM; return -EPERM;
error = security_inode_symlink(dir, dentry, oldname); error = security_inode_symlink(dir, dentry, oldname);
...@@ -2401,7 +2395,7 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de ...@@ -2401,7 +2395,7 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
*/ */
if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
return -EPERM; return -EPERM;
if (!dir->i_op || !dir->i_op->link) if (!dir->i_op->link)
return -EPERM; return -EPERM;
if (S_ISDIR(inode->i_mode)) if (S_ISDIR(inode->i_mode))
return -EPERM; return -EPERM;
...@@ -2608,7 +2602,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -2608,7 +2602,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
if (error) if (error)
return error; return error;
if (!old_dir->i_op || !old_dir->i_op->rename) if (!old_dir->i_op->rename)
return -EPERM; return -EPERM;
DQUOT_INIT(old_dir); DQUOT_INIT(old_dir);
......
...@@ -744,45 +744,16 @@ nfsd_close(struct file *filp) ...@@ -744,45 +744,16 @@ nfsd_close(struct file *filp)
fput(filp); fput(filp);
} }
/*
* Sync a file
* As this calls fsync (not fdatasync) there is no need for a write_inode
* after it.
*/
static inline int nfsd_dosync(struct file *filp, struct dentry *dp,
const struct file_operations *fop)
{
struct inode *inode = dp->d_inode;
int (*fsync) (struct file *, struct dentry *, int);
int err;
err = filemap_fdatawrite(inode->i_mapping);
if (err == 0 && fop && (fsync = fop->fsync))
err = fsync(filp, dp, 0);
if (err == 0)
err = filemap_fdatawait(inode->i_mapping);
return err;
}
static int static int
nfsd_sync(struct file *filp) nfsd_sync(struct file *filp)
{ {
int err; return vfs_fsync(filp, filp->f_path.dentry, 0);
struct inode *inode = filp->f_path.dentry->d_inode;
dprintk("nfsd: sync file %s\n", filp->f_path.dentry->d_name.name);
mutex_lock(&inode->i_mutex);
err=nfsd_dosync(filp, filp->f_path.dentry, filp->f_op);
mutex_unlock(&inode->i_mutex);
return err;
} }
int int
nfsd_sync_dir(struct dentry *dp) nfsd_sync_dir(struct dentry *dentry)
{ {
return nfsd_dosync(NULL, dp, dp->d_inode->i_fop); return vfs_fsync(NULL, dentry, 0);
} }
/* /*
...@@ -1211,7 +1182,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -1211,7 +1182,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
dirp = dentry->d_inode; dirp = dentry->d_inode;
err = nfserr_notdir; err = nfserr_notdir;
if(!dirp->i_op || !dirp->i_op->lookup) if (!dirp->i_op->lookup)
goto out; goto out;
/* /*
* Check whether the response file handle has been verified yet. * Check whether the response file handle has been verified yet.
...@@ -1347,7 +1318,7 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -1347,7 +1318,7 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
/* Get all the sanity checks out of the way before /* Get all the sanity checks out of the way before
* we lock the parent. */ * we lock the parent. */
err = nfserr_notdir; err = nfserr_notdir;
if(!dirp->i_op || !dirp->i_op->lookup) if (!dirp->i_op->lookup)
goto out; goto out;
fh_lock_nested(fhp, I_MUTEX_PARENT); fh_lock_nested(fhp, I_MUTEX_PARENT);
...@@ -1482,7 +1453,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp) ...@@ -1482,7 +1453,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
inode = dentry->d_inode; inode = dentry->d_inode;
err = nfserr_inval; err = nfserr_inval;
if (!inode->i_op || !inode->i_op->readlink) if (!inode->i_op->readlink)
goto out; goto out;
touch_atime(fhp->fh_export->ex_path.mnt, dentry); touch_atime(fhp->fh_export->ex_path.mnt, dentry);
...@@ -2162,7 +2133,7 @@ nfsd_set_posix_acl(struct svc_fh *fhp, int type, struct posix_acl *acl) ...@@ -2162,7 +2133,7 @@ nfsd_set_posix_acl(struct svc_fh *fhp, int type, struct posix_acl *acl)
size_t size; size_t size;
int error; int error;
if (!IS_POSIXACL(inode) || !inode->i_op || if (!IS_POSIXACL(inode) ||
!inode->i_op->setxattr || !inode->i_op->removexattr) !inode->i_op->setxattr || !inode->i_op->removexattr)
return -EOPNOTSUPP; return -EOPNOTSUPP;
switch(type) { switch(type) {
......
...@@ -704,7 +704,7 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *pathname, u32 m ...@@ -704,7 +704,7 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *pathname, u32 m
return ret; return ret;
} }
asmlinkage long sys_inotify_rm_watch(int fd, u32 wd) asmlinkage long sys_inotify_rm_watch(int fd, __s32 wd)
{ {
struct file *filp; struct file *filp;
struct inotify_device *dev; struct inotify_device *dev;
......
...@@ -1406,9 +1406,6 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi) ...@@ -1406,9 +1406,6 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
ni->allocated_size = sle64_to_cpu( ni->allocated_size = sle64_to_cpu(
a->data.non_resident.allocated_size); a->data.non_resident.allocated_size);
} }
/* Setup the operations for this attribute inode. */
vi->i_op = NULL;
vi->i_fop = NULL;
if (NInoMstProtected(ni)) if (NInoMstProtected(ni))
vi->i_mapping->a_ops = &ntfs_mst_aops; vi->i_mapping->a_ops = &ntfs_mst_aops;
else else
......
...@@ -341,7 +341,6 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb) ...@@ -341,7 +341,6 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb)
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = current_fsuid(); inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid(); inode->i_gid = current_fsgid();
inode->i_blocks = 0;
inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info; inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inc_nlink(inode); inc_nlink(inode);
...@@ -367,7 +366,6 @@ static struct inode *dlmfs_get_inode(struct inode *parent, ...@@ -367,7 +366,6 @@ static struct inode *dlmfs_get_inode(struct inode *parent,
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = current_fsuid(); inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid(); inode->i_gid = current_fsgid();
inode->i_blocks = 0;
inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info; inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
......
...@@ -39,7 +39,6 @@ struct inode *omfs_new_inode(struct inode *dir, int mode) ...@@ -39,7 +39,6 @@ struct inode *omfs_new_inode(struct inode *dir, int mode)
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = current_fsuid(); inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid(); inode->i_gid = current_fsgid();
inode->i_blocks = 0;
inode->i_mapping->a_ops = &omfs_aops; inode->i_mapping->a_ops = &omfs_aops;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
......
...@@ -412,7 +412,7 @@ asmlinkage long sys_fallocate(int fd, int mode, loff_t offset, loff_t len) ...@@ -412,7 +412,7 @@ asmlinkage long sys_fallocate(int fd, int mode, loff_t offset, loff_t len)
if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0)) if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0))
goto out_fput; goto out_fput;
if (inode->i_op && inode->i_op->fallocate) if (inode->i_op->fallocate)
ret = inode->i_op->fallocate(inode, mode, offset, len); ret = inode->i_op->fallocate(inode, mode, offset, len);
else else
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
......
...@@ -256,9 +256,6 @@ static struct dentry *openpromfs_lookup(struct inode *dir, struct dentry *dentry ...@@ -256,9 +256,6 @@ static struct dentry *openpromfs_lookup(struct inode *dir, struct dentry *dentry
break; break;
} }
inode->i_gid = 0;
inode->i_uid = 0;
d_add(dentry, inode); d_add(dentry, inode);
return NULL; return NULL;
} }
......
...@@ -1426,8 +1426,6 @@ static struct inode *proc_pid_make_inode(struct super_block * sb, struct task_st ...@@ -1426,8 +1426,6 @@ static struct inode *proc_pid_make_inode(struct super_block * sb, struct task_st
if (!ei->pid) if (!ei->pid)
goto out_unlock; goto out_unlock;
inode->i_uid = 0;
inode->i_gid = 0;
if (task_dumpable(task)) { if (task_dumpable(task)) {
rcu_read_lock(); rcu_read_lock();
cred = __task_cred(task); cred = __task_cred(task);
...@@ -2349,8 +2347,6 @@ static struct dentry *proc_base_instantiate(struct inode *dir, ...@@ -2349,8 +2347,6 @@ static struct dentry *proc_base_instantiate(struct inode *dir,
if (!ei->pid) if (!ei->pid)
goto out_iput; goto out_iput;
inode->i_uid = 0;
inode->i_gid = 0;
inode->i_mode = p->mode; inode->i_mode = p->mode;
if (S_ISDIR(inode->i_mode)) if (S_ISDIR(inode->i_mode))
inode->i_nlink = 2; inode->i_nlink = 2;
......
...@@ -31,7 +31,6 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, ...@@ -31,7 +31,6 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
inode->i_flags |= S_PRIVATE; /* tell selinux to ignore this inode */ inode->i_flags |= S_PRIVATE; /* tell selinux to ignore this inode */
inode->i_mode = table->mode; inode->i_mode = table->mode;
inode->i_uid = inode->i_gid = 0;
if (!table->child) { if (!table->child) {
inode->i_mode |= S_IFREG; inode->i_mode |= S_IFREG;
inode->i_op = &proc_sys_inode_operations; inode->i_op = &proc_sys_inode_operations;
......
...@@ -57,7 +57,6 @@ struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev) ...@@ -57,7 +57,6 @@ struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev)
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = current_fsuid(); inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid(); inode->i_gid = current_fsgid();
inode->i_blocks = 0;
inode->i_mapping->a_ops = &ramfs_aops; inode->i_mapping->a_ops = &ramfs_aops;
inode->i_mapping->backing_dev_info = &ramfs_backing_dev_info; inode->i_mapping->backing_dev_info = &ramfs_backing_dev_info;
mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER); mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER);
......
...@@ -50,6 +50,14 @@ generic_file_llseek_unlocked(struct file *file, loff_t offset, int origin) ...@@ -50,6 +50,14 @@ generic_file_llseek_unlocked(struct file *file, loff_t offset, int origin)
offset += inode->i_size; offset += inode->i_size;
break; break;
case SEEK_CUR: case SEEK_CUR:
/*
* Here we special-case the lseek(fd, 0, SEEK_CUR)
* position-querying operation. Avoid rewriting the "same"
* f_pos value back to the file because a concurrent read(),
* write() or lseek() might have altered it
*/
if (offset == 0)
return file->f_pos;
offset += file->f_pos; offset += file->f_pos;
break; break;
} }
...@@ -105,6 +113,10 @@ loff_t default_llseek(struct file *file, loff_t offset, int origin) ...@@ -105,6 +113,10 @@ loff_t default_llseek(struct file *file, loff_t offset, int origin)
offset += i_size_read(file->f_path.dentry->d_inode); offset += i_size_read(file->f_path.dentry->d_inode);
break; break;
case SEEK_CUR: case SEEK_CUR:
if (offset == 0) {
retval = file->f_pos;
goto out;
}
offset += file->f_pos; offset += file->f_pos;
} }
retval = -EINVAL; retval = -EINVAL;
...@@ -115,6 +127,7 @@ loff_t default_llseek(struct file *file, loff_t offset, int origin) ...@@ -115,6 +127,7 @@ loff_t default_llseek(struct file *file, loff_t offset, int origin)
} }
retval = offset; retval = offset;
} }
out:
unlock_kernel(); unlock_kernel();
return retval; return retval;
} }
......
...@@ -1782,6 +1782,12 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th, ...@@ -1782,6 +1782,12 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
goto out_bad_inode; goto out_bad_inode;
} }
args.objectid = inode->i_ino = le32_to_cpu(ih.ih_key.k_objectid); args.objectid = inode->i_ino = le32_to_cpu(ih.ih_key.k_objectid);
if (old_format_only(sb))
make_le_item_head(&ih, NULL, KEY_FORMAT_3_5, SD_OFFSET,
TYPE_STAT_DATA, SD_V1_SIZE, MAX_US_INT);
else
make_le_item_head(&ih, NULL, KEY_FORMAT_3_6, SD_OFFSET,
TYPE_STAT_DATA, SD_SIZE, MAX_US_INT);
memcpy(INODE_PKEY(inode), &(ih.ih_key), KEY_SIZE); memcpy(INODE_PKEY(inode), &(ih.ih_key), KEY_SIZE);
args.dirid = le32_to_cpu(ih.ih_key.k_dir_id); args.dirid = le32_to_cpu(ih.ih_key.k_dir_id);
if (insert_inode_locked4(inode, args.objectid, if (insert_inode_locked4(inode, args.objectid,
...@@ -1834,13 +1840,6 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th, ...@@ -1834,13 +1840,6 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
reiserfs_init_acl_default(inode); reiserfs_init_acl_default(inode);
reiserfs_init_xattr_rwsem(inode); reiserfs_init_xattr_rwsem(inode);
if (old_format_only(sb))
make_le_item_head(&ih, NULL, KEY_FORMAT_3_5, SD_OFFSET,
TYPE_STAT_DATA, SD_V1_SIZE, MAX_US_INT);
else
make_le_item_head(&ih, NULL, KEY_FORMAT_3_6, SD_OFFSET,
TYPE_STAT_DATA, SD_SIZE, MAX_US_INT);
/* key to search for correct place for new stat data */ /* key to search for correct place for new stat data */
_make_cpu_key(&key, KEY_FORMAT_3_6, le32_to_cpu(ih.ih_key.k_dir_id), _make_cpu_key(&key, KEY_FORMAT_3_6, le32_to_cpu(ih.ih_key.k_dir_id),
le32_to_cpu(ih.ih_key.k_objectid), SD_OFFSET, le32_to_cpu(ih.ih_key.k_objectid), SD_OFFSET,
......
...@@ -524,7 +524,6 @@ romfs_iget(struct super_block *sb, unsigned long ino) ...@@ -524,7 +524,6 @@ romfs_iget(struct super_block *sb, unsigned long ino)
i->i_size = be32_to_cpu(ri.size); i->i_size = be32_to_cpu(ri.size);
i->i_mtime.tv_sec = i->i_atime.tv_sec = i->i_ctime.tv_sec = 0; i->i_mtime.tv_sec = i->i_atime.tv_sec = i->i_ctime.tv_sec = 0;
i->i_mtime.tv_nsec = i->i_atime.tv_nsec = i->i_ctime.tv_nsec = 0; i->i_mtime.tv_nsec = i->i_atime.tv_nsec = i->i_ctime.tv_nsec = 0;
i->i_uid = i->i_gid = 0;
/* Precalculate the data offset */ /* Precalculate the data offset */
ino = romfs_strnlen(i, ino+ROMFH_SIZE, ROMFS_MAXFN); ino = romfs_strnlen(i, ino+ROMFH_SIZE, ROMFS_MAXFN);
......
...@@ -305,7 +305,7 @@ asmlinkage long sys_readlinkat(int dfd, const char __user *pathname, ...@@ -305,7 +305,7 @@ asmlinkage long sys_readlinkat(int dfd, const char __user *pathname,
struct inode *inode = path.dentry->d_inode; struct inode *inode = path.dentry->d_inode;
error = -EINVAL; error = -EINVAL;
if (inode->i_op && inode->i_op->readlink) { if (inode->i_op->readlink) {
error = security_inode_readlink(path.dentry); error = security_inode_readlink(path.dentry);
if (!error) { if (!error) {
touch_atime(path.mnt, path.dentry); touch_atime(path.mnt, path.dentry);
......
...@@ -75,14 +75,39 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync) ...@@ -75,14 +75,39 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync)
return ret; return ret;
} }
long do_fsync(struct file *file, int datasync) /**
* vfs_fsync - perform a fsync or fdatasync on a file
* @file: file to sync
* @dentry: dentry of @file
* @data: only perform a fdatasync operation
*
* Write back data and metadata for @file to disk. If @datasync is
* set only metadata needed to access modified file data is written.
*
* In case this function is called from nfsd @file may be %NULL and
* only @dentry is set. This can only happen when the filesystem
* implements the export_operations API.
*/
int vfs_fsync(struct file *file, struct dentry *dentry, int datasync)
{ {
int ret; const struct file_operations *fop;
int err; struct address_space *mapping;
struct address_space *mapping = file->f_mapping; int err, ret;
/*
* Get mapping and operations from the file in case we have
* as file, or get the default values for them in case we
* don't have a struct file available. Damn nfsd..
*/
if (file) {
mapping = file->f_mapping;
fop = file->f_op;
} else {
mapping = dentry->d_inode->i_mapping;
fop = dentry->d_inode->i_fop;
}
if (!file->f_op || !file->f_op->fsync) { if (!fop || !fop->fsync) {
/* Why? We can still call filemap_fdatawrite */
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
...@@ -94,7 +119,7 @@ long do_fsync(struct file *file, int datasync) ...@@ -94,7 +119,7 @@ long do_fsync(struct file *file, int datasync)
* livelocks in fsync_buffers_list(). * livelocks in fsync_buffers_list().
*/ */
mutex_lock(&mapping->host->i_mutex); mutex_lock(&mapping->host->i_mutex);
err = file->f_op->fsync(file, file->f_path.dentry, datasync); err = fop->fsync(file, dentry, datasync);
if (!ret) if (!ret)
ret = err; ret = err;
mutex_unlock(&mapping->host->i_mutex); mutex_unlock(&mapping->host->i_mutex);
...@@ -104,15 +129,16 @@ long do_fsync(struct file *file, int datasync) ...@@ -104,15 +129,16 @@ long do_fsync(struct file *file, int datasync)
out: out:
return ret; return ret;
} }
EXPORT_SYMBOL(vfs_fsync);
static long __do_fsync(unsigned int fd, int datasync) static int do_fsync(unsigned int fd, int datasync)
{ {
struct file *file; struct file *file;
int ret = -EBADF; int ret = -EBADF;
file = fget(fd); file = fget(fd);
if (file) { if (file) {
ret = do_fsync(file, datasync); ret = vfs_fsync(file, file->f_path.dentry, datasync);
fput(file); fput(file);
} }
return ret; return ret;
...@@ -120,12 +146,12 @@ static long __do_fsync(unsigned int fd, int datasync) ...@@ -120,12 +146,12 @@ static long __do_fsync(unsigned int fd, int datasync)
asmlinkage long sys_fsync(unsigned int fd) asmlinkage long sys_fsync(unsigned int fd)
{ {
return __do_fsync(fd, 0); return do_fsync(fd, 0);
} }
asmlinkage long sys_fdatasync(unsigned int fd) asmlinkage long sys_fdatasync(unsigned int fd)
{ {
return __do_fsync(fd, 1); return do_fsync(fd, 1);
} }
/* /*
......
...@@ -107,8 +107,6 @@ int sysfs_setattr(struct dentry * dentry, struct iattr * iattr) ...@@ -107,8 +107,6 @@ int sysfs_setattr(struct dentry * dentry, struct iattr * iattr)
static inline void set_default_inode_attr(struct inode * inode, mode_t mode) static inline void set_default_inode_attr(struct inode * inode, mode_t mode)
{ {
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = 0;
inode->i_gid = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
} }
...@@ -149,7 +147,6 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode) ...@@ -149,7 +147,6 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
{ {
struct bin_attribute *bin_attr; struct bin_attribute *bin_attr;
inode->i_blocks = 0;
inode->i_mapping->a_ops = &sysfs_aops; inode->i_mapping->a_ops = &sysfs_aops;
inode->i_mapping->backing_dev_info = &sysfs_backing_dev_info; inode->i_mapping->backing_dev_info = &sysfs_backing_dev_info;
inode->i_op = &sysfs_inode_operations; inode->i_op = &sysfs_inode_operations;
......
...@@ -175,7 +175,7 @@ vfs_listxattr(struct dentry *d, char *list, size_t size) ...@@ -175,7 +175,7 @@ vfs_listxattr(struct dentry *d, char *list, size_t size)
if (error) if (error)
return error; return error;
error = -EOPNOTSUPP; error = -EOPNOTSUPP;
if (d->d_inode->i_op && d->d_inode->i_op->listxattr) { if (d->d_inode->i_op->listxattr) {
error = d->d_inode->i_op->listxattr(d, list, size); error = d->d_inode->i_op->listxattr(d, list, size);
} else { } else {
error = security_inode_listsecurity(d->d_inode, list, size); error = security_inode_listsecurity(d->d_inode, list, size);
......
...@@ -1830,7 +1830,7 @@ extern int __filemap_fdatawrite_range(struct address_space *mapping, ...@@ -1830,7 +1830,7 @@ extern int __filemap_fdatawrite_range(struct address_space *mapping,
extern int filemap_fdatawrite_range(struct address_space *mapping, extern int filemap_fdatawrite_range(struct address_space *mapping,
loff_t start, loff_t end); loff_t start, loff_t end);
extern long do_fsync(struct file *file, int datasync); extern int vfs_fsync(struct file *file, struct dentry *dentry, int datasync);
extern void sync_supers(void); extern void sync_supers(void);
extern void sync_filesystems(int wait); extern void sync_filesystems(int wait);
extern void __fsync_super(struct super_block *sb); extern void __fsync_super(struct super_block *sb);
......
...@@ -549,7 +549,7 @@ asmlinkage long sys_inotify_init(void); ...@@ -549,7 +549,7 @@ asmlinkage long sys_inotify_init(void);
asmlinkage long sys_inotify_init1(int flags); asmlinkage long sys_inotify_init1(int flags);
asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, asmlinkage long sys_inotify_add_watch(int fd, const char __user *path,
u32 mask); u32 mask);
asmlinkage long sys_inotify_rm_watch(int fd, u32 wd); asmlinkage long sys_inotify_rm_watch(int fd, __s32 wd);
asmlinkage long sys_spu_run(int fd, __u32 __user *unpc, asmlinkage long sys_spu_run(int fd, __u32 __user *unpc,
__u32 __user *ustatus); __u32 __user *ustatus);
......
...@@ -120,7 +120,6 @@ static struct inode *mqueue_get_inode(struct super_block *sb, int mode, ...@@ -120,7 +120,6 @@ static struct inode *mqueue_get_inode(struct super_block *sb, int mode,
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = current_fsuid(); inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid(); inode->i_gid = current_fsgid();
inode->i_blocks = 0;
inode->i_mtime = inode->i_ctime = inode->i_atime = inode->i_mtime = inode->i_ctime = inode->i_atime =
CURRENT_TIME; CURRENT_TIME;
......
...@@ -573,7 +573,6 @@ static struct inode *cgroup_new_inode(mode_t mode, struct super_block *sb) ...@@ -573,7 +573,6 @@ static struct inode *cgroup_new_inode(mode_t mode, struct super_block *sb)
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = current_fsuid(); inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid(); inode->i_gid = current_fsgid();
inode->i_blocks = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_mapping->backing_dev_info = &cgroup_backing_dev_info; inode->i_mapping->backing_dev_info = &cgroup_backing_dev_info;
} }
......
...@@ -1766,7 +1766,7 @@ int should_remove_suid(struct dentry *dentry) ...@@ -1766,7 +1766,7 @@ int should_remove_suid(struct dentry *dentry)
if (unlikely((mode & S_ISGID) && (mode & S_IXGRP))) if (unlikely((mode & S_ISGID) && (mode & S_IXGRP)))
kill |= ATTR_KILL_SGID; kill |= ATTR_KILL_SGID;
if (unlikely(kill && !capable(CAP_FSETID))) if (unlikely(kill && !capable(CAP_FSETID) && S_ISREG(mode)))
return kill; return kill;
return 0; return 0;
......
...@@ -2266,7 +2266,7 @@ int vmtruncate(struct inode * inode, loff_t offset) ...@@ -2266,7 +2266,7 @@ int vmtruncate(struct inode * inode, loff_t offset)
unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1); unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1);
} }
if (inode->i_op && inode->i_op->truncate) if (inode->i_op->truncate)
inode->i_op->truncate(inode); inode->i_op->truncate(inode);
return 0; return 0;
...@@ -2286,7 +2286,7 @@ int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end) ...@@ -2286,7 +2286,7 @@ int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end)
* a way to truncate a range of blocks (punch a hole) - * a way to truncate a range of blocks (punch a hole) -
* we should return failure right now. * we should return failure right now.
*/ */
if (!inode->i_op || !inode->i_op->truncate_range) if (!inode->i_op->truncate_range)
return -ENOSYS; return -ENOSYS;
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
......
...@@ -82,7 +82,7 @@ asmlinkage long sys_msync(unsigned long start, size_t len, int flags) ...@@ -82,7 +82,7 @@ asmlinkage long sys_msync(unsigned long start, size_t len, int flags)
(vma->vm_flags & VM_SHARED)) { (vma->vm_flags & VM_SHARED)) {
get_file(file); get_file(file);
up_read(&mm->mmap_sem); up_read(&mm->mmap_sem);
error = do_fsync(file, 0); error = vfs_fsync(file, file->f_path.dentry, 0);
fput(file); fput(file);
if (error || start >= end) if (error || start >= end)
goto out; goto out;
......
...@@ -86,7 +86,7 @@ int vmtruncate(struct inode *inode, loff_t offset) ...@@ -86,7 +86,7 @@ int vmtruncate(struct inode *inode, loff_t offset)
i_size_write(inode, offset); i_size_write(inode, offset);
out_truncate: out_truncate:
if (inode->i_op && inode->i_op->truncate) if (inode->i_op->truncate)
inode->i_op->truncate(inode); inode->i_op->truncate(inode);
return 0; return 0;
out_sig: out_sig:
......
...@@ -522,8 +522,6 @@ rpc_get_inode(struct super_block *sb, int mode) ...@@ -522,8 +522,6 @@ rpc_get_inode(struct super_block *sb, int mode)
if (!inode) if (!inode)
return NULL; return NULL;
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = inode->i_gid = 0;
inode->i_blocks = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
switch(mode & S_IFMT) { switch(mode & S_IFMT) {
case S_IFDIR: case S_IFDIR:
......
...@@ -238,7 +238,7 @@ int cap_inode_need_killpriv(struct dentry *dentry) ...@@ -238,7 +238,7 @@ int cap_inode_need_killpriv(struct dentry *dentry)
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
int error; int error;
if (!inode->i_op || !inode->i_op->getxattr) if (!inode->i_op->getxattr)
return 0; return 0;
error = inode->i_op->getxattr(dentry, XATTR_NAME_CAPS, NULL, 0); error = inode->i_op->getxattr(dentry, XATTR_NAME_CAPS, NULL, 0);
...@@ -259,7 +259,7 @@ int cap_inode_killpriv(struct dentry *dentry) ...@@ -259,7 +259,7 @@ int cap_inode_killpriv(struct dentry *dentry)
{ {
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
if (!inode->i_op || !inode->i_op->removexattr) if (!inode->i_op->removexattr)
return 0; return 0;
return inode->i_op->removexattr(dentry, XATTR_NAME_CAPS); return inode->i_op->removexattr(dentry, XATTR_NAME_CAPS);
...@@ -317,7 +317,7 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data ...@@ -317,7 +317,7 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
memset(cpu_caps, 0, sizeof(struct cpu_vfs_cap_data)); memset(cpu_caps, 0, sizeof(struct cpu_vfs_cap_data));
if (!inode || !inode->i_op || !inode->i_op->getxattr) if (!inode || !inode->i_op->getxattr)
return -ENODATA; return -ENODATA;
size = inode->i_op->getxattr((struct dentry *)dentry, XATTR_NAME_CAPS, &caps, size = inode->i_op->getxattr((struct dentry *)dentry, XATTR_NAME_CAPS, &caps,
......
...@@ -61,9 +61,6 @@ static struct inode *get_inode(struct super_block *sb, int mode, dev_t dev) ...@@ -61,9 +61,6 @@ static struct inode *get_inode(struct super_block *sb, int mode, dev_t dev)
if (inode) { if (inode) {
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = 0;
inode->i_gid = 0;
inode->i_blocks = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
switch (mode & S_IFMT) { switch (mode & S_IFMT) {
default: default:
......
...@@ -847,8 +847,6 @@ static struct inode *sel_make_inode(struct super_block *sb, int mode) ...@@ -847,8 +847,6 @@ static struct inode *sel_make_inode(struct super_block *sb, int mode)
if (ret) { if (ret) {
ret->i_mode = mode; ret->i_mode = mode;
ret->i_uid = ret->i_gid = 0;
ret->i_blocks = 0;
ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
} }
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册