2 * linux/fs/9p/vfs_inode.c
4 * This file contains vfs inode ops for the 9P2000 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>
50 static const struct inode_operations v9fs_dir_inode_operations;
51 static const struct inode_operations v9fs_dir_inode_operations_dotu;
52 static const struct inode_operations v9fs_dir_inode_operations_dotl;
53 static const struct inode_operations v9fs_file_inode_operations;
54 static const struct inode_operations v9fs_file_inode_operations_dotl;
55 static const struct inode_operations v9fs_symlink_inode_operations;
56 static const struct inode_operations v9fs_symlink_inode_operations_dotl;
59 * unixmode2p9mode - convert unix mode bits to plan 9
60 * @v9ses: v9fs session information
61 * @mode: mode to convert
65 static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode)
71 if (v9fs_proto_dotu(v9ses)) {
74 if (v9ses->nodev == 0) {
78 res |= P9_DMNAMEDPIPE;
85 if ((mode & S_ISUID) == S_ISUID)
87 if ((mode & S_ISGID) == S_ISGID)
89 if ((mode & S_ISVTX) == S_ISVTX)
91 if ((mode & P9_DMLINK))
99 * p9mode2unixmode- convert plan9 mode bits to unix mode bits
100 * @v9ses: v9fs session information
101 * @mode: mode to convert
105 static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode)
111 if ((mode & P9_DMDIR) == P9_DMDIR)
113 else if ((mode & P9_DMSYMLINK) && (v9fs_proto_dotu(v9ses)))
115 else if ((mode & P9_DMSOCKET) && (v9fs_proto_dotu(v9ses))
116 && (v9ses->nodev == 0))
118 else if ((mode & P9_DMNAMEDPIPE) && (v9fs_proto_dotu(v9ses))
119 && (v9ses->nodev == 0))
121 else if ((mode & P9_DMDEVICE) && (v9fs_proto_dotu(v9ses))
122 && (v9ses->nodev == 0))
127 if (v9fs_proto_dotu(v9ses)) {
128 if ((mode & P9_DMSETUID) == P9_DMSETUID)
131 if ((mode & P9_DMSETGID) == P9_DMSETGID)
134 if ((mode & P9_DMSETVTX) == P9_DMSETVTX)
142 * v9fs_uflags2omode- convert posix open flags to plan 9 mode bits
143 * @uflags: flags to convert
144 * @extended: if .u extensions are active
147 int v9fs_uflags2omode(int uflags, int extended)
167 if (uflags & O_TRUNC)
174 if (uflags & O_APPEND)
182 * v9fs_blank_wstat - helper function to setup a 9P stat structure
183 * @wstat: structure to initialize
188 v9fs_blank_wstat(struct p9_wstat *wstat)
192 wstat->qid.type = ~0;
193 wstat->qid.version = ~0;
194 *((long long *)&wstat->qid.path) = ~0;
206 wstat->extension = NULL;
209 #ifdef CONFIG_9P_FSCACHE
211 * v9fs_alloc_inode - helper function to allocate an inode
212 * This callback is executed before setting up the inode so that we
213 * can associate a vcookie with each inode.
217 struct inode *v9fs_alloc_inode(struct super_block *sb)
219 struct v9fs_cookie *vcookie;
220 vcookie = (struct v9fs_cookie *)kmem_cache_alloc(vcookie_cache,
225 vcookie->fscache = NULL;
227 spin_lock_init(&vcookie->lock);
228 return &vcookie->inode;
232 * v9fs_destroy_inode - destroy an inode
236 void v9fs_destroy_inode(struct inode *inode)
238 kmem_cache_free(vcookie_cache, v9fs_inode2cookie(inode));
243 * v9fs_get_fsgid_for_create - Helper function to get the gid for creating a
244 * new file system object. This checks the S_ISGID to determine the owning
245 * group of the new file system object.
248 static gid_t v9fs_get_fsgid_for_create(struct inode *dir_inode)
250 BUG_ON(dir_inode == NULL);
252 if (dir_inode->i_mode & S_ISGID) {
253 /* set_gid bit is set.*/
254 return dir_inode->i_gid;
256 return current_fsgid();
260 * v9fs_dentry_from_dir_inode - helper function to get the dentry from
265 static struct dentry *v9fs_dentry_from_dir_inode(struct inode *inode)
267 struct dentry *dentry;
269 spin_lock(&dcache_lock);
270 /* Directory should have only one entry. */
271 BUG_ON(S_ISDIR(inode->i_mode) && !list_is_singular(&inode->i_dentry));
272 dentry = list_entry(inode->i_dentry.next, struct dentry, d_alias);
273 spin_unlock(&dcache_lock);
278 * v9fs_get_inode - helper function to setup an inode
280 * @mode: mode to setup inode with
284 struct inode *v9fs_get_inode(struct super_block *sb, int mode)
288 struct v9fs_session_info *v9ses = sb->s_fs_info;
290 P9_DPRINTK(P9_DEBUG_VFS, "super block: %p mode: %o\n", sb, mode);
292 inode = new_inode(sb);
294 P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n");
295 return ERR_PTR(-ENOMEM);
298 inode_init_owner(inode, NULL, mode);
301 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
302 inode->i_mapping->a_ops = &v9fs_addr_operations;
304 switch (mode & S_IFMT) {
309 if (v9fs_proto_dotl(v9ses)) {
310 inode->i_op = &v9fs_file_inode_operations_dotl;
311 inode->i_fop = &v9fs_file_operations_dotl;
312 } else if (v9fs_proto_dotu(v9ses)) {
313 inode->i_op = &v9fs_file_inode_operations;
314 inode->i_fop = &v9fs_file_operations;
316 P9_DPRINTK(P9_DEBUG_ERROR,
317 "special files without extended mode\n");
321 init_special_inode(inode, inode->i_mode, inode->i_rdev);
324 if (v9fs_proto_dotl(v9ses)) {
325 inode->i_op = &v9fs_file_inode_operations_dotl;
326 inode->i_fop = &v9fs_file_operations_dotl;
328 inode->i_op = &v9fs_file_inode_operations;
329 inode->i_fop = &v9fs_file_operations;
335 if (!v9fs_proto_dotu(v9ses) && !v9fs_proto_dotl(v9ses)) {
336 P9_DPRINTK(P9_DEBUG_ERROR, "extended modes used with "
337 "legacy protocol.\n");
342 if (v9fs_proto_dotl(v9ses))
343 inode->i_op = &v9fs_symlink_inode_operations_dotl;
345 inode->i_op = &v9fs_symlink_inode_operations;
350 if (v9fs_proto_dotl(v9ses))
351 inode->i_op = &v9fs_dir_inode_operations_dotl;
352 else if (v9fs_proto_dotu(v9ses))
353 inode->i_op = &v9fs_dir_inode_operations_dotu;
355 inode->i_op = &v9fs_dir_inode_operations;
357 if (v9fs_proto_dotl(v9ses))
358 inode->i_fop = &v9fs_dir_operations_dotl;
360 inode->i_fop = &v9fs_dir_operations;
364 P9_DPRINTK(P9_DEBUG_ERROR, "BAD mode 0x%x S_IFMT 0x%x\n",
365 mode, mode & S_IFMT);
378 static struct v9fs_fid*
379 v9fs_clone_walk(struct v9fs_session_info *v9ses, u32 fid, struct dentry *dentry)
383 struct v9fs_fid *ret;
384 struct v9fs_fcall *fcall;
386 nfid = v9fs_get_idpool(&v9ses->fidpool);
388 eprintk(KERN_WARNING, "no free fids available\n");
389 return ERR_PTR(-ENOSPC);
392 err = v9fs_t_walk(v9ses, fid, nfid, (char *) dentry->d_name.name,
396 if (fcall && fcall->id == RWALK)
399 PRINT_FCALL_ERROR("walk error", fcall);
400 v9fs_put_idpool(nfid, &v9ses->fidpool);
406 ret = v9fs_fid_create(v9ses, nfid);
412 err = v9fs_fid_insert(ret, dentry);
414 v9fs_fid_destroy(ret);
421 v9fs_t_clunk(v9ses, nfid);
431 * v9fs_clear_inode - release an inode
432 * @inode: inode to release
435 void v9fs_evict_inode(struct inode *inode)
437 truncate_inode_pages(inode->i_mapping, 0);
438 end_writeback(inode);
439 filemap_fdatawrite(inode->i_mapping);
441 #ifdef CONFIG_9P_FSCACHE
442 v9fs_cache_inode_put_cookie(inode);
446 static struct inode *
447 v9fs_inode(struct v9fs_session_info *v9ses, struct p9_fid *fid,
448 struct super_block *sb)
451 struct inode *ret = NULL;
454 st = p9_client_stat(fid);
458 umode = p9mode2unixmode(v9ses, st->mode);
459 ret = v9fs_get_inode(sb, umode);
465 v9fs_stat2inode(st, ret, sb);
466 ret->i_ino = v9fs_qid2ino(&st->qid);
468 #ifdef CONFIG_9P_FSCACHE
469 v9fs_vcookie_set_qid(ret, &st->qid);
470 v9fs_cache_inode_get_cookie(ret);
481 static struct inode *
482 v9fs_inode_dotl(struct v9fs_session_info *v9ses, struct p9_fid *fid,
483 struct super_block *sb)
485 struct inode *ret = NULL;
487 struct p9_stat_dotl *st;
489 st = p9_client_getattr_dotl(fid, P9_STATS_BASIC);
493 ret = v9fs_get_inode(sb, st->st_mode);
499 v9fs_stat2inode_dotl(st, ret);
500 ret->i_ino = v9fs_qid2ino(&st->qid);
501 #ifdef CONFIG_9P_FSCACHE
502 v9fs_vcookie_set_qid(ret, &st->qid);
503 v9fs_cache_inode_get_cookie(ret);
505 err = v9fs_get_acl(ret, fid);
518 * v9fs_inode_from_fid - Helper routine to populate an inode by
519 * issuing a attribute request
520 * @v9ses: session information
521 * @fid: fid to issue attribute request for
522 * @sb: superblock on which to create inode
525 static inline struct inode *
526 v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
527 struct super_block *sb)
529 if (v9fs_proto_dotl(v9ses))
530 return v9fs_inode_dotl(v9ses, fid, sb);
532 return v9fs_inode(v9ses, fid, sb);
536 * v9fs_remove - helper function to remove files and directories
537 * @dir: directory inode that is being deleted
538 * @file: dentry that is being deleted
539 * @rmdir: removing a directory
543 static int v9fs_remove(struct inode *dir, struct dentry *file, int rmdir)
546 struct inode *file_inode;
547 struct p9_fid *v9fid;
549 P9_DPRINTK(P9_DEBUG_VFS, "inode: %p dentry: %p rmdir: %d\n", dir, file,
552 file_inode = file->d_inode;
553 v9fid = v9fs_fid_clone(file);
555 return PTR_ERR(v9fid);
557 retval = p9_client_remove(v9fid);
559 drop_nlink(file_inode);
564 v9fs_open_created(struct inode *inode, struct file *file)
571 * v9fs_create - Create a file
572 * @v9ses: session information
573 * @dir: directory that dentry is being created in
574 * @dentry: dentry that is being created
575 * @extension: 9p2000.u extension string to support devices, etc.
576 * @perm: create permissions
580 static struct p9_fid *
581 v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
582 struct dentry *dentry, char *extension, u32 perm, u8 mode)
586 struct p9_fid *dfid, *ofid, *fid;
589 P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", dentry->d_name.name);
594 name = (char *) dentry->d_name.name;
595 dfid = v9fs_fid_lookup(dentry->d_parent);
598 P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
602 /* clone a fid to use for creation */
603 ofid = p9_client_walk(dfid, 0, NULL, 1);
606 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
610 err = p9_client_fcreate(ofid, name, perm, mode, extension);
612 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_fcreate failed %d\n", err);
616 /* now walk from the parent so we can get unopened fid */
617 fid = p9_client_walk(dfid, 1, &name, 1);
620 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
625 /* instantiate inode and assign the unopened fid to the dentry */
626 inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb);
628 err = PTR_ERR(inode);
629 P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err);
634 dentry->d_op = &v9fs_cached_dentry_operations;
636 dentry->d_op = &v9fs_dentry_operations;
638 d_instantiate(dentry, inode);
639 err = v9fs_fid_add(dentry, fid);
647 p9_client_clunk(ofid);
650 p9_client_clunk(fid);
656 * v9fs_vfs_create_dotl - VFS hook to create files for 9P2000.L protocol.
657 * @dir: directory inode that is being created
658 * @dentry: dentry that is being deleted
659 * @mode: create permissions
660 * @nd: path information
665 v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int mode,
666 struct nameidata *nd)
672 struct v9fs_session_info *v9ses;
673 struct p9_fid *fid = NULL;
674 struct p9_fid *dfid, *ofid;
679 v9ses = v9fs_inode2v9ses(dir);
680 if (nd && nd->flags & LOOKUP_OPEN)
681 flags = nd->intent.open.flags - 1;
685 name = (char *) dentry->d_name.name;
686 P9_DPRINTK(P9_DEBUG_VFS, "v9fs_vfs_create_dotl: name:%s flags:0x%x "
687 "mode:0x%x\n", name, flags, mode);
689 dfid = v9fs_fid_lookup(dentry->d_parent);
692 P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
696 /* clone a fid to use for creation */
697 ofid = p9_client_walk(dfid, 0, NULL, 1);
700 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
704 gid = v9fs_get_fsgid_for_create(dir);
705 err = p9_client_create_dotl(ofid, name, flags, mode, gid, &qid);
707 P9_DPRINTK(P9_DEBUG_VFS,
708 "p9_client_open_dotl failed in creat %d\n",
713 /* No need to populate the inode if we are not opening the file AND
714 * not in cached mode.
716 if (!v9ses->cache && !(nd && nd->flags & LOOKUP_OPEN)) {
717 /* Not in cached mode. No need to populate inode with stat */
718 dentry->d_op = &v9fs_dentry_operations;
719 p9_client_clunk(ofid);
720 d_instantiate(dentry, NULL);
724 /* Now walk from the parent so we can get an unopened fid. */
725 fid = p9_client_walk(dfid, 1, &name, 1);
728 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
733 /* instantiate inode and assign the unopened fid to dentry */
734 inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb);
736 err = PTR_ERR(inode);
737 P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err);
741 dentry->d_op = &v9fs_cached_dentry_operations;
743 dentry->d_op = &v9fs_dentry_operations;
744 d_instantiate(dentry, inode);
745 err = v9fs_fid_add(dentry, fid);
749 /* if we are opening a file, assign the open fid to the file */
750 if (nd && nd->flags & LOOKUP_OPEN) {
751 filp = lookup_instantiate_filp(nd, dentry, v9fs_open_created);
753 p9_client_clunk(ofid);
754 return PTR_ERR(filp);
756 filp->private_data = ofid;
758 p9_client_clunk(ofid);
764 p9_client_clunk(ofid);
766 p9_client_clunk(fid);
771 * v9fs_vfs_create - VFS hook to create files
772 * @dir: directory inode that is being created
773 * @dentry: dentry that is being deleted
774 * @mode: create permissions
775 * @nd: path information
780 v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode,
781 struct nameidata *nd)
786 struct v9fs_session_info *v9ses;
792 v9ses = v9fs_inode2v9ses(dir);
793 perm = unixmode2p9mode(v9ses, mode);
794 if (nd && nd->flags & LOOKUP_OPEN)
795 flags = nd->intent.open.flags - 1;
799 fid = v9fs_create(v9ses, dir, dentry, NULL, perm,
800 v9fs_uflags2omode(flags,
801 v9fs_proto_dotu(v9ses)));
808 /* if we are opening a file, assign the open fid to the file */
809 if (nd && nd->flags & LOOKUP_OPEN) {
810 filp = lookup_instantiate_filp(nd, dentry, v9fs_open_created);
816 filp->private_data = fid;
818 p9_client_clunk(fid);
824 p9_client_clunk(fid);
830 * v9fs_vfs_mkdir - VFS mkdir hook to create a directory
831 * @dir: inode that is being unlinked
832 * @dentry: dentry that is being unlinked
833 * @mode: mode for new directory
837 static int v9fs_vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
841 struct v9fs_session_info *v9ses;
844 P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", dentry->d_name.name);
846 v9ses = v9fs_inode2v9ses(dir);
847 perm = unixmode2p9mode(v9ses, mode | S_IFDIR);
848 fid = v9fs_create(v9ses, dir, dentry, NULL, perm, P9_OREAD);
855 p9_client_clunk(fid);
862 * v9fs_vfs_mkdir_dotl - VFS mkdir hook to create a directory
863 * @dir: inode that is being unlinked
864 * @dentry: dentry that is being unlinked
865 * @mode: mode for new directory
869 static int v9fs_vfs_mkdir_dotl(struct inode *dir, struct dentry *dentry,
873 struct v9fs_session_info *v9ses;
874 struct p9_fid *fid = NULL, *dfid = NULL;
879 struct dentry *dir_dentry;
881 P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", dentry->d_name.name);
883 v9ses = v9fs_inode2v9ses(dir);
886 if (dir->i_mode & S_ISGID)
888 dir_dentry = v9fs_dentry_from_dir_inode(dir);
889 dfid = v9fs_fid_lookup(dir_dentry);
892 P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
897 gid = v9fs_get_fsgid_for_create(dir);
899 name = (char *) dentry->d_name.name;
900 err = p9_client_mkdir_dotl(dfid, name, mode, gid, &qid);
904 /* instantiate inode and assign the unopened fid to the dentry */
905 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
906 fid = p9_client_walk(dfid, 1, &name, 1);
909 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n",
915 inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb);
917 err = PTR_ERR(inode);
918 P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n",
922 dentry->d_op = &v9fs_cached_dentry_operations;
923 d_instantiate(dentry, inode);
924 err = v9fs_fid_add(dentry, fid);
931 p9_client_clunk(fid);
936 * v9fs_vfs_lookup - VFS lookup hook to "walk" to a new inode
937 * @dir: inode that is being walked from
938 * @dentry: dentry that is being walked to?
939 * @nameidata: path data
943 static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
944 struct nameidata *nameidata)
946 struct super_block *sb;
947 struct v9fs_session_info *v9ses;
948 struct p9_fid *dfid, *fid;
953 P9_DPRINTK(P9_DEBUG_VFS, "dir: %p dentry: (%s) %p nameidata: %p\n",
954 dir, dentry->d_name.name, dentry, nameidata);
956 if (dentry->d_name.len > NAME_MAX)
957 return ERR_PTR(-ENAMETOOLONG);
960 v9ses = v9fs_inode2v9ses(dir);
961 /* We can walk d_parent because we hold the dir->i_mutex */
962 dfid = v9fs_fid_lookup(dentry->d_parent);
964 return ERR_CAST(dfid);
966 name = (char *) dentry->d_name.name;
967 fid = p9_client_walk(dfid, 1, &name, 1);
969 result = PTR_ERR(fid);
970 if (result == -ENOENT) {
975 return ERR_PTR(result);
978 inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb);
980 result = PTR_ERR(inode);
985 result = v9fs_fid_add(dentry, fid);
991 dentry->d_op = &v9fs_cached_dentry_operations;
993 dentry->d_op = &v9fs_dentry_operations;
995 d_add(dentry, inode);
999 p9_client_clunk(fid);
1001 return ERR_PTR(result);
1005 * v9fs_vfs_unlink - VFS unlink hook to delete an inode
1006 * @i: inode that is being unlinked
1007 * @d: dentry that is being unlinked
1011 static int v9fs_vfs_unlink(struct inode *i, struct dentry *d)
1013 return v9fs_remove(i, d, 0);
1017 * v9fs_vfs_rmdir - VFS unlink hook to delete a directory
1018 * @i: inode that is being unlinked
1019 * @d: dentry that is being unlinked
1023 static int v9fs_vfs_rmdir(struct inode *i, struct dentry *d)
1025 return v9fs_remove(i, d, 1);
1029 * v9fs_vfs_rename - VFS hook to rename an inode
1030 * @old_dir: old dir inode
1031 * @old_dentry: old dentry
1032 * @new_dir: new dir inode
1033 * @new_dentry: new dentry
1038 v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1039 struct inode *new_dir, struct dentry *new_dentry)
1041 struct inode *old_inode;
1042 struct v9fs_session_info *v9ses;
1043 struct p9_fid *oldfid;
1044 struct p9_fid *olddirfid;
1045 struct p9_fid *newdirfid;
1046 struct p9_wstat wstat;
1049 P9_DPRINTK(P9_DEBUG_VFS, "\n");
1051 old_inode = old_dentry->d_inode;
1052 v9ses = v9fs_inode2v9ses(old_inode);
1053 oldfid = v9fs_fid_lookup(old_dentry);
1055 return PTR_ERR(oldfid);
1057 olddirfid = v9fs_fid_clone(old_dentry->d_parent);
1058 if (IS_ERR(olddirfid)) {
1059 retval = PTR_ERR(olddirfid);
1063 newdirfid = v9fs_fid_clone(new_dentry->d_parent);
1064 if (IS_ERR(newdirfid)) {
1065 retval = PTR_ERR(newdirfid);
1069 down_write(&v9ses->rename_sem);
1070 if (v9fs_proto_dotl(v9ses)) {
1071 retval = p9_client_rename(oldfid, newdirfid,
1072 (char *) new_dentry->d_name.name);
1073 if (retval != -ENOSYS)
1076 if (old_dentry->d_parent != new_dentry->d_parent) {
1078 * 9P .u can only handle file rename in the same directory
1081 P9_DPRINTK(P9_DEBUG_ERROR,
1082 "old dir and new dir are different\n");
1086 v9fs_blank_wstat(&wstat);
1087 wstat.muid = v9ses->uname;
1088 wstat.name = (char *) new_dentry->d_name.name;
1089 retval = p9_client_wstat(oldfid, &wstat);
1093 /* successful rename */
1094 d_move(old_dentry, new_dentry);
1095 up_write(&v9ses->rename_sem);
1096 p9_client_clunk(newdirfid);
1099 p9_client_clunk(olddirfid);
1106 * v9fs_vfs_getattr - retrieve file metadata
1107 * @mnt: mount information
1108 * @dentry: file to get attributes on
1109 * @stat: metadata structure to populate
1114 v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
1118 struct v9fs_session_info *v9ses;
1120 struct p9_wstat *st;
1122 P9_DPRINTK(P9_DEBUG_VFS, "dentry: %p\n", dentry);
1124 v9ses = v9fs_inode2v9ses(dentry->d_inode);
1125 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
1126 return simple_getattr(mnt, dentry, stat);
1128 fid = v9fs_fid_lookup(dentry);
1130 return PTR_ERR(fid);
1132 st = p9_client_stat(fid);
1136 v9fs_stat2inode(st, dentry->d_inode, dentry->d_inode->i_sb);
1137 generic_fillattr(dentry->d_inode, stat);
1145 v9fs_vfs_getattr_dotl(struct vfsmount *mnt, struct dentry *dentry,
1149 struct v9fs_session_info *v9ses;
1151 struct p9_stat_dotl *st;
1153 P9_DPRINTK(P9_DEBUG_VFS, "dentry: %p\n", dentry);
1155 v9ses = v9fs_inode2v9ses(dentry->d_inode);
1156 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
1157 return simple_getattr(mnt, dentry, stat);
1159 fid = v9fs_fid_lookup(dentry);
1161 return PTR_ERR(fid);
1163 /* Ask for all the fields in stat structure. Server will return
1164 * whatever it supports
1167 st = p9_client_getattr_dotl(fid, P9_STATS_ALL);
1171 v9fs_stat2inode_dotl(st, dentry->d_inode);
1172 generic_fillattr(dentry->d_inode, stat);
1173 /* Change block size to what the server returned */
1174 stat->blksize = st->st_blksize;
1181 * v9fs_vfs_setattr - set file metadata
1182 * @dentry: file whose metadata to set
1183 * @iattr: metadata assignment structure
1187 static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
1190 struct v9fs_session_info *v9ses;
1192 struct p9_wstat wstat;
1194 P9_DPRINTK(P9_DEBUG_VFS, "\n");
1196 v9ses = v9fs_inode2v9ses(dentry->d_inode);
1197 fid = v9fs_fid_lookup(dentry);
1199 return PTR_ERR(fid);
1201 v9fs_blank_wstat(&wstat);
1202 if (iattr->ia_valid & ATTR_MODE)
1203 wstat.mode = unixmode2p9mode(v9ses, iattr->ia_mode);
1205 if (iattr->ia_valid & ATTR_MTIME)
1206 wstat.mtime = iattr->ia_mtime.tv_sec;
1208 if (iattr->ia_valid & ATTR_ATIME)
1209 wstat.atime = iattr->ia_atime.tv_sec;
1211 if (iattr->ia_valid & ATTR_SIZE)
1212 wstat.length = iattr->ia_size;
1214 if (v9fs_proto_dotu(v9ses)) {
1215 if (iattr->ia_valid & ATTR_UID)
1216 wstat.n_uid = iattr->ia_uid;
1218 if (iattr->ia_valid & ATTR_GID)
1219 wstat.n_gid = iattr->ia_gid;
1222 retval = p9_client_wstat(fid, &wstat);
1226 if ((iattr->ia_valid & ATTR_SIZE) &&
1227 iattr->ia_size != i_size_read(dentry->d_inode)) {
1228 retval = vmtruncate(dentry->d_inode, iattr->ia_size);
1233 setattr_copy(dentry->d_inode, iattr);
1234 mark_inode_dirty(dentry->d_inode);
1239 * v9fs_vfs_setattr_dotl - set file metadata
1240 * @dentry: file whose metadata to set
1241 * @iattr: metadata assignment structure
1245 static int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
1248 struct v9fs_session_info *v9ses;
1250 struct p9_iattr_dotl p9attr;
1252 P9_DPRINTK(P9_DEBUG_VFS, "\n");
1254 retval = inode_change_ok(dentry->d_inode, iattr);
1258 p9attr.valid = iattr->ia_valid;
1259 p9attr.mode = iattr->ia_mode;
1260 p9attr.uid = iattr->ia_uid;
1261 p9attr.gid = iattr->ia_gid;
1262 p9attr.size = iattr->ia_size;
1263 p9attr.atime_sec = iattr->ia_atime.tv_sec;
1264 p9attr.atime_nsec = iattr->ia_atime.tv_nsec;
1265 p9attr.mtime_sec = iattr->ia_mtime.tv_sec;
1266 p9attr.mtime_nsec = iattr->ia_mtime.tv_nsec;
1269 v9ses = v9fs_inode2v9ses(dentry->d_inode);
1270 fid = v9fs_fid_lookup(dentry);
1272 return PTR_ERR(fid);
1274 retval = p9_client_setattr(fid, &p9attr);
1278 if ((iattr->ia_valid & ATTR_SIZE) &&
1279 iattr->ia_size != i_size_read(dentry->d_inode)) {
1280 retval = vmtruncate(dentry->d_inode, iattr->ia_size);
1285 setattr_copy(dentry->d_inode, iattr);
1286 mark_inode_dirty(dentry->d_inode);
1291 * v9fs_stat2inode - populate an inode structure with mistat info
1292 * @stat: Plan 9 metadata (mistat) structure
1293 * @inode: inode to populate
1294 * @sb: superblock of filesystem
1299 v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
1300 struct super_block *sb)
1304 unsigned int i_nlink;
1305 struct v9fs_session_info *v9ses = sb->s_fs_info;
1309 inode->i_atime.tv_sec = stat->atime;
1310 inode->i_mtime.tv_sec = stat->mtime;
1311 inode->i_ctime.tv_sec = stat->mtime;
1313 inode->i_uid = v9ses->dfltuid;
1314 inode->i_gid = v9ses->dfltgid;
1316 if (v9fs_proto_dotu(v9ses)) {
1317 inode->i_uid = stat->n_uid;
1318 inode->i_gid = stat->n_gid;
1320 if ((S_ISREG(inode->i_mode)) || (S_ISDIR(inode->i_mode))) {
1321 if (v9fs_proto_dotu(v9ses) && (stat->extension[0] != '\0')) {
1323 * Hadlink support got added later to
1324 * to the .u extension. So there can be
1325 * server out there that doesn't support
1326 * this even with .u extension. So check
1327 * for non NULL stat->extension
1329 strncpy(ext, stat->extension, sizeof(ext));
1330 /* HARDLINKCOUNT %u */
1331 sscanf(ext, "%13s %u", tag_name, &i_nlink);
1332 if (!strncmp(tag_name, "HARDLINKCOUNT", 13))
1333 inode->i_nlink = i_nlink;
1336 inode->i_mode = p9mode2unixmode(v9ses, stat->mode);
1337 if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode))) {
1342 strncpy(ext, stat->extension, sizeof(ext));
1343 sscanf(ext, "%c %u %u", &type, &major, &minor);
1346 inode->i_mode &= ~S_IFBLK;
1347 inode->i_mode |= S_IFCHR;
1352 P9_DPRINTK(P9_DEBUG_ERROR,
1353 "Unknown special type %c %s\n", type,
1356 inode->i_rdev = MKDEV(major, minor);
1357 init_special_inode(inode, inode->i_mode, inode->i_rdev);
1361 i_size_write(inode, stat->length);
1363 /* not real number of blocks, but 512 byte ones ... */
1364 inode->i_blocks = (i_size_read(inode) + 512 - 1) >> 9;
1368 * v9fs_stat2inode_dotl - populate an inode structure with stat info
1369 * @stat: stat structure
1370 * @inode: inode to populate
1371 * @sb: superblock of filesystem
1376 v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode)
1379 if ((stat->st_result_mask & P9_STATS_BASIC) == P9_STATS_BASIC) {
1380 inode->i_atime.tv_sec = stat->st_atime_sec;
1381 inode->i_atime.tv_nsec = stat->st_atime_nsec;
1382 inode->i_mtime.tv_sec = stat->st_mtime_sec;
1383 inode->i_mtime.tv_nsec = stat->st_mtime_nsec;
1384 inode->i_ctime.tv_sec = stat->st_ctime_sec;
1385 inode->i_ctime.tv_nsec = stat->st_ctime_nsec;
1386 inode->i_uid = stat->st_uid;
1387 inode->i_gid = stat->st_gid;
1388 inode->i_nlink = stat->st_nlink;
1389 inode->i_mode = stat->st_mode;
1390 inode->i_rdev = new_decode_dev(stat->st_rdev);
1392 if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode)))
1393 init_special_inode(inode, inode->i_mode, inode->i_rdev);
1395 i_size_write(inode, stat->st_size);
1396 inode->i_blocks = stat->st_blocks;
1398 if (stat->st_result_mask & P9_STATS_ATIME) {
1399 inode->i_atime.tv_sec = stat->st_atime_sec;
1400 inode->i_atime.tv_nsec = stat->st_atime_nsec;
1402 if (stat->st_result_mask & P9_STATS_MTIME) {
1403 inode->i_mtime.tv_sec = stat->st_mtime_sec;
1404 inode->i_mtime.tv_nsec = stat->st_mtime_nsec;
1406 if (stat->st_result_mask & P9_STATS_CTIME) {
1407 inode->i_ctime.tv_sec = stat->st_ctime_sec;
1408 inode->i_ctime.tv_nsec = stat->st_ctime_nsec;
1410 if (stat->st_result_mask & P9_STATS_UID)
1411 inode->i_uid = stat->st_uid;
1412 if (stat->st_result_mask & P9_STATS_GID)
1413 inode->i_gid = stat->st_gid;
1414 if (stat->st_result_mask & P9_STATS_NLINK)
1415 inode->i_nlink = stat->st_nlink;
1416 if (stat->st_result_mask & P9_STATS_MODE) {
1417 inode->i_mode = stat->st_mode;
1418 if ((S_ISBLK(inode->i_mode)) ||
1419 (S_ISCHR(inode->i_mode)))
1420 init_special_inode(inode, inode->i_mode,
1423 if (stat->st_result_mask & P9_STATS_RDEV)
1424 inode->i_rdev = new_decode_dev(stat->st_rdev);
1425 if (stat->st_result_mask & P9_STATS_SIZE)
1426 i_size_write(inode, stat->st_size);
1427 if (stat->st_result_mask & P9_STATS_BLOCKS)
1428 inode->i_blocks = stat->st_blocks;
1430 if (stat->st_result_mask & P9_STATS_GEN)
1431 inode->i_generation = stat->st_gen;
1433 /* Currently we don't support P9_STATS_BTIME and P9_STATS_DATA_VERSION
1434 * because the inode structure does not have fields for them.
1439 * v9fs_qid2ino - convert qid into inode number
1442 * BUG: potential for inode number collisions?
1445 ino_t v9fs_qid2ino(struct p9_qid *qid)
1447 u64 path = qid->path + 2;
1450 if (sizeof(ino_t) == sizeof(path))
1451 memcpy(&i, &path, sizeof(ino_t));
1453 i = (ino_t) (path ^ (path >> 32));
1459 * v9fs_readlink - read a symlink's location (internal version)
1460 * @dentry: dentry for symlink
1461 * @buffer: buffer to load symlink location into
1462 * @buflen: length of buffer
1466 static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen)
1470 struct v9fs_session_info *v9ses;
1472 struct p9_wstat *st;
1474 P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name);
1476 v9ses = v9fs_inode2v9ses(dentry->d_inode);
1477 fid = v9fs_fid_lookup(dentry);
1479 return PTR_ERR(fid);
1481 if (!v9fs_proto_dotu(v9ses) && !v9fs_proto_dotl(v9ses))
1484 st = p9_client_stat(fid);
1488 if (!(st->mode & P9_DMSYMLINK)) {
1493 /* copy extension buffer into buffer */
1494 strncpy(buffer, st->extension, buflen);
1496 P9_DPRINTK(P9_DEBUG_VFS,
1497 "%s -> %s (%s)\n", dentry->d_name.name, st->extension, buffer);
1499 retval = strnlen(buffer, buflen);
1507 * v9fs_vfs_follow_link - follow a symlink path
1508 * @dentry: dentry for symlink
1513 static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
1516 char *link = __getname();
1518 P9_DPRINTK(P9_DEBUG_VFS, "%s n", dentry->d_name.name);
1521 link = ERR_PTR(-ENOMEM);
1523 len = v9fs_readlink(dentry, link, PATH_MAX);
1527 link = ERR_PTR(len);
1529 link[min(len, PATH_MAX-1)] = 0;
1531 nd_set_link(nd, link);
1537 * v9fs_vfs_put_link - release a symlink path
1538 * @dentry: dentry for symlink
1545 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
1547 char *s = nd_get_link(nd);
1549 P9_DPRINTK(P9_DEBUG_VFS, " %s %s\n", dentry->d_name.name,
1550 IS_ERR(s) ? "<error>" : s);
1556 * v9fs_vfs_mkspecial - create a special file
1557 * @dir: inode to create special file in
1558 * @dentry: dentry to create
1559 * @mode: mode to create special file
1560 * @extension: 9p2000.u format extension string representing special file
1564 static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
1565 int mode, const char *extension)
1568 struct v9fs_session_info *v9ses;
1571 v9ses = v9fs_inode2v9ses(dir);
1572 if (!v9fs_proto_dotu(v9ses)) {
1573 P9_DPRINTK(P9_DEBUG_ERROR, "not extended\n");
1577 perm = unixmode2p9mode(v9ses, mode);
1578 fid = v9fs_create(v9ses, dir, dentry, (char *) extension, perm,
1581 return PTR_ERR(fid);
1583 p9_client_clunk(fid);
1588 * v9fs_vfs_symlink_dotl - helper function to create symlinks
1589 * @dir: directory inode containing symlink
1590 * @dentry: dentry for symlink
1591 * @symname: symlink data
1593 * See Also: 9P2000.L RFC for more information
1598 v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry,
1599 const char *symname)
1601 struct v9fs_session_info *v9ses;
1602 struct p9_fid *dfid;
1603 struct p9_fid *fid = NULL;
1604 struct inode *inode;
1610 name = (char *) dentry->d_name.name;
1611 P9_DPRINTK(P9_DEBUG_VFS, "v9fs_vfs_symlink_dotl : %lu,%s,%s\n",
1612 dir->i_ino, name, symname);
1613 v9ses = v9fs_inode2v9ses(dir);
1615 dfid = v9fs_fid_lookup(dentry->d_parent);
1617 err = PTR_ERR(dfid);
1618 P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
1622 gid = v9fs_get_fsgid_for_create(dir);
1624 /* Server doesn't alter fid on TSYMLINK. Hence no need to clone it. */
1625 err = p9_client_symlink(dfid, name, (char *)symname, gid, &qid);
1628 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_symlink failed %d\n", err);
1633 /* Now walk from the parent so we can get an unopened fid. */
1634 fid = p9_client_walk(dfid, 1, &name, 1);
1637 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n",
1643 /* instantiate inode and assign the unopened fid to dentry */
1644 inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb);
1645 if (IS_ERR(inode)) {
1646 err = PTR_ERR(inode);
1647 P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n",
1651 dentry->d_op = &v9fs_cached_dentry_operations;
1652 d_instantiate(dentry, inode);
1653 err = v9fs_fid_add(dentry, fid);
1658 /* Not in cached mode. No need to populate inode with stat */
1659 inode = v9fs_get_inode(dir->i_sb, S_IFLNK);
1660 if (IS_ERR(inode)) {
1661 err = PTR_ERR(inode);
1664 dentry->d_op = &v9fs_dentry_operations;
1665 d_instantiate(dentry, inode);
1670 p9_client_clunk(fid);
1676 * v9fs_vfs_symlink - helper function to create symlinks
1677 * @dir: directory inode containing symlink
1678 * @dentry: dentry for symlink
1679 * @symname: symlink data
1681 * See Also: 9P2000.u RFC for more information
1686 v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
1688 P9_DPRINTK(P9_DEBUG_VFS, " %lu,%s,%s\n", dir->i_ino,
1689 dentry->d_name.name, symname);
1691 return v9fs_vfs_mkspecial(dir, dentry, S_IFLNK, symname);
1695 * v9fs_vfs_link - create a hardlink
1696 * @old_dentry: dentry for file to link to
1697 * @dir: inode destination for new link
1698 * @dentry: dentry for link
1703 v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,
1704 struct dentry *dentry)
1707 struct p9_fid *oldfid;
1710 P9_DPRINTK(P9_DEBUG_VFS,
1711 " %lu,%s,%s\n", dir->i_ino, dentry->d_name.name,
1712 old_dentry->d_name.name);
1714 oldfid = v9fs_fid_clone(old_dentry);
1716 return PTR_ERR(oldfid);
1719 if (unlikely(!name)) {
1724 sprintf(name, "%d\n", oldfid->fid);
1725 retval = v9fs_vfs_mkspecial(dir, dentry, P9_DMLINK, name);
1729 p9_client_clunk(oldfid);
1734 * v9fs_vfs_link_dotl - create a hardlink for dotl
1735 * @old_dentry: dentry for file to link to
1736 * @dir: inode destination for new link
1737 * @dentry: dentry for link
1742 v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir,
1743 struct dentry *dentry)
1746 struct p9_fid *dfid, *oldfid;
1748 struct v9fs_session_info *v9ses;
1749 struct dentry *dir_dentry;
1751 P9_DPRINTK(P9_DEBUG_VFS, "dir ino: %lu, old_name: %s, new_name: %s\n",
1752 dir->i_ino, old_dentry->d_name.name,
1753 dentry->d_name.name);
1755 v9ses = v9fs_inode2v9ses(dir);
1756 dir_dentry = v9fs_dentry_from_dir_inode(dir);
1757 dfid = v9fs_fid_lookup(dir_dentry);
1759 return PTR_ERR(dfid);
1761 oldfid = v9fs_fid_lookup(old_dentry);
1763 return PTR_ERR(oldfid);
1765 name = (char *) dentry->d_name.name;
1767 err = p9_client_link(dfid, oldfid, (char *)dentry->d_name.name);
1770 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_link failed %d\n", err);
1774 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
1775 /* Get the latest stat info from server. */
1777 struct p9_stat_dotl *st;
1779 fid = v9fs_fid_lookup(old_dentry);
1781 return PTR_ERR(fid);
1783 st = p9_client_getattr_dotl(fid, P9_STATS_BASIC);
1787 v9fs_stat2inode_dotl(st, old_dentry->d_inode);
1791 /* Caching disabled. No need to get upto date stat info.
1792 * This dentry will be released immediately. So, just hold the
1795 ihold(old_dentry->d_inode);
1798 dentry->d_op = old_dentry->d_op;
1799 d_instantiate(dentry, old_dentry->d_inode);
1805 * v9fs_vfs_mknod - create a special file
1806 * @dir: inode destination for new link
1807 * @dentry: dentry for file
1808 * @mode: mode for creation
1809 * @rdev: device associated with special file
1814 v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
1819 P9_DPRINTK(P9_DEBUG_VFS,
1820 " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino,
1821 dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev));
1823 if (!new_valid_dev(rdev))
1829 /* build extension */
1831 sprintf(name, "b %u %u", MAJOR(rdev), MINOR(rdev));
1832 else if (S_ISCHR(mode))
1833 sprintf(name, "c %u %u", MAJOR(rdev), MINOR(rdev));
1834 else if (S_ISFIFO(mode))
1836 else if (S_ISSOCK(mode))
1843 retval = v9fs_vfs_mkspecial(dir, dentry, mode, name);
1850 * v9fs_vfs_mknod_dotl - create a special file
1851 * @dir: inode destination for new link
1852 * @dentry: dentry for file
1853 * @mode: mode for creation
1854 * @rdev: device associated with special file
1858 v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int mode,
1863 struct v9fs_session_info *v9ses;
1864 struct p9_fid *fid = NULL, *dfid = NULL;
1865 struct inode *inode;
1868 struct dentry *dir_dentry;
1870 P9_DPRINTK(P9_DEBUG_VFS,
1871 " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino,
1872 dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev));
1874 if (!new_valid_dev(rdev))
1877 v9ses = v9fs_inode2v9ses(dir);
1878 dir_dentry = v9fs_dentry_from_dir_inode(dir);
1879 dfid = v9fs_fid_lookup(dir_dentry);
1881 err = PTR_ERR(dfid);
1882 P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
1887 gid = v9fs_get_fsgid_for_create(dir);
1889 name = (char *) dentry->d_name.name;
1891 err = p9_client_mknod_dotl(dfid, name, mode, rdev, gid, &qid);
1895 /* instantiate inode and assign the unopened fid to the dentry */
1896 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
1897 fid = p9_client_walk(dfid, 1, &name, 1);
1900 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n",
1906 inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb);
1907 if (IS_ERR(inode)) {
1908 err = PTR_ERR(inode);
1909 P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n",
1913 dentry->d_op = &v9fs_cached_dentry_operations;
1914 d_instantiate(dentry, inode);
1915 err = v9fs_fid_add(dentry, fid);
1921 * Not in cached mode. No need to populate inode with stat.
1922 * socket syscall returns a fd, so we need instantiate
1924 inode = v9fs_get_inode(dir->i_sb, mode);
1925 if (IS_ERR(inode)) {
1926 err = PTR_ERR(inode);
1929 dentry->d_op = &v9fs_dentry_operations;
1930 d_instantiate(dentry, inode);
1935 p9_client_clunk(fid);
1939 static const struct inode_operations v9fs_dir_inode_operations_dotu = {
1940 .create = v9fs_vfs_create,
1941 .lookup = v9fs_vfs_lookup,
1942 .symlink = v9fs_vfs_symlink,
1943 .link = v9fs_vfs_link,
1944 .unlink = v9fs_vfs_unlink,
1945 .mkdir = v9fs_vfs_mkdir,
1946 .rmdir = v9fs_vfs_rmdir,
1947 .mknod = v9fs_vfs_mknod,
1948 .rename = v9fs_vfs_rename,
1949 .getattr = v9fs_vfs_getattr,
1950 .setattr = v9fs_vfs_setattr,
1953 static const struct inode_operations v9fs_dir_inode_operations_dotl = {
1954 .create = v9fs_vfs_create_dotl,
1955 .lookup = v9fs_vfs_lookup,
1956 .link = v9fs_vfs_link_dotl,
1957 .symlink = v9fs_vfs_symlink_dotl,
1958 .unlink = v9fs_vfs_unlink,
1959 .mkdir = v9fs_vfs_mkdir_dotl,
1960 .rmdir = v9fs_vfs_rmdir,
1961 .mknod = v9fs_vfs_mknod_dotl,
1962 .rename = v9fs_vfs_rename,
1963 .getattr = v9fs_vfs_getattr_dotl,
1964 .setattr = v9fs_vfs_setattr_dotl,
1965 .setxattr = generic_setxattr,
1966 .getxattr = generic_getxattr,
1967 .removexattr = generic_removexattr,
1968 .listxattr = v9fs_listxattr,
1969 .check_acl = v9fs_check_acl,
1972 static const struct inode_operations v9fs_dir_inode_operations = {
1973 .create = v9fs_vfs_create,
1974 .lookup = v9fs_vfs_lookup,
1975 .unlink = v9fs_vfs_unlink,
1976 .mkdir = v9fs_vfs_mkdir,
1977 .rmdir = v9fs_vfs_rmdir,
1978 .mknod = v9fs_vfs_mknod,
1979 .rename = v9fs_vfs_rename,
1980 .getattr = v9fs_vfs_getattr,
1981 .setattr = v9fs_vfs_setattr,
1984 static const struct inode_operations v9fs_file_inode_operations = {
1985 .getattr = v9fs_vfs_getattr,
1986 .setattr = v9fs_vfs_setattr,
1989 static const struct inode_operations v9fs_file_inode_operations_dotl = {
1990 .getattr = v9fs_vfs_getattr_dotl,
1991 .setattr = v9fs_vfs_setattr_dotl,
1992 .setxattr = generic_setxattr,
1993 .getxattr = generic_getxattr,
1994 .removexattr = generic_removexattr,
1995 .listxattr = v9fs_listxattr,
1996 .check_acl = v9fs_check_acl,
1999 static const struct inode_operations v9fs_symlink_inode_operations = {
2000 .readlink = generic_readlink,
2001 .follow_link = v9fs_vfs_follow_link,
2002 .put_link = v9fs_vfs_put_link,
2003 .getattr = v9fs_vfs_getattr,
2004 .setattr = v9fs_vfs_setattr,
2007 static const struct inode_operations v9fs_symlink_inode_operations_dotl = {
2008 .readlink = generic_readlink,
2009 .follow_link = v9fs_vfs_follow_link,
2010 .put_link = v9fs_vfs_put_link,
2011 .getattr = v9fs_vfs_getattr_dotl,
2012 .setattr = v9fs_vfs_setattr_dotl,
2013 .setxattr = generic_setxattr,
2014 .getxattr = generic_getxattr,
2015 .removexattr = generic_removexattr,
2016 .listxattr = v9fs_listxattr,