login
Header Space

 
 

Re: VFS + path walktrough

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <trond.myklebust@...>
Cc: <miklos@...>, <viro@...>, <weigelt@...>, <linux-kernel@...>
Date: Monday, May 5, 2008 - 4:35 pm

> On Mon, 2008-05-05 at 20:31 +0200, Miklos Szeredi wrote:

And just to show how utterly trivially this could be done, here's a
patch (totally untested).

Hack?  Hell, yes.

Miklos

---
 fs/namei.c         |   20 ++++++++++++--------
 include/linux/fs.h |    1 +
 2 files changed, 13 insertions(+), 8 deletions(-)

Index: linux-2.6/fs/namei.c
===================================================================
--- linux-2.6.orig/fs/namei.c	2008-05-05 12:03:24.000000000 +0200
+++ linux-2.6/fs/namei.c	2008-05-05 22:25:52.000000000 +0200
@@ -519,14 +519,18 @@ static struct dentry * real_lookup(struc
 	 */
 	result = d_lookup(parent, name);
 	if (!result) {
-		struct dentry * dentry = d_alloc(parent, name);
-		result = ERR_PTR(-ENOMEM);
-		if (dentry) {
-			result = dir->i_op->lookup(dir, dentry, nd);
-			if (result)
-				dput(dentry);
-			else
-				result = dentry;
+		if (dir->i_op->lookup_path) {
+			result = dir->i_op->lookup_path(dir, name);
+		} else  {
+			struct dentry * dentry = d_alloc(parent, name);
+			result = ERR_PTR(-ENOMEM);
+			if (dentry) {
+				result = dir->i_op->lookup(dir, dentry, nd);
+				if (result)
+					dput(dentry);
+				else
+					result = dentry;
+			}
 		}
 		mutex_unlock(&dir->i_mutex);
 		return result;
Index: linux-2.6/include/linux/fs.h
===================================================================
--- linux-2.6.orig/include/linux/fs.h	2008-05-05 12:03:24.000000000 +0200
+++ linux-2.6/include/linux/fs.h	2008-05-05 22:26:59.000000000 +0200
@@ -1251,6 +1251,7 @@ struct file_operations {
 struct inode_operations {
 	int (*create) (struct inode *,struct dentry *,int, struct nameidata *);
 	struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
+	struct dentry * (*lookup_path) (struct inode *, struct qstr *);
 	int (*link) (struct dentry *,struct inode *,struct dentry *);
 	int (*unlink) (struct inode *,struct dentry *);
 	int (*symlink) (struct inode *,struct dentry *,const char *);





--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
VFS + path walktrough, Enrico Weigelt, (Mon May 5, 8:40 am)
Re: VFS + path walktrough, Enrico Weigelt, (Mon May 5, 9:06 am)
Re: VFS + path walktrough, Al Viro, (Mon May 5, 9:13 am)
Re: VFS + path walktrough, Enrico Weigelt, (Mon May 5, 9:43 am)
Re: VFS + path walktrough, Al Viro, (Mon May 5, 11:35 am)
Re: VFS + path walktrough, Miklos Szeredi, (Mon May 5, 12:43 pm)
Re: VFS + path walktrough, Al Viro, (Mon May 5, 1:14 pm)
Re: VFS + path walktrough, Miklos Szeredi, (Mon May 5, 1:33 pm)
Re: VFS + path walktrough, Al Viro, (Mon May 5, 1:40 pm)
Re: VFS + path walktrough, Enrico Weigelt, (Mon May 5, 2:23 pm)
Re: VFS + path walktrough, Al Viro, (Mon May 5, 2:34 pm)
Re: VFS + path walktrough, Enrico Weigelt, (Mon May 5, 3:02 pm)
Re: VFS + path walktrough, Al Viro, (Mon May 5, 3:09 pm)
Re: VFS + path walktrough, Miklos Szeredi, (Mon May 5, 2:03 pm)
Re: VFS + path walktrough, Enrico Weigelt, (Mon May 5, 2:50 pm)
Re: VFS + path walktrough, Miklos Szeredi, (Mon May 5, 2:31 pm)
Re: VFS + path walktrough, Trond Myklebust, (Mon May 5, 4:16 pm)
Re: VFS + path walktrough, Miklos Szeredi, (Mon May 5, 4:35 pm)
Re: VFS + path walktrough, Miklos Szeredi, (Mon May 5, 1:03 pm)
speck-geostationary