📄 vfs_intent-2.6-sles10.patch
字号:
Index: LINUX-SRC-TREE/fs/9p/vfs_inode.c===================================================================--- LINUX-SRC-TREE.orig/fs/9p/vfs_inode.c+++ LINUX-SRC-TREE/fs/9p/vfs_inode.c@@ -469,7 +469,7 @@ v9fs_vfs_create(struct inode *dir, struc perm = unixmode2p9mode(v9ses, mode); if (nd && nd->flags & LOOKUP_OPEN)- flags = nd->intent.open.flags - 1;+ flags = nd->intent.flags - 1; else flags = O_RDWR; Index: LINUX-SRC-TREE/fs/cifs/dir.c===================================================================--- LINUX-SRC-TREE.orig/fs/cifs/dir.c+++ LINUX-SRC-TREE/fs/cifs/dir.c@@ -157,11 +157,7 @@ cifs_create(struct inode *inode, struct #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) if(nd && (nd->flags & LOOKUP_OPEN)) {-#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,5) /* SUSE included Lustre patch */ int oflags = nd->intent.it_flags;-#else- int oflags = nd->intent.open.flags;-#endif desiredAccess = 0; if (oflags & FMODE_READ)Index: LINUX-SRC-TREE/fs/exec.c===================================================================--- LINUX-SRC-TREE.orig/fs/exec.c+++ LINUX-SRC-TREE/fs/exec.c@@ -129,7 +129,9 @@ asmlinkage long sys_uselib(const char __ struct nameidata nd; int error; - error = __user_path_lookup_open(library, LOOKUP_FOLLOW, &nd, FMODE_READ);+ intent_init(&nd.intent, IT_OPEN);+ error = __user_path_lookup_open(library, LOOKUP_FOLLOW, &nd,+ FMODE_READ | FMODE_EXEC); if (error) goto out; @@ -481,7 +483,9 @@ struct file *open_exec(const char *name) int err; struct file *file; - err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd, FMODE_READ);+ intent_init(&nd.intent, IT_OPEN);+ err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd,+ FMODE_READ | FMODE_EXEC, 0); file = ERR_PTR(err); if (!err) {@@ -1543,7 +1547,7 @@ int do_coredump(long signr, int exit_cod goto close_fail; if (!file->f_op->write) goto close_fail;- if (do_truncate(file->f_dentry, 0, 0, file) != 0)+ if (do_truncate(file->f_dentry, 0, 0, file, 0) != 0) goto close_fail; retval = binfmt->core_dump(signr, regs, file);Index: LINUX-SRC-TREE/fs/fuse/dir.c===================================================================--- LINUX-SRC-TREE.orig/fs/fuse/dir.c+++ LINUX-SRC-TREE/fs/fuse/dir.c@@ -242,7 +242,7 @@ static int fuse_create_open(struct inode struct fuse_entry_out outentry; struct fuse_file *ff; struct file *file;- int flags = nd->intent.open.flags - 1;+ int flags = nd->intent.flags - 1; err = -ENOSYS; if (fc->no_create)Index: LINUX-SRC-TREE/fs/inode.c===================================================================--- LINUX-SRC-TREE.orig/fs/inode.c+++ LINUX-SRC-TREE/fs/inode.c@@ -236,6 +236,7 @@ void __iget(struct inode * inode) inodes_stat.nr_unused--; } +EXPORT_SYMBOL(__iget); /** * clear_inode - clear an inode * @inode: inode to clearIndex: LINUX-SRC-TREE/fs/namei.c===================================================================--- LINUX-SRC-TREE.orig/fs/namei.c+++ LINUX-SRC-TREE/fs/namei.c@@ -337,8 +337,19 @@ int deny_write_access(struct file * file return 0; } +void intent_release(struct lookup_intent *it)+{+ if (!it)+ return;+ if (it->it_magic != INTENT_MAGIC)+ return;+ if (it->it_op_release)+ it->it_op_release(it);+}+ void path_release(struct nameidata *nd) {+ intent_release(&nd->intent); dput(nd->dentry); mntput(nd->mnt); }@@ -359,10 +370,10 @@ void path_release_on_umount(struct namei */ void release_open_intent(struct nameidata *nd) {- if (nd->intent.open.file->f_dentry == NULL)- put_filp(nd->intent.open.file);+ if (nd->intent.file->f_dentry == NULL)+ put_filp(nd->intent.file); else- fput(nd->intent.open.file);+ fput(nd->intent.file); } /*@@ -440,8 +451,12 @@ static struct dentry * real_lookup(struc { struct dentry * result; struct inode *dir = parent->d_inode;+ int counter = 0; mutex_lock(&dir->i_mutex);+again:+ counter++;+ /* * First re-do the cached lookup just in case it was created * while we waited for the directory semaphore..@@ -475,13 +490,16 @@ static struct dentry * real_lookup(struc * Uhhuh! Nasty case: the cache was re-populated while * we waited on the semaphore. Need to revalidate. */- mutex_unlock(&dir->i_mutex); if (result->d_op && result->d_op->d_revalidate) { if (!result->d_op->d_revalidate(result, nd) && !d_invalidate(result)) { dput(result);- result = ERR_PTR(-ENOENT);+ if (counter > 10)+ result = ERR_PTR(-ESTALE);+ if (!IS_ERR(result))+ goto again; } }+ mutex_unlock(&dir->i_mutex); return result; } @@ -510,6 +528,7 @@ static __always_inline int __vfs_follow_ { int res = 0; char *name;+ if (IS_ERR(link)) goto fail; @@ -519,6 +538,7 @@ static __always_inline int __vfs_follow_ /* weird __emul_prefix() stuff did it */ goto out; }+ intent_reset_fs_part(&nd->intent); res = link_path_walk(link, nd); out: if (nd->depth || res || nd->last_type!=LAST_NORM)@@ -768,6 +788,33 @@ fail: return PTR_ERR(dentry); } +static int revalidate_special(struct nameidata *nd)+{+ struct dentry *dentry = nd->dentry;+ int err, counter = 0;++ revalidate_again:+ if (!dentry->d_op || !dentry->d_op->d_revalidate)+ return 0;+ if (!dentry->d_op->d_revalidate(dentry, nd)) {+ struct dentry *new;+ if ((err = permission(dentry->d_parent->d_inode, MAY_EXEC, nd)))+ return err;+ new = real_lookup(dentry->d_parent, &dentry->d_name, nd);+ if (IS_ERR(new))+ return PTR_ERR(new);+ d_invalidate(dentry);+ dput(dentry);+ nd->dentry = dentry = new;+ counter++;+ if (counter < 10)+ goto revalidate_again;+ printk("excessive revalidate_it loops\n");+ return -ESTALE;+ }+ return 0;+}+ /* * Name resolution. * This is the basic name resolution function, turning a pathname into@@ -864,7 +911,11 @@ static fastcall int __link_path_walk(con goto out_dput; if (inode->i_op->follow_link) {+ int save_flags = nd->flags;+ nd->flags |= LOOKUP_LINK_NOTLAST; err = do_follow_link(&next, nd);+ if (!(save_flags & LOOKUP_LINK_NOTLAST))+ nd->flags &= ~LOOKUP_LINK_NOTLAST; if (err) goto return_err; err = -ENOENT;@@ -899,6 +950,23 @@ last_component: inode = nd->dentry->d_inode; /* fallthrough */ case 1:+ nd->flags |= LOOKUP_LAST;+ err = revalidate_special(nd);+ nd->flags &= ~LOOKUP_LAST;+ if (!nd->dentry->d_inode)+ err = -ENOENT;+ if (err) {+ path_release(nd);+ goto return_err;+ }+ if (lookup_flags & LOOKUP_DIRECTORY) {+ err = -ENOTDIR;+ if(!nd->dentry->d_inode->i_op ||+ !nd->dentry->d_inode->i_op->lookup) {+ path_release(nd);+ goto return_err;+ }+ } goto return_reval; } if (nd->dentry->d_op && nd->dentry->d_op->d_hash) {@@ -906,7 +974,9 @@ last_component: if (err < 0) break; }+ nd->flags |= LOOKUP_LAST; err = do_lookup(nd, &this, &next);+ nd->flags &= ~LOOKUP_LAST; if (err) break; inode = next.dentry->d_inode;@@ -1066,7 +1136,7 @@ set_it: } /* Returns 0 and nd will be valid on success; Retuns error, otherwise. */-static int fastcall do_path_lookup(int dfd, const char *name,+static int fastcall do_path_lookup_it(int dfd, const char *name, unsigned int flags, struct nameidata *nd) { int retval = 0;@@ -1134,10 +1204,23 @@ fput_fail: goto out_fail; } -int fastcall path_lookup(const char *name, unsigned int flags,+static int fastcall do_path_lookup(int dfd, const char *name,+ unsigned int flags, struct nameidata *nd)+{+ intent_init(&nd->intent, IT_GETATTR);+ return do_path_lookup_it(dfd, name, flags, nd);+}++int fastcall path_lookup_it(const char *name, unsigned int flags, struct nameidata *nd) {- return do_path_lookup(AT_FDCWD, name, flags, nd);+ return do_path_lookup_it(AT_FDCWD, name, flags, nd);+}++int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata *nd)+{+ intent_init(&nd->intent, IT_GETATTR);+ return path_lookup_it(name, flags, nd); } static int __path_lookup_intent_open(int dfd, const char *name,@@ -1149,13 +1232,13 @@ static int __path_lookup_intent_open(int if (filp == NULL) return -ENFILE;- nd->intent.open.file = filp;- nd->intent.open.flags = open_flags;- nd->intent.open.create_mode = create_mode;- err = do_path_lookup(dfd, name, lookup_flags|LOOKUP_OPEN, nd);- if (IS_ERR(nd->intent.open.file)) {+ nd->intent.file = filp;+ nd->intent.flags = open_flags;+ nd->intent.create_mode = create_mode;+ err = do_path_lookup_it(dfd, name, lookup_flags|LOOKUP_OPEN, nd);+ if (IS_ERR(nd->intent.file)) { if (err == 0) {- err = PTR_ERR(nd->intent.open.file);+ err = PTR_ERR(nd->intent.file); path_release(nd); } } else if (err != 0)@@ -1172,10 +1255,10 @@ static int __path_lookup_intent_open(int * @open_flags: open intent flags */ int path_lookup_open(int dfd, const char *name, unsigned int lookup_flags,- struct nameidata *nd, int open_flags)+ struct nameidata *nd, int open_flags, int create_mode) { return __path_lookup_intent_open(dfd, name, lookup_flags, nd,- open_flags, 0);+ open_flags, create_mode); } /**@@ -1258,7 +1341,7 @@ struct dentry * lookup_hash(struct namei } /* SMP-safe */-struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)+struct dentry * lookup_one_len_it(const char * name, struct dentry * base, int len, struct nameidata *nd) { unsigned long hash; struct qstr this;@@ -1278,11 +1361,17 @@ struct dentry * lookup_one_len(const cha } this.hash = end_name_hash(hash); - return __lookup_hash(&this, base, NULL);+ return __lookup_hash(&this, base, nd); access: return ERR_PTR(-EACCES); } +struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)+{+ return lookup_one_len_it(name, base, len, NULL);+}++ /* * namei() *@@ -1294,22 +1383,36 @@ access: * that namei follows links, while lnamei does not. * SMP-safe */-int fastcall __user_walk_fd(int dfd, const char __user *name, unsigned flags,- struct nameidata *nd)++int fastcall __user_walk_fd_it(int dfd, const char __user *name, unsigned flags,+ struct nameidata *nd) { char *tmp = getname(name); int err = PTR_ERR(tmp); if (!IS_ERR(tmp)) {- err = do_path_lookup(dfd, tmp, flags, nd);+ err = do_path_lookup_it(dfd, tmp, flags, nd); putname(tmp); } return err; } +int fastcall __user_walk_fd(int dfd, const char __user *name, unsigned flags,+ struct nameidata *nd)+{+ intent_init(&nd->intent, IT_LOOKUP);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -