2 * linux/fs/9p/vfs_inode_dotl.c
4 * This file contains vfs inode ops for the 9P2000.L protocol.
6 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
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.
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.
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
26 #include <linux/module.h>
27 #include <linux/errno.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>
51 v9fs_vfs_mknod_dotl(struct inode
*dir
, struct dentry
*dentry
, int omode
,
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.
60 static gid_t
v9fs_get_fsgid_for_create(struct inode
*dir_inode
)
62 BUG_ON(dir_inode
== NULL
);
64 if (dir_inode
->i_mode
& S_ISGID
) {
65 /* set_gid bit is set.*/
66 return dir_inode
->i_gid
;
68 return current_fsgid();
72 * v9fs_dentry_from_dir_inode - helper function to get the dentry from
77 static struct dentry
*v9fs_dentry_from_dir_inode(struct inode
*inode
)
79 struct dentry
*dentry
;
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
);
89 static struct inode
*v9fs_qid_iget_dotl(struct super_block
*sb
,
92 struct p9_stat_dotl
*st
)
97 struct v9fs_session_info
*v9ses
= sb
->s_fs_info
;
99 i_ino
= v9fs_qid2ino(qid
);
100 inode
= iget_locked(sb
, i_ino
);
102 return ERR_PTR(-ENOMEM
);
103 if (!(inode
->i_state
& I_NEW
))
106 * initialize the inode with the stat info
107 * FIXME!! we may need support for stale inodes
110 retval
= v9fs_init_inode(v9ses
, inode
, st
->st_mode
);
114 v9fs_stat2inode_dotl(st
, inode
);
115 #ifdef CONFIG_9P_FSCACHE
116 v9fs_fscache_set_key(inode
, &st
->qid
);
117 v9fs_cache_inode_get_cookie(inode
);
119 retval
= v9fs_get_acl(inode
, fid
);
123 unlock_new_inode(inode
);
126 unlock_new_inode(inode
);
128 return ERR_PTR(retval
);
133 v9fs_inode_from_fid_dotl(struct v9fs_session_info
*v9ses
, struct p9_fid
*fid
,
134 struct super_block
*sb
)
136 struct p9_stat_dotl
*st
;
137 struct inode
*inode
= NULL
;
139 st
= p9_client_getattr_dotl(fid
, P9_STATS_BASIC
);
143 inode
= v9fs_qid_iget_dotl(sb
, &st
->qid
, fid
, st
);
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
158 v9fs_vfs_create_dotl(struct inode
*dir
, struct dentry
*dentry
, int omode
,
159 struct nameidata
*nd
)
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
;
173 struct posix_acl
*pacl
= NULL
, *dacl
= NULL
;
175 v9ses
= v9fs_inode2v9ses(dir
);
176 if (nd
&& nd
->flags
& LOOKUP_OPEN
)
177 flags
= nd
->intent
.open
.flags
- 1;
180 * create call without LOOKUP_OPEN is due
181 * to mknod of regular files. So use mknod
184 return v9fs_vfs_mknod_dotl(dir
, dentry
, omode
, 0);
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
);
191 dfid
= v9fs_fid_lookup(dentry
->d_parent
);
194 P9_DPRINTK(P9_DEBUG_VFS
, "fid lookup failed %d\n", err
);
198 /* clone a fid to use for creation */
199 ofid
= p9_client_walk(dfid
, 0, NULL
, 1);
202 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_walk failed %d\n", err
);
206 gid
= v9fs_get_fsgid_for_create(dir
);
209 /* Update mode based on ACL value */
210 err
= v9fs_acl_mode(dir
, &mode
, &dacl
, &pacl
);
212 P9_DPRINTK(P9_DEBUG_VFS
,
213 "Failed to get acl values in creat %d\n", err
);
216 err
= p9_client_create_dotl(ofid
, name
, flags
, mode
, gid
, &qid
);
218 P9_DPRINTK(P9_DEBUG_VFS
,
219 "p9_client_open_dotl failed in creat %d\n",
223 v9fs_invalidate_inode_attr(dir
);
225 /* instantiate inode and assign the unopened fid to the dentry */
226 fid
= p9_client_walk(dfid
, 1, &name
, 1);
229 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_walk failed %d\n", err
);
233 inode
= v9fs_get_inode_from_fid(v9ses
, fid
, dir
->i_sb
);
235 err
= PTR_ERR(inode
);
236 P9_DPRINTK(P9_DEBUG_VFS
, "inode creation failed %d\n", err
);
239 d_instantiate(dentry
, inode
);
240 err
= v9fs_fid_add(dentry
, fid
);
244 /* Now set the ACL based on the default value */
245 v9fs_set_create_acl(dentry
, dacl
, pacl
);
247 v9inode
= V9FS_I(inode
);
248 mutex_lock(&v9inode
->v_mutex
);
249 if (v9ses
->cache
&& !v9inode
->writeback_fid
) {
251 * clone a fid and add it to writeback_fid
252 * we do it during open time instead of
253 * page dirty time via write_begin/page_mkwrite
254 * because we want write after unlink usecase
257 inode_fid
= v9fs_writeback_fid(dentry
);
258 if (IS_ERR(inode_fid
)) {
259 err
= PTR_ERR(inode_fid
);
260 mutex_unlock(&v9inode
->v_mutex
);
263 v9inode
->writeback_fid
= (void *) inode_fid
;
265 mutex_unlock(&v9inode
->v_mutex
);
266 /* Since we are opening a file, assign the open fid to the file */
267 filp
= lookup_instantiate_filp(nd
, dentry
, generic_file_open
);
269 p9_client_clunk(ofid
);
270 return PTR_ERR(filp
);
272 filp
->private_data
= ofid
;
273 #ifdef CONFIG_9P_FSCACHE
275 v9fs_cache_inode_set_cookie(inode
, filp
);
281 p9_client_clunk(ofid
);
283 p9_client_clunk(fid
);
288 * v9fs_vfs_mkdir_dotl - VFS mkdir hook to create a directory
289 * @dir: inode that is being unlinked
290 * @dentry: dentry that is being unlinked
291 * @mode: mode for new directory
295 static int v9fs_vfs_mkdir_dotl(struct inode
*dir
,
296 struct dentry
*dentry
, int omode
)
299 struct v9fs_session_info
*v9ses
;
300 struct p9_fid
*fid
= NULL
, *dfid
= NULL
;
306 struct dentry
*dir_dentry
;
307 struct posix_acl
*dacl
= NULL
, *pacl
= NULL
;
309 P9_DPRINTK(P9_DEBUG_VFS
, "name %s\n", dentry
->d_name
.name
);
311 v9ses
= v9fs_inode2v9ses(dir
);
314 if (dir
->i_mode
& S_ISGID
)
317 dir_dentry
= v9fs_dentry_from_dir_inode(dir
);
318 dfid
= v9fs_fid_lookup(dir_dentry
);
321 P9_DPRINTK(P9_DEBUG_VFS
, "fid lookup failed %d\n", err
);
326 gid
= v9fs_get_fsgid_for_create(dir
);
328 /* Update mode based on ACL value */
329 err
= v9fs_acl_mode(dir
, &mode
, &dacl
, &pacl
);
331 P9_DPRINTK(P9_DEBUG_VFS
,
332 "Failed to get acl values in mkdir %d\n", err
);
335 name
= (char *) dentry
->d_name
.name
;
336 err
= p9_client_mkdir_dotl(dfid
, name
, mode
, gid
, &qid
);
340 /* instantiate inode and assign the unopened fid to the dentry */
341 if (v9ses
->cache
== CACHE_LOOSE
|| v9ses
->cache
== CACHE_FSCACHE
) {
342 fid
= p9_client_walk(dfid
, 1, &name
, 1);
345 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_walk failed %d\n",
351 inode
= v9fs_get_inode_from_fid(v9ses
, fid
, dir
->i_sb
);
353 err
= PTR_ERR(inode
);
354 P9_DPRINTK(P9_DEBUG_VFS
, "inode creation failed %d\n",
358 d_instantiate(dentry
, inode
);
359 err
= v9fs_fid_add(dentry
, fid
);
365 * Not in cached mode. No need to populate
366 * inode with stat. We need to get an inode
367 * so that we can set the acl with dentry
369 inode
= v9fs_get_inode(dir
->i_sb
, mode
);
371 err
= PTR_ERR(inode
);
374 d_instantiate(dentry
, inode
);
376 /* Now set the ACL based on the default value */
377 v9fs_set_create_acl(dentry
, dacl
, pacl
);
379 v9fs_invalidate_inode_attr(dir
);
382 p9_client_clunk(fid
);
387 v9fs_vfs_getattr_dotl(struct vfsmount
*mnt
, struct dentry
*dentry
,
391 struct v9fs_session_info
*v9ses
;
393 struct p9_stat_dotl
*st
;
395 P9_DPRINTK(P9_DEBUG_VFS
, "dentry: %p\n", dentry
);
397 v9ses
= v9fs_inode2v9ses(dentry
->d_inode
);
398 if (v9ses
->cache
== CACHE_LOOSE
|| v9ses
->cache
== CACHE_FSCACHE
) {
399 generic_fillattr(dentry
->d_inode
, stat
);
402 fid
= v9fs_fid_lookup(dentry
);
406 /* Ask for all the fields in stat structure. Server will return
407 * whatever it supports
410 st
= p9_client_getattr_dotl(fid
, P9_STATS_ALL
);
414 v9fs_stat2inode_dotl(st
, dentry
->d_inode
);
415 generic_fillattr(dentry
->d_inode
, stat
);
416 /* Change block size to what the server returned */
417 stat
->blksize
= st
->st_blksize
;
424 * v9fs_vfs_setattr_dotl - set file metadata
425 * @dentry: file whose metadata to set
426 * @iattr: metadata assignment structure
430 int v9fs_vfs_setattr_dotl(struct dentry
*dentry
, struct iattr
*iattr
)
433 struct v9fs_session_info
*v9ses
;
435 struct p9_iattr_dotl p9attr
;
437 P9_DPRINTK(P9_DEBUG_VFS
, "\n");
439 retval
= inode_change_ok(dentry
->d_inode
, iattr
);
443 p9attr
.valid
= iattr
->ia_valid
;
444 p9attr
.mode
= iattr
->ia_mode
;
445 p9attr
.uid
= iattr
->ia_uid
;
446 p9attr
.gid
= iattr
->ia_gid
;
447 p9attr
.size
= iattr
->ia_size
;
448 p9attr
.atime_sec
= iattr
->ia_atime
.tv_sec
;
449 p9attr
.atime_nsec
= iattr
->ia_atime
.tv_nsec
;
450 p9attr
.mtime_sec
= iattr
->ia_mtime
.tv_sec
;
451 p9attr
.mtime_nsec
= iattr
->ia_mtime
.tv_nsec
;
454 v9ses
= v9fs_inode2v9ses(dentry
->d_inode
);
455 fid
= v9fs_fid_lookup(dentry
);
459 /* Write all dirty data */
460 if (S_ISREG(dentry
->d_inode
->i_mode
))
461 filemap_write_and_wait(dentry
->d_inode
->i_mapping
);
463 retval
= p9_client_setattr(fid
, &p9attr
);
467 if ((iattr
->ia_valid
& ATTR_SIZE
) &&
468 iattr
->ia_size
!= i_size_read(dentry
->d_inode
))
469 truncate_setsize(dentry
->d_inode
, iattr
->ia_size
);
471 v9fs_invalidate_inode_attr(dentry
->d_inode
);
472 setattr_copy(dentry
->d_inode
, iattr
);
473 mark_inode_dirty(dentry
->d_inode
);
474 if (iattr
->ia_valid
& ATTR_MODE
) {
475 /* We also want to update ACL when we update mode bits */
476 retval
= v9fs_acl_chmod(dentry
);
484 * v9fs_stat2inode_dotl - populate an inode structure with stat info
485 * @stat: stat structure
486 * @inode: inode to populate
487 * @sb: superblock of filesystem
492 v9fs_stat2inode_dotl(struct p9_stat_dotl
*stat
, struct inode
*inode
)
494 struct v9fs_inode
*v9inode
= V9FS_I(inode
);
496 if ((stat
->st_result_mask
& P9_STATS_BASIC
) == P9_STATS_BASIC
) {
497 inode
->i_atime
.tv_sec
= stat
->st_atime_sec
;
498 inode
->i_atime
.tv_nsec
= stat
->st_atime_nsec
;
499 inode
->i_mtime
.tv_sec
= stat
->st_mtime_sec
;
500 inode
->i_mtime
.tv_nsec
= stat
->st_mtime_nsec
;
501 inode
->i_ctime
.tv_sec
= stat
->st_ctime_sec
;
502 inode
->i_ctime
.tv_nsec
= stat
->st_ctime_nsec
;
503 inode
->i_uid
= stat
->st_uid
;
504 inode
->i_gid
= stat
->st_gid
;
505 inode
->i_nlink
= stat
->st_nlink
;
506 inode
->i_mode
= stat
->st_mode
;
507 inode
->i_rdev
= new_decode_dev(stat
->st_rdev
);
509 if ((S_ISBLK(inode
->i_mode
)) || (S_ISCHR(inode
->i_mode
)))
510 init_special_inode(inode
, inode
->i_mode
, inode
->i_rdev
);
512 i_size_write(inode
, stat
->st_size
);
513 inode
->i_blocks
= stat
->st_blocks
;
515 if (stat
->st_result_mask
& P9_STATS_ATIME
) {
516 inode
->i_atime
.tv_sec
= stat
->st_atime_sec
;
517 inode
->i_atime
.tv_nsec
= stat
->st_atime_nsec
;
519 if (stat
->st_result_mask
& P9_STATS_MTIME
) {
520 inode
->i_mtime
.tv_sec
= stat
->st_mtime_sec
;
521 inode
->i_mtime
.tv_nsec
= stat
->st_mtime_nsec
;
523 if (stat
->st_result_mask
& P9_STATS_CTIME
) {
524 inode
->i_ctime
.tv_sec
= stat
->st_ctime_sec
;
525 inode
->i_ctime
.tv_nsec
= stat
->st_ctime_nsec
;
527 if (stat
->st_result_mask
& P9_STATS_UID
)
528 inode
->i_uid
= stat
->st_uid
;
529 if (stat
->st_result_mask
& P9_STATS_GID
)
530 inode
->i_gid
= stat
->st_gid
;
531 if (stat
->st_result_mask
& P9_STATS_NLINK
)
532 inode
->i_nlink
= stat
->st_nlink
;
533 if (stat
->st_result_mask
& P9_STATS_MODE
) {
534 inode
->i_mode
= stat
->st_mode
;
535 if ((S_ISBLK(inode
->i_mode
)) ||
536 (S_ISCHR(inode
->i_mode
)))
537 init_special_inode(inode
, inode
->i_mode
,
540 if (stat
->st_result_mask
& P9_STATS_RDEV
)
541 inode
->i_rdev
= new_decode_dev(stat
->st_rdev
);
542 if (stat
->st_result_mask
& P9_STATS_SIZE
)
543 i_size_write(inode
, stat
->st_size
);
544 if (stat
->st_result_mask
& P9_STATS_BLOCKS
)
545 inode
->i_blocks
= stat
->st_blocks
;
547 if (stat
->st_result_mask
& P9_STATS_GEN
)
548 inode
->i_generation
= stat
->st_gen
;
550 /* Currently we don't support P9_STATS_BTIME and P9_STATS_DATA_VERSION
551 * because the inode structure does not have fields for them.
553 v9inode
->cache_validity
&= ~V9FS_INO_INVALID_ATTR
;
557 v9fs_vfs_symlink_dotl(struct inode
*dir
, struct dentry
*dentry
,
566 struct p9_fid
*fid
= NULL
;
567 struct v9fs_session_info
*v9ses
;
569 name
= (char *) dentry
->d_name
.name
;
570 P9_DPRINTK(P9_DEBUG_VFS
, "v9fs_vfs_symlink_dotl : %lu,%s,%s\n",
571 dir
->i_ino
, name
, symname
);
572 v9ses
= v9fs_inode2v9ses(dir
);
574 dfid
= v9fs_fid_lookup(dentry
->d_parent
);
577 P9_DPRINTK(P9_DEBUG_VFS
, "fid lookup failed %d\n", err
);
581 gid
= v9fs_get_fsgid_for_create(dir
);
583 /* Server doesn't alter fid on TSYMLINK. Hence no need to clone it. */
584 err
= p9_client_symlink(dfid
, name
, (char *)symname
, gid
, &qid
);
587 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_symlink failed %d\n", err
);
591 v9fs_invalidate_inode_attr(dir
);
593 /* Now walk from the parent so we can get an unopened fid. */
594 fid
= p9_client_walk(dfid
, 1, &name
, 1);
597 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_walk failed %d\n",
603 /* instantiate inode and assign the unopened fid to dentry */
604 inode
= v9fs_get_inode_from_fid(v9ses
, fid
, dir
->i_sb
);
606 err
= PTR_ERR(inode
);
607 P9_DPRINTK(P9_DEBUG_VFS
, "inode creation failed %d\n",
611 d_instantiate(dentry
, inode
);
612 err
= v9fs_fid_add(dentry
, fid
);
617 /* Not in cached mode. No need to populate inode with stat */
618 inode
= v9fs_get_inode(dir
->i_sb
, S_IFLNK
);
620 err
= PTR_ERR(inode
);
623 d_instantiate(dentry
, inode
);
628 p9_client_clunk(fid
);
634 * v9fs_vfs_link_dotl - create a hardlink for dotl
635 * @old_dentry: dentry for file to link to
636 * @dir: inode destination for new link
637 * @dentry: dentry for link
642 v9fs_vfs_link_dotl(struct dentry
*old_dentry
, struct inode
*dir
,
643 struct dentry
*dentry
)
647 struct dentry
*dir_dentry
;
648 struct p9_fid
*dfid
, *oldfid
;
649 struct v9fs_session_info
*v9ses
;
651 P9_DPRINTK(P9_DEBUG_VFS
, "dir ino: %lu, old_name: %s, new_name: %s\n",
652 dir
->i_ino
, old_dentry
->d_name
.name
,
653 dentry
->d_name
.name
);
655 v9ses
= v9fs_inode2v9ses(dir
);
656 dir_dentry
= v9fs_dentry_from_dir_inode(dir
);
657 dfid
= v9fs_fid_lookup(dir_dentry
);
659 return PTR_ERR(dfid
);
661 oldfid
= v9fs_fid_lookup(old_dentry
);
663 return PTR_ERR(oldfid
);
665 name
= (char *) dentry
->d_name
.name
;
667 err
= p9_client_link(dfid
, oldfid
, (char *)dentry
->d_name
.name
);
670 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_link failed %d\n", err
);
674 v9fs_invalidate_inode_attr(dir
);
675 if (v9ses
->cache
== CACHE_LOOSE
|| v9ses
->cache
== CACHE_FSCACHE
) {
676 /* Get the latest stat info from server. */
678 fid
= v9fs_fid_lookup(old_dentry
);
682 v9fs_refresh_inode_dotl(fid
, old_dentry
->d_inode
);
684 ihold(old_dentry
->d_inode
);
685 d_instantiate(dentry
, old_dentry
->d_inode
);
691 * v9fs_vfs_mknod_dotl - create a special file
692 * @dir: inode destination for new link
693 * @dentry: dentry for file
694 * @mode: mode for creation
695 * @rdev: device associated with special file
699 v9fs_vfs_mknod_dotl(struct inode
*dir
, struct dentry
*dentry
, int omode
,
706 struct v9fs_session_info
*v9ses
;
707 struct p9_fid
*fid
= NULL
, *dfid
= NULL
;
710 struct dentry
*dir_dentry
;
711 struct posix_acl
*dacl
= NULL
, *pacl
= NULL
;
713 P9_DPRINTK(P9_DEBUG_VFS
,
714 " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir
->i_ino
,
715 dentry
->d_name
.name
, omode
, MAJOR(rdev
), MINOR(rdev
));
717 if (!new_valid_dev(rdev
))
720 v9ses
= v9fs_inode2v9ses(dir
);
721 dir_dentry
= v9fs_dentry_from_dir_inode(dir
);
722 dfid
= v9fs_fid_lookup(dir_dentry
);
725 P9_DPRINTK(P9_DEBUG_VFS
, "fid lookup failed %d\n", err
);
730 gid
= v9fs_get_fsgid_for_create(dir
);
732 /* Update mode based on ACL value */
733 err
= v9fs_acl_mode(dir
, &mode
, &dacl
, &pacl
);
735 P9_DPRINTK(P9_DEBUG_VFS
,
736 "Failed to get acl values in mknod %d\n", err
);
739 name
= (char *) dentry
->d_name
.name
;
741 err
= p9_client_mknod_dotl(dfid
, name
, mode
, rdev
, gid
, &qid
);
745 v9fs_invalidate_inode_attr(dir
);
746 /* instantiate inode and assign the unopened fid to the dentry */
747 if (v9ses
->cache
== CACHE_LOOSE
|| v9ses
->cache
== CACHE_FSCACHE
) {
748 fid
= p9_client_walk(dfid
, 1, &name
, 1);
751 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_walk failed %d\n",
757 inode
= v9fs_get_inode_from_fid(v9ses
, fid
, dir
->i_sb
);
759 err
= PTR_ERR(inode
);
760 P9_DPRINTK(P9_DEBUG_VFS
, "inode creation failed %d\n",
764 d_instantiate(dentry
, inode
);
765 err
= v9fs_fid_add(dentry
, fid
);
771 * Not in cached mode. No need to populate inode with stat.
772 * socket syscall returns a fd, so we need instantiate
774 inode
= v9fs_get_inode(dir
->i_sb
, mode
);
776 err
= PTR_ERR(inode
);
779 d_instantiate(dentry
, inode
);
781 /* Now set the ACL based on the default value */
782 v9fs_set_create_acl(dentry
, dacl
, pacl
);
785 p9_client_clunk(fid
);
790 * v9fs_vfs_follow_link_dotl - follow a symlink path
791 * @dentry: dentry for symlink
797 v9fs_vfs_follow_link_dotl(struct dentry
*dentry
, struct nameidata
*nd
)
801 char *link
= __getname();
804 P9_DPRINTK(P9_DEBUG_VFS
, "%s\n", dentry
->d_name
.name
);
807 link
= ERR_PTR(-ENOMEM
);
810 fid
= v9fs_fid_lookup(dentry
);
813 link
= ERR_PTR(PTR_ERR(fid
));
816 retval
= p9_client_readlink(fid
, &target
);
818 strcpy(link
, target
);
823 link
= ERR_PTR(retval
);
825 nd_set_link(nd
, link
);
829 int v9fs_refresh_inode_dotl(struct p9_fid
*fid
, struct inode
*inode
)
832 struct p9_stat_dotl
*st
;
833 struct v9fs_session_info
*v9ses
;
835 v9ses
= v9fs_inode2v9ses(inode
);
836 st
= p9_client_getattr_dotl(fid
, P9_STATS_ALL
);
840 spin_lock(&inode
->i_lock
);
842 * We don't want to refresh inode->i_size,
843 * because we may have cached data
845 i_size
= inode
->i_size
;
846 v9fs_stat2inode_dotl(st
, inode
);
848 inode
->i_size
= i_size
;
849 spin_unlock(&inode
->i_lock
);
854 const struct inode_operations v9fs_dir_inode_operations_dotl
= {
855 .create
= v9fs_vfs_create_dotl
,
856 .lookup
= v9fs_vfs_lookup
,
857 .link
= v9fs_vfs_link_dotl
,
858 .symlink
= v9fs_vfs_symlink_dotl
,
859 .unlink
= v9fs_vfs_unlink
,
860 .mkdir
= v9fs_vfs_mkdir_dotl
,
861 .rmdir
= v9fs_vfs_rmdir
,
862 .mknod
= v9fs_vfs_mknod_dotl
,
863 .rename
= v9fs_vfs_rename
,
864 .getattr
= v9fs_vfs_getattr_dotl
,
865 .setattr
= v9fs_vfs_setattr_dotl
,
866 .setxattr
= generic_setxattr
,
867 .getxattr
= generic_getxattr
,
868 .removexattr
= generic_removexattr
,
869 .listxattr
= v9fs_listxattr
,
870 .check_acl
= v9fs_check_acl
,
873 const struct inode_operations v9fs_file_inode_operations_dotl
= {
874 .getattr
= v9fs_vfs_getattr_dotl
,
875 .setattr
= v9fs_vfs_setattr_dotl
,
876 .setxattr
= generic_setxattr
,
877 .getxattr
= generic_getxattr
,
878 .removexattr
= generic_removexattr
,
879 .listxattr
= v9fs_listxattr
,
880 .check_acl
= v9fs_check_acl
,
883 const struct inode_operations v9fs_symlink_inode_operations_dotl
= {
884 .readlink
= generic_readlink
,
885 .follow_link
= v9fs_vfs_follow_link_dotl
,
886 .put_link
= v9fs_vfs_put_link
,
887 .getattr
= v9fs_vfs_getattr_dotl
,
888 .setattr
= v9fs_vfs_setattr_dotl
,
889 .setxattr
= generic_setxattr
,
890 .getxattr
= generic_getxattr
,
891 .removexattr
= generic_removexattr
,
892 .listxattr
= v9fs_listxattr
,