aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2012-01-05 03:09:49 -0500
committerEric Van Hensbergen <ericvh@gmail.com>2012-01-05 11:51:44 -0500
commitdf345c674b6366952a21a67604c8f6d489bb7ea7 (patch)
tree8e78d60bbdd04c3ab465be28698edb899fa48097 /fs/9p
parent5d3851530d6d68564e4e0ce04d0547d4d106fc72 (diff)
fs/9p: v9fs_stat2inode should update suid/sgid bits.
Create a new helper that update the permission bits and use that, instead of opencoding the logic. Reported and bisected by: M. Mohan Kumar <mohan@in.ibm.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'fs/9p')
-rw-r--r--fs/9p/vfs_inode.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 85c29733d8b..cf3dd6bc537 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -95,6 +95,32 @@ static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode)
95} 95}
96 96
97/** 97/**
98 * p9mode2perm- convert plan9 mode bits to unix permission bits
99 * @v9ses: v9fs session information
100 * @stat: p9_wstat from which mode need to be derived
101 *
102 */
103static int p9mode2perm(struct v9fs_session_info *v9ses,
104 struct p9_wstat *stat)
105{
106 int res;
107 int mode = stat->mode;
108
109 res = mode & S_IALLUGO;
110 if (v9fs_proto_dotu(v9ses)) {
111 if ((mode & P9_DMSETUID) == P9_DMSETUID)
112 res |= S_ISUID;
113
114 if ((mode & P9_DMSETGID) == P9_DMSETGID)
115 res |= S_ISGID;
116
117 if ((mode & P9_DMSETVTX) == P9_DMSETVTX)
118 res |= S_ISVTX;
119 }
120 return res;
121}
122
123/**
98 * p9mode2unixmode- convert plan9 mode bits to unix mode bits 124 * p9mode2unixmode- convert plan9 mode bits to unix mode bits
99 * @v9ses: v9fs session information 125 * @v9ses: v9fs session information
100 * @stat: p9_wstat from which mode need to be derived 126 * @stat: p9_wstat from which mode need to be derived
@@ -107,8 +133,8 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses,
107 int res; 133 int res;
108 int mode = stat->mode; 134 int mode = stat->mode;
109 135
110 res = mode & S_IALLUGO;
111 *rdev = 0; 136 *rdev = 0;
137 res = p9mode2perm(v9ses, stat);
112 138
113 if ((mode & P9_DMDIR) == P9_DMDIR) 139 if ((mode & P9_DMDIR) == P9_DMDIR)
114 res |= S_IFDIR; 140 res |= S_IFDIR;
@@ -142,16 +168,6 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses,
142 } else 168 } else
143 res |= S_IFREG; 169 res |= S_IFREG;
144 170
145 if (v9fs_proto_dotu(v9ses)) {
146 if ((mode & P9_DMSETUID) == P9_DMSETUID)
147 res |= S_ISUID;
148
149 if ((mode & P9_DMSETGID) == P9_DMSETGID)
150 res |= S_ISGID;
151
152 if ((mode & P9_DMSETVTX) == P9_DMSETVTX)
153 res |= S_ISVTX;
154 }
155 return res; 171 return res;
156} 172}
157 173
@@ -1168,7 +1184,7 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
1168 set_nlink(inode, i_nlink); 1184 set_nlink(inode, i_nlink);
1169 } 1185 }
1170 } 1186 }
1171 mode = stat->mode & S_IALLUGO; 1187 mode = p9mode2perm(v9ses, stat);
1172 mode |= inode->i_mode & ~S_IALLUGO; 1188 mode |= inode->i_mode & ~S_IALLUGO;
1173 inode->i_mode = mode; 1189 inode->i_mode = mode;
1174 i_size_write(inode, stat->length); 1190 i_size_write(inode, stat->length);