Re: [RFC PATCH 1/5] Remove existing directory listing implementation
On Wed, 2007-12-05 at 20:08 +0530, Bharata B Rao wrote: > Remove the existing readdir implementation. You may have had a better description in your 0/5 mail, but this is what goes into the git log in the end, so I think you need to beef this up a bit. -- Dave -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH 1/5] Remove existing directory listing implementation
Remove the existing readdir implementation. Signed-off-by: Bharata B Rao <[EMAIL PROTECTED]> --- fs/readdir.c | 10 + fs/union.c| 333 -- include/linux/union.h | 23 --- 3 files changed, 8 insertions(+), 358 deletions(-) --- a/fs/readdir.c +++ b/fs/readdir.c @@ -16,12 +16,12 @@ #include #include #include -#include #include int vfs_readdir(struct file *file, filldir_t filler, void *buf) { + struct inode *inode = file->f_path.dentry->d_inode; int res = -ENOTDIR; if (!file->f_op || !file->f_op->readdir) @@ -31,7 +31,13 @@ int vfs_readdir(struct file *file, filld if (res) goto out; - res = do_readdir(file, buf, filler); + mutex_lock(>i_mutex); + res = -ENOENT; + if (!IS_DEADDIR(inode)) { + res = file->f_op->readdir(file, buf, filler); + file_accessed(file); + } + mutex_unlock(>i_mutex); out: return res; } --- a/fs/union.c +++ b/fs/union.c @@ -516,339 +516,6 @@ int last_union_is_root(struct path *path } /* - * Union mounts support for readdir. - */ - -/* This is a copy from fs/readdir.c */ -struct getdents_callback { - struct linux_dirent __user *current_dir; - struct linux_dirent __user *previous; - int count; - int error; -}; - -/* The readdir union cache object */ -struct union_cache_entry { - struct list_head list; - struct qstr name; -}; - -static int union_cache_add_entry(struct list_head *list, -const char *name, int namelen) -{ - struct union_cache_entry *this; - char *tmp_name; - - this = kmalloc(sizeof(*this), GFP_KERNEL); - if (!this) { - printk(KERN_CRIT - "union_cache_add_entry(): out of kernel memory\n"); - return -ENOMEM; - } - - tmp_name = kmalloc(namelen + 1, GFP_KERNEL); - if (!tmp_name) { - printk(KERN_CRIT - "union_cache_add_entry(): out of kernel memory\n"); - kfree(this); - return -ENOMEM; - } - - this->name.name = tmp_name; - this->name.len = namelen; - this->name.hash = 0; - memcpy(tmp_name, name, namelen); - tmp_name[namelen] = 0; - INIT_LIST_HEAD(>list); - list_add(>list, list); - return 0; -} - -static void union_cache_free(struct list_head *uc_list) -{ - struct list_head *p; - struct list_head *ptmp; - int count = 0; - - list_for_each_safe(p, ptmp, uc_list) { - struct union_cache_entry *this; - - this = list_entry(p, struct union_cache_entry, list); - list_del_init(>list); - kfree(this->name.name); - kfree(this); - count++; - } - return; -} - -static int union_cache_find_entry(struct list_head *uc_list, - const char *name, int namelen) -{ - struct union_cache_entry *p; - int ret = 0; - - list_for_each_entry(p, uc_list, list) { - if (p->name.len != namelen) - continue; - if (strncmp(p->name.name, name, namelen) == 0) { - ret = 1; - break; - } - } - - return ret; -} - -/* - * There are four filldir() wrapper necessary for the union mount readdir - * implementation: - * - * - filldir_topmost(): fills the union's readdir cache and the user space - * buffer. This is only used for the topmost directory - * in the union stack. - * - filldir_topmost_cacheonly(): only fills the union's readdir cache. - * This is only used for the topmost directory in the - * union stack. - * - filldir_overlaid(): fills the union's readdir cache and the user space - * buffer. This is only used for directories on the - * stack's lower layers. - * - filldir_overlaid_cacheonly(): only fills the union's readdir cache. - * This is only used for directories on the stack's - * lower layers. - */ - -struct union_cache_callback { - struct getdents_callback *buf; /* original getdents_callback */ - struct list_head list; /* list of union cache entries */ - filldir_t filler; /* the filldir() we should call */ - loff_t offset; /* base offset of our dirents */ - loff_t count; /* maximum number of bytes to "read" */ -}; - -static int filldir_topmost(void *buf, const char *name, int namlen, - loff_t offset, u64 ino, unsigned int d_type) -{ - struct union_cache_callback *cb = buf; - - union_cache_add_entry(>list, name, namlen); - return cb->filler(cb->buf, name,
[RFC PATCH 1/5] Remove existing directory listing implementation
Remove the existing readdir implementation. Signed-off-by: Bharata B Rao [EMAIL PROTECTED] --- fs/readdir.c | 10 + fs/union.c| 333 -- include/linux/union.h | 23 --- 3 files changed, 8 insertions(+), 358 deletions(-) --- a/fs/readdir.c +++ b/fs/readdir.c @@ -16,12 +16,12 @@ #include linux/security.h #include linux/syscalls.h #include linux/unistd.h -#include linux/union.h #include asm/uaccess.h int vfs_readdir(struct file *file, filldir_t filler, void *buf) { + struct inode *inode = file-f_path.dentry-d_inode; int res = -ENOTDIR; if (!file-f_op || !file-f_op-readdir) @@ -31,7 +31,13 @@ int vfs_readdir(struct file *file, filld if (res) goto out; - res = do_readdir(file, buf, filler); + mutex_lock(inode-i_mutex); + res = -ENOENT; + if (!IS_DEADDIR(inode)) { + res = file-f_op-readdir(file, buf, filler); + file_accessed(file); + } + mutex_unlock(inode-i_mutex); out: return res; } --- a/fs/union.c +++ b/fs/union.c @@ -516,339 +516,6 @@ int last_union_is_root(struct path *path } /* - * Union mounts support for readdir. - */ - -/* This is a copy from fs/readdir.c */ -struct getdents_callback { - struct linux_dirent __user *current_dir; - struct linux_dirent __user *previous; - int count; - int error; -}; - -/* The readdir union cache object */ -struct union_cache_entry { - struct list_head list; - struct qstr name; -}; - -static int union_cache_add_entry(struct list_head *list, -const char *name, int namelen) -{ - struct union_cache_entry *this; - char *tmp_name; - - this = kmalloc(sizeof(*this), GFP_KERNEL); - if (!this) { - printk(KERN_CRIT - union_cache_add_entry(): out of kernel memory\n); - return -ENOMEM; - } - - tmp_name = kmalloc(namelen + 1, GFP_KERNEL); - if (!tmp_name) { - printk(KERN_CRIT - union_cache_add_entry(): out of kernel memory\n); - kfree(this); - return -ENOMEM; - } - - this-name.name = tmp_name; - this-name.len = namelen; - this-name.hash = 0; - memcpy(tmp_name, name, namelen); - tmp_name[namelen] = 0; - INIT_LIST_HEAD(this-list); - list_add(this-list, list); - return 0; -} - -static void union_cache_free(struct list_head *uc_list) -{ - struct list_head *p; - struct list_head *ptmp; - int count = 0; - - list_for_each_safe(p, ptmp, uc_list) { - struct union_cache_entry *this; - - this = list_entry(p, struct union_cache_entry, list); - list_del_init(this-list); - kfree(this-name.name); - kfree(this); - count++; - } - return; -} - -static int union_cache_find_entry(struct list_head *uc_list, - const char *name, int namelen) -{ - struct union_cache_entry *p; - int ret = 0; - - list_for_each_entry(p, uc_list, list) { - if (p-name.len != namelen) - continue; - if (strncmp(p-name.name, name, namelen) == 0) { - ret = 1; - break; - } - } - - return ret; -} - -/* - * There are four filldir() wrapper necessary for the union mount readdir - * implementation: - * - * - filldir_topmost(): fills the union's readdir cache and the user space - * buffer. This is only used for the topmost directory - * in the union stack. - * - filldir_topmost_cacheonly(): only fills the union's readdir cache. - * This is only used for the topmost directory in the - * union stack. - * - filldir_overlaid(): fills the union's readdir cache and the user space - * buffer. This is only used for directories on the - * stack's lower layers. - * - filldir_overlaid_cacheonly(): only fills the union's readdir cache. - * This is only used for directories on the stack's - * lower layers. - */ - -struct union_cache_callback { - struct getdents_callback *buf; /* original getdents_callback */ - struct list_head list; /* list of union cache entries */ - filldir_t filler; /* the filldir() we should call */ - loff_t offset; /* base offset of our dirents */ - loff_t count; /* maximum number of bytes to read */ -}; - -static int filldir_topmost(void *buf, const char *name, int namlen, - loff_t offset, u64 ino, unsigned int d_type) -{ - struct union_cache_callback *cb = buf; - -
Re: [RFC PATCH 1/5] Remove existing directory listing implementation
On Wed, 2007-12-05 at 20:08 +0530, Bharata B Rao wrote: Remove the existing readdir implementation. You may have had a better description in your 0/5 mail, but this is what goes into the git log in the end, so I think you need to beef this up a bit. -- Dave -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/