mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 11:46:19 +00:00
cleanup may_open
Add a switch for the various i_mode fmt cases, and remove the comment about writeability of devices nodes - that part is handled in inode_permission and comment on (briefly) there. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
b6520c8193
commit
c8fe8f30c7
1 changed files with 12 additions and 14 deletions
26
fs/namei.c
26
fs/namei.c
|
@ -1486,24 +1486,22 @@ int may_open(struct path *path, int acc_mode, int flag)
|
||||||
if (!inode)
|
if (!inode)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
if (S_ISLNK(inode->i_mode))
|
switch (inode->i_mode & S_IFMT) {
|
||||||
|
case S_IFLNK:
|
||||||
return -ELOOP;
|
return -ELOOP;
|
||||||
|
case S_IFDIR:
|
||||||
if (S_ISDIR(inode->i_mode) && (acc_mode & MAY_WRITE))
|
if (acc_mode & MAY_WRITE)
|
||||||
return -EISDIR;
|
return -EISDIR;
|
||||||
|
break;
|
||||||
/*
|
case S_IFBLK:
|
||||||
* FIFO's, sockets and device files are special: they don't
|
case S_IFCHR:
|
||||||
* actually live on the filesystem itself, and as such you
|
|
||||||
* can write to them even if the filesystem is read-only.
|
|
||||||
*/
|
|
||||||
if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
|
|
||||||
flag &= ~O_TRUNC;
|
|
||||||
} else if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) {
|
|
||||||
if (path->mnt->mnt_flags & MNT_NODEV)
|
if (path->mnt->mnt_flags & MNT_NODEV)
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
|
/*FALLTHRU*/
|
||||||
|
case S_IFIFO:
|
||||||
|
case S_IFSOCK:
|
||||||
flag &= ~O_TRUNC;
|
flag &= ~O_TRUNC;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = inode_permission(inode, acc_mode);
|
error = inode_permission(inode, acc_mode);
|
||||||
|
|
Loading…
Reference in a new issue