diff options
Diffstat (limited to 'fs/9p/vfs_inode.c')
| -rw-r--r-- | fs/9p/vfs_inode.c | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index a407fa3388c0..5fe45d692c9f 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
| @@ -60,7 +60,7 @@ static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) | |||
| 60 | res = mode & 0777; | 60 | res = mode & 0777; |
| 61 | if (S_ISDIR(mode)) | 61 | if (S_ISDIR(mode)) |
| 62 | res |= P9_DMDIR; | 62 | res |= P9_DMDIR; |
| 63 | if (v9fs_extended(v9ses)) { | 63 | if (v9fs_proto_dotu(v9ses)) { |
| 64 | if (S_ISLNK(mode)) | 64 | if (S_ISLNK(mode)) |
| 65 | res |= P9_DMSYMLINK; | 65 | res |= P9_DMSYMLINK; |
| 66 | if (v9ses->nodev == 0) { | 66 | if (v9ses->nodev == 0) { |
| @@ -102,21 +102,21 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode) | |||
| 102 | 102 | ||
| 103 | if ((mode & P9_DMDIR) == P9_DMDIR) | 103 | if ((mode & P9_DMDIR) == P9_DMDIR) |
| 104 | res |= S_IFDIR; | 104 | res |= S_IFDIR; |
| 105 | else if ((mode & P9_DMSYMLINK) && (v9fs_extended(v9ses))) | 105 | else if ((mode & P9_DMSYMLINK) && (v9fs_proto_dotu(v9ses))) |
| 106 | res |= S_IFLNK; | 106 | res |= S_IFLNK; |
| 107 | else if ((mode & P9_DMSOCKET) && (v9fs_extended(v9ses)) | 107 | else if ((mode & P9_DMSOCKET) && (v9fs_proto_dotu(v9ses)) |
| 108 | && (v9ses->nodev == 0)) | 108 | && (v9ses->nodev == 0)) |
| 109 | res |= S_IFSOCK; | 109 | res |= S_IFSOCK; |
| 110 | else if ((mode & P9_DMNAMEDPIPE) && (v9fs_extended(v9ses)) | 110 | else if ((mode & P9_DMNAMEDPIPE) && (v9fs_proto_dotu(v9ses)) |
| 111 | && (v9ses->nodev == 0)) | 111 | && (v9ses->nodev == 0)) |
| 112 | res |= S_IFIFO; | 112 | res |= S_IFIFO; |
| 113 | else if ((mode & P9_DMDEVICE) && (v9fs_extended(v9ses)) | 113 | else if ((mode & P9_DMDEVICE) && (v9fs_proto_dotu(v9ses)) |
| 114 | && (v9ses->nodev == 0)) | 114 | && (v9ses->nodev == 0)) |
| 115 | res |= S_IFBLK; | 115 | res |= S_IFBLK; |
| 116 | else | 116 | else |
| 117 | res |= S_IFREG; | 117 | res |= S_IFREG; |
| 118 | 118 | ||
| 119 | if (v9fs_extended(v9ses)) { | 119 | if (v9fs_proto_dotu(v9ses)) { |
| 120 | if ((mode & P9_DMSETUID) == P9_DMSETUID) | 120 | if ((mode & P9_DMSETUID) == P9_DMSETUID) |
| 121 | res |= S_ISUID; | 121 | res |= S_ISUID; |
| 122 | 122 | ||
| @@ -265,7 +265,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) | |||
| 265 | case S_IFBLK: | 265 | case S_IFBLK: |
| 266 | case S_IFCHR: | 266 | case S_IFCHR: |
| 267 | case S_IFSOCK: | 267 | case S_IFSOCK: |
| 268 | if (!v9fs_extended(v9ses)) { | 268 | if (!v9fs_proto_dotu(v9ses)) { |
| 269 | P9_DPRINTK(P9_DEBUG_ERROR, | 269 | P9_DPRINTK(P9_DEBUG_ERROR, |
| 270 | "special files without extended mode\n"); | 270 | "special files without extended mode\n"); |
| 271 | err = -EINVAL; | 271 | err = -EINVAL; |
| @@ -278,7 +278,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) | |||
| 278 | inode->i_fop = &v9fs_file_operations; | 278 | inode->i_fop = &v9fs_file_operations; |
| 279 | break; | 279 | break; |
| 280 | case S_IFLNK: | 280 | case S_IFLNK: |
| 281 | if (!v9fs_extended(v9ses)) { | 281 | if (!v9fs_proto_dotu(v9ses)) { |
| 282 | P9_DPRINTK(P9_DEBUG_ERROR, | 282 | P9_DPRINTK(P9_DEBUG_ERROR, |
| 283 | "extended modes used w/o 9P2000.u\n"); | 283 | "extended modes used w/o 9P2000.u\n"); |
| 284 | err = -EINVAL; | 284 | err = -EINVAL; |
| @@ -288,7 +288,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) | |||
| 288 | break; | 288 | break; |
| 289 | case S_IFDIR: | 289 | case S_IFDIR: |
| 290 | inc_nlink(inode); | 290 | inc_nlink(inode); |
| 291 | if (v9fs_extended(v9ses)) | 291 | if (v9fs_proto_dotu(v9ses)) |
| 292 | inode->i_op = &v9fs_dir_inode_operations_ext; | 292 | inode->i_op = &v9fs_dir_inode_operations_ext; |
| 293 | else | 293 | else |
| 294 | inode->i_op = &v9fs_dir_inode_operations; | 294 | inode->i_op = &v9fs_dir_inode_operations; |
| @@ -575,7 +575,8 @@ v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
| 575 | flags = O_RDWR; | 575 | flags = O_RDWR; |
| 576 | 576 | ||
| 577 | fid = v9fs_create(v9ses, dir, dentry, NULL, perm, | 577 | fid = v9fs_create(v9ses, dir, dentry, NULL, perm, |
| 578 | v9fs_uflags2omode(flags, v9fs_extended(v9ses))); | 578 | v9fs_uflags2omode(flags, |
| 579 | v9fs_proto_dotu(v9ses))); | ||
| 579 | if (IS_ERR(fid)) { | 580 | if (IS_ERR(fid)) { |
| 580 | err = PTR_ERR(fid); | 581 | err = PTR_ERR(fid); |
| 581 | fid = NULL; | 582 | fid = NULL; |
| @@ -858,7 +859,7 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr) | |||
| 858 | if (iattr->ia_valid & ATTR_SIZE) | 859 | if (iattr->ia_valid & ATTR_SIZE) |
| 859 | wstat.length = iattr->ia_size; | 860 | wstat.length = iattr->ia_size; |
| 860 | 861 | ||
| 861 | if (v9fs_extended(v9ses)) { | 862 | if (v9fs_proto_dotu(v9ses)) { |
| 862 | if (iattr->ia_valid & ATTR_UID) | 863 | if (iattr->ia_valid & ATTR_UID) |
| 863 | wstat.n_uid = iattr->ia_uid; | 864 | wstat.n_uid = iattr->ia_uid; |
| 864 | 865 | ||
| @@ -886,6 +887,8 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, | |||
| 886 | struct super_block *sb) | 887 | struct super_block *sb) |
| 887 | { | 888 | { |
| 888 | char ext[32]; | 889 | char ext[32]; |
| 890 | char tag_name[14]; | ||
| 891 | unsigned int i_nlink; | ||
| 889 | struct v9fs_session_info *v9ses = sb->s_fs_info; | 892 | struct v9fs_session_info *v9ses = sb->s_fs_info; |
| 890 | 893 | ||
| 891 | inode->i_nlink = 1; | 894 | inode->i_nlink = 1; |
| @@ -897,11 +900,26 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, | |||
| 897 | inode->i_uid = v9ses->dfltuid; | 900 | inode->i_uid = v9ses->dfltuid; |
| 898 | inode->i_gid = v9ses->dfltgid; | 901 | inode->i_gid = v9ses->dfltgid; |
| 899 | 902 | ||
| 900 | if (v9fs_extended(v9ses)) { | 903 | if (v9fs_proto_dotu(v9ses)) { |
| 901 | inode->i_uid = stat->n_uid; | 904 | inode->i_uid = stat->n_uid; |
| 902 | inode->i_gid = stat->n_gid; | 905 | inode->i_gid = stat->n_gid; |
| 903 | } | 906 | } |
| 904 | 907 | if ((S_ISREG(inode->i_mode)) || (S_ISDIR(inode->i_mode))) { | |
| 908 | if (v9fs_proto_dotu(v9ses) && (stat->extension[0] != '\0')) { | ||
| 909 | /* | ||
| 910 | * Hadlink support got added later to | ||
| 911 | * to the .u extension. So there can be | ||
| 912 | * server out there that doesn't support | ||
| 913 | * this even with .u extension. So check | ||
| 914 | * for non NULL stat->extension | ||
| 915 | */ | ||
| 916 | strncpy(ext, stat->extension, sizeof(ext)); | ||
| 917 | /* HARDLINKCOUNT %u */ | ||
| 918 | sscanf(ext, "%13s %u", tag_name, &i_nlink); | ||
| 919 | if (!strncmp(tag_name, "HARDLINKCOUNT", 13)) | ||
| 920 | inode->i_nlink = i_nlink; | ||
| 921 | } | ||
| 922 | } | ||
| 905 | inode->i_mode = p9mode2unixmode(v9ses, stat->mode); | 923 | inode->i_mode = p9mode2unixmode(v9ses, stat->mode); |
| 906 | if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode))) { | 924 | if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode))) { |
| 907 | char type = 0; | 925 | char type = 0; |
| @@ -976,7 +994,7 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen) | |||
| 976 | if (IS_ERR(fid)) | 994 | if (IS_ERR(fid)) |
| 977 | return PTR_ERR(fid); | 995 | return PTR_ERR(fid); |
| 978 | 996 | ||
| 979 | if (!v9fs_extended(v9ses)) | 997 | if (!v9fs_proto_dotu(v9ses)) |
| 980 | return -EBADF; | 998 | return -EBADF; |
| 981 | 999 | ||
| 982 | st = p9_client_stat(fid); | 1000 | st = p9_client_stat(fid); |
| @@ -1066,7 +1084,7 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry, | |||
| 1066 | struct p9_fid *fid; | 1084 | struct p9_fid *fid; |
| 1067 | 1085 | ||
| 1068 | v9ses = v9fs_inode2v9ses(dir); | 1086 | v9ses = v9fs_inode2v9ses(dir); |
| 1069 | if (!v9fs_extended(v9ses)) { | 1087 | if (!v9fs_proto_dotu(v9ses)) { |
| 1070 | P9_DPRINTK(P9_DEBUG_ERROR, "not extended\n"); | 1088 | P9_DPRINTK(P9_DEBUG_ERROR, "not extended\n"); |
| 1071 | return -EPERM; | 1089 | return -EPERM; |
| 1072 | } | 1090 | } |
