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, umode_t 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();
71 static int v9fs_test_inode_dotl(struct inode *inode, void *data)
73 struct v9fs_inode *v9inode = V9FS_I(inode);
74 struct p9_stat_dotl *st = (struct p9_stat_dotl *)data;
76 /* don't match inode of different type */
77 if ((inode->i_mode & S_IFMT) != (st->st_mode & S_IFMT))
80 if (inode->i_generation != st->st_gen)
83 /* compare qid details */
84 if (memcmp(&v9inode->qid.version,
85 &st->qid.version, sizeof(v9inode->qid.version)))
88 if (v9inode->qid.type != st->qid.type)
93 /* Always get a new inode */
94 static int v9fs_test_new_inode_dotl(struct inode *inode, void *data)
99 static int v9fs_set_inode_dotl(struct inode *inode, void *data)
101 struct v9fs_inode *v9inode = V9FS_I(inode);
102 struct p9_stat_dotl *st = (struct p9_stat_dotl *)data;
104 memcpy(&v9inode->qid, &st->qid, sizeof(st->qid));
105 inode->i_generation = st->st_gen;
109 static struct inode *v9fs_qid_iget_dotl(struct super_block *sb,
112 struct p9_stat_dotl *st,
118 struct v9fs_session_info *v9ses = sb->s_fs_info;
119 int (*test)(struct inode *, void *);
122 test = v9fs_test_new_inode_dotl;
124 test = v9fs_test_inode_dotl;
126 i_ino = v9fs_qid2ino(qid);
127 inode = iget5_locked(sb, i_ino, test, v9fs_set_inode_dotl, st);
129 return ERR_PTR(-ENOMEM);
130 if (!(inode->i_state & I_NEW))
133 * initialize the inode with the stat info
134 * FIXME!! we may need support for stale inodes
137 inode->i_ino = i_ino;
138 retval = v9fs_init_inode(v9ses, inode,
139 st->st_mode, new_decode_dev(st->st_rdev));
143 v9fs_stat2inode_dotl(st, inode);
144 #ifdef CONFIG_9P_FSCACHE
145 v9fs_cache_inode_get_cookie(inode);
147 retval = v9fs_get_acl(inode, fid);
151 unlock_new_inode(inode);
154 unlock_new_inode(inode);
156 return ERR_PTR(retval);
161 v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9ses, struct p9_fid *fid,
162 struct super_block *sb, int new)
164 struct p9_stat_dotl *st;
165 struct inode *inode = NULL;
167 st = p9_client_getattr_dotl(fid, P9_STATS_BASIC | P9_STATS_GEN);
171 inode = v9fs_qid_iget_dotl(sb, &st->qid, fid, st, new);
176 struct dotl_openflag_map {
181 static int v9fs_mapped_dotl_flags(int flags)
185 struct dotl_openflag_map dotl_oflag_map[] = {
186 { O_CREAT, P9_DOTL_CREATE },
187 { O_EXCL, P9_DOTL_EXCL },
188 { O_NOCTTY, P9_DOTL_NOCTTY },
189 { O_TRUNC, P9_DOTL_TRUNC },
190 { O_APPEND, P9_DOTL_APPEND },
191 { O_NONBLOCK, P9_DOTL_NONBLOCK },
192 { O_DSYNC, P9_DOTL_DSYNC },
193 { FASYNC, P9_DOTL_FASYNC },
194 { O_DIRECT, P9_DOTL_DIRECT },
195 { O_LARGEFILE, P9_DOTL_LARGEFILE },
196 { O_DIRECTORY, P9_DOTL_DIRECTORY },
197 { O_NOFOLLOW, P9_DOTL_NOFOLLOW },
198 { O_NOATIME, P9_DOTL_NOATIME },
199 { O_CLOEXEC, P9_DOTL_CLOEXEC },
200 { O_SYNC, P9_DOTL_SYNC},
202 for (i = 0; i < ARRAY_SIZE(dotl_oflag_map); i++) {
203 if (flags & dotl_oflag_map[i].open_flag)
204 rflags |= dotl_oflag_map[i].dotl_flag;
210 * v9fs_open_to_dotl_flags- convert Linux specific open flags to
212 * @flags: flags to convert
214 int v9fs_open_to_dotl_flags(int flags)
219 * We have same bits for P9_DOTL_READONLY, P9_DOTL_WRONLY
220 * and P9_DOTL_NOACCESS
222 rflags |= flags & O_ACCMODE;
223 rflags |= v9fs_mapped_dotl_flags(flags);
229 * v9fs_vfs_create_dotl - VFS hook to create files for 9P2000.L protocol.
230 * @dir: directory inode that is being created
231 * @dentry: dentry that is being deleted
232 * @mode: create permissions
233 * @nd: path information
238 v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
239 struct nameidata *nd)
249 struct p9_fid *fid = NULL;
250 struct v9fs_inode *v9inode;
251 struct p9_fid *dfid, *ofid, *inode_fid;
252 struct v9fs_session_info *v9ses;
253 struct posix_acl *pacl = NULL, *dacl = NULL;
255 v9ses = v9fs_inode2v9ses(dir);
257 flags = nd->intent.open.flags;
260 * create call without LOOKUP_OPEN is due
261 * to mknod of regular files. So use mknod
264 return v9fs_vfs_mknod_dotl(dir, dentry, omode, 0);
267 name = (char *) dentry->d_name.name;
268 p9_debug(P9_DEBUG_VFS, "name:%s flags:0x%x mode:0x%hx\n",
271 dfid = v9fs_fid_lookup(dentry->d_parent);
274 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
278 /* clone a fid to use for creation */
279 ofid = p9_client_walk(dfid, 0, NULL, 1);
282 p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
286 gid = v9fs_get_fsgid_for_create(dir);
289 /* Update mode based on ACL value */
290 err = v9fs_acl_mode(dir, &mode, &dacl, &pacl);
292 p9_debug(P9_DEBUG_VFS, "Failed to get acl values in creat %d\n",
296 err = p9_client_create_dotl(ofid, name, v9fs_open_to_dotl_flags(flags),
299 p9_debug(P9_DEBUG_VFS, "p9_client_open_dotl failed in creat %d\n",
303 v9fs_invalidate_inode_attr(dir);
305 /* instantiate inode and assign the unopened fid to the dentry */
306 fid = p9_client_walk(dfid, 1, &name, 1);
309 p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
313 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
315 err = PTR_ERR(inode);
316 p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n", err);
319 err = v9fs_fid_add(dentry, fid);
322 d_instantiate(dentry, inode);
324 /* Now set the ACL based on the default value */
325 v9fs_set_create_acl(dentry, &dacl, &pacl);
327 v9inode = V9FS_I(inode);
328 mutex_lock(&v9inode->v_mutex);
329 if (v9ses->cache && !v9inode->writeback_fid &&
330 ((flags & O_ACCMODE) != O_RDONLY)) {
332 * clone a fid and add it to writeback_fid
333 * we do it during open time instead of
334 * page dirty time via write_begin/page_mkwrite
335 * because we want write after unlink usecase
338 inode_fid = v9fs_writeback_fid(dentry);
339 if (IS_ERR(inode_fid)) {
340 err = PTR_ERR(inode_fid);
341 mutex_unlock(&v9inode->v_mutex);
342 goto err_clunk_old_fid;
344 v9inode->writeback_fid = (void *) inode_fid;
346 mutex_unlock(&v9inode->v_mutex);
347 /* Since we are opening a file, assign the open fid to the file */
348 filp = lookup_instantiate_filp(nd, dentry, generic_file_open);
351 goto err_clunk_old_fid;
353 filp->private_data = ofid;
354 #ifdef CONFIG_9P_FSCACHE
356 v9fs_cache_inode_set_cookie(inode, filp);
362 p9_client_clunk(fid);
365 p9_client_clunk(ofid);
366 v9fs_set_create_acl(NULL, &dacl, &pacl);
371 * v9fs_vfs_mkdir_dotl - VFS mkdir hook to create a directory
372 * @dir: inode that is being unlinked
373 * @dentry: dentry that is being unlinked
374 * @mode: mode for new directory
378 static int v9fs_vfs_mkdir_dotl(struct inode *dir,
379 struct dentry *dentry, umode_t omode)
382 struct v9fs_session_info *v9ses;
383 struct p9_fid *fid = NULL, *dfid = NULL;
389 struct dentry *dir_dentry;
390 struct posix_acl *dacl = NULL, *pacl = NULL;
392 p9_debug(P9_DEBUG_VFS, "name %s\n", dentry->d_name.name);
394 v9ses = v9fs_inode2v9ses(dir);
397 if (dir->i_mode & S_ISGID)
400 dir_dentry = dentry->d_parent;
401 dfid = v9fs_fid_lookup(dir_dentry);
404 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
409 gid = v9fs_get_fsgid_for_create(dir);
411 /* Update mode based on ACL value */
412 err = v9fs_acl_mode(dir, &mode, &dacl, &pacl);
414 p9_debug(P9_DEBUG_VFS, "Failed to get acl values in mkdir %d\n",
418 name = (char *) dentry->d_name.name;
419 err = p9_client_mkdir_dotl(dfid, name, mode, gid, &qid);
423 /* instantiate inode and assign the unopened fid to the dentry */
424 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
425 fid = p9_client_walk(dfid, 1, &name, 1);
428 p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n",
434 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
436 err = PTR_ERR(inode);
437 p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n",
441 err = v9fs_fid_add(dentry, fid);
444 d_instantiate(dentry, inode);
448 * Not in cached mode. No need to populate
449 * inode with stat. We need to get an inode
450 * so that we can set the acl with dentry
452 inode = v9fs_get_inode(dir->i_sb, mode, 0);
454 err = PTR_ERR(inode);
457 d_instantiate(dentry, inode);
459 /* Now set the ACL based on the default value */
460 v9fs_set_create_acl(dentry, &dacl, &pacl);
462 v9fs_invalidate_inode_attr(dir);
465 p9_client_clunk(fid);
466 v9fs_set_create_acl(NULL, &dacl, &pacl);
471 v9fs_vfs_getattr_dotl(struct vfsmount *mnt, struct dentry *dentry,
475 struct v9fs_session_info *v9ses;
477 struct p9_stat_dotl *st;
479 p9_debug(P9_DEBUG_VFS, "dentry: %p\n", dentry);
481 v9ses = v9fs_dentry2v9ses(dentry);
482 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
483 generic_fillattr(dentry->d_inode, stat);
486 fid = v9fs_fid_lookup(dentry);
490 /* Ask for all the fields in stat structure. Server will return
491 * whatever it supports
494 st = p9_client_getattr_dotl(fid, P9_STATS_ALL);
498 v9fs_stat2inode_dotl(st, dentry->d_inode);
499 generic_fillattr(dentry->d_inode, stat);
500 /* Change block size to what the server returned */
501 stat->blksize = st->st_blksize;
510 #define P9_ATTR_MODE (1 << 0)
511 #define P9_ATTR_UID (1 << 1)
512 #define P9_ATTR_GID (1 << 2)
513 #define P9_ATTR_SIZE (1 << 3)
514 #define P9_ATTR_ATIME (1 << 4)
515 #define P9_ATTR_MTIME (1 << 5)
516 #define P9_ATTR_CTIME (1 << 6)
517 #define P9_ATTR_ATIME_SET (1 << 7)
518 #define P9_ATTR_MTIME_SET (1 << 8)
520 struct dotl_iattr_map {
525 static int v9fs_mapped_iattr_valid(int iattr_valid)
528 int p9_iattr_valid = 0;
529 struct dotl_iattr_map dotl_iattr_map[] = {
530 { ATTR_MODE, P9_ATTR_MODE },
531 { ATTR_UID, P9_ATTR_UID },
532 { ATTR_GID, P9_ATTR_GID },
533 { ATTR_SIZE, P9_ATTR_SIZE },
534 { ATTR_ATIME, P9_ATTR_ATIME },
535 { ATTR_MTIME, P9_ATTR_MTIME },
536 { ATTR_CTIME, P9_ATTR_CTIME },
537 { ATTR_ATIME_SET, P9_ATTR_ATIME_SET },
538 { ATTR_MTIME_SET, P9_ATTR_MTIME_SET },
540 for (i = 0; i < ARRAY_SIZE(dotl_iattr_map); i++) {
541 if (iattr_valid & dotl_iattr_map[i].iattr_valid)
542 p9_iattr_valid |= dotl_iattr_map[i].p9_iattr_valid;
544 return p9_iattr_valid;
548 * v9fs_vfs_setattr_dotl - set file metadata
549 * @dentry: file whose metadata to set
550 * @iattr: metadata assignment structure
554 int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
557 struct v9fs_session_info *v9ses;
559 struct p9_iattr_dotl p9attr;
561 p9_debug(P9_DEBUG_VFS, "\n");
563 retval = inode_change_ok(dentry->d_inode, iattr);
567 p9attr.valid = v9fs_mapped_iattr_valid(iattr->ia_valid);
568 p9attr.mode = iattr->ia_mode;
569 p9attr.uid = iattr->ia_uid;
570 p9attr.gid = iattr->ia_gid;
571 p9attr.size = iattr->ia_size;
572 p9attr.atime_sec = iattr->ia_atime.tv_sec;
573 p9attr.atime_nsec = iattr->ia_atime.tv_nsec;
574 p9attr.mtime_sec = iattr->ia_mtime.tv_sec;
575 p9attr.mtime_nsec = iattr->ia_mtime.tv_nsec;
578 v9ses = v9fs_dentry2v9ses(dentry);
579 fid = v9fs_fid_lookup(dentry);
583 /* Write all dirty data */
584 if (S_ISREG(dentry->d_inode->i_mode))
585 filemap_write_and_wait(dentry->d_inode->i_mapping);
587 retval = p9_client_setattr(fid, &p9attr);
591 if ((iattr->ia_valid & ATTR_SIZE) &&
592 iattr->ia_size != i_size_read(dentry->d_inode))
593 truncate_setsize(dentry->d_inode, iattr->ia_size);
595 v9fs_invalidate_inode_attr(dentry->d_inode);
596 setattr_copy(dentry->d_inode, iattr);
597 mark_inode_dirty(dentry->d_inode);
598 if (iattr->ia_valid & ATTR_MODE) {
599 /* We also want to update ACL when we update mode bits */
600 retval = v9fs_acl_chmod(dentry);
608 * v9fs_stat2inode_dotl - populate an inode structure with stat info
609 * @stat: stat structure
610 * @inode: inode to populate
611 * @sb: superblock of filesystem
616 v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode)
619 struct v9fs_inode *v9inode = V9FS_I(inode);
621 if ((stat->st_result_mask & P9_STATS_BASIC) == P9_STATS_BASIC) {
622 inode->i_atime.tv_sec = stat->st_atime_sec;
623 inode->i_atime.tv_nsec = stat->st_atime_nsec;
624 inode->i_mtime.tv_sec = stat->st_mtime_sec;
625 inode->i_mtime.tv_nsec = stat->st_mtime_nsec;
626 inode->i_ctime.tv_sec = stat->st_ctime_sec;
627 inode->i_ctime.tv_nsec = stat->st_ctime_nsec;
628 inode->i_uid = stat->st_uid;
629 inode->i_gid = stat->st_gid;
630 set_nlink(inode, stat->st_nlink);
632 mode = stat->st_mode & S_IALLUGO;
633 mode |= inode->i_mode & ~S_IALLUGO;
634 inode->i_mode = mode;
636 i_size_write(inode, stat->st_size);
637 inode->i_blocks = stat->st_blocks;
639 if (stat->st_result_mask & P9_STATS_ATIME) {
640 inode->i_atime.tv_sec = stat->st_atime_sec;
641 inode->i_atime.tv_nsec = stat->st_atime_nsec;
643 if (stat->st_result_mask & P9_STATS_MTIME) {
644 inode->i_mtime.tv_sec = stat->st_mtime_sec;
645 inode->i_mtime.tv_nsec = stat->st_mtime_nsec;
647 if (stat->st_result_mask & P9_STATS_CTIME) {
648 inode->i_ctime.tv_sec = stat->st_ctime_sec;
649 inode->i_ctime.tv_nsec = stat->st_ctime_nsec;
651 if (stat->st_result_mask & P9_STATS_UID)
652 inode->i_uid = stat->st_uid;
653 if (stat->st_result_mask & P9_STATS_GID)
654 inode->i_gid = stat->st_gid;
655 if (stat->st_result_mask & P9_STATS_NLINK)
656 set_nlink(inode, stat->st_nlink);
657 if (stat->st_result_mask & P9_STATS_MODE) {
658 inode->i_mode = stat->st_mode;
659 if ((S_ISBLK(inode->i_mode)) ||
660 (S_ISCHR(inode->i_mode)))
661 init_special_inode(inode, inode->i_mode,
664 if (stat->st_result_mask & P9_STATS_RDEV)
665 inode->i_rdev = new_decode_dev(stat->st_rdev);
666 if (stat->st_result_mask & P9_STATS_SIZE)
667 i_size_write(inode, stat->st_size);
668 if (stat->st_result_mask & P9_STATS_BLOCKS)
669 inode->i_blocks = stat->st_blocks;
671 if (stat->st_result_mask & P9_STATS_GEN)
672 inode->i_generation = stat->st_gen;
674 /* Currently we don't support P9_STATS_BTIME and P9_STATS_DATA_VERSION
675 * because the inode structure does not have fields for them.
677 v9inode->cache_validity &= ~V9FS_INO_INVALID_ATTR;
681 v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry,
690 struct p9_fid *fid = NULL;
691 struct v9fs_session_info *v9ses;
693 name = (char *) dentry->d_name.name;
694 p9_debug(P9_DEBUG_VFS, "%lu,%s,%s\n", dir->i_ino, name, symname);
695 v9ses = v9fs_inode2v9ses(dir);
697 dfid = v9fs_fid_lookup(dentry->d_parent);
700 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
704 gid = v9fs_get_fsgid_for_create(dir);
706 /* Server doesn't alter fid on TSYMLINK. Hence no need to clone it. */
707 err = p9_client_symlink(dfid, name, (char *)symname, gid, &qid);
710 p9_debug(P9_DEBUG_VFS, "p9_client_symlink failed %d\n", err);
714 v9fs_invalidate_inode_attr(dir);
716 /* Now walk from the parent so we can get an unopened fid. */
717 fid = p9_client_walk(dfid, 1, &name, 1);
720 p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n",
726 /* instantiate inode and assign the unopened fid to dentry */
727 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
729 err = PTR_ERR(inode);
730 p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n",
734 err = v9fs_fid_add(dentry, fid);
737 d_instantiate(dentry, inode);
740 /* Not in cached mode. No need to populate inode with stat */
741 inode = v9fs_get_inode(dir->i_sb, S_IFLNK, 0);
743 err = PTR_ERR(inode);
746 d_instantiate(dentry, inode);
751 p9_client_clunk(fid);
757 * v9fs_vfs_link_dotl - create a hardlink for dotl
758 * @old_dentry: dentry for file to link to
759 * @dir: inode destination for new link
760 * @dentry: dentry for link
765 v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir,
766 struct dentry *dentry)
770 struct dentry *dir_dentry;
771 struct p9_fid *dfid, *oldfid;
772 struct v9fs_session_info *v9ses;
774 p9_debug(P9_DEBUG_VFS, "dir ino: %lu, old_name: %s, new_name: %s\n",
775 dir->i_ino, old_dentry->d_name.name, dentry->d_name.name);
777 v9ses = v9fs_inode2v9ses(dir);
778 dir_dentry = dentry->d_parent;
779 dfid = v9fs_fid_lookup(dir_dentry);
781 return PTR_ERR(dfid);
783 oldfid = v9fs_fid_lookup(old_dentry);
785 return PTR_ERR(oldfid);
787 name = (char *) dentry->d_name.name;
789 err = p9_client_link(dfid, oldfid, (char *)dentry->d_name.name);
792 p9_debug(P9_DEBUG_VFS, "p9_client_link failed %d\n", err);
796 v9fs_invalidate_inode_attr(dir);
797 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
798 /* Get the latest stat info from server. */
800 fid = v9fs_fid_lookup(old_dentry);
804 v9fs_refresh_inode_dotl(fid, old_dentry->d_inode);
806 ihold(old_dentry->d_inode);
807 d_instantiate(dentry, old_dentry->d_inode);
813 * v9fs_vfs_mknod_dotl - create a special file
814 * @dir: inode destination for new link
815 * @dentry: dentry for file
816 * @mode: mode for creation
817 * @rdev: device associated with special file
821 v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
828 struct v9fs_session_info *v9ses;
829 struct p9_fid *fid = NULL, *dfid = NULL;
832 struct dentry *dir_dentry;
833 struct posix_acl *dacl = NULL, *pacl = NULL;
835 p9_debug(P9_DEBUG_VFS, " %lu,%s mode: %hx MAJOR: %u MINOR: %u\n",
836 dir->i_ino, dentry->d_name.name, omode,
837 MAJOR(rdev), MINOR(rdev));
839 if (!new_valid_dev(rdev))
842 v9ses = v9fs_inode2v9ses(dir);
843 dir_dentry = dentry->d_parent;
844 dfid = v9fs_fid_lookup(dir_dentry);
847 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
852 gid = v9fs_get_fsgid_for_create(dir);
854 /* Update mode based on ACL value */
855 err = v9fs_acl_mode(dir, &mode, &dacl, &pacl);
857 p9_debug(P9_DEBUG_VFS, "Failed to get acl values in mknod %d\n",
861 name = (char *) dentry->d_name.name;
863 err = p9_client_mknod_dotl(dfid, name, mode, rdev, gid, &qid);
867 v9fs_invalidate_inode_attr(dir);
868 /* instantiate inode and assign the unopened fid to the dentry */
869 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
870 fid = p9_client_walk(dfid, 1, &name, 1);
873 p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n",
879 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
881 err = PTR_ERR(inode);
882 p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n",
886 err = v9fs_fid_add(dentry, fid);
889 d_instantiate(dentry, inode);
893 * Not in cached mode. No need to populate inode with stat.
894 * socket syscall returns a fd, so we need instantiate
896 inode = v9fs_get_inode(dir->i_sb, mode, rdev);
898 err = PTR_ERR(inode);
901 d_instantiate(dentry, inode);
903 /* Now set the ACL based on the default value */
904 v9fs_set_create_acl(dentry, &dacl, &pacl);
907 p9_client_clunk(fid);
908 v9fs_set_create_acl(NULL, &dacl, &pacl);
913 * v9fs_vfs_follow_link_dotl - follow a symlink path
914 * @dentry: dentry for symlink
920 v9fs_vfs_follow_link_dotl(struct dentry *dentry, struct nameidata *nd)
924 char *link = __getname();
927 p9_debug(P9_DEBUG_VFS, "%s\n", dentry->d_name.name);
930 link = ERR_PTR(-ENOMEM);
933 fid = v9fs_fid_lookup(dentry);
936 link = ERR_CAST(fid);
939 retval = p9_client_readlink(fid, &target);
941 strcpy(link, target);
946 link = ERR_PTR(retval);
948 nd_set_link(nd, link);
952 int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode)
955 struct p9_stat_dotl *st;
956 struct v9fs_session_info *v9ses;
958 v9ses = v9fs_inode2v9ses(inode);
959 st = p9_client_getattr_dotl(fid, P9_STATS_ALL);
963 * Don't update inode if the file type is different
965 if ((inode->i_mode & S_IFMT) != (st->st_mode & S_IFMT))
968 spin_lock(&inode->i_lock);
970 * We don't want to refresh inode->i_size,
971 * because we may have cached data
973 i_size = inode->i_size;
974 v9fs_stat2inode_dotl(st, inode);
976 inode->i_size = i_size;
977 spin_unlock(&inode->i_lock);
983 const struct inode_operations v9fs_dir_inode_operations_dotl = {
984 .create = v9fs_vfs_create_dotl,
985 .lookup = v9fs_vfs_lookup,
986 .link = v9fs_vfs_link_dotl,
987 .symlink = v9fs_vfs_symlink_dotl,
988 .unlink = v9fs_vfs_unlink,
989 .mkdir = v9fs_vfs_mkdir_dotl,
990 .rmdir = v9fs_vfs_rmdir,
991 .mknod = v9fs_vfs_mknod_dotl,
992 .rename = v9fs_vfs_rename,
993 .getattr = v9fs_vfs_getattr_dotl,
994 .setattr = v9fs_vfs_setattr_dotl,
995 .setxattr = generic_setxattr,
996 .getxattr = generic_getxattr,
997 .removexattr = generic_removexattr,
998 .listxattr = v9fs_listxattr,
999 .get_acl = v9fs_iop_get_acl,
1002 const struct inode_operations v9fs_file_inode_operations_dotl = {
1003 .getattr = v9fs_vfs_getattr_dotl,
1004 .setattr = v9fs_vfs_setattr_dotl,
1005 .setxattr = generic_setxattr,
1006 .getxattr = generic_getxattr,
1007 .removexattr = generic_removexattr,
1008 .listxattr = v9fs_listxattr,
1009 .get_acl = v9fs_iop_get_acl,
1012 const struct inode_operations v9fs_symlink_inode_operations_dotl = {
1013 .readlink = generic_readlink,
1014 .follow_link = v9fs_vfs_follow_link_dotl,
1015 .put_link = v9fs_vfs_put_link,
1016 .getattr = v9fs_vfs_getattr_dotl,
1017 .setattr = v9fs_vfs_setattr_dotl,
1018 .setxattr = generic_setxattr,
1019 .getxattr = generic_getxattr,
1020 .removexattr = generic_removexattr,
1021 .listxattr = v9fs_listxattr,