?? vfs_intent-2.6-fc3.patch
字號(hào):
res = permission(nd.dentry->d_inode, mode, &nd); /* SuS v2 requires we report a read only fs too */ if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode) && !special_file(nd.dentry->d_inode->i_mode)) res = -EROFS;+ path_release(&nd); } @@ -520,8 +522,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; @@ -573,8 +576,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; @@ -758,8 +762,10 @@ struct file *filp_open(const char * filename, int flags, int mode) { int namei_flags, error;+ struct file * temp_filp; struct nameidata nd; + intent_init(&nd.intent, IT_OPEN); namei_flags = flags; if ((namei_flags+1) & O_ACCMODE) namei_flags++;@@ -767,15 +773,26 @@ namei_flags |= 2; error = open_namei(filename, namei_flags, mode, &nd);- if (!error)- return dentry_open(nd.dentry, nd.mnt, flags);-+ if (!error) {+ temp_filp = dentry_open_it(nd.dentry, nd.mnt, flags, &nd.intent);+ return temp_filp;+ } return ERR_PTR(error); } -EXPORT_SYMBOL(filp_open); struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)+ {++ struct lookup_intent it;+ intent_init(&it, IT_LOOKUP);++ return dentry_open_it(dentry, mnt, flags, &it);+}++EXPORT_SYMBOL(dentry_open);++struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags,struct lookup_intent *it) { struct file * f; struct inode *inode;@@ -787,6 +804,7 @@ goto cleanup_dentry; f->f_flags = flags; f->f_mode = ((flags+1) & O_ACCMODE) | FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE;+ f->f_it = it; inode = dentry->d_inode; if (f->f_mode & FMODE_WRITE) { error = get_write_access(inode);@@ -805,6 +823,7 @@ error = f->f_op->open(inode,f); if (error) goto cleanup_all;+ intent_release(it); } f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); @@ -830,13 +849,12 @@ cleanup_file: put_filp(f); cleanup_dentry:+ intent_release(it); dput(dentry); mntput(mnt); return ERR_PTR(error); } -EXPORT_SYMBOL(dentry_open);- /* * Find an empty file descriptor entry, and mark it busy. */--- linux-2.6.10.orig/fs/stat.c+++ linux-2.6.10/fs/stat.c@@ -38,7 +38,7 @@ EXPORT_SYMBOL(generic_fillattr); -int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)+int vfs_getattr_it(struct vfsmount *mnt, struct dentry *dentry, struct lookup_intent *it, struct kstat *stat) { struct inode *inode = dentry->d_inode; int retval;@@ -47,6 +47,8 @@ if (retval) return retval; + if (inode->i_op->getattr_it)+ return inode->i_op->getattr_it(mnt, dentry, it, stat); if (inode->i_op->getattr) return inode->i_op->getattr(mnt, dentry, stat); @@ -63,14 +65,20 @@ EXPORT_SYMBOL(vfs_getattr); +int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)+{+ return vfs_getattr_it(mnt, dentry, NULL, stat);+}+ int vfs_stat(char __user *name, struct kstat *stat) { struct nameidata nd; int error;+ intent_init(&nd.intent, IT_GETATTR); - error = user_path_walk(name, &nd);+ error = user_path_walk_it(name, &nd); if (!error) {- error = vfs_getattr(nd.mnt, nd.dentry, stat);+ error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat); path_release(&nd); } return error;@@ -82,10 +90,11 @@ { struct nameidata nd; int error;+ intent_init(&nd.intent, IT_GETATTR); - error = user_path_walk_link(name, &nd);+ error = user_path_walk_link_it(name, &nd); if (!error) {- error = vfs_getattr(nd.mnt, nd.dentry, stat);+ error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat); path_release(&nd); } return error;@@ -97,9 +106,12 @@ { struct file *f = fget(fd); int error = -EBADF;+ struct nameidata nd;+ intent_init(&nd.intent, IT_GETATTR); if (f) {- error = vfs_getattr(f->f_vfsmnt, f->f_dentry, stat);+ error = vfs_getattr_it(f->f_vfsmnt, f->f_dentry, &nd.intent, stat);+ intent_release(&nd.intent); fput(f); } return error;--- linux-2.6.10.orig/include/linux/dcache.h+++ linux-2.6.10/include/linux/dcache.h@@ -4,6 +4,7 @@ #ifdef __KERNEL__ #include <asm/atomic.h>+#include <linux/string.h> #include <linux/list.h> #include <linux/spinlock.h> #include <linux/cache.h>@@ -37,6 +38,8 @@ const unsigned char *name; }; +#include <linux/namei.h>+ struct dentry_stat_t { int nr_dentry; int nr_unused;--- linux-2.6.10.orig/include/linux/fs.h+++ linux-2.6.10/include/linux/fs.h@@ -78,6 +78,7 @@ #define FMODE_READ 1 #define FMODE_WRITE 2+#define FMODE_EXEC 4 /* Internal kernel extensions */ #define FMODE_LSEEK 4@@ -262,6 +263,8 @@ #define ATTR_ATTR_FLAG 1024 #define ATTR_KILL_SUID 2048 #define ATTR_KILL_SGID 4096+#define ATTR_RAW 8192 /* file system, not vfs will massage attrs */+#define ATTR_FROM_OPEN 16384 /* called from open path, ie O_TRUNC */ /* * This is the Inode Attributes structure, used for notify_change(). It@@ -465,6 +468,7 @@ struct block_device *i_bdev; struct cdev *i_cdev; int i_cindex;+ void *i_filterdata; __u32 i_generation; @@ -600,6 +604,7 @@ spinlock_t f_ep_lock; #endif /* #ifdef CONFIG_EPOLL */ struct address_space *f_mapping;+ struct lookup_intent *f_it; }; extern spinlock_t files_lock; #define file_list_lock() spin_lock(&files_lock);@@ -950,7 +955,9 @@ void (*truncate) (struct inode *); int (*permission) (struct inode *, int, struct nameidata *); int (*setattr) (struct dentry *, struct iattr *);+ int (*setattr_raw) (struct inode *, struct iattr *); int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);+ int (*getattr_it) (struct vfsmount *, struct dentry *, struct lookup_intent *, struct kstat *); int (*setxattr) (struct dentry *, const char *,const void *,size_t,int); ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t); ssize_t (*listxattr) (struct dentry *, char *, size_t);@@ -990,6 +997,7 @@ int (*remount_fs) (struct super_block *, int *, char *); void (*clear_inode) (struct inode *); void (*umount_begin) (struct super_block *);+ void (*umount_lustre) (struct super_block *); int (*show_options)(struct seq_file *, struct vfsmount *); };@@ -1181,6 +1189,7 @@ extern struct vfsmount *kern_mount(struct file_system_type *); extern int may_umount_tree(struct vfsmount *); extern int may_umount(struct vfsmount *);+struct vfsmount *do_kern_mount(const char *type, int flags, const char *name, void *data); extern long do_mount(char *, char *, char *, unsigned long, void *); extern int vfs_statfs(struct super_block *, struct kstatfs *);@@ -1245,6 +1254,7 @@ extern int do_truncate(struct dentry *, loff_t start); extern struct file *filp_open(const char *, int, int); extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);+extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct lookup_intent *); extern int filp_close(struct file *, fl_owner_t id); extern char * getname(const char __user *); --- linux-2.6.10.orig/include/linux/mount.h+++ linux-2.6.10/include/linux/mount.h@@ -36,6 +36,8 @@ struct list_head mnt_list; struct list_head mnt_fslink; /* link in fs-specific expiry list */ struct namespace *mnt_namespace; /* containing namespace */+ struct list_head mnt_lustre_list; /* GNS mount list */+ unsigned long mnt_last_used; /* for GNS auto-umount (jiffies) */ }; static inline struct vfsmount *mntget(struct vfsmount *mnt)--- linux-2.6.10.orig/include/linux/namei.h+++ linux-2.6.10/include/linux/namei.h@@ -2,14 +2,55 @@ #define _LINUX_NAMEI_H #include <linux/linkage.h>+#include <linux/string.h> struct vfsmount;+struct nameidata; -struct open_intent {- int flags;- int create_mode;+/* intent opcodes */+#define IT_OPEN (1)+#define IT_CREAT (1<<1)+#define IT_READDIR (1<<2)+#define IT_GETATTR (1<<3)+#define IT_LOOKUP (1<<4)+#define IT_UNLINK (1<<5)+#define IT_TRUNC (1<<6)+#define IT_GETXATTR (1<<7)++struct lustre_intent_data {+ int it_disposition;+ int it_status;+ __u64 it_lock_handle;+ void *it_data;+ int it_lock_mode; }; +#define INTENT_MAGIC 0x19620323+struct lookup_intent {+ int it_magic;+ void (*it_op_release)(struct lookup_intent *);+ int it_op;+ int it_flags;+ int it_create_mode;+ union {+ struct lustre_intent_data lustre;+ } d;+};++static inline void intent_reset_fs_part(struct lookup_intent *it)+{+ memset(&it->d, 0, sizeof(it->d));+ it->it_magic = INTENT_MAGIC;+ it->it_op_release = NULL;+}++static inline void intent_init(struct lookup_intent *it, int op)+{+ memset(it, 0, sizeof(*it));+ it->it_magic = INTENT_MAGIC;+ it->it_op = op;+}+ enum { MAX_NESTED_LINKS = 8 }; struct nameidata {@@ -21,10 +62,7 @@ unsigned depth; char *saved_names[MAX_NESTED_LINKS + 1]; - /* Intent data */- union {- struct open_intent open;- } intent;+ struct lookup_intent intent; }; /*@@ -47,6 +85,8 @@ #define LOOKUP_NOALT 32 #define LOOKUP_ATOMIC 64 #define LOOKUP_REVAL 128+#define LOOKUP_LAST (0x1000)+#define LOOKUP_LINK_NOTLAST (0x2000) /* * Intent data@@ -56,6 +96,12 @@ #define LOOKUP_ACCESS (0x0400) extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata *));+extern int FASTCALL(__user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd));+#define user_path_walk_it(name,nd) \+ __user_walk_it(name, LOOKUP_FOLLOW, nd)+#define user_path_walk_link_it(name,nd) \+ __user_walk_it(name, 0, nd)+extern void intent_release(struct lookup_intent *); #define user_path_walk(name,nd) \ __user_walk(name, LOOKUP_FOLLOW, nd) #define user_path_walk_link(name,nd) \@@ -68,7 +114,6 @@ extern struct dentry * lookup_one_len(const char *, struct dentry *, int); extern struct dentry * lookup_hash(struct qstr *, struct dentry *);- extern int follow_down(struct vfsmount **, struct dentry **); extern int follow_up(struct vfsmount **, struct dentry **);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -