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 /* Always get a new inode */
112 static int v9fs_test_new_inode_dotl(struct inode
*inode
, void *data
)
117 static int v9fs_set_inode_dotl(struct inode
*inode
, void *data
)
119 struct v9fs_inode
*v9inode
= V9FS_I(inode
);
120 struct p9_stat_dotl
*st
= (struct p9_stat_dotl
*)data
;
122 memcpy(&v9inode
->qid
, &st
->qid
, sizeof(st
->qid
));
123 inode
->i_generation
= st
->st_gen
;
127 static struct inode
*v9fs_qid_iget_dotl(struct super_block
*sb
,
130 struct p9_stat_dotl
*st
,
136 struct v9fs_session_info
*v9ses
= sb
->s_fs_info
;
137 int (*test
)(struct inode
*, void *);
140 test
= v9fs_test_new_inode_dotl
;
142 test
= v9fs_test_inode_dotl
;
144 i_ino
= v9fs_qid2ino(qid
);
145 inode
= iget5_locked(sb
, i_ino
, test
, v9fs_set_inode_dotl
, st
);
147 return ERR_PTR(-ENOMEM
);
148 if (!(inode
->i_state
& I_NEW
))
151 * initialize the inode with the stat info
152 * FIXME!! we may need support for stale inodes
155 inode
->i_ino
= i_ino
;
156 retval
= v9fs_init_inode(v9ses
, inode
,
157 st
->st_mode
, new_decode_dev(st
->st_rdev
));
161 v9fs_stat2inode_dotl(st
, inode
);
162 #ifdef CONFIG_9P_FSCACHE
163 v9fs_cache_inode_get_cookie(inode
);
165 retval
= v9fs_get_acl(inode
, fid
);
169 unlock_new_inode(inode
);
172 unlock_new_inode(inode
);
174 return ERR_PTR(retval
);
179 v9fs_inode_from_fid_dotl(struct v9fs_session_info
*v9ses
, struct p9_fid
*fid
,
180 struct super_block
*sb
, int new)
182 struct p9_stat_dotl
*st
;
183 struct inode
*inode
= NULL
;
185 st
= p9_client_getattr_dotl(fid
, P9_STATS_BASIC
| P9_STATS_GEN
);
189 inode
= v9fs_qid_iget_dotl(sb
, &st
->qid
, fid
, st
, new);
195 * v9fs_vfs_create_dotl - VFS hook to create files for 9P2000.L protocol.
196 * @dir: directory inode that is being created
197 * @dentry: dentry that is being deleted
198 * @mode: create permissions
199 * @nd: path information
204 v9fs_vfs_create_dotl(struct inode
*dir
, struct dentry
*dentry
, int omode
,
205 struct nameidata
*nd
)
215 struct p9_fid
*fid
= NULL
;
216 struct v9fs_inode
*v9inode
;
217 struct p9_fid
*dfid
, *ofid
, *inode_fid
;
218 struct v9fs_session_info
*v9ses
;
219 struct posix_acl
*pacl
= NULL
, *dacl
= NULL
;
221 v9ses
= v9fs_inode2v9ses(dir
);
223 flags
= nd
->intent
.open
.flags
;
226 * create call without LOOKUP_OPEN is due
227 * to mknod of regular files. So use mknod
230 return v9fs_vfs_mknod_dotl(dir
, dentry
, omode
, 0);
233 name
= (char *) dentry
->d_name
.name
;
234 P9_DPRINTK(P9_DEBUG_VFS
, "v9fs_vfs_create_dotl: name:%s flags:0x%x "
235 "mode:0x%x\n", name
, flags
, omode
);
237 dfid
= v9fs_fid_lookup(dentry
->d_parent
);
240 P9_DPRINTK(P9_DEBUG_VFS
, "fid lookup failed %d\n", err
);
244 /* clone a fid to use for creation */
245 ofid
= p9_client_walk(dfid
, 0, NULL
, 1);
248 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_walk failed %d\n", err
);
252 gid
= v9fs_get_fsgid_for_create(dir
);
255 /* Update mode based on ACL value */
256 err
= v9fs_acl_mode(dir
, &mode
, &dacl
, &pacl
);
258 P9_DPRINTK(P9_DEBUG_VFS
,
259 "Failed to get acl values in creat %d\n", err
);
262 err
= p9_client_create_dotl(ofid
, name
, flags
, mode
, gid
, &qid
);
264 P9_DPRINTK(P9_DEBUG_VFS
,
265 "p9_client_open_dotl failed in creat %d\n",
269 v9fs_invalidate_inode_attr(dir
);
271 /* instantiate inode and assign the unopened fid to the dentry */
272 fid
= p9_client_walk(dfid
, 1, &name
, 1);
275 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_walk failed %d\n", err
);
279 inode
= v9fs_get_new_inode_from_fid(v9ses
, fid
, dir
->i_sb
);
281 err
= PTR_ERR(inode
);
282 P9_DPRINTK(P9_DEBUG_VFS
, "inode creation failed %d\n", err
);
285 err
= v9fs_fid_add(dentry
, fid
);
288 d_instantiate(dentry
, inode
);
290 /* Now set the ACL based on the default value */
291 v9fs_set_create_acl(dentry
, &dacl
, &pacl
);
293 v9inode
= V9FS_I(inode
);
294 mutex_lock(&v9inode
->v_mutex
);
295 if (v9ses
->cache
&& !v9inode
->writeback_fid
&&
296 ((flags
& O_ACCMODE
) != O_RDONLY
)) {
298 * clone a fid and add it to writeback_fid
299 * we do it during open time instead of
300 * page dirty time via write_begin/page_mkwrite
301 * because we want write after unlink usecase
304 inode_fid
= v9fs_writeback_fid(dentry
);
305 if (IS_ERR(inode_fid
)) {
306 err
= PTR_ERR(inode_fid
);
307 mutex_unlock(&v9inode
->v_mutex
);
308 goto err_clunk_old_fid
;
310 v9inode
->writeback_fid
= (void *) inode_fid
;
312 mutex_unlock(&v9inode
->v_mutex
);
313 /* Since we are opening a file, assign the open fid to the file */
314 filp
= lookup_instantiate_filp(nd
, dentry
, generic_file_open
);
317 goto err_clunk_old_fid
;
319 filp
->private_data
= ofid
;
320 #ifdef CONFIG_9P_FSCACHE
322 v9fs_cache_inode_set_cookie(inode
, filp
);
328 p9_client_clunk(fid
);
331 p9_client_clunk(ofid
);
332 v9fs_set_create_acl(NULL
, &dacl
, &pacl
);
337 * v9fs_vfs_mkdir_dotl - VFS mkdir hook to create a directory
338 * @dir: inode that is being unlinked
339 * @dentry: dentry that is being unlinked
340 * @mode: mode for new directory
344 static int v9fs_vfs_mkdir_dotl(struct inode
*dir
,
345 struct dentry
*dentry
, int omode
)
348 struct v9fs_session_info
*v9ses
;
349 struct p9_fid
*fid
= NULL
, *dfid
= NULL
;
355 struct dentry
*dir_dentry
;
356 struct posix_acl
*dacl
= NULL
, *pacl
= NULL
;
358 P9_DPRINTK(P9_DEBUG_VFS
, "name %s\n", dentry
->d_name
.name
);
360 v9ses
= v9fs_inode2v9ses(dir
);
363 if (dir
->i_mode
& S_ISGID
)
366 dir_dentry
= v9fs_dentry_from_dir_inode(dir
);
367 dfid
= v9fs_fid_lookup(dir_dentry
);
370 P9_DPRINTK(P9_DEBUG_VFS
, "fid lookup failed %d\n", err
);
375 gid
= v9fs_get_fsgid_for_create(dir
);
377 /* Update mode based on ACL value */
378 err
= v9fs_acl_mode(dir
, &mode
, &dacl
, &pacl
);
380 P9_DPRINTK(P9_DEBUG_VFS
,
381 "Failed to get acl values in mkdir %d\n", err
);
384 name
= (char *) dentry
->d_name
.name
;
385 err
= p9_client_mkdir_dotl(dfid
, name
, mode
, gid
, &qid
);
389 /* instantiate inode and assign the unopened fid to the dentry */
390 if (v9ses
->cache
== CACHE_LOOSE
|| v9ses
->cache
== CACHE_FSCACHE
) {
391 fid
= p9_client_walk(dfid
, 1, &name
, 1);
394 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_walk failed %d\n",
400 inode
= v9fs_get_new_inode_from_fid(v9ses
, fid
, dir
->i_sb
);
402 err
= PTR_ERR(inode
);
403 P9_DPRINTK(P9_DEBUG_VFS
, "inode creation failed %d\n",
407 err
= v9fs_fid_add(dentry
, fid
);
410 d_instantiate(dentry
, inode
);
414 * Not in cached mode. No need to populate
415 * inode with stat. We need to get an inode
416 * so that we can set the acl with dentry
418 inode
= v9fs_get_inode(dir
->i_sb
, mode
, 0);
420 err
= PTR_ERR(inode
);
423 d_instantiate(dentry
, inode
);
425 /* Now set the ACL based on the default value */
426 v9fs_set_create_acl(dentry
, &dacl
, &pacl
);
428 v9fs_invalidate_inode_attr(dir
);
431 p9_client_clunk(fid
);
432 v9fs_set_create_acl(NULL
, &dacl
, &pacl
);
437 v9fs_vfs_getattr_dotl(struct vfsmount
*mnt
, struct dentry
*dentry
,
441 struct v9fs_session_info
*v9ses
;
443 struct p9_stat_dotl
*st
;
445 P9_DPRINTK(P9_DEBUG_VFS
, "dentry: %p\n", dentry
);
447 v9ses
= v9fs_dentry2v9ses(dentry
);
448 if (v9ses
->cache
== CACHE_LOOSE
|| v9ses
->cache
== CACHE_FSCACHE
) {
449 generic_fillattr(dentry
->d_inode
, stat
);
452 fid
= v9fs_fid_lookup(dentry
);
456 /* Ask for all the fields in stat structure. Server will return
457 * whatever it supports
460 st
= p9_client_getattr_dotl(fid
, P9_STATS_ALL
);
464 v9fs_stat2inode_dotl(st
, dentry
->d_inode
);
465 generic_fillattr(dentry
->d_inode
, stat
);
466 /* Change block size to what the server returned */
467 stat
->blksize
= st
->st_blksize
;
474 * v9fs_vfs_setattr_dotl - set file metadata
475 * @dentry: file whose metadata to set
476 * @iattr: metadata assignment structure
480 int v9fs_vfs_setattr_dotl(struct dentry
*dentry
, struct iattr
*iattr
)
483 struct v9fs_session_info
*v9ses
;
485 struct p9_iattr_dotl p9attr
;
487 P9_DPRINTK(P9_DEBUG_VFS
, "\n");
489 retval
= inode_change_ok(dentry
->d_inode
, iattr
);
493 p9attr
.valid
= iattr
->ia_valid
;
494 p9attr
.mode
= iattr
->ia_mode
;
495 p9attr
.uid
= iattr
->ia_uid
;
496 p9attr
.gid
= iattr
->ia_gid
;
497 p9attr
.size
= iattr
->ia_size
;
498 p9attr
.atime_sec
= iattr
->ia_atime
.tv_sec
;
499 p9attr
.atime_nsec
= iattr
->ia_atime
.tv_nsec
;
500 p9attr
.mtime_sec
= iattr
->ia_mtime
.tv_sec
;
501 p9attr
.mtime_nsec
= iattr
->ia_mtime
.tv_nsec
;
504 v9ses
= v9fs_dentry2v9ses(dentry
);
505 fid
= v9fs_fid_lookup(dentry
);
509 /* Write all dirty data */
510 if (S_ISREG(dentry
->d_inode
->i_mode
))
511 filemap_write_and_wait(dentry
->d_inode
->i_mapping
);
513 retval
= p9_client_setattr(fid
, &p9attr
);
517 if ((iattr
->ia_valid
& ATTR_SIZE
) &&
518 iattr
->ia_size
!= i_size_read(dentry
->d_inode
))
519 truncate_setsize(dentry
->d_inode
, iattr
->ia_size
);
521 v9fs_invalidate_inode_attr(dentry
->d_inode
);
522 setattr_copy(dentry
->d_inode
, iattr
);
523 mark_inode_dirty(dentry
->d_inode
);
524 if (iattr
->ia_valid
& ATTR_MODE
) {
525 /* We also want to update ACL when we update mode bits */
526 retval
= v9fs_acl_chmod(dentry
);
534 * v9fs_stat2inode_dotl - populate an inode structure with stat info
535 * @stat: stat structure
536 * @inode: inode to populate
537 * @sb: superblock of filesystem
542 v9fs_stat2inode_dotl(struct p9_stat_dotl
*stat
, struct inode
*inode
)
545 struct v9fs_inode
*v9inode
= V9FS_I(inode
);
547 if ((stat
->st_result_mask
& P9_STATS_BASIC
) == P9_STATS_BASIC
) {
548 inode
->i_atime
.tv_sec
= stat
->st_atime_sec
;
549 inode
->i_atime
.tv_nsec
= stat
->st_atime_nsec
;
550 inode
->i_mtime
.tv_sec
= stat
->st_mtime_sec
;
551 inode
->i_mtime
.tv_nsec
= stat
->st_mtime_nsec
;
552 inode
->i_ctime
.tv_sec
= stat
->st_ctime_sec
;
553 inode
->i_ctime
.tv_nsec
= stat
->st_ctime_nsec
;
554 inode
->i_uid
= stat
->st_uid
;
555 inode
->i_gid
= stat
->st_gid
;
556 inode
->i_nlink
= stat
->st_nlink
;
558 mode
= stat
->st_mode
& S_IALLUGO
;
559 mode
|= inode
->i_mode
& ~S_IALLUGO
;
560 inode
->i_mode
= mode
;
562 i_size_write(inode
, stat
->st_size
);
563 inode
->i_blocks
= stat
->st_blocks
;
565 if (stat
->st_result_mask
& P9_STATS_ATIME
) {
566 inode
->i_atime
.tv_sec
= stat
->st_atime_sec
;
567 inode
->i_atime
.tv_nsec
= stat
->st_atime_nsec
;
569 if (stat
->st_result_mask
& P9_STATS_MTIME
) {
570 inode
->i_mtime
.tv_sec
= stat
->st_mtime_sec
;
571 inode
->i_mtime
.tv_nsec
= stat
->st_mtime_nsec
;
573 if (stat
->st_result_mask
& P9_STATS_CTIME
) {
574 inode
->i_ctime
.tv_sec
= stat
->st_ctime_sec
;
575 inode
->i_ctime
.tv_nsec
= stat
->st_ctime_nsec
;
577 if (stat
->st_result_mask
& P9_STATS_UID
)
578 inode
->i_uid
= stat
->st_uid
;
579 if (stat
->st_result_mask
& P9_STATS_GID
)
580 inode
->i_gid
= stat
->st_gid
;
581 if (stat
->st_result_mask
& P9_STATS_NLINK
)
582 inode
->i_nlink
= stat
->st_nlink
;
583 if (stat
->st_result_mask
& P9_STATS_MODE
) {
584 inode
->i_mode
= stat
->st_mode
;
585 if ((S_ISBLK(inode
->i_mode
)) ||
586 (S_ISCHR(inode
->i_mode
)))
587 init_special_inode(inode
, inode
->i_mode
,
590 if (stat
->st_result_mask
& P9_STATS_RDEV
)
591 inode
->i_rdev
= new_decode_dev(stat
->st_rdev
);
592 if (stat
->st_result_mask
& P9_STATS_SIZE
)
593 i_size_write(inode
, stat
->st_size
);
594 if (stat
->st_result_mask
& P9_STATS_BLOCKS
)
595 inode
->i_blocks
= stat
->st_blocks
;
597 if (stat
->st_result_mask
& P9_STATS_GEN
)
598 inode
->i_generation
= stat
->st_gen
;
600 /* Currently we don't support P9_STATS_BTIME and P9_STATS_DATA_VERSION
601 * because the inode structure does not have fields for them.
603 v9inode
->cache_validity
&= ~V9FS_INO_INVALID_ATTR
;
607 v9fs_vfs_symlink_dotl(struct inode
*dir
, struct dentry
*dentry
,
616 struct p9_fid
*fid
= NULL
;
617 struct v9fs_session_info
*v9ses
;
619 name
= (char *) dentry
->d_name
.name
;
620 P9_DPRINTK(P9_DEBUG_VFS
, "v9fs_vfs_symlink_dotl : %lu,%s,%s\n",
621 dir
->i_ino
, name
, symname
);
622 v9ses
= v9fs_inode2v9ses(dir
);
624 dfid
= v9fs_fid_lookup(dentry
->d_parent
);
627 P9_DPRINTK(P9_DEBUG_VFS
, "fid lookup failed %d\n", err
);
631 gid
= v9fs_get_fsgid_for_create(dir
);
633 /* Server doesn't alter fid on TSYMLINK. Hence no need to clone it. */
634 err
= p9_client_symlink(dfid
, name
, (char *)symname
, gid
, &qid
);
637 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_symlink failed %d\n", err
);
641 v9fs_invalidate_inode_attr(dir
);
643 /* Now walk from the parent so we can get an unopened fid. */
644 fid
= p9_client_walk(dfid
, 1, &name
, 1);
647 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_walk failed %d\n",
653 /* instantiate inode and assign the unopened fid to dentry */
654 inode
= v9fs_get_new_inode_from_fid(v9ses
, fid
, dir
->i_sb
);
656 err
= PTR_ERR(inode
);
657 P9_DPRINTK(P9_DEBUG_VFS
, "inode creation failed %d\n",
661 err
= v9fs_fid_add(dentry
, fid
);
664 d_instantiate(dentry
, inode
);
667 /* Not in cached mode. No need to populate inode with stat */
668 inode
= v9fs_get_inode(dir
->i_sb
, S_IFLNK
, 0);
670 err
= PTR_ERR(inode
);
673 d_instantiate(dentry
, inode
);
678 p9_client_clunk(fid
);
684 * v9fs_vfs_link_dotl - create a hardlink for dotl
685 * @old_dentry: dentry for file to link to
686 * @dir: inode destination for new link
687 * @dentry: dentry for link
692 v9fs_vfs_link_dotl(struct dentry
*old_dentry
, struct inode
*dir
,
693 struct dentry
*dentry
)
697 struct dentry
*dir_dentry
;
698 struct p9_fid
*dfid
, *oldfid
;
699 struct v9fs_session_info
*v9ses
;
701 P9_DPRINTK(P9_DEBUG_VFS
, "dir ino: %lu, old_name: %s, new_name: %s\n",
702 dir
->i_ino
, old_dentry
->d_name
.name
,
703 dentry
->d_name
.name
);
705 v9ses
= v9fs_inode2v9ses(dir
);
706 dir_dentry
= v9fs_dentry_from_dir_inode(dir
);
707 dfid
= v9fs_fid_lookup(dir_dentry
);
709 return PTR_ERR(dfid
);
711 oldfid
= v9fs_fid_lookup(old_dentry
);
713 return PTR_ERR(oldfid
);
715 name
= (char *) dentry
->d_name
.name
;
717 err
= p9_client_link(dfid
, oldfid
, (char *)dentry
->d_name
.name
);
720 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_link failed %d\n", err
);
724 v9fs_invalidate_inode_attr(dir
);
725 if (v9ses
->cache
== CACHE_LOOSE
|| v9ses
->cache
== CACHE_FSCACHE
) {
726 /* Get the latest stat info from server. */
728 fid
= v9fs_fid_lookup(old_dentry
);
732 v9fs_refresh_inode_dotl(fid
, old_dentry
->d_inode
);
734 ihold(old_dentry
->d_inode
);
735 d_instantiate(dentry
, old_dentry
->d_inode
);
741 * v9fs_vfs_mknod_dotl - create a special file
742 * @dir: inode destination for new link
743 * @dentry: dentry for file
744 * @mode: mode for creation
745 * @rdev: device associated with special file
749 v9fs_vfs_mknod_dotl(struct inode
*dir
, struct dentry
*dentry
, int omode
,
756 struct v9fs_session_info
*v9ses
;
757 struct p9_fid
*fid
= NULL
, *dfid
= NULL
;
760 struct dentry
*dir_dentry
;
761 struct posix_acl
*dacl
= NULL
, *pacl
= NULL
;
763 P9_DPRINTK(P9_DEBUG_VFS
,
764 " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir
->i_ino
,
765 dentry
->d_name
.name
, omode
, MAJOR(rdev
), MINOR(rdev
));
767 if (!new_valid_dev(rdev
))
770 v9ses
= v9fs_inode2v9ses(dir
);
771 dir_dentry
= v9fs_dentry_from_dir_inode(dir
);
772 dfid
= v9fs_fid_lookup(dir_dentry
);
775 P9_DPRINTK(P9_DEBUG_VFS
, "fid lookup failed %d\n", err
);
780 gid
= v9fs_get_fsgid_for_create(dir
);
782 /* Update mode based on ACL value */
783 err
= v9fs_acl_mode(dir
, &mode
, &dacl
, &pacl
);
785 P9_DPRINTK(P9_DEBUG_VFS
,
786 "Failed to get acl values in mknod %d\n", err
);
789 name
= (char *) dentry
->d_name
.name
;
791 err
= p9_client_mknod_dotl(dfid
, name
, mode
, rdev
, gid
, &qid
);
795 v9fs_invalidate_inode_attr(dir
);
796 /* instantiate inode and assign the unopened fid to the dentry */
797 if (v9ses
->cache
== CACHE_LOOSE
|| v9ses
->cache
== CACHE_FSCACHE
) {
798 fid
= p9_client_walk(dfid
, 1, &name
, 1);
801 P9_DPRINTK(P9_DEBUG_VFS
, "p9_client_walk failed %d\n",
807 inode
= v9fs_get_new_inode_from_fid(v9ses
, fid
, dir
->i_sb
);
809 err
= PTR_ERR(inode
);
810 P9_DPRINTK(P9_DEBUG_VFS
, "inode creation failed %d\n",
814 err
= v9fs_fid_add(dentry
, fid
);
817 d_instantiate(dentry
, inode
);
821 * Not in cached mode. No need to populate inode with stat.
822 * socket syscall returns a fd, so we need instantiate
824 inode
= v9fs_get_inode(dir
->i_sb
, mode
, rdev
);
826 err
= PTR_ERR(inode
);
829 d_instantiate(dentry
, inode
);
831 /* Now set the ACL based on the default value */
832 v9fs_set_create_acl(dentry
, &dacl
, &pacl
);
835 p9_client_clunk(fid
);
836 v9fs_set_create_acl(NULL
, &dacl
, &pacl
);
841 * v9fs_vfs_follow_link_dotl - follow a symlink path
842 * @dentry: dentry for symlink
848 v9fs_vfs_follow_link_dotl(struct dentry
*dentry
, struct nameidata
*nd
)
852 char *link
= __getname();
855 P9_DPRINTK(P9_DEBUG_VFS
, "%s\n", dentry
->d_name
.name
);
858 link
= ERR_PTR(-ENOMEM
);
861 fid
= v9fs_fid_lookup(dentry
);
864 link
= ERR_CAST(fid
);
867 retval
= p9_client_readlink(fid
, &target
);
869 strcpy(link
, target
);
874 link
= ERR_PTR(retval
);
876 nd_set_link(nd
, link
);
880 int v9fs_refresh_inode_dotl(struct p9_fid
*fid
, struct inode
*inode
)
883 struct p9_stat_dotl
*st
;
884 struct v9fs_session_info
*v9ses
;
886 v9ses
= v9fs_inode2v9ses(inode
);
887 st
= p9_client_getattr_dotl(fid
, P9_STATS_ALL
);
891 * Don't update inode if the file type is different
893 if ((inode
->i_mode
& S_IFMT
) != (st
->st_mode
& S_IFMT
))
896 spin_lock(&inode
->i_lock
);
898 * We don't want to refresh inode->i_size,
899 * because we may have cached data
901 i_size
= inode
->i_size
;
902 v9fs_stat2inode_dotl(st
, inode
);
904 inode
->i_size
= i_size
;
905 spin_unlock(&inode
->i_lock
);
911 const struct inode_operations v9fs_dir_inode_operations_dotl
= {
912 .create
= v9fs_vfs_create_dotl
,
913 .lookup
= v9fs_vfs_lookup
,
914 .link
= v9fs_vfs_link_dotl
,
915 .symlink
= v9fs_vfs_symlink_dotl
,
916 .unlink
= v9fs_vfs_unlink
,
917 .mkdir
= v9fs_vfs_mkdir_dotl
,
918 .rmdir
= v9fs_vfs_rmdir
,
919 .mknod
= v9fs_vfs_mknod_dotl
,
920 .rename
= v9fs_vfs_rename
,
921 .getattr
= v9fs_vfs_getattr_dotl
,
922 .setattr
= v9fs_vfs_setattr_dotl
,
923 .setxattr
= generic_setxattr
,
924 .getxattr
= generic_getxattr
,
925 .removexattr
= generic_removexattr
,
926 .listxattr
= v9fs_listxattr
,
927 .get_acl
= v9fs_iop_get_acl
,
930 const struct inode_operations v9fs_file_inode_operations_dotl
= {
931 .getattr
= v9fs_vfs_getattr_dotl
,
932 .setattr
= v9fs_vfs_setattr_dotl
,
933 .setxattr
= generic_setxattr
,
934 .getxattr
= generic_getxattr
,
935 .removexattr
= generic_removexattr
,
936 .listxattr
= v9fs_listxattr
,
937 .get_acl
= v9fs_iop_get_acl
,
940 const struct inode_operations v9fs_symlink_inode_operations_dotl
= {
941 .readlink
= generic_readlink
,
942 .follow_link
= v9fs_vfs_follow_link_dotl
,
943 .put_link
= v9fs_vfs_put_link
,
944 .getattr
= v9fs_vfs_getattr_dotl
,
945 .setattr
= v9fs_vfs_setattr_dotl
,
946 .setxattr
= generic_setxattr
,
947 .getxattr
= generic_getxattr
,
948 .removexattr
= generic_removexattr
,
949 .listxattr
= v9fs_listxattr
,