Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 1 | /* |
| 2 | * linux/fs/9p/vfs_inode_dotl.c |
| 3 | * |
| 4 | * This file contains vfs inode ops for the 9P2000.L protocol. |
| 5 | * |
| 6 | * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> |
| 7 | * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 |
| 11 | * as published by the Free Software Foundation. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to: |
| 20 | * Free Software Foundation |
| 21 | * 51 Franklin Street, Fifth Floor |
| 22 | * Boston, MA 02111-1301 USA |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | #include <linux/module.h> |
| 27 | #include <linux/errno.h> |
| 28 | #include <linux/fs.h> |
| 29 | #include <linux/file.h> |
| 30 | #include <linux/pagemap.h> |
| 31 | #include <linux/stat.h> |
| 32 | #include <linux/string.h> |
| 33 | #include <linux/inet.h> |
| 34 | #include <linux/namei.h> |
| 35 | #include <linux/idr.h> |
| 36 | #include <linux/sched.h> |
| 37 | #include <linux/slab.h> |
| 38 | #include <linux/xattr.h> |
| 39 | #include <linux/posix_acl.h> |
| 40 | #include <net/9p/9p.h> |
| 41 | #include <net/9p/client.h> |
| 42 | |
| 43 | #include "v9fs.h" |
| 44 | #include "v9fs_vfs.h" |
| 45 | #include "fid.h" |
| 46 | #include "cache.h" |
| 47 | #include "xattr.h" |
| 48 | #include "acl.h" |
| 49 | |
| 50 | static int |
| 51 | v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode, |
| 52 | dev_t rdev); |
| 53 | |
| 54 | /** |
| 55 | * v9fs_get_fsgid_for_create - Helper function to get the gid for creating a |
| 56 | * new file system object. This checks the S_ISGID to determine the owning |
| 57 | * group of the new file system object. |
| 58 | */ |
| 59 | |
| 60 | static gid_t v9fs_get_fsgid_for_create(struct inode *dir_inode) |
| 61 | { |
| 62 | BUG_ON(dir_inode == NULL); |
| 63 | |
| 64 | if (dir_inode->i_mode & S_ISGID) { |
| 65 | /* set_gid bit is set.*/ |
| 66 | return dir_inode->i_gid; |
| 67 | } |
| 68 | return current_fsgid(); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * v9fs_dentry_from_dir_inode - helper function to get the dentry from |
| 73 | * dir inode. |
| 74 | * |
| 75 | */ |
| 76 | |
| 77 | static struct dentry *v9fs_dentry_from_dir_inode(struct inode *inode) |
| 78 | { |
| 79 | struct dentry *dentry; |
| 80 | |
| 81 | spin_lock(&inode->i_lock); |
| 82 | /* Directory should have only one entry. */ |
| 83 | BUG_ON(S_ISDIR(inode->i_mode) && !list_is_singular(&inode->i_dentry)); |
| 84 | dentry = list_entry(inode->i_dentry.next, struct dentry, d_alias); |
| 85 | spin_unlock(&inode->i_lock); |
| 86 | return dentry; |
| 87 | } |
| 88 | |
Aneesh Kumar K.V | 5ffc0cb | 2011-02-28 17:04:01 +0530 | [diff] [blame] | 89 | static struct inode *v9fs_qid_iget_dotl(struct super_block *sb, |
| 90 | struct p9_qid *qid, |
| 91 | struct p9_fid *fid, |
| 92 | struct p9_stat_dotl *st) |
| 93 | { |
| 94 | int retval; |
| 95 | unsigned long i_ino; |
| 96 | struct inode *inode; |
| 97 | struct v9fs_session_info *v9ses = sb->s_fs_info; |
| 98 | |
| 99 | i_ino = v9fs_qid2ino(qid); |
| 100 | inode = iget_locked(sb, i_ino); |
| 101 | if (!inode) |
| 102 | return ERR_PTR(-ENOMEM); |
| 103 | if (!(inode->i_state & I_NEW)) |
| 104 | return inode; |
| 105 | /* |
| 106 | * initialize the inode with the stat info |
| 107 | * FIXME!! we may need support for stale inodes |
| 108 | * later. |
| 109 | */ |
| 110 | retval = v9fs_init_inode(v9ses, inode, st->st_mode); |
| 111 | if (retval) |
| 112 | goto error; |
| 113 | |
| 114 | v9fs_stat2inode_dotl(st, inode); |
| 115 | #ifdef CONFIG_9P_FSCACHE |
Aneesh Kumar K.V | a78ce05 | 2011-02-28 17:04:02 +0530 | [diff] [blame] | 116 | v9fs_fscache_set_key(inode, &st->qid); |
Aneesh Kumar K.V | 5ffc0cb | 2011-02-28 17:04:01 +0530 | [diff] [blame] | 117 | v9fs_cache_inode_get_cookie(inode); |
| 118 | #endif |
| 119 | retval = v9fs_get_acl(inode, fid); |
| 120 | if (retval) |
| 121 | goto error; |
| 122 | |
| 123 | unlock_new_inode(inode); |
| 124 | return inode; |
| 125 | error: |
| 126 | unlock_new_inode(inode); |
| 127 | iput(inode); |
| 128 | return ERR_PTR(retval); |
| 129 | |
| 130 | } |
| 131 | |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 132 | struct inode * |
Aneesh Kumar K.V | a78ce05 | 2011-02-28 17:04:02 +0530 | [diff] [blame] | 133 | v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9ses, struct p9_fid *fid, |
| 134 | struct super_block *sb) |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 135 | { |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 136 | struct p9_stat_dotl *st; |
Aneesh Kumar K.V | 5ffc0cb | 2011-02-28 17:04:01 +0530 | [diff] [blame] | 137 | struct inode *inode = NULL; |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 138 | |
| 139 | st = p9_client_getattr_dotl(fid, P9_STATS_BASIC); |
| 140 | if (IS_ERR(st)) |
| 141 | return ERR_CAST(st); |
| 142 | |
Aneesh Kumar K.V | 5ffc0cb | 2011-02-28 17:04:01 +0530 | [diff] [blame] | 143 | inode = v9fs_qid_iget_dotl(sb, &st->qid, fid, st); |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 144 | kfree(st); |
Aneesh Kumar K.V | 5ffc0cb | 2011-02-28 17:04:01 +0530 | [diff] [blame] | 145 | return inode; |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | /** |
| 149 | * v9fs_vfs_create_dotl - VFS hook to create files for 9P2000.L protocol. |
| 150 | * @dir: directory inode that is being created |
| 151 | * @dentry: dentry that is being deleted |
| 152 | * @mode: create permissions |
| 153 | * @nd: path information |
| 154 | * |
| 155 | */ |
| 156 | |
| 157 | static int |
| 158 | v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode, |
| 159 | struct nameidata *nd) |
| 160 | { |
| 161 | int err = 0; |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 162 | gid_t gid; |
| 163 | int flags; |
| 164 | mode_t mode; |
Aneesh Kumar K.V | 6b39f6d | 2011-02-28 17:04:03 +0530 | [diff] [blame] | 165 | char *name = NULL; |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 166 | struct file *filp; |
| 167 | struct p9_qid qid; |
| 168 | struct inode *inode; |
Aneesh Kumar K.V | 6b39f6d | 2011-02-28 17:04:03 +0530 | [diff] [blame] | 169 | struct p9_fid *fid = NULL; |
| 170 | struct v9fs_inode *v9inode; |
| 171 | struct p9_fid *dfid, *ofid, *inode_fid; |
| 172 | struct v9fs_session_info *v9ses; |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 173 | struct posix_acl *pacl = NULL, *dacl = NULL; |
| 174 | |
| 175 | v9ses = v9fs_inode2v9ses(dir); |
| 176 | if (nd && nd->flags & LOOKUP_OPEN) |
| 177 | flags = nd->intent.open.flags - 1; |
| 178 | else { |
| 179 | /* |
| 180 | * create call without LOOKUP_OPEN is due |
| 181 | * to mknod of regular files. So use mknod |
| 182 | * operation. |
| 183 | */ |
| 184 | return v9fs_vfs_mknod_dotl(dir, dentry, omode, 0); |
| 185 | } |
| 186 | |
| 187 | name = (char *) dentry->d_name.name; |
| 188 | P9_DPRINTK(P9_DEBUG_VFS, "v9fs_vfs_create_dotl: name:%s flags:0x%x " |
| 189 | "mode:0x%x\n", name, flags, omode); |
| 190 | |
| 191 | dfid = v9fs_fid_lookup(dentry->d_parent); |
| 192 | if (IS_ERR(dfid)) { |
| 193 | err = PTR_ERR(dfid); |
| 194 | P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err); |
| 195 | return err; |
| 196 | } |
| 197 | |
| 198 | /* clone a fid to use for creation */ |
| 199 | ofid = p9_client_walk(dfid, 0, NULL, 1); |
| 200 | if (IS_ERR(ofid)) { |
| 201 | err = PTR_ERR(ofid); |
| 202 | P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err); |
| 203 | return err; |
| 204 | } |
| 205 | |
| 206 | gid = v9fs_get_fsgid_for_create(dir); |
| 207 | |
| 208 | mode = omode; |
| 209 | /* Update mode based on ACL value */ |
| 210 | err = v9fs_acl_mode(dir, &mode, &dacl, &pacl); |
| 211 | if (err) { |
| 212 | P9_DPRINTK(P9_DEBUG_VFS, |
| 213 | "Failed to get acl values in creat %d\n", err); |
| 214 | goto error; |
| 215 | } |
| 216 | err = p9_client_create_dotl(ofid, name, flags, mode, gid, &qid); |
| 217 | if (err < 0) { |
| 218 | P9_DPRINTK(P9_DEBUG_VFS, |
| 219 | "p9_client_open_dotl failed in creat %d\n", |
| 220 | err); |
| 221 | goto error; |
| 222 | } |
Aneesh Kumar K.V | d28c61f | 2011-02-28 17:04:08 +0530 | [diff] [blame] | 223 | v9fs_invalidate_inode_attr(dir); |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 224 | |
Aneesh Kumar K.V | af7542f | 2011-01-10 14:22:21 -0600 | [diff] [blame] | 225 | /* instantiate inode and assign the unopened fid to the dentry */ |
| 226 | fid = p9_client_walk(dfid, 1, &name, 1); |
| 227 | if (IS_ERR(fid)) { |
| 228 | err = PTR_ERR(fid); |
Eric Van Hensbergen | c25a61f | 2011-01-11 09:49:03 -0600 | [diff] [blame] | 229 | P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err); |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 230 | fid = NULL; |
Aneesh Kumar K.V | af7542f | 2011-01-10 14:22:21 -0600 | [diff] [blame] | 231 | goto error; |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 232 | } |
Aneesh Kumar K.V | a78ce05 | 2011-02-28 17:04:02 +0530 | [diff] [blame] | 233 | inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb); |
Aneesh Kumar K.V | af7542f | 2011-01-10 14:22:21 -0600 | [diff] [blame] | 234 | if (IS_ERR(inode)) { |
| 235 | err = PTR_ERR(inode); |
| 236 | P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err); |
| 237 | goto error; |
| 238 | } |
Aneesh Kumar K.V | af7542f | 2011-01-10 14:22:21 -0600 | [diff] [blame] | 239 | d_instantiate(dentry, inode); |
| 240 | err = v9fs_fid_add(dentry, fid); |
| 241 | if (err < 0) |
| 242 | goto error; |
| 243 | |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 244 | /* Now set the ACL based on the default value */ |
| 245 | v9fs_set_create_acl(dentry, dacl, pacl); |
Aneesh Kumar K.V | 6b39f6d | 2011-02-28 17:04:03 +0530 | [diff] [blame] | 246 | |
| 247 | v9inode = V9FS_I(inode); |
| 248 | if (v9ses->cache && !v9inode->writeback_fid) { |
Aneesh Kumar K.V | 3cf387d | 2011-02-28 17:03:57 +0530 | [diff] [blame] | 249 | /* |
Aneesh Kumar K.V | 6b39f6d | 2011-02-28 17:04:03 +0530 | [diff] [blame] | 250 | * clone a fid and add it to writeback_fid |
Aneesh Kumar K.V | 3cf387d | 2011-02-28 17:03:57 +0530 | [diff] [blame] | 251 | * we do it during open time instead of |
| 252 | * page dirty time via write_begin/page_mkwrite |
| 253 | * because we want write after unlink usecase |
| 254 | * to work. |
| 255 | */ |
| 256 | inode_fid = v9fs_writeback_fid(dentry); |
| 257 | if (IS_ERR(inode_fid)) { |
| 258 | err = PTR_ERR(inode_fid); |
| 259 | goto error; |
| 260 | } |
Aneesh Kumar K.V | 6b39f6d | 2011-02-28 17:04:03 +0530 | [diff] [blame] | 261 | v9inode->writeback_fid = (void *) inode_fid; |
Aneesh Kumar K.V | 3cf387d | 2011-02-28 17:03:57 +0530 | [diff] [blame] | 262 | } |
Aneesh Kumar K.V | af7542f | 2011-01-10 14:22:21 -0600 | [diff] [blame] | 263 | /* Since we are opening a file, assign the open fid to the file */ |
| 264 | filp = lookup_instantiate_filp(nd, dentry, generic_file_open); |
| 265 | if (IS_ERR(filp)) { |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 266 | p9_client_clunk(ofid); |
Aneesh Kumar K.V | af7542f | 2011-01-10 14:22:21 -0600 | [diff] [blame] | 267 | return PTR_ERR(filp); |
| 268 | } |
| 269 | filp->private_data = ofid; |
Aneesh Kumar K.V | 46848de | 2011-02-28 17:03:55 +0530 | [diff] [blame] | 270 | #ifdef CONFIG_9P_FSCACHE |
| 271 | if (v9ses->cache) |
| 272 | v9fs_cache_inode_set_cookie(inode, filp); |
| 273 | #endif |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 274 | return 0; |
| 275 | |
| 276 | error: |
| 277 | if (ofid) |
| 278 | p9_client_clunk(ofid); |
| 279 | if (fid) |
| 280 | p9_client_clunk(fid); |
| 281 | return err; |
| 282 | } |
| 283 | |
| 284 | /** |
| 285 | * v9fs_vfs_mkdir_dotl - VFS mkdir hook to create a directory |
| 286 | * @dir: inode that is being unlinked |
| 287 | * @dentry: dentry that is being unlinked |
| 288 | * @mode: mode for new directory |
| 289 | * |
| 290 | */ |
| 291 | |
| 292 | static int v9fs_vfs_mkdir_dotl(struct inode *dir, |
| 293 | struct dentry *dentry, int omode) |
| 294 | { |
| 295 | int err; |
| 296 | struct v9fs_session_info *v9ses; |
| 297 | struct p9_fid *fid = NULL, *dfid = NULL; |
| 298 | gid_t gid; |
| 299 | char *name; |
| 300 | mode_t mode; |
| 301 | struct inode *inode; |
| 302 | struct p9_qid qid; |
| 303 | struct dentry *dir_dentry; |
| 304 | struct posix_acl *dacl = NULL, *pacl = NULL; |
| 305 | |
| 306 | P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", dentry->d_name.name); |
| 307 | err = 0; |
| 308 | v9ses = v9fs_inode2v9ses(dir); |
| 309 | |
| 310 | omode |= S_IFDIR; |
| 311 | if (dir->i_mode & S_ISGID) |
| 312 | omode |= S_ISGID; |
| 313 | |
| 314 | dir_dentry = v9fs_dentry_from_dir_inode(dir); |
| 315 | dfid = v9fs_fid_lookup(dir_dentry); |
| 316 | if (IS_ERR(dfid)) { |
| 317 | err = PTR_ERR(dfid); |
| 318 | P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err); |
| 319 | dfid = NULL; |
| 320 | goto error; |
| 321 | } |
| 322 | |
| 323 | gid = v9fs_get_fsgid_for_create(dir); |
| 324 | mode = omode; |
| 325 | /* Update mode based on ACL value */ |
| 326 | err = v9fs_acl_mode(dir, &mode, &dacl, &pacl); |
| 327 | if (err) { |
| 328 | P9_DPRINTK(P9_DEBUG_VFS, |
| 329 | "Failed to get acl values in mkdir %d\n", err); |
| 330 | goto error; |
| 331 | } |
| 332 | name = (char *) dentry->d_name.name; |
| 333 | err = p9_client_mkdir_dotl(dfid, name, mode, gid, &qid); |
| 334 | if (err < 0) |
| 335 | goto error; |
| 336 | |
| 337 | /* instantiate inode and assign the unopened fid to the dentry */ |
| 338 | if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { |
| 339 | fid = p9_client_walk(dfid, 1, &name, 1); |
| 340 | if (IS_ERR(fid)) { |
| 341 | err = PTR_ERR(fid); |
| 342 | P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", |
| 343 | err); |
| 344 | fid = NULL; |
| 345 | goto error; |
| 346 | } |
| 347 | |
Aneesh Kumar K.V | a78ce05 | 2011-02-28 17:04:02 +0530 | [diff] [blame] | 348 | inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb); |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 349 | if (IS_ERR(inode)) { |
| 350 | err = PTR_ERR(inode); |
| 351 | P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", |
| 352 | err); |
| 353 | goto error; |
| 354 | } |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 355 | d_instantiate(dentry, inode); |
| 356 | err = v9fs_fid_add(dentry, fid); |
| 357 | if (err < 0) |
| 358 | goto error; |
| 359 | fid = NULL; |
| 360 | } else { |
| 361 | /* |
| 362 | * Not in cached mode. No need to populate |
| 363 | * inode with stat. We need to get an inode |
| 364 | * so that we can set the acl with dentry |
| 365 | */ |
| 366 | inode = v9fs_get_inode(dir->i_sb, mode); |
| 367 | if (IS_ERR(inode)) { |
| 368 | err = PTR_ERR(inode); |
| 369 | goto error; |
| 370 | } |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 371 | d_instantiate(dentry, inode); |
| 372 | } |
| 373 | /* Now set the ACL based on the default value */ |
| 374 | v9fs_set_create_acl(dentry, dacl, pacl); |
Aneesh Kumar K.V | b271ec4 | 2011-02-28 17:04:05 +0530 | [diff] [blame] | 375 | inc_nlink(dir); |
Aneesh Kumar K.V | d28c61f | 2011-02-28 17:04:08 +0530 | [diff] [blame] | 376 | v9fs_invalidate_inode_attr(dir); |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 377 | error: |
| 378 | if (fid) |
| 379 | p9_client_clunk(fid); |
| 380 | return err; |
| 381 | } |
| 382 | |
| 383 | static int |
| 384 | v9fs_vfs_getattr_dotl(struct vfsmount *mnt, struct dentry *dentry, |
| 385 | struct kstat *stat) |
| 386 | { |
| 387 | int err; |
| 388 | struct v9fs_session_info *v9ses; |
| 389 | struct p9_fid *fid; |
| 390 | struct p9_stat_dotl *st; |
| 391 | |
| 392 | P9_DPRINTK(P9_DEBUG_VFS, "dentry: %p\n", dentry); |
| 393 | err = -EPERM; |
| 394 | v9ses = v9fs_inode2v9ses(dentry->d_inode); |
Aneesh Kumar K.V | a121190 | 2011-02-28 17:04:01 +0530 | [diff] [blame] | 395 | if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { |
| 396 | generic_fillattr(dentry->d_inode, stat); |
| 397 | return 0; |
| 398 | } |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 399 | fid = v9fs_fid_lookup(dentry); |
| 400 | if (IS_ERR(fid)) |
| 401 | return PTR_ERR(fid); |
| 402 | |
| 403 | /* Ask for all the fields in stat structure. Server will return |
| 404 | * whatever it supports |
| 405 | */ |
| 406 | |
| 407 | st = p9_client_getattr_dotl(fid, P9_STATS_ALL); |
| 408 | if (IS_ERR(st)) |
| 409 | return PTR_ERR(st); |
| 410 | |
| 411 | v9fs_stat2inode_dotl(st, dentry->d_inode); |
| 412 | generic_fillattr(dentry->d_inode, stat); |
| 413 | /* Change block size to what the server returned */ |
| 414 | stat->blksize = st->st_blksize; |
| 415 | |
| 416 | kfree(st); |
| 417 | return 0; |
| 418 | } |
| 419 | |
| 420 | /** |
| 421 | * v9fs_vfs_setattr_dotl - set file metadata |
| 422 | * @dentry: file whose metadata to set |
| 423 | * @iattr: metadata assignment structure |
| 424 | * |
| 425 | */ |
| 426 | |
| 427 | int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr) |
| 428 | { |
| 429 | int retval; |
| 430 | struct v9fs_session_info *v9ses; |
| 431 | struct p9_fid *fid; |
| 432 | struct p9_iattr_dotl p9attr; |
| 433 | |
| 434 | P9_DPRINTK(P9_DEBUG_VFS, "\n"); |
| 435 | |
| 436 | retval = inode_change_ok(dentry->d_inode, iattr); |
| 437 | if (retval) |
| 438 | return retval; |
| 439 | |
| 440 | p9attr.valid = iattr->ia_valid; |
| 441 | p9attr.mode = iattr->ia_mode; |
| 442 | p9attr.uid = iattr->ia_uid; |
| 443 | p9attr.gid = iattr->ia_gid; |
| 444 | p9attr.size = iattr->ia_size; |
| 445 | p9attr.atime_sec = iattr->ia_atime.tv_sec; |
| 446 | p9attr.atime_nsec = iattr->ia_atime.tv_nsec; |
| 447 | p9attr.mtime_sec = iattr->ia_mtime.tv_sec; |
| 448 | p9attr.mtime_nsec = iattr->ia_mtime.tv_nsec; |
| 449 | |
| 450 | retval = -EPERM; |
| 451 | v9ses = v9fs_inode2v9ses(dentry->d_inode); |
| 452 | fid = v9fs_fid_lookup(dentry); |
| 453 | if (IS_ERR(fid)) |
| 454 | return PTR_ERR(fid); |
| 455 | |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 456 | if ((iattr->ia_valid & ATTR_SIZE) && |
| 457 | iattr->ia_size != i_size_read(dentry->d_inode)) { |
| 458 | retval = vmtruncate(dentry->d_inode, iattr->ia_size); |
| 459 | if (retval) |
| 460 | return retval; |
| 461 | } |
Aneesh Kumar K.V | f10fc50 | 2011-02-28 17:04:10 +0530 | [diff] [blame^] | 462 | retval = p9_client_setattr(fid, &p9attr); |
| 463 | if (retval < 0) |
| 464 | return retval; |
| 465 | v9fs_invalidate_inode_attr(dentry->d_inode); |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 466 | |
| 467 | setattr_copy(dentry->d_inode, iattr); |
| 468 | mark_inode_dirty(dentry->d_inode); |
| 469 | if (iattr->ia_valid & ATTR_MODE) { |
| 470 | /* We also want to update ACL when we update mode bits */ |
| 471 | retval = v9fs_acl_chmod(dentry); |
| 472 | if (retval < 0) |
| 473 | return retval; |
| 474 | } |
| 475 | return 0; |
| 476 | } |
| 477 | |
| 478 | /** |
| 479 | * v9fs_stat2inode_dotl - populate an inode structure with stat info |
| 480 | * @stat: stat structure |
| 481 | * @inode: inode to populate |
| 482 | * @sb: superblock of filesystem |
| 483 | * |
| 484 | */ |
| 485 | |
| 486 | void |
| 487 | v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode) |
| 488 | { |
Aneesh Kumar K.V | b3cbea0 | 2011-02-28 17:04:06 +0530 | [diff] [blame] | 489 | struct v9fs_inode *v9inode = V9FS_I(inode); |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 490 | |
| 491 | if ((stat->st_result_mask & P9_STATS_BASIC) == P9_STATS_BASIC) { |
| 492 | inode->i_atime.tv_sec = stat->st_atime_sec; |
| 493 | inode->i_atime.tv_nsec = stat->st_atime_nsec; |
| 494 | inode->i_mtime.tv_sec = stat->st_mtime_sec; |
| 495 | inode->i_mtime.tv_nsec = stat->st_mtime_nsec; |
| 496 | inode->i_ctime.tv_sec = stat->st_ctime_sec; |
| 497 | inode->i_ctime.tv_nsec = stat->st_ctime_nsec; |
| 498 | inode->i_uid = stat->st_uid; |
| 499 | inode->i_gid = stat->st_gid; |
| 500 | inode->i_nlink = stat->st_nlink; |
| 501 | inode->i_mode = stat->st_mode; |
| 502 | inode->i_rdev = new_decode_dev(stat->st_rdev); |
| 503 | |
| 504 | if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode))) |
| 505 | init_special_inode(inode, inode->i_mode, inode->i_rdev); |
| 506 | |
| 507 | i_size_write(inode, stat->st_size); |
| 508 | inode->i_blocks = stat->st_blocks; |
| 509 | } else { |
| 510 | if (stat->st_result_mask & P9_STATS_ATIME) { |
| 511 | inode->i_atime.tv_sec = stat->st_atime_sec; |
| 512 | inode->i_atime.tv_nsec = stat->st_atime_nsec; |
| 513 | } |
| 514 | if (stat->st_result_mask & P9_STATS_MTIME) { |
| 515 | inode->i_mtime.tv_sec = stat->st_mtime_sec; |
| 516 | inode->i_mtime.tv_nsec = stat->st_mtime_nsec; |
| 517 | } |
| 518 | if (stat->st_result_mask & P9_STATS_CTIME) { |
| 519 | inode->i_ctime.tv_sec = stat->st_ctime_sec; |
| 520 | inode->i_ctime.tv_nsec = stat->st_ctime_nsec; |
| 521 | } |
| 522 | if (stat->st_result_mask & P9_STATS_UID) |
| 523 | inode->i_uid = stat->st_uid; |
| 524 | if (stat->st_result_mask & P9_STATS_GID) |
| 525 | inode->i_gid = stat->st_gid; |
| 526 | if (stat->st_result_mask & P9_STATS_NLINK) |
| 527 | inode->i_nlink = stat->st_nlink; |
| 528 | if (stat->st_result_mask & P9_STATS_MODE) { |
| 529 | inode->i_mode = stat->st_mode; |
| 530 | if ((S_ISBLK(inode->i_mode)) || |
| 531 | (S_ISCHR(inode->i_mode))) |
| 532 | init_special_inode(inode, inode->i_mode, |
| 533 | inode->i_rdev); |
| 534 | } |
| 535 | if (stat->st_result_mask & P9_STATS_RDEV) |
| 536 | inode->i_rdev = new_decode_dev(stat->st_rdev); |
| 537 | if (stat->st_result_mask & P9_STATS_SIZE) |
| 538 | i_size_write(inode, stat->st_size); |
| 539 | if (stat->st_result_mask & P9_STATS_BLOCKS) |
| 540 | inode->i_blocks = stat->st_blocks; |
| 541 | } |
| 542 | if (stat->st_result_mask & P9_STATS_GEN) |
| 543 | inode->i_generation = stat->st_gen; |
| 544 | |
| 545 | /* Currently we don't support P9_STATS_BTIME and P9_STATS_DATA_VERSION |
| 546 | * because the inode structure does not have fields for them. |
| 547 | */ |
Aneesh Kumar K.V | b3cbea0 | 2011-02-28 17:04:06 +0530 | [diff] [blame] | 548 | v9inode->cache_validity &= ~V9FS_INO_INVALID_ATTR; |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | static int |
| 552 | v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry, |
| 553 | const char *symname) |
| 554 | { |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 555 | int err; |
| 556 | gid_t gid; |
Aneesh Kumar K.V | d28c61f | 2011-02-28 17:04:08 +0530 | [diff] [blame] | 557 | char *name; |
| 558 | struct p9_qid qid; |
| 559 | struct inode *inode; |
| 560 | struct p9_fid *dfid; |
| 561 | struct p9_fid *fid = NULL; |
| 562 | struct v9fs_session_info *v9ses; |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 563 | |
| 564 | name = (char *) dentry->d_name.name; |
| 565 | P9_DPRINTK(P9_DEBUG_VFS, "v9fs_vfs_symlink_dotl : %lu,%s,%s\n", |
| 566 | dir->i_ino, name, symname); |
| 567 | v9ses = v9fs_inode2v9ses(dir); |
| 568 | |
| 569 | dfid = v9fs_fid_lookup(dentry->d_parent); |
| 570 | if (IS_ERR(dfid)) { |
| 571 | err = PTR_ERR(dfid); |
| 572 | P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err); |
| 573 | return err; |
| 574 | } |
| 575 | |
| 576 | gid = v9fs_get_fsgid_for_create(dir); |
| 577 | |
| 578 | /* Server doesn't alter fid on TSYMLINK. Hence no need to clone it. */ |
| 579 | err = p9_client_symlink(dfid, name, (char *)symname, gid, &qid); |
| 580 | |
| 581 | if (err < 0) { |
| 582 | P9_DPRINTK(P9_DEBUG_VFS, "p9_client_symlink failed %d\n", err); |
| 583 | goto error; |
| 584 | } |
| 585 | |
Aneesh Kumar K.V | d28c61f | 2011-02-28 17:04:08 +0530 | [diff] [blame] | 586 | v9fs_invalidate_inode_attr(dir); |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 587 | if (v9ses->cache) { |
| 588 | /* Now walk from the parent so we can get an unopened fid. */ |
| 589 | fid = p9_client_walk(dfid, 1, &name, 1); |
| 590 | if (IS_ERR(fid)) { |
| 591 | err = PTR_ERR(fid); |
| 592 | P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", |
| 593 | err); |
| 594 | fid = NULL; |
| 595 | goto error; |
| 596 | } |
| 597 | |
| 598 | /* instantiate inode and assign the unopened fid to dentry */ |
Aneesh Kumar K.V | a78ce05 | 2011-02-28 17:04:02 +0530 | [diff] [blame] | 599 | inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb); |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 600 | if (IS_ERR(inode)) { |
| 601 | err = PTR_ERR(inode); |
| 602 | P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", |
| 603 | err); |
| 604 | goto error; |
| 605 | } |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 606 | d_instantiate(dentry, inode); |
| 607 | err = v9fs_fid_add(dentry, fid); |
| 608 | if (err < 0) |
| 609 | goto error; |
| 610 | fid = NULL; |
| 611 | } else { |
| 612 | /* Not in cached mode. No need to populate inode with stat */ |
| 613 | inode = v9fs_get_inode(dir->i_sb, S_IFLNK); |
| 614 | if (IS_ERR(inode)) { |
| 615 | err = PTR_ERR(inode); |
| 616 | goto error; |
| 617 | } |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 618 | d_instantiate(dentry, inode); |
| 619 | } |
| 620 | |
| 621 | error: |
| 622 | if (fid) |
| 623 | p9_client_clunk(fid); |
| 624 | |
| 625 | return err; |
| 626 | } |
| 627 | |
| 628 | /** |
| 629 | * v9fs_vfs_link_dotl - create a hardlink for dotl |
| 630 | * @old_dentry: dentry for file to link to |
| 631 | * @dir: inode destination for new link |
| 632 | * @dentry: dentry for link |
| 633 | * |
| 634 | */ |
| 635 | |
| 636 | static int |
| 637 | v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir, |
| 638 | struct dentry *dentry) |
| 639 | { |
| 640 | int err; |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 641 | char *name; |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 642 | struct dentry *dir_dentry; |
Aneesh Kumar K.V | d28c61f | 2011-02-28 17:04:08 +0530 | [diff] [blame] | 643 | struct p9_fid *dfid, *oldfid; |
| 644 | struct v9fs_session_info *v9ses; |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 645 | |
| 646 | P9_DPRINTK(P9_DEBUG_VFS, "dir ino: %lu, old_name: %s, new_name: %s\n", |
| 647 | dir->i_ino, old_dentry->d_name.name, |
| 648 | dentry->d_name.name); |
| 649 | |
| 650 | v9ses = v9fs_inode2v9ses(dir); |
| 651 | dir_dentry = v9fs_dentry_from_dir_inode(dir); |
| 652 | dfid = v9fs_fid_lookup(dir_dentry); |
| 653 | if (IS_ERR(dfid)) |
| 654 | return PTR_ERR(dfid); |
| 655 | |
| 656 | oldfid = v9fs_fid_lookup(old_dentry); |
| 657 | if (IS_ERR(oldfid)) |
| 658 | return PTR_ERR(oldfid); |
| 659 | |
| 660 | name = (char *) dentry->d_name.name; |
| 661 | |
| 662 | err = p9_client_link(dfid, oldfid, (char *)dentry->d_name.name); |
| 663 | |
| 664 | if (err < 0) { |
| 665 | P9_DPRINTK(P9_DEBUG_VFS, "p9_client_link failed %d\n", err); |
| 666 | return err; |
| 667 | } |
| 668 | |
Aneesh Kumar K.V | d28c61f | 2011-02-28 17:04:08 +0530 | [diff] [blame] | 669 | v9fs_invalidate_inode_attr(dir); |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 670 | if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { |
| 671 | /* Get the latest stat info from server. */ |
| 672 | struct p9_fid *fid; |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 673 | fid = v9fs_fid_lookup(old_dentry); |
| 674 | if (IS_ERR(fid)) |
| 675 | return PTR_ERR(fid); |
| 676 | |
Aneesh Kumar K.V | c06c066 | 2011-02-28 17:04:09 +0530 | [diff] [blame] | 677 | v9fs_refresh_inode_dotl(fid, old_dentry->d_inode); |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 678 | } |
Aneesh Kumar K.V | 20656a4 | 2011-02-28 17:03:55 +0530 | [diff] [blame] | 679 | ihold(old_dentry->d_inode); |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 680 | d_instantiate(dentry, old_dentry->d_inode); |
| 681 | |
| 682 | return err; |
| 683 | } |
| 684 | |
| 685 | /** |
| 686 | * v9fs_vfs_mknod_dotl - create a special file |
| 687 | * @dir: inode destination for new link |
| 688 | * @dentry: dentry for file |
| 689 | * @mode: mode for creation |
| 690 | * @rdev: device associated with special file |
| 691 | * |
| 692 | */ |
| 693 | static int |
| 694 | v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode, |
| 695 | dev_t rdev) |
| 696 | { |
| 697 | int err; |
Aneesh Kumar K.V | d28c61f | 2011-02-28 17:04:08 +0530 | [diff] [blame] | 698 | gid_t gid; |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 699 | char *name; |
| 700 | mode_t mode; |
| 701 | struct v9fs_session_info *v9ses; |
| 702 | struct p9_fid *fid = NULL, *dfid = NULL; |
| 703 | struct inode *inode; |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 704 | struct p9_qid qid; |
| 705 | struct dentry *dir_dentry; |
| 706 | struct posix_acl *dacl = NULL, *pacl = NULL; |
| 707 | |
| 708 | P9_DPRINTK(P9_DEBUG_VFS, |
| 709 | " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino, |
| 710 | dentry->d_name.name, omode, MAJOR(rdev), MINOR(rdev)); |
| 711 | |
| 712 | if (!new_valid_dev(rdev)) |
| 713 | return -EINVAL; |
| 714 | |
| 715 | v9ses = v9fs_inode2v9ses(dir); |
| 716 | dir_dentry = v9fs_dentry_from_dir_inode(dir); |
| 717 | dfid = v9fs_fid_lookup(dir_dentry); |
| 718 | if (IS_ERR(dfid)) { |
| 719 | err = PTR_ERR(dfid); |
| 720 | P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err); |
| 721 | dfid = NULL; |
| 722 | goto error; |
| 723 | } |
| 724 | |
| 725 | gid = v9fs_get_fsgid_for_create(dir); |
| 726 | mode = omode; |
| 727 | /* Update mode based on ACL value */ |
| 728 | err = v9fs_acl_mode(dir, &mode, &dacl, &pacl); |
| 729 | if (err) { |
| 730 | P9_DPRINTK(P9_DEBUG_VFS, |
| 731 | "Failed to get acl values in mknod %d\n", err); |
| 732 | goto error; |
| 733 | } |
| 734 | name = (char *) dentry->d_name.name; |
| 735 | |
| 736 | err = p9_client_mknod_dotl(dfid, name, mode, rdev, gid, &qid); |
| 737 | if (err < 0) |
| 738 | goto error; |
| 739 | |
Aneesh Kumar K.V | d28c61f | 2011-02-28 17:04:08 +0530 | [diff] [blame] | 740 | v9fs_invalidate_inode_attr(dir); |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 741 | /* instantiate inode and assign the unopened fid to the dentry */ |
| 742 | if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { |
| 743 | fid = p9_client_walk(dfid, 1, &name, 1); |
| 744 | if (IS_ERR(fid)) { |
| 745 | err = PTR_ERR(fid); |
| 746 | P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", |
| 747 | err); |
| 748 | fid = NULL; |
| 749 | goto error; |
| 750 | } |
| 751 | |
Aneesh Kumar K.V | a78ce05 | 2011-02-28 17:04:02 +0530 | [diff] [blame] | 752 | inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb); |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 753 | if (IS_ERR(inode)) { |
| 754 | err = PTR_ERR(inode); |
| 755 | P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", |
| 756 | err); |
| 757 | goto error; |
| 758 | } |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 759 | d_instantiate(dentry, inode); |
| 760 | err = v9fs_fid_add(dentry, fid); |
| 761 | if (err < 0) |
| 762 | goto error; |
| 763 | fid = NULL; |
| 764 | } else { |
| 765 | /* |
| 766 | * Not in cached mode. No need to populate inode with stat. |
| 767 | * socket syscall returns a fd, so we need instantiate |
| 768 | */ |
| 769 | inode = v9fs_get_inode(dir->i_sb, mode); |
| 770 | if (IS_ERR(inode)) { |
| 771 | err = PTR_ERR(inode); |
| 772 | goto error; |
| 773 | } |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 774 | d_instantiate(dentry, inode); |
| 775 | } |
| 776 | /* Now set the ACL based on the default value */ |
| 777 | v9fs_set_create_acl(dentry, dacl, pacl); |
| 778 | error: |
| 779 | if (fid) |
| 780 | p9_client_clunk(fid); |
| 781 | return err; |
| 782 | } |
| 783 | |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 784 | /** |
| 785 | * v9fs_vfs_follow_link_dotl - follow a symlink path |
| 786 | * @dentry: dentry for symlink |
| 787 | * @nd: nameidata |
| 788 | * |
| 789 | */ |
| 790 | |
| 791 | static void * |
| 792 | v9fs_vfs_follow_link_dotl(struct dentry *dentry, struct nameidata *nd) |
| 793 | { |
M. Mohan Kumar | 31b6cea | 2011-01-08 07:28:46 +0530 | [diff] [blame] | 794 | int retval; |
| 795 | struct p9_fid *fid; |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 796 | char *link = __getname(); |
M. Mohan Kumar | 31b6cea | 2011-01-08 07:28:46 +0530 | [diff] [blame] | 797 | char *target; |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 798 | |
M. Mohan Kumar | 31b6cea | 2011-01-08 07:28:46 +0530 | [diff] [blame] | 799 | P9_DPRINTK(P9_DEBUG_VFS, "%s\n", dentry->d_name.name); |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 800 | |
M. Mohan Kumar | 31b6cea | 2011-01-08 07:28:46 +0530 | [diff] [blame] | 801 | if (!link) { |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 802 | link = ERR_PTR(-ENOMEM); |
M. Mohan Kumar | 31b6cea | 2011-01-08 07:28:46 +0530 | [diff] [blame] | 803 | goto ndset; |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 804 | } |
M. Mohan Kumar | 31b6cea | 2011-01-08 07:28:46 +0530 | [diff] [blame] | 805 | fid = v9fs_fid_lookup(dentry); |
| 806 | if (IS_ERR(fid)) { |
| 807 | __putname(link); |
| 808 | link = ERR_PTR(PTR_ERR(fid)); |
| 809 | goto ndset; |
| 810 | } |
| 811 | retval = p9_client_readlink(fid, &target); |
| 812 | if (!retval) { |
| 813 | strcpy(link, target); |
| 814 | kfree(target); |
| 815 | goto ndset; |
| 816 | } |
| 817 | __putname(link); |
| 818 | link = ERR_PTR(retval); |
| 819 | ndset: |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 820 | nd_set_link(nd, link); |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 821 | return NULL; |
| 822 | } |
| 823 | |
Aneesh Kumar K.V | b3cbea0 | 2011-02-28 17:04:06 +0530 | [diff] [blame] | 824 | int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode) |
| 825 | { |
| 826 | loff_t i_size; |
| 827 | struct p9_stat_dotl *st; |
| 828 | struct v9fs_session_info *v9ses; |
| 829 | |
| 830 | v9ses = v9fs_inode2v9ses(inode); |
| 831 | st = p9_client_getattr_dotl(fid, P9_STATS_ALL); |
| 832 | if (IS_ERR(st)) |
| 833 | return PTR_ERR(st); |
| 834 | |
| 835 | spin_lock(&inode->i_lock); |
| 836 | /* |
| 837 | * We don't want to refresh inode->i_size, |
| 838 | * because we may have cached data |
| 839 | */ |
| 840 | i_size = inode->i_size; |
| 841 | v9fs_stat2inode_dotl(st, inode); |
| 842 | if (v9ses->cache) |
| 843 | inode->i_size = i_size; |
| 844 | spin_unlock(&inode->i_lock); |
| 845 | kfree(st); |
| 846 | return 0; |
| 847 | } |
| 848 | |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 849 | const struct inode_operations v9fs_dir_inode_operations_dotl = { |
| 850 | .create = v9fs_vfs_create_dotl, |
| 851 | .lookup = v9fs_vfs_lookup, |
| 852 | .link = v9fs_vfs_link_dotl, |
| 853 | .symlink = v9fs_vfs_symlink_dotl, |
| 854 | .unlink = v9fs_vfs_unlink, |
| 855 | .mkdir = v9fs_vfs_mkdir_dotl, |
| 856 | .rmdir = v9fs_vfs_rmdir, |
| 857 | .mknod = v9fs_vfs_mknod_dotl, |
| 858 | .rename = v9fs_vfs_rename, |
| 859 | .getattr = v9fs_vfs_getattr_dotl, |
| 860 | .setattr = v9fs_vfs_setattr_dotl, |
| 861 | .setxattr = generic_setxattr, |
| 862 | .getxattr = generic_getxattr, |
| 863 | .removexattr = generic_removexattr, |
| 864 | .listxattr = v9fs_listxattr, |
| 865 | .check_acl = v9fs_check_acl, |
| 866 | }; |
| 867 | |
| 868 | const struct inode_operations v9fs_file_inode_operations_dotl = { |
| 869 | .getattr = v9fs_vfs_getattr_dotl, |
| 870 | .setattr = v9fs_vfs_setattr_dotl, |
| 871 | .setxattr = generic_setxattr, |
| 872 | .getxattr = generic_getxattr, |
| 873 | .removexattr = generic_removexattr, |
| 874 | .listxattr = v9fs_listxattr, |
| 875 | .check_acl = v9fs_check_acl, |
| 876 | }; |
| 877 | |
| 878 | const struct inode_operations v9fs_symlink_inode_operations_dotl = { |
M. Mohan Kumar | 31b6cea | 2011-01-08 07:28:46 +0530 | [diff] [blame] | 879 | .readlink = generic_readlink, |
Aneesh Kumar K.V | 53c06f4 | 2011-01-10 13:51:47 -0600 | [diff] [blame] | 880 | .follow_link = v9fs_vfs_follow_link_dotl, |
| 881 | .put_link = v9fs_vfs_put_link, |
| 882 | .getattr = v9fs_vfs_getattr_dotl, |
| 883 | .setattr = v9fs_vfs_setattr_dotl, |
| 884 | .setxattr = generic_setxattr, |
| 885 | .getxattr = generic_getxattr, |
| 886 | .removexattr = generic_removexattr, |
| 887 | .listxattr = v9fs_listxattr, |
| 888 | }; |