Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

Al Viro c2837de7 18cb1b08

+8 -12
+8 -12
fs/9p/vfs_inode.c
··· 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 64 int res; 65 65 res = mode & 0777; 66 66 if (S_ISDIR(mode)) 67 67 res |= P9_DMDIR; 68 68 if (v9fs_proto_dotu(v9ses)) { 69 - if (S_ISLNK(mode)) 70 - res |= P9_DMSYMLINK; 71 69 if (v9ses->nodev == 0) { 72 70 if (S_ISSOCK(mode)) 73 71 res |= P9_DMSOCKET; ··· 83 85 res |= P9_DMSETGID; 84 86 if ((mode & S_ISVTX) == S_ISVTX) 85 87 res |= P9_DMSETVTX; 86 - if ((mode & P9_DMLINK)) 87 - res |= P9_DMLINK; 88 88 } 89 - 90 89 return res; 91 90 } 92 91 ··· 1298 1303 */ 1299 1304 1300 1305 static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry, 1301 - int mode, const char *extension) 1306 + u32 perm, const char *extension) 1302 1307 { 1303 - u32 perm; 1304 1308 struct p9_fid *fid; 1305 1309 struct v9fs_session_info *v9ses; 1306 1310 ··· 1309 1315 return -EPERM; 1310 1316 } 1311 1317 1312 - perm = unixmode2p9mode(v9ses, mode); 1313 1318 fid = v9fs_create(v9ses, dir, dentry, (char *) extension, perm, 1314 1319 P9_OREAD); 1315 1320 if (IS_ERR(fid)) ··· 1335 1342 P9_DPRINTK(P9_DEBUG_VFS, " %lu,%s,%s\n", dir->i_ino, 1336 1343 dentry->d_name.name, symname); 1337 1344 1338 - return v9fs_vfs_mkspecial(dir, dentry, S_IFLNK, symname); 1345 + return v9fs_vfs_mkspecial(dir, dentry, P9_DMSYMLINK, symname); 1339 1346 } 1340 1347 1341 1348 /** ··· 1392 1399 static int 1393 1400 v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) 1394 1401 { 1402 + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); 1395 1403 int retval; 1396 1404 char *name; 1405 + u32 perm; 1397 1406 1398 1407 P9_DPRINTK(P9_DEBUG_VFS, 1399 - " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino, 1408 + " %lu,%s mode: %hx MAJOR: %u MINOR: %u\n", dir->i_ino, 1400 1409 dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev)); 1401 1410 1402 1411 if (!new_valid_dev(rdev)) ··· 1421 1426 return -EINVAL; 1422 1427 } 1423 1428 1424 - retval = v9fs_vfs_mkspecial(dir, dentry, mode, name); 1429 + perm = unixmode2p9mode(v9ses, mode); 1430 + retval = v9fs_vfs_mkspecial(dir, dentry, perm, name); 1425 1431 __putname(name); 1426 1432 1427 1433 return retval;