diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-07-24 18:59:07 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-01-03 22:54:58 -0500 |
commit | c2837de73e8081bd33bc72ad73f49d6bcba9d1b6 (patch) | |
tree | 3fca43b0147fc075c24a26aba1a60568ffd25f90 /fs/9p/vfs_inode.c | |
parent | 18cb1b08d2e1ff6907130fc0ce78a5912efa0ba5 (diff) |
9p: don't bother with unixmode2p9mode() for link() and symlink()
Pass perm to v9fs_vfs_mkspecial() instead of passing mode;
calculate in caller when done for mknod(), use known value for link()
and symlink(). As the result, we avoid a bit of work *and* stop
mixing mode_t with P9_DMLINK.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/9p/vfs_inode.c')
-rw-r--r-- | fs/9p/vfs_inode.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index f54a26859fcc..cde57a850adb 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -59,15 +59,13 @@ static const struct inode_operations v9fs_symlink_inode_operations; | |||
59 | * | 59 | * |
60 | */ | 60 | */ |
61 | 61 | ||
62 | static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) | 62 | static u32 unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) |
63 | { | 63 | { |
64 | int res; | 64 | int res; |
65 | res = mode & 0777; | 65 | res = mode & 0777; |
66 | if (S_ISDIR(mode)) | 66 | if (S_ISDIR(mode)) |
67 | res |= P9_DMDIR; | 67 | res |= P9_DMDIR; |
68 | if (v9fs_proto_dotu(v9ses)) { | 68 | if (v9fs_proto_dotu(v9ses)) { |
69 | if (S_ISLNK(mode)) | ||
70 | res |= P9_DMSYMLINK; | ||
71 | if (v9ses->nodev == 0) { | 69 | if (v9ses->nodev == 0) { |
72 | if (S_ISSOCK(mode)) | 70 | if (S_ISSOCK(mode)) |
73 | res |= P9_DMSOCKET; | 71 | res |= P9_DMSOCKET; |
@@ -85,10 +83,7 @@ static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) | |||
85 | res |= P9_DMSETGID; | 83 | res |= P9_DMSETGID; |
86 | if ((mode & S_ISVTX) == S_ISVTX) | 84 | if ((mode & S_ISVTX) == S_ISVTX) |
87 | res |= P9_DMSETVTX; | 85 | res |= P9_DMSETVTX; |
88 | if ((mode & P9_DMLINK)) | ||
89 | res |= P9_DMLINK; | ||
90 | } | 86 | } |
91 | |||
92 | return res; | 87 | return res; |
93 | } | 88 | } |
94 | 89 | ||
@@ -1303,9 +1298,8 @@ v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p) | |||
1303 | */ | 1298 | */ |
1304 | 1299 | ||
1305 | static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry, | 1300 | static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry, |
1306 | int mode, const char *extension) | 1301 | u32 perm, const char *extension) |
1307 | { | 1302 | { |
1308 | u32 perm; | ||
1309 | struct p9_fid *fid; | 1303 | struct p9_fid *fid; |
1310 | struct v9fs_session_info *v9ses; | 1304 | struct v9fs_session_info *v9ses; |
1311 | 1305 | ||
@@ -1315,7 +1309,6 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry, | |||
1315 | return -EPERM; | 1309 | return -EPERM; |
1316 | } | 1310 | } |
1317 | 1311 | ||
1318 | perm = unixmode2p9mode(v9ses, mode); | ||
1319 | fid = v9fs_create(v9ses, dir, dentry, (char *) extension, perm, | 1312 | fid = v9fs_create(v9ses, dir, dentry, (char *) extension, perm, |
1320 | P9_OREAD); | 1313 | P9_OREAD); |
1321 | if (IS_ERR(fid)) | 1314 | if (IS_ERR(fid)) |
@@ -1342,7 +1335,7 @@ v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) | |||
1342 | P9_DPRINTK(P9_DEBUG_VFS, " %lu,%s,%s\n", dir->i_ino, | 1335 | P9_DPRINTK(P9_DEBUG_VFS, " %lu,%s,%s\n", dir->i_ino, |
1343 | dentry->d_name.name, symname); | 1336 | dentry->d_name.name, symname); |
1344 | 1337 | ||
1345 | return v9fs_vfs_mkspecial(dir, dentry, S_IFLNK, symname); | 1338 | return v9fs_vfs_mkspecial(dir, dentry, P9_DMSYMLINK, symname); |
1346 | } | 1339 | } |
1347 | 1340 | ||
1348 | /** | 1341 | /** |
@@ -1399,11 +1392,13 @@ clunk_fid: | |||
1399 | static int | 1392 | static int |
1400 | v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) | 1393 | v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) |
1401 | { | 1394 | { |
1395 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); | ||
1402 | int retval; | 1396 | int retval; |
1403 | char *name; | 1397 | char *name; |
1398 | u32 perm; | ||
1404 | 1399 | ||
1405 | P9_DPRINTK(P9_DEBUG_VFS, | 1400 | P9_DPRINTK(P9_DEBUG_VFS, |
1406 | " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino, | 1401 | " %lu,%s mode: %hx MAJOR: %u MINOR: %u\n", dir->i_ino, |
1407 | dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev)); | 1402 | dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev)); |
1408 | 1403 | ||
1409 | if (!new_valid_dev(rdev)) | 1404 | if (!new_valid_dev(rdev)) |
@@ -1426,7 +1421,8 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rde | |||
1426 | return -EINVAL; | 1421 | return -EINVAL; |
1427 | } | 1422 | } |
1428 | 1423 | ||
1429 | retval = v9fs_vfs_mkspecial(dir, dentry, mode, name); | 1424 | perm = unixmode2p9mode(v9ses, mode); |
1425 | retval = v9fs_vfs_mkspecial(dir, dentry, perm, name); | ||
1430 | __putname(name); | 1426 | __putname(name); |
1431 | 1427 | ||
1432 | return retval; | 1428 | return retval; |