📄 vfs_intent-2.6-fc5.patch
字号:
Index: linux-2.6.15-fc5/fs/inode.c===================================================================--- linux-2.6.15-fc5.orig/fs/inode.c 2006-05-31 04:08:19.000000000 +0800+++ linux-2.6.15-fc5/fs/inode.c 2006-05-31 17:24:35.000000000 +0800@@ -236,6 +236,7 @@ inodes_stat.nr_unused--; } +EXPORT_SYMBOL(__iget); /** * clear_inode - clear an inode * @inode: inode to clearIndex: linux-2.6.15-fc5/fs/open.c===================================================================--- linux-2.6.15-fc5.orig/fs/open.c 2006-05-31 04:08:39.000000000 +0800+++ linux-2.6.15-fc5/fs/open.c 2006-05-31 17:24:35.000000000 +0800@@ -224,12 +224,12 @@ struct nameidata nd; struct inode * inode; int error;-+ intent_init(&nd.intent, IT_GETATTR); error = -EINVAL; if (length < 0) /* sorry, but loff_t says... */ goto out; - error = user_path_walk(path, &nd);+ error = user_path_walk_it(path, &nd); if (error) goto out; inode = nd.dentry->d_inode;@@ -488,6 +488,7 @@ int old_fsuid, old_fsgid; kernel_cap_t old_cap; int res;+ intent_init(&nd.intent, IT_GETATTR); if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */ return -EINVAL;@@ -512,7 +513,7 @@ else current->cap_effective = current->cap_permitted; - res = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);+ res = __user_walk_fd_it(dfd, filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd); if (!res) { res = vfs_permission(&nd, mode); /* SuS v2 requires we report a read only fs too */@@ -538,8 +539,9 @@ { struct nameidata nd; int error;+ intent_init(&nd.intent, IT_GETATTR); - error = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);+ error = __user_walk_it(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd); if (error) goto out; @@ -591,8 +593,9 @@ { struct nameidata nd; int error;+ intent_init(&nd.intent, IT_GETATTR); - error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);+ error = __user_walk_it(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd); if (error) goto out; @@ -815,6 +818,7 @@ error = open(inode, f); if (error) goto cleanup_all;+ intent_release(f->f_it); } f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);@@ -841,6 +845,7 @@ f->f_dentry = NULL; f->f_vfsmnt = NULL; cleanup_file:+ intent_release(f->f_it); put_filp(f); dput(dentry); mntput(mnt);@@ -866,6 +871,7 @@ { int namei_flags, error; struct nameidata nd;+ intent_init(&nd.intent, IT_OPEN); namei_flags = flags; if ((namei_flags+1) & O_ACCMODE)@@ -902,19 +908,19 @@ struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry, int (*open)(struct inode *, struct file *)) {- if (IS_ERR(nd->intent.open.file))+ if (IS_ERR(nd->intent.file)) goto out; if (IS_ERR(dentry)) goto out_err;- nd->intent.open.file = __dentry_open(dget(dentry), mntget(nd->mnt),- nd->intent.open.flags - 1,- nd->intent.open.file,+ nd->intent.file = __dentry_open(dget(dentry), mntget(nd->mnt),+ nd->intent.flags - 1,+ nd->intent.file, open); out:- return nd->intent.open.file;+ return nd->intent.file; out_err: release_open_intent(nd);- nd->intent.open.file = (struct file *)dentry;+ nd->intent.file = (struct file *)dentry; goto out; } EXPORT_SYMBOL_GPL(lookup_instantiate_filp);@@ -931,7 +937,8 @@ struct file *filp; /* Pick up the filp from the open intent */- filp = nd->intent.open.file;+ filp = nd->intent.file;+ filp->f_it = &nd->intent; /* Has the filesystem initialised the file for us? */ if (filp->f_dentry == NULL) filp = __dentry_open(nd->dentry, nd->mnt, flags, filp, NULL);Index: linux-2.6.15-fc5/fs/nfsctl.c===================================================================--- linux-2.6.15-fc5.orig/fs/nfsctl.c 2006-05-31 04:08:20.000000000 +0800+++ linux-2.6.15-fc5/fs/nfsctl.c 2006-05-31 17:24:35.000000000 +0800@@ -26,6 +26,7 @@ struct nameidata nd; int error; + intent_init(&nd.intent, IT_OPEN); nd.mnt = do_kern_mount("nfsd", 0, "nfsd", NULL); if (IS_ERR(nd.mnt))Index: linux-2.6.15-fc5/fs/namei.c===================================================================--- linux-2.6.15-fc5.orig/fs/namei.c 2006-05-31 04:08:33.000000000 +0800+++ linux-2.6.15-fc5/fs/namei.c 2006-05-31 17:24:35.000000000 +0800@@ -337,8 +337,19 @@ 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 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 @@ { 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 @@ * 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; } @@ -509,7 +527,9 @@ static __always_inline int __vfs_follow_link(struct nameidata *nd, const char *link) { int res = 0;+ struct lookup_intent it = nd->intent; char *name;+ if (IS_ERR(link)) goto fail; @@ -519,6 +539,10 @@ /* weird __emul_prefix() stuff did it */ goto out; }+ intent_init(&nd->intent, it.it_op);+ nd->intent.it_flags = it.it_flags;+ nd->intent.it_create_mode = it.it_create_mode;+ nd->intent.file = it.file; res = link_path_walk(link, nd); out: if (nd->depth || res || nd->last_type!=LAST_NORM)@@ -772,6 +796,33 @@ 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@@ -870,7 +921,11 @@ 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;@@ -905,6 +960,23 @@ 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) {@@ -912,7 +984,9 @@ if (err < 0) break; }+ nd->flags |= LOOKUP_LAST; err = do_lookup(nd, &this, &next, atomic);+ nd->flags &= ~LOOKUP_LAST; if (err) break; inode = next.dentry->d_inode;@@ -1154,13 +1228,13 @@ if (filp == NULL) return -ENFILE;- nd->intent.open.file = filp;- nd->intent.open.flags = open_flags;- nd->intent.open.create_mode = create_mode;+ nd->intent.file = filp;+ nd->intent.flags = open_flags;+ nd->intent.create_mode = create_mode; err = do_path_lookup(dfd, name, lookup_flags|LOOKUP_OPEN, nd);- if (IS_ERR(nd->intent.open.file)) {+ 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)@@ -1263,7 +1337,7 @@ } /* 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;@@ -1283,11 +1357,17 @@ } 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() *@@ -1299,8 +1379,9 @@ * 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);@@ -1312,9 +1393,22 @@ return err; } +int fastcall __user_walk_fd(int dfd, const char __user *name, unsigned flags,+ struct nameidata *nd)+{+ intent_init(&nd->intent, IT_LOOKUP);+ return __user_walk_fd_it(dfd, name, flags, nd); +}++int fastcall __user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd)+{+ return __user_walk_fd_it(AT_FDCWD, name, flags, nd);+}+ int fastcall __user_walk(const char __user *name, unsigned flags, struct nameidata *nd) {- return __user_walk_fd(AT_FDCWD, name, flags, nd);+ intent_init(&nd->intent, IT_LOOKUP);+ return __user_walk_it(name, flags, nd); } /*@@ -1596,6 +1690,8 @@ if (flag & O_APPEND) acc_mode |= MAY_APPEND; + nd->intent.it_flags = flag;+ nd->intent.it_create_mode = mode; /* * The simplest case - just a plain lookup. */@@ -1610,6 +1706,7 @@ /* * Create - we need to know the parent. */+ nd->intent.it_op |= IT_CREAT; error = path_lookup_create(dfd,pathname,LOOKUP_PARENT,nd,flag,mode); if (error) return error;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -