Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 282950
b: refs/heads/master
c: df345c6
h: refs/heads/master
v: v3
  • Loading branch information
Aneesh Kumar K.V authored and Eric Van Hensbergen committed Jan 5, 2012
1 parent 2ed5e00 commit eb68585
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 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: 5d3851530d6d68564e4e0ce04d0547d4d106fc72
refs/heads/master: df345c674b6366952a21a67604c8f6d489bb7ea7
40 changes: 28 additions & 12 deletions trunk/fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,32 @@ static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode)
return res;
}

/**
* p9mode2perm- convert plan9 mode bits to unix permission bits
* @v9ses: v9fs session information
* @stat: p9_wstat from which mode need to be derived
*
*/
static int p9mode2perm(struct v9fs_session_info *v9ses,
struct p9_wstat *stat)
{
int res;
int mode = stat->mode;

res = mode & S_IALLUGO;
if (v9fs_proto_dotu(v9ses)) {
if ((mode & P9_DMSETUID) == P9_DMSETUID)
res |= S_ISUID;

if ((mode & P9_DMSETGID) == P9_DMSETGID)
res |= S_ISGID;

if ((mode & P9_DMSETVTX) == P9_DMSETVTX)
res |= S_ISVTX;
}
return res;
}

/**
* p9mode2unixmode- convert plan9 mode bits to unix mode bits
* @v9ses: v9fs session information
Expand All @@ -107,8 +133,8 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses,
int res;
int mode = stat->mode;

res = mode & S_IALLUGO;
*rdev = 0;
res = p9mode2perm(v9ses, stat);

if ((mode & P9_DMDIR) == P9_DMDIR)
res |= S_IFDIR;
Expand Down Expand Up @@ -142,16 +168,6 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses,
} else
res |= S_IFREG;

if (v9fs_proto_dotu(v9ses)) {
if ((mode & P9_DMSETUID) == P9_DMSETUID)
res |= S_ISUID;

if ((mode & P9_DMSETGID) == P9_DMSETGID)
res |= S_ISGID;

if ((mode & P9_DMSETVTX) == P9_DMSETVTX)
res |= S_ISVTX;
}
return res;
}

Expand Down Expand Up @@ -1168,7 +1184,7 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
set_nlink(inode, i_nlink);
}
}
mode = stat->mode & S_IALLUGO;
mode = p9mode2perm(v9ses, stat);
mode |= inode->i_mode & ~S_IALLUGO;
inode->i_mode = mode;
i_size_write(inode, stat->length);
Expand Down

0 comments on commit eb68585

Please sign in to comment.