2005-09-23 14:51:00

by Miklos Szeredi

[permalink] [raw]
Subject: [PATCH] open: cleanup in lookup_flags()

lookup_flags() is only called from the non-create case, so it needn't
check for O_CREAT|O_EXCL.

Signed-off-by: Miklos Szeredi <[email protected]>

Index: linux/fs/namei.c
===================================================================
--- linux.orig/fs/namei.c 2005-09-23 16:34:22.000000000 +0200
+++ linux/fs/namei.c 2005-09-23 16:34:27.000000000 +0200
@@ -1246,9 +1246,6 @@ static inline int lookup_flags(unsigned
if (f & O_NOFOLLOW)
retval &= ~LOOKUP_FOLLOW;

- if ((f & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL))
- retval &= ~LOOKUP_FOLLOW;
-
if (f & O_DIRECTORY)
retval |= LOOKUP_DIRECTORY;


2005-09-23 15:22:33

by Miklos Szeredi

[permalink] [raw]
Subject: Re: [PATCH] open: cleanup in lookup_flags()

I only see now, that comment should be cleaned too. Sorry.

lookup_flags() is only called from the non-create case, so it needn't
check for O_CREAT|O_EXCL.

Signed-off-by: Miklos Szeredi <[email protected]>

Index: linux/fs/namei.c
===================================================================
--- linux.orig/fs/namei.c 2005-09-23 16:36:19.000000000 +0200
+++ linux/fs/namei.c 2005-09-23 17:16:57.000000000 +0200
@@ -1234,9 +1234,6 @@ static inline int may_create(struct inod
}

/*
- * Special case: O_CREAT|O_EXCL implies O_NOFOLLOW for security
- * reasons.
- *
* O_DIRECTORY translates into forcing a directory lookup.
*/
static inline int lookup_flags(unsigned int f)
@@ -1246,9 +1243,6 @@ static inline int lookup_flags(unsigned
if (f & O_NOFOLLOW)
retval &= ~LOOKUP_FOLLOW;

- if ((f & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL))
- retval &= ~LOOKUP_FOLLOW;
-
if (f & O_DIRECTORY)
retval |= LOOKUP_DIRECTORY;