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 int v9fs_test_inode_dotl(struct inode
*inode
, void *data
)
91 struct v9fs_inode
*v9inode
= V9FS_I(inode
);
92 struct p9_stat_dotl
*st
= (struct p9_stat_dotl
*)data
;
94 /* don't match inode of different type */
95 if ((inode
->i_mode
& S_IFMT
) != (st
->st_mode
& S_IFMT
))
98 if (inode
->i_generation
!= st
->st_gen
)
101 /* compare qid details */
102 if (memcmp(&v9inode
->qid
.version
,
103 &st
->qid
.version
, sizeof(v9inode
->qid
.version
)))
106 if (v9inode
->qid
.type
!= st
->qid
.type
)
111 static int v9fs_set_inode_dotl(struct inode
*inode
, void *data
)
113 struct v9fs_inode
*v9inode
= V9FS_I(inode
);
114 struct p9_stat_dotl
*st
= (struct p9_stat_dotl
*)data
;
116 memcpy(&v9inode
->qid
, &st
->qid
, sizeof(st
->qid
));
117 inode
->i_generation
= st
->st_gen
;
121 static struct inode
*v9fs_qid_iget_dotl(struct super_block
*sb
,
124 struct p9_stat_dotl
*st
)
129 struct v9fs_session_info
*v9ses
= sb
->s_fs_info
;
131 i_ino
= v9fs_qid2ino(qid
);
132 inode
= iget5_locked(sb
, i_ino
, v9fs_test_inode_dotl
,
133 v9fs_set_inode_dotl
, st
);
135 return ERR_PTR(-ENOMEM
);
136 if (!(inode
->i_state
& I_NEW
))
139 * initialize the inode with the stat info
140 * FIXME!! we may need support for stale inodes
143 inode
->i_ino
= i_ino
;
144 retval
= v9fs_init_inode(v9ses
, inode
, st
->st_mode
);
148 v9fs_stat2inode_dotl(st
, inode
);
149 #ifdef CONFIG_9P_FSCACHE
150 v9fs_cache_inode_get_cookie(inode
);
152 retval
= v9fs_get_acl(inode
, fid
);
156 unlock_new_inode(inode
);
159 unlock_new_inode(inode
);
161 return ERR_PTR(retval
);
166 v9fs_inode_from_fid_dotl(struct v9fs_session_info
*v9ses
, struct p9_fid
*fid
,
167 struct super_block
*sb
)
169 struct p9_stat_dotl
*st
;
170 struct inode
*inode
= NULL
;
172 st
= p9_client_getattr_dotl(fid
, P9_STATS_BASIC
| P9_STATS_GEN
);
176 inode
= v9fs_qid_iget_dotl(sb
, &st
->qid
, fid
, st
);
182 * v9fs_vfs_create_dotl - VFS hook to create files for 9P2000.L protocol.
183 * @dir: directory inode that is being created
184 * @dentry: dentry that is being deleted
185 * @mode: create permissions
186 * @nd: path information
191 v9fs_vfs_create_dotl(struct inode
*dir
, struct dentry
*dentry
, int omode
,
192 struct nameidata
*nd
)
202 struct p9_fid
*fid
= NULL
;
203 struct v9fs_inode
*v9inode
;
204 struct p9_fid
*dfid
, *ofid
, *inode_fid
;
205 struct v9fs_session_info
*v9ses
;
206 struct posix_acl
*pacl
= NULL
, *dacl
= NULL
;
208 v9ses
= v9fs_inode2v9ses(dir
);
209 if (nd
&& nd
->flags
& LOOKUP_OPEN
)
210 flags
= nd
->intent
.open
.flags
- 1;
213 * create call without LOOKUP_OPEN is due
214 * to mknod of regular files. So use mknod
217 return v9fs_vfs_mknod_dotl(dir
, dentry
, omode
, 0);
220 name
= (char *) dentry
->d_name
.name
;
221 P9_DPRINTK(P9_DEBUG_VFS
, "v9fs_vfs_create_dotl: name:%s flags:0x%x "
222 "mode:0x%x\n", name
, flags
, omode
);
224 dfid
= v9fs_fid_lookup(dentry
->d_parent
);
227 P9_DPRINTK(P9_DEBUG_VFS
, "fid lookup failed %d\n", err
);
231 /* clone a fid to use for creation */
232 ofid
= p9_client_walk(dfid
, 0, NULL
, 1);
235 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_walk failed %d\n", err
);
239 gid
= v9fs_get_fsgid_for_create(dir
);
242 /* Update mode based on ACL value */
243 err
= v9fs_acl_mode(dir
, &mode
, &dacl
, &pacl
);
245 P9_DPRINTK(P9_DEBUG_VFS
,
246 "Failed to get acl values in creat %d\n", err
);
249 err
= p9_client_create_dotl(ofid
, name
, flags
, mode
, gid
, &qid
);
251 P9_DPRINTK(P9_DEBUG_VFS
,
252 "p9_client_open_dotl failed in creat %d\n",
256 v9fs_invalidate_inode_attr(dir
);
258 /* instantiate inode and assign the unopened fid to the dentry */
259 fid
= p9_client_walk(dfid
, 1, &name
, 1);
262 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_walk failed %d\n", err
);
266 inode
= v9fs_get_inode_from_fid(v9ses
, fid
, dir
->i_sb
);
268 err
= PTR_ERR(inode
);
269 P9_DPRINTK(P9_DEBUG_VFS
, "inode creation failed %d\n", err
);
272 d_instantiate(dentry
, inode
);
273 err
= v9fs_fid_add(dentry
, fid
);
277 /* Now set the ACL based on the default value */
278 v9fs_set_create_acl(dentry
, dacl
, pacl
);
280 v9inode
= V9FS_I(inode
);
281 mutex_lock(&v9inode
->v_mutex
);
282 if (v9ses
->cache
&& !v9inode
->writeback_fid
&&
283 ((flags
& O_ACCMODE
) != O_RDONLY
)) {
285 * clone a fid and add it to writeback_fid
286 * we do it during open time instead of
287 * page dirty time via write_begin/page_mkwrite
288 * because we want write after unlink usecase
291 inode_fid
= v9fs_writeback_fid(dentry
);
292 if (IS_ERR(inode_fid
)) {
293 err
= PTR_ERR(inode_fid
);
294 mutex_unlock(&v9inode
->v_mutex
);
295 goto err_clunk_old_fid
;
297 v9inode
->writeback_fid
= (void *) inode_fid
;
299 mutex_unlock(&v9inode
->v_mutex
);
300 /* Since we are opening a file, assign the open fid to the file */
301 filp
= lookup_instantiate_filp(nd
, dentry
, generic_file_open
);
304 goto err_clunk_old_fid
;
306 filp
->private_data
= ofid
;
307 #ifdef CONFIG_9P_FSCACHE
309 v9fs_cache_inode_set_cookie(inode
, filp
);
315 p9_client_clunk(fid
);
318 p9_client_clunk(ofid
);
323 * v9fs_vfs_mkdir_dotl - VFS mkdir hook to create a directory
324 * @dir: inode that is being unlinked
325 * @dentry: dentry that is being unlinked
326 * @mode: mode for new directory
330 static int v9fs_vfs_mkdir_dotl(struct inode
*dir
,
331 struct dentry
*dentry
, int omode
)
334 struct v9fs_session_info
*v9ses
;
335 struct p9_fid
*fid
= NULL
, *dfid
= NULL
;
341 struct dentry
*dir_dentry
;
342 struct posix_acl
*dacl
= NULL
, *pacl
= NULL
;
344 P9_DPRINTK(P9_DEBUG_VFS
, "name %s\n", dentry
->d_name
.name
);
346 v9ses
= v9fs_inode2v9ses(dir
);
349 if (dir
->i_mode
& S_ISGID
)
352 dir_dentry
= v9fs_dentry_from_dir_inode(dir
);
353 dfid
= v9fs_fid_lookup(dir_dentry
);
356 P9_DPRINTK(P9_DEBUG_VFS
, "fid lookup failed %d\n", err
);
361 gid
= v9fs_get_fsgid_for_create(dir
);
363 /* Update mode based on ACL value */
364 err
= v9fs_acl_mode(dir
, &mode
, &dacl
, &pacl
);
366 P9_DPRINTK(P9_DEBUG_VFS
,
367 "Failed to get acl values in mkdir %d\n", err
);
370 name
= (char *) dentry
->d_name
.name
;
371 err
= p9_client_mkdir_dotl(dfid
, name
, mode
, gid
, &qid
);
375 /* instantiate inode and assign the unopened fid to the dentry */
376 if (v9ses
->cache
== CACHE_LOOSE
|| v9ses
->cache
== CACHE_FSCACHE
) {
377 fid
= p9_client_walk(dfid
, 1, &name
, 1);
380 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_walk failed %d\n",
386 inode
= v9fs_get_inode_from_fid(v9ses
, fid
, dir
->i_sb
);
388 err
= PTR_ERR(inode
);
389 P9_DPRINTK(P9_DEBUG_VFS
, "inode creation failed %d\n",
393 d_instantiate(dentry
, inode
);
394 err
= v9fs_fid_add(dentry
, fid
);
400 * Not in cached mode. No need to populate
401 * inode with stat. We need to get an inode
402 * so that we can set the acl with dentry
404 inode
= v9fs_get_inode(dir
->i_sb
, mode
);
406 err
= PTR_ERR(inode
);
409 d_instantiate(dentry
, inode
);
411 /* Now set the ACL based on the default value */
412 v9fs_set_create_acl(dentry
, dacl
, pacl
);
414 v9fs_invalidate_inode_attr(dir
);
417 p9_client_clunk(fid
);
422 v9fs_vfs_getattr_dotl(struct vfsmount
*mnt
, struct dentry
*dentry
,
426 struct v9fs_session_info
*v9ses
;
428 struct p9_stat_dotl
*st
;
430 P9_DPRINTK(P9_DEBUG_VFS
, "dentry: %p\n", dentry
);
432 v9ses
= v9fs_dentry2v9ses(dentry
);
433 if (v9ses
->cache
== CACHE_LOOSE
|| v9ses
->cache
== CACHE_FSCACHE
) {
434 generic_fillattr(dentry
->d_inode
, stat
);
437 fid
= v9fs_fid_lookup(dentry
);
441 /* Ask for all the fields in stat structure. Server will return
442 * whatever it supports
445 st
= p9_client_getattr_dotl(fid
, P9_STATS_ALL
);
449 v9fs_stat2inode_dotl(st
, dentry
->d_inode
);
450 generic_fillattr(dentry
->d_inode
, stat
);
451 /* Change block size to what the server returned */
452 stat
->blksize
= st
->st_blksize
;
459 * v9fs_vfs_setattr_dotl - set file metadata
460 * @dentry: file whose metadata to set
461 * @iattr: metadata assignment structure
465 int v9fs_vfs_setattr_dotl(struct dentry
*dentry
, struct iattr
*iattr
)
468 struct v9fs_session_info
*v9ses
;
470 struct p9_iattr_dotl p9attr
;
472 P9_DPRINTK(P9_DEBUG_VFS
, "\n");
474 retval
= inode_change_ok(dentry
->d_inode
, iattr
);
478 p9attr
.valid
= iattr
->ia_valid
;
479 p9attr
.mode
= iattr
->ia_mode
;
480 p9attr
.uid
= iattr
->ia_uid
;
481 p9attr
.gid
= iattr
->ia_gid
;
482 p9attr
.size
= iattr
->ia_size
;
483 p9attr
.atime_sec
= iattr
->ia_atime
.tv_sec
;
484 p9attr
.atime_nsec
= iattr
->ia_atime
.tv_nsec
;
485 p9attr
.mtime_sec
= iattr
->ia_mtime
.tv_sec
;
486 p9attr
.mtime_nsec
= iattr
->ia_mtime
.tv_nsec
;
489 v9ses
= v9fs_dentry2v9ses(dentry
);
490 fid
= v9fs_fid_lookup(dentry
);
494 /* Write all dirty data */
495 if (S_ISREG(dentry
->d_inode
->i_mode
))
496 filemap_write_and_wait(dentry
->d_inode
->i_mapping
);
498 retval
= p9_client_setattr(fid
, &p9attr
);
502 if ((iattr
->ia_valid
& ATTR_SIZE
) &&
503 iattr
->ia_size
!= i_size_read(dentry
->d_inode
))
504 truncate_setsize(dentry
->d_inode
, iattr
->ia_size
);
506 v9fs_invalidate_inode_attr(dentry
->d_inode
);
507 setattr_copy(dentry
->d_inode
, iattr
);
508 mark_inode_dirty(dentry
->d_inode
);
509 if (iattr
->ia_valid
& ATTR_MODE
) {
510 /* We also want to update ACL when we update mode bits */
511 retval
= v9fs_acl_chmod(dentry
);
519 * v9fs_stat2inode_dotl - populate an inode structure with stat info
520 * @stat: stat structure
521 * @inode: inode to populate
522 * @sb: superblock of filesystem
527 v9fs_stat2inode_dotl(struct p9_stat_dotl
*stat
, struct inode
*inode
)
529 struct v9fs_inode
*v9inode
= V9FS_I(inode
);
531 if ((stat
->st_result_mask
& P9_STATS_BASIC
) == P9_STATS_BASIC
) {
532 inode
->i_atime
.tv_sec
= stat
->st_atime_sec
;
533 inode
->i_atime
.tv_nsec
= stat
->st_atime_nsec
;
534 inode
->i_mtime
.tv_sec
= stat
->st_mtime_sec
;
535 inode
->i_mtime
.tv_nsec
= stat
->st_mtime_nsec
;
536 inode
->i_ctime
.tv_sec
= stat
->st_ctime_sec
;
537 inode
->i_ctime
.tv_nsec
= stat
->st_ctime_nsec
;
538 inode
->i_uid
= stat
->st_uid
;
539 inode
->i_gid
= stat
->st_gid
;
540 inode
->i_nlink
= stat
->st_nlink
;
541 inode
->i_mode
= stat
->st_mode
;
542 inode
->i_rdev
= new_decode_dev(stat
->st_rdev
);
544 if ((S_ISBLK(inode
->i_mode
)) || (S_ISCHR(inode
->i_mode
)))
545 init_special_inode(inode
, inode
->i_mode
, inode
->i_rdev
);
547 i_size_write(inode
, stat
->st_size
);
548 inode
->i_blocks
= stat
->st_blocks
;
550 if (stat
->st_result_mask
& P9_STATS_ATIME
) {
551 inode
->i_atime
.tv_sec
= stat
->st_atime_sec
;
552 inode
->i_atime
.tv_nsec
= stat
->st_atime_nsec
;
554 if (stat
->st_result_mask
& P9_STATS_MTIME
) {
555 inode
->i_mtime
.tv_sec
= stat
->st_mtime_sec
;
556 inode
->i_mtime
.tv_nsec
= stat
->st_mtime_nsec
;
558 if (stat
->st_result_mask
& P9_STATS_CTIME
) {
559 inode
->i_ctime
.tv_sec
= stat
->st_ctime_sec
;
560 inode
->i_ctime
.tv_nsec
= stat
->st_ctime_nsec
;
562 if (stat
->st_result_mask
& P9_STATS_UID
)
563 inode
->i_uid
= stat
->st_uid
;
564 if (stat
->st_result_mask
& P9_STATS_GID
)
565 inode
->i_gid
= stat
->st_gid
;
566 if (stat
->st_result_mask
& P9_STATS_NLINK
)
567 inode
->i_nlink
= stat
->st_nlink
;
568 if (stat
->st_result_mask
& P9_STATS_MODE
) {
569 inode
->i_mode
= stat
->st_mode
;
570 if ((S_ISBLK(inode
->i_mode
)) ||
571 (S_ISCHR(inode
->i_mode
)))
572 init_special_inode(inode
, inode
->i_mode
,
575 if (stat
->st_result_mask
& P9_STATS_RDEV
)
576 inode
->i_rdev
= new_decode_dev(stat
->st_rdev
);
577 if (stat
->st_result_mask
& P9_STATS_SIZE
)
578 i_size_write(inode
, stat
->st_size
);
579 if (stat
->st_result_mask
& P9_STATS_BLOCKS
)
580 inode
->i_blocks
= stat
->st_blocks
;
582 if (stat
->st_result_mask
& P9_STATS_GEN
)
583 inode
->i_generation
= stat
->st_gen
;
585 /* Currently we don't support P9_STATS_BTIME and P9_STATS_DATA_VERSION
586 * because the inode structure does not have fields for them.
588 v9inode
->cache_validity
&= ~V9FS_INO_INVALID_ATTR
;
592 v9fs_vfs_symlink_dotl(struct inode
*dir
, struct dentry
*dentry
,
601 struct p9_fid
*fid
= NULL
;
602 struct v9fs_session_info
*v9ses
;
604 name
= (char *) dentry
->d_name
.name
;
605 P9_DPRINTK(P9_DEBUG_VFS
, "v9fs_vfs_symlink_dotl : %lu,%s,%s\n",
606 dir
->i_ino
, name
, symname
);
607 v9ses
= v9fs_inode2v9ses(dir
);
609 dfid
= v9fs_fid_lookup(dentry
->d_parent
);
612 P9_DPRINTK(P9_DEBUG_VFS
, "fid lookup failed %d\n", err
);
616 gid
= v9fs_get_fsgid_for_create(dir
);
618 /* Server doesn't alter fid on TSYMLINK. Hence no need to clone it. */
619 err
= p9_client_symlink(dfid
, name
, (char *)symname
, gid
, &qid
);
622 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_symlink failed %d\n", err
);
626 v9fs_invalidate_inode_attr(dir
);
628 /* Now walk from the parent so we can get an unopened fid. */
629 fid
= p9_client_walk(dfid
, 1, &name
, 1);
632 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_walk failed %d\n",
638 /* instantiate inode and assign the unopened fid to dentry */
639 inode
= v9fs_get_inode_from_fid(v9ses
, fid
, dir
->i_sb
);
641 err
= PTR_ERR(inode
);
642 P9_DPRINTK(P9_DEBUG_VFS
, "inode creation failed %d\n",
646 d_instantiate(dentry
, inode
);
647 err
= v9fs_fid_add(dentry
, fid
);
652 /* Not in cached mode. No need to populate inode with stat */
653 inode
= v9fs_get_inode(dir
->i_sb
, S_IFLNK
);
655 err
= PTR_ERR(inode
);
658 d_instantiate(dentry
, inode
);
663 p9_client_clunk(fid
);
669 * v9fs_vfs_link_dotl - create a hardlink for dotl
670 * @old_dentry: dentry for file to link to
671 * @dir: inode destination for new link
672 * @dentry: dentry for link
677 v9fs_vfs_link_dotl(struct dentry
*old_dentry
, struct inode
*dir
,
678 struct dentry
*dentry
)
682 struct dentry
*dir_dentry
;
683 struct p9_fid
*dfid
, *oldfid
;
684 struct v9fs_session_info
*v9ses
;
686 P9_DPRINTK(P9_DEBUG_VFS
, "dir ino: %lu, old_name: %s, new_name: %s\n",
687 dir
->i_ino
, old_dentry
->d_name
.name
,
688 dentry
->d_name
.name
);
690 v9ses
= v9fs_inode2v9ses(dir
);
691 dir_dentry
= v9fs_dentry_from_dir_inode(dir
);
692 dfid
= v9fs_fid_lookup(dir_dentry
);
694 return PTR_ERR(dfid
);
696 oldfid
= v9fs_fid_lookup(old_dentry
);
698 return PTR_ERR(oldfid
);
700 name
= (char *) dentry
->d_name
.name
;
702 err
= p9_client_link(dfid
, oldfid
, (char *)dentry
->d_name
.name
);
705 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_link failed %d\n", err
);
709 v9fs_invalidate_inode_attr(dir
);
710 if (v9ses
->cache
== CACHE_LOOSE
|| v9ses
->cache
== CACHE_FSCACHE
) {
711 /* Get the latest stat info from server. */
713 fid
= v9fs_fid_lookup(old_dentry
);
717 v9fs_refresh_inode_dotl(fid
, old_dentry
->d_inode
);
719 ihold(old_dentry
->d_inode
);
720 d_instantiate(dentry
, old_dentry
->d_inode
);
726 * v9fs_vfs_mknod_dotl - create a special file
727 * @dir: inode destination for new link
728 * @dentry: dentry for file
729 * @mode: mode for creation
730 * @rdev: device associated with special file
734 v9fs_vfs_mknod_dotl(struct inode
*dir
, struct dentry
*dentry
, int omode
,
741 struct v9fs_session_info
*v9ses
;
742 struct p9_fid
*fid
= NULL
, *dfid
= NULL
;
745 struct dentry
*dir_dentry
;
746 struct posix_acl
*dacl
= NULL
, *pacl
= NULL
;
748 P9_DPRINTK(P9_DEBUG_VFS
,
749 " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir
->i_ino
,
750 dentry
->d_name
.name
, omode
, MAJOR(rdev
), MINOR(rdev
));
752 if (!new_valid_dev(rdev
))
755 v9ses
= v9fs_inode2v9ses(dir
);
756 dir_dentry
= v9fs_dentry_from_dir_inode(dir
);
757 dfid
= v9fs_fid_lookup(dir_dentry
);
760 P9_DPRINTK(P9_DEBUG_VFS
, "fid lookup failed %d\n", err
);
765 gid
= v9fs_get_fsgid_for_create(dir
);
767 /* Update mode based on ACL value */
768 err
= v9fs_acl_mode(dir
, &mode
, &dacl
, &pacl
);
770 P9_DPRINTK(P9_DEBUG_VFS
,
771 "Failed to get acl values in mknod %d\n", err
);
774 name
= (char *) dentry
->d_name
.name
;
776 err
= p9_client_mknod_dotl(dfid
, name
, mode
, rdev
, gid
, &qid
);
780 v9fs_invalidate_inode_attr(dir
);
781 /* instantiate inode and assign the unopened fid to the dentry */
782 if (v9ses
->cache
== CACHE_LOOSE
|| v9ses
->cache
== CACHE_FSCACHE
) {
783 fid
= p9_client_walk(dfid
, 1, &name
, 1);
786 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_walk failed %d\n",
792 inode
= v9fs_get_inode_from_fid(v9ses
, fid
, dir
->i_sb
);
794 err
= PTR_ERR(inode
);
795 P9_DPRINTK(P9_DEBUG_VFS
, "inode creation failed %d\n",
799 d_instantiate(dentry
, inode
);
800 err
= v9fs_fid_add(dentry
, fid
);
806 * Not in cached mode. No need to populate inode with stat.
807 * socket syscall returns a fd, so we need instantiate
809 inode
= v9fs_get_inode(dir
->i_sb
, mode
);
811 err
= PTR_ERR(inode
);
814 d_instantiate(dentry
, inode
);
816 /* Now set the ACL based on the default value */
817 v9fs_set_create_acl(dentry
, dacl
, pacl
);
820 p9_client_clunk(fid
);
825 * v9fs_vfs_follow_link_dotl - follow a symlink path
826 * @dentry: dentry for symlink
832 v9fs_vfs_follow_link_dotl(struct dentry
*dentry
, struct nameidata
*nd
)
836 char *link
= __getname();
839 P9_DPRINTK(P9_DEBUG_VFS
, "%s\n", dentry
->d_name
.name
);
842 link
= ERR_PTR(-ENOMEM
);
845 fid
= v9fs_fid_lookup(dentry
);
848 link
= ERR_CAST(fid
);
851 retval
= p9_client_readlink(fid
, &target
);
853 strcpy(link
, target
);
858 link
= ERR_PTR(retval
);
860 nd_set_link(nd
, link
);
864 int v9fs_refresh_inode_dotl(struct p9_fid
*fid
, struct inode
*inode
)
867 struct p9_stat_dotl
*st
;
868 struct v9fs_session_info
*v9ses
;
870 v9ses
= v9fs_inode2v9ses(inode
);
871 st
= p9_client_getattr_dotl(fid
, P9_STATS_ALL
);
875 spin_lock(&inode
->i_lock
);
877 * We don't want to refresh inode->i_size,
878 * because we may have cached data
880 i_size
= inode
->i_size
;
881 v9fs_stat2inode_dotl(st
, inode
);
883 inode
->i_size
= i_size
;
884 spin_unlock(&inode
->i_lock
);
889 const struct inode_operations v9fs_dir_inode_operations_dotl
= {
890 .create
= v9fs_vfs_create_dotl
,
891 .lookup
= v9fs_vfs_lookup
,
892 .link
= v9fs_vfs_link_dotl
,
893 .symlink
= v9fs_vfs_symlink_dotl
,
894 .unlink
= v9fs_vfs_unlink
,
895 .mkdir
= v9fs_vfs_mkdir_dotl
,
896 .rmdir
= v9fs_vfs_rmdir
,
897 .mknod
= v9fs_vfs_mknod_dotl
,
898 .rename
= v9fs_vfs_rename
,
899 .getattr
= v9fs_vfs_getattr_dotl
,
900 .setattr
= v9fs_vfs_setattr_dotl
,
901 .setxattr
= generic_setxattr
,
902 .getxattr
= generic_getxattr
,
903 .removexattr
= generic_removexattr
,
904 .listxattr
= v9fs_listxattr
,
905 .check_acl
= v9fs_check_acl
,
908 const struct inode_operations v9fs_file_inode_operations_dotl
= {
909 .getattr
= v9fs_vfs_getattr_dotl
,
910 .setattr
= v9fs_vfs_setattr_dotl
,
911 .setxattr
= generic_setxattr
,
912 .getxattr
= generic_getxattr
,
913 .removexattr
= generic_removexattr
,
914 .listxattr
= v9fs_listxattr
,
915 .check_acl
= v9fs_check_acl
,
918 const struct inode_operations v9fs_symlink_inode_operations_dotl
= {
919 .readlink
= generic_readlink
,
920 .follow_link
= v9fs_vfs_follow_link_dotl
,
921 .put_link
= v9fs_vfs_put_link
,
922 .getattr
= v9fs_vfs_getattr_dotl
,
923 .setattr
= v9fs_vfs_setattr_dotl
,
924 .setxattr
= generic_setxattr
,
925 .getxattr
= generic_getxattr
,
926 .removexattr
= generic_removexattr
,
927 .listxattr
= v9fs_listxattr
,