diff options
Diffstat (limited to 'fs/9p')
| -rw-r--r-- | fs/9p/v9fs.c | 33 | ||||
| -rw-r--r-- | fs/9p/v9fs_vfs.h | 1 | ||||
| -rw-r--r-- | fs/9p/vfs_file.c | 19 | ||||
| -rw-r--r-- | fs/9p/vfs_inode.c | 43 | ||||
| -rw-r--r-- | fs/9p/vfs_super.c | 3 |
5 files changed, 45 insertions, 54 deletions
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index cf62b05e296..7d6c2139891 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c | |||
| @@ -84,7 +84,7 @@ static const match_table_t tokens = { | |||
| 84 | 84 | ||
| 85 | static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) | 85 | static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) |
| 86 | { | 86 | { |
| 87 | char *options; | 87 | char *options, *tmp_options; |
| 88 | substring_t args[MAX_OPT_ARGS]; | 88 | substring_t args[MAX_OPT_ARGS]; |
| 89 | char *p; | 89 | char *p; |
| 90 | int option = 0; | 90 | int option = 0; |
| @@ -102,9 +102,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) | |||
| 102 | if (!opts) | 102 | if (!opts) |
| 103 | return 0; | 103 | return 0; |
| 104 | 104 | ||
| 105 | options = kstrdup(opts, GFP_KERNEL); | 105 | tmp_options = kstrdup(opts, GFP_KERNEL); |
| 106 | if (!options) | 106 | if (!tmp_options) { |
| 107 | ret = -ENOMEM; | ||
| 107 | goto fail_option_alloc; | 108 | goto fail_option_alloc; |
| 109 | } | ||
| 110 | options = tmp_options; | ||
| 108 | 111 | ||
| 109 | while ((p = strsep(&options, ",")) != NULL) { | 112 | while ((p = strsep(&options, ",")) != NULL) { |
| 110 | int token; | 113 | int token; |
| @@ -159,8 +162,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) | |||
| 159 | break; | 162 | break; |
| 160 | case Opt_cache: | 163 | case Opt_cache: |
| 161 | s = match_strdup(&args[0]); | 164 | s = match_strdup(&args[0]); |
| 162 | if (!s) | 165 | if (!s) { |
| 163 | goto fail_option_alloc; | 166 | ret = -ENOMEM; |
| 167 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
| 168 | "problem allocating copy of cache arg\n"); | ||
| 169 | goto free_and_return; | ||
| 170 | } | ||
| 164 | 171 | ||
| 165 | if (strcmp(s, "loose") == 0) | 172 | if (strcmp(s, "loose") == 0) |
| 166 | v9ses->cache = CACHE_LOOSE; | 173 | v9ses->cache = CACHE_LOOSE; |
| @@ -173,8 +180,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) | |||
| 173 | 180 | ||
| 174 | case Opt_access: | 181 | case Opt_access: |
| 175 | s = match_strdup(&args[0]); | 182 | s = match_strdup(&args[0]); |
| 176 | if (!s) | 183 | if (!s) { |
| 177 | goto fail_option_alloc; | 184 | ret = -ENOMEM; |
| 185 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
| 186 | "problem allocating copy of access arg\n"); | ||
| 187 | goto free_and_return; | ||
| 188 | } | ||
| 178 | 189 | ||
| 179 | v9ses->flags &= ~V9FS_ACCESS_MASK; | 190 | v9ses->flags &= ~V9FS_ACCESS_MASK; |
| 180 | if (strcmp(s, "user") == 0) | 191 | if (strcmp(s, "user") == 0) |
| @@ -194,13 +205,11 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) | |||
| 194 | continue; | 205 | continue; |
| 195 | } | 206 | } |
| 196 | } | 207 | } |
| 197 | kfree(options); | ||
| 198 | return ret; | ||
| 199 | 208 | ||
| 209 | free_and_return: | ||
| 210 | kfree(tmp_options); | ||
| 200 | fail_option_alloc: | 211 | fail_option_alloc: |
| 201 | P9_DPRINTK(P9_DEBUG_ERROR, | 212 | return ret; |
| 202 | "failed to allocate copy of option argument\n"); | ||
| 203 | return -ENOMEM; | ||
| 204 | } | 213 | } |
| 205 | 214 | ||
| 206 | /** | 215 | /** |
diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h index 3a7560e3586..ed835836e0d 100644 --- a/fs/9p/v9fs_vfs.h +++ b/fs/9p/v9fs_vfs.h | |||
| @@ -60,3 +60,4 @@ void v9fs_dentry_release(struct dentry *); | |||
| 60 | int v9fs_uflags2omode(int uflags, int extended); | 60 | int v9fs_uflags2omode(int uflags, int extended); |
| 61 | 61 | ||
| 62 | ssize_t v9fs_file_readn(struct file *, char *, char __user *, u32, u64); | 62 | ssize_t v9fs_file_readn(struct file *, char *, char __user *, u32, u64); |
| 63 | void v9fs_blank_wstat(struct p9_wstat *wstat); | ||
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 3902bf43a08..74a0461a9ac 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c | |||
| @@ -257,6 +257,23 @@ v9fs_file_write(struct file *filp, const char __user * data, | |||
| 257 | return total; | 257 | return total; |
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | static int v9fs_file_fsync(struct file *filp, struct dentry *dentry, | ||
| 261 | int datasync) | ||
| 262 | { | ||
| 263 | struct p9_fid *fid; | ||
| 264 | struct p9_wstat wstat; | ||
| 265 | int retval; | ||
| 266 | |||
| 267 | P9_DPRINTK(P9_DEBUG_VFS, "filp %p dentry %p datasync %x\n", filp, | ||
| 268 | dentry, datasync); | ||
| 269 | |||
| 270 | fid = filp->private_data; | ||
| 271 | v9fs_blank_wstat(&wstat); | ||
| 272 | |||
| 273 | retval = p9_client_wstat(fid, &wstat); | ||
| 274 | return retval; | ||
| 275 | } | ||
| 276 | |||
| 260 | static const struct file_operations v9fs_cached_file_operations = { | 277 | static const struct file_operations v9fs_cached_file_operations = { |
| 261 | .llseek = generic_file_llseek, | 278 | .llseek = generic_file_llseek, |
| 262 | .read = do_sync_read, | 279 | .read = do_sync_read, |
| @@ -266,6 +283,7 @@ static const struct file_operations v9fs_cached_file_operations = { | |||
| 266 | .release = v9fs_dir_release, | 283 | .release = v9fs_dir_release, |
| 267 | .lock = v9fs_file_lock, | 284 | .lock = v9fs_file_lock, |
| 268 | .mmap = generic_file_readonly_mmap, | 285 | .mmap = generic_file_readonly_mmap, |
| 286 | .fsync = v9fs_file_fsync, | ||
| 269 | }; | 287 | }; |
| 270 | 288 | ||
| 271 | const struct file_operations v9fs_file_operations = { | 289 | const struct file_operations v9fs_file_operations = { |
| @@ -276,4 +294,5 @@ const struct file_operations v9fs_file_operations = { | |||
| 276 | .release = v9fs_dir_release, | 294 | .release = v9fs_dir_release, |
| 277 | .lock = v9fs_file_lock, | 295 | .lock = v9fs_file_lock, |
| 278 | .mmap = generic_file_readonly_mmap, | 296 | .mmap = generic_file_readonly_mmap, |
| 297 | .fsync = v9fs_file_fsync, | ||
| 279 | }; | 298 | }; |
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 18f74ec4dce..a407fa3388c 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
| @@ -176,7 +176,7 @@ int v9fs_uflags2omode(int uflags, int extended) | |||
| 176 | * | 176 | * |
| 177 | */ | 177 | */ |
| 178 | 178 | ||
| 179 | static void | 179 | void |
| 180 | v9fs_blank_wstat(struct p9_wstat *wstat) | 180 | v9fs_blank_wstat(struct p9_wstat *wstat) |
| 181 | { | 181 | { |
| 182 | wstat->type = ~0; | 182 | wstat->type = ~0; |
| @@ -1001,44 +1001,6 @@ done: | |||
| 1001 | } | 1001 | } |
| 1002 | 1002 | ||
| 1003 | /** | 1003 | /** |
| 1004 | * v9fs_vfs_readlink - read a symlink's location | ||
| 1005 | * @dentry: dentry for symlink | ||
| 1006 | * @buffer: buffer to load symlink location into | ||
| 1007 | * @buflen: length of buffer | ||
| 1008 | * | ||
| 1009 | */ | ||
| 1010 | |||
| 1011 | static int v9fs_vfs_readlink(struct dentry *dentry, char __user * buffer, | ||
| 1012 | int buflen) | ||
| 1013 | { | ||
| 1014 | int retval; | ||
| 1015 | int ret; | ||
| 1016 | char *link = __getname(); | ||
| 1017 | |||
| 1018 | if (unlikely(!link)) | ||
| 1019 | return -ENOMEM; | ||
| 1020 | |||
| 1021 | if (buflen > PATH_MAX) | ||
| 1022 | buflen = PATH_MAX; | ||
| 1023 | |||
| 1024 | P9_DPRINTK(P9_DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_name.name, | ||
| 1025 | dentry); | ||
| 1026 | |||
| 1027 | retval = v9fs_readlink(dentry, link, buflen); | ||
| 1028 | |||
| 1029 | if (retval > 0) { | ||
| 1030 | if ((ret = copy_to_user(buffer, link, retval)) != 0) { | ||
| 1031 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
| 1032 | "problem copying to user: %d\n", ret); | ||
| 1033 | retval = ret; | ||
| 1034 | } | ||
| 1035 | } | ||
| 1036 | |||
| 1037 | __putname(link); | ||
| 1038 | return retval; | ||
| 1039 | } | ||
| 1040 | |||
| 1041 | /** | ||
| 1042 | * v9fs_vfs_follow_link - follow a symlink path | 1004 | * v9fs_vfs_follow_link - follow a symlink path |
| 1043 | * @dentry: dentry for symlink | 1005 | * @dentry: dentry for symlink |
| 1044 | * @nd: nameidata | 1006 | * @nd: nameidata |
| @@ -1230,7 +1192,6 @@ static const struct inode_operations v9fs_dir_inode_operations_ext = { | |||
| 1230 | .rmdir = v9fs_vfs_rmdir, | 1192 | .rmdir = v9fs_vfs_rmdir, |
| 1231 | .mknod = v9fs_vfs_mknod, | 1193 | .mknod = v9fs_vfs_mknod, |
| 1232 | .rename = v9fs_vfs_rename, | 1194 | .rename = v9fs_vfs_rename, |
| 1233 | .readlink = v9fs_vfs_readlink, | ||
| 1234 | .getattr = v9fs_vfs_getattr, | 1195 | .getattr = v9fs_vfs_getattr, |
| 1235 | .setattr = v9fs_vfs_setattr, | 1196 | .setattr = v9fs_vfs_setattr, |
| 1236 | }; | 1197 | }; |
| @@ -1253,7 +1214,7 @@ static const struct inode_operations v9fs_file_inode_operations = { | |||
| 1253 | }; | 1214 | }; |
| 1254 | 1215 | ||
| 1255 | static const struct inode_operations v9fs_symlink_inode_operations = { | 1216 | static const struct inode_operations v9fs_symlink_inode_operations = { |
| 1256 | .readlink = v9fs_vfs_readlink, | 1217 | .readlink = generic_readlink, |
| 1257 | .follow_link = v9fs_vfs_follow_link, | 1218 | .follow_link = v9fs_vfs_follow_link, |
| 1258 | .put_link = v9fs_vfs_put_link, | 1219 | .put_link = v9fs_vfs_put_link, |
| 1259 | .getattr = v9fs_vfs_getattr, | 1220 | .getattr = v9fs_vfs_getattr, |
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index 14a86448572..69357c0d989 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c | |||
| @@ -188,7 +188,8 @@ static void v9fs_kill_super(struct super_block *s) | |||
| 188 | 188 | ||
| 189 | P9_DPRINTK(P9_DEBUG_VFS, " %p\n", s); | 189 | P9_DPRINTK(P9_DEBUG_VFS, " %p\n", s); |
| 190 | 190 | ||
| 191 | v9fs_dentry_release(s->s_root); /* clunk root */ | 191 | if (s->s_root) |
| 192 | v9fs_dentry_release(s->s_root); /* clunk root */ | ||
| 192 | 193 | ||
| 193 | kill_anon_super(s); | 194 | kill_anon_super(s); |
| 194 | 195 | ||
