Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 135924
b: refs/heads/master
c: c8fe8f3
h: refs/heads/master
v: v3
  • Loading branch information
Christoph Hellwig authored and Al Viro committed Mar 27, 2009
1 parent 485513d commit 672c760
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b6520c81934848cef126d93951f7ce242e0f656d
refs/heads/master: c8fe8f30c7fe6ce6fc44a1db7d5bfa5144cd9211
26 changes: 12 additions & 14 deletions trunk/fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1486,24 +1486,22 @@ int may_open(struct path *path, int acc_mode, int flag)
if (!inode)
return -ENOENT;

if (S_ISLNK(inode->i_mode))
switch (inode->i_mode & S_IFMT) {
case S_IFLNK:
return -ELOOP;

if (S_ISDIR(inode->i_mode) && (acc_mode & MAY_WRITE))
return -EISDIR;

/*
* FIFO's, sockets and device files are special: they don't
* 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)) {
case S_IFDIR:
if (acc_mode & MAY_WRITE)
return -EISDIR;
break;
case S_IFBLK:
case S_IFCHR:
if (path->mnt->mnt_flags & MNT_NODEV)
return -EACCES;

/*FALLTHRU*/
case S_IFIFO:
case S_IFSOCK:
flag &= ~O_TRUNC;
break;
}

error = inode_permission(inode, acc_mode);
Expand Down

0 comments on commit 672c760

Please sign in to comment.