use S_ISDIR() in link_path_walk() to decide whether the last path component is a directory
PATCH 1/1 use S_ISDIR() in link_path_walk() to decide whether the last path component is a directory
Hi,
This patch does not allow open(name, O_DIRECTORY) to be successful for non-directories in reiser4. It replaces ->i_op->lookup != NULL "is dir" check for the last path component by explicit S_ISDIR(->i_mode) check.
Regardless to reiser4, S_ISDIR() looks more clear there.
Thanks in advance.
===== fs/namei.c 1.104 vs edited =====
fs/namei.c +1 -1
@@ -816,7 +816,7 @@break ;if (lookup_flags &LOOKUP_DIRECTORY ) { err = -ENOTDIR ; -if (!inode->i_op || !inode->i_op->lookup) +if (!S_ISDIR (inode->i_mode))break ; } goto return_base;
Quoted 7 lines · Alex Zarochentsev
Hi,
This patch does not allow
open(name, O_DIRECTORY)to be successful for non-directories in reiser4. It replaces ->i_op->lookup != NULL "is dir" check for the last path component by explicitS_ISDIR(->i_mode)check.Regardless to reiser4,
S_ISDIR()looks more clear there.
The only objection here is that right now we are guaranteed that cwd and root of every task have non-NULL ->lookup(). With your patch all we have is S_ISDIR().
So we either need to check for non-NULL ->lookup() before the beginning of loop in link_path_walk() or split the flag in two. I would rather do the former...