This patch adds a new readdir() inode operation. The purpose of this patch is to enable the VFS to support directory reading on a stack of directories. The new interface isn't passing the struct file to the filesystem implementation anymore. Normally the filesystem implementation shouldn't depend on any information in struct file except for the dentry, the cookie (f_pos) and the users credentials. The new interface for the readdir inode operation is as follows: int (*readdir) (struct dentry *dentry, loff_t *pos, void *private, filldir_t filler, void *dirent); @dentry: the dentry of the directory @pos: pointer to the cookie @private: the credentials (at the moment it is still filp->private_data @filler: the filldir to call @dirent: the dirent buffer Signed-off-by: Jan Blunck --- fs/readdir.c | 14 ++++++++++++-- include/linux/fs.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) Index: b/fs/readdir.c =================================================================== --- a/fs/readdir.c +++ b/fs/readdir.c @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -23,7 +24,8 @@ int vfs_readdir(struct file *file, filld { struct inode *inode = file->f_path.dentry->d_inode; int res = -ENOTDIR; - if (!file->f_op || !file->f_op->readdir) + if ((!file->f_op || !file->f_op->readdir) && + (!inode->i_op || !inode->i_op->readdir)) goto out; res = security_file_permission(file, MAY_READ); @@ -33,7 +35,15 @@ int vfs_readdir(struct file *file, filld mutex_lock(&inode->i_mutex); res = -ENOENT; if (!IS_DEADDIR(inode)) { - res = file->f_op->readdir(file, buf, filler); + if (inode->i_op->readdir) { + printk(KERN_DEBUG "i_op->readdir @ "); + print_ip_sym((unsigned long)inode->i_op); + res = inode->i_op->readdir(file->f_path.dentry, + &file->f_pos, + file->private_data, + filler, buf); + } else + res = file->f_op->readdir(file, buf, filler); file_accessed(file); } mutex_unlock(&inode->i_mutex); Index: b/include/linux/fs.h =================================================================== --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1214,6 +1214,8 @@ struct inode_operations { int (*mkdir) (struct inode *,struct dentry *,int); int (*rmdir) (struct inode *,struct dentry *); int (*mknod) (struct inode *,struct dentry *,int,dev_t); + /* readdir(dentry, position, private/credential, filler, buffer) */ + int (*readdir) (struct dentry *, loff_t *, void *, filldir_t, void *); int (*rename) (struct inode *, struct dentry *, struct inode *, struct dentry *); int (*readlink) (struct dentry *, char __user *,int); -- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/