26 #include <linux/module.h>
27 #include <linux/errno.h>
31 #include <linux/stat.h>
32 #include <linux/string.h>
36 #include <linux/sched.h>
37 #include <linux/slab.h>
38 #include <linux/xattr.h>
60 static gid_t v9fs_get_fsgid_for_create(
struct inode *dir_inode)
66 return dir_inode->
i_gid;
85 &st->
qid.version,
sizeof(v9inode->
qid.version)))
88 if (v9inode->
qid.type != st->
qid.type)
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)
109 static struct inode *v9fs_qid_iget_dotl(
struct super_block *
sb,
119 int (*
test)(
struct inode *,
void *);
122 test = v9fs_test_new_inode_dotl;
124 test = v9fs_test_inode_dotl;
144 #ifdef CONFIG_9P_FSCACHE
156 return ERR_PTR(retval);
165 struct inode *inode =
NULL;
171 inode = v9fs_qid_iget_dotl(sb, &st->
qid, fid, st,
new);
181 static int v9fs_mapped_dotl_flags(
int flags)
202 for (i = 0; i <
ARRAY_SIZE(dotl_oflag_map); i++) {
223 rflags |= v9fs_mapped_dotl_flags(flags);
240 return v9fs_vfs_mknod_dotl(dir, dentry, omode, 0);
244 v9fs_vfs_atomic_open_dotl(
struct inode *dir,
struct dentry *
dentry,
256 struct p9_fid *dfid, *ofid, *inode_fid;
261 if (d_unhashed(dentry)) {
274 v9ses = v9fs_inode2v9ses(dir);
276 name = (
char *) dentry->
d_name.name;
295 gid = v9fs_get_fsgid_for_create(dir);
312 v9fs_invalidate_inode_attr(dir);
322 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->
i_sb);
324 err = PTR_ERR(inode);
336 v9inode = V9FS_I(inode);
348 if (IS_ERR(inode_fid)) {
349 err = PTR_ERR(inode_fid);
351 goto err_clunk_old_fid;
359 goto err_clunk_old_fid;
361 #ifdef CONFIG_9P_FSCACHE
388 static int v9fs_vfs_mkdir_dotl(
struct inode *dir,
389 struct dentry *dentry,
umode_t omode)
399 struct dentry *dir_dentry;
404 v9ses = v9fs_inode2v9ses(dir);
419 gid = v9fs_get_fsgid_for_create(dir);
428 name = (
char *) dentry->
d_name.name;
444 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->
i_sb);
446 err = PTR_ERR(inode);
464 err = PTR_ERR(inode);
472 v9fs_invalidate_inode_attr(dir);
481 v9fs_vfs_getattr_dotl(
struct vfsmount *mnt,
struct dentry *dentry,
491 v9ses = v9fs_dentry2v9ses(dentry);
520 #define P9_ATTR_MODE (1 << 0)
521 #define P9_ATTR_UID (1 << 1)
522 #define P9_ATTR_GID (1 << 2)
523 #define P9_ATTR_SIZE (1 << 3)
524 #define P9_ATTR_ATIME (1 << 4)
525 #define P9_ATTR_MTIME (1 << 5)
526 #define P9_ATTR_CTIME (1 << 6)
527 #define P9_ATTR_ATIME_SET (1 << 7)
528 #define P9_ATTR_MTIME_SET (1 << 8)
535 static int v9fs_mapped_iattr_valid(
int iattr_valid)
538 int p9_iattr_valid = 0;
550 for (i = 0; i <
ARRAY_SIZE(dotl_iattr_map); i++) {
551 if (iattr_valid & dotl_iattr_map[i].iattr_valid)
588 v9ses = v9fs_dentry2v9ses(dentry);
605 v9fs_invalidate_inode_attr(dentry->
d_inode);
607 mark_inode_dirty(dentry->
d_inode);
646 i_size_write(inode, stat->
st_size);
677 i_size_write(inode, stat->
st_size);
691 v9fs_vfs_symlink_dotl(
struct inode *dir,
struct dentry *dentry,
703 name = (
char *) dentry->
d_name.name;
705 v9ses = v9fs_inode2v9ses(dir);
714 gid = v9fs_get_fsgid_for_create(dir);
724 v9fs_invalidate_inode_attr(dir);
737 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->
i_sb);
739 err = PTR_ERR(inode);
753 err = PTR_ERR(inode);
775 v9fs_vfs_link_dotl(
struct dentry *old_dentry,
struct inode *dir,
776 struct dentry *dentry)
780 struct dentry *dir_dentry;
781 struct p9_fid *dfid, *oldfid;
787 v9ses = v9fs_inode2v9ses(dir);
791 return PTR_ERR(dfid);
795 return PTR_ERR(oldfid);
797 name = (
char *) dentry->
d_name.name;
806 v9fs_invalidate_inode_attr(dir);
831 v9fs_vfs_mknod_dotl(
struct inode *dir,
struct dentry *dentry,
umode_t omode,
842 struct dentry *dir_dentry;
849 if (!new_valid_dev(rdev))
852 v9ses = v9fs_inode2v9ses(dir);
862 gid = v9fs_get_fsgid_for_create(dir);
871 name = (
char *) dentry->
d_name.name;
877 v9fs_invalidate_inode_attr(dir);
889 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->
i_sb);
891 err = PTR_ERR(inode);
908 err = PTR_ERR(inode);
930 v9fs_vfs_follow_link_dotl(
struct dentry *dentry,
struct nameidata *nd)
946 link = ERR_CAST(fid);
956 link = ERR_PTR(retval);
958 nd_set_link(nd, link);
968 v9ses = v9fs_inode2v9ses(inode);
978 spin_lock(&inode->
i_lock);
987 spin_unlock(&inode->
i_lock);
994 .create = v9fs_vfs_create_dotl,
995 .atomic_open = v9fs_vfs_atomic_open_dotl,
997 .link = v9fs_vfs_link_dotl,
998 .symlink = v9fs_vfs_symlink_dotl,
1000 .mkdir = v9fs_vfs_mkdir_dotl,
1002 .mknod = v9fs_vfs_mknod_dotl,
1004 .getattr = v9fs_vfs_getattr_dotl,
1014 .getattr = v9fs_vfs_getattr_dotl,
1025 .follow_link = v9fs_vfs_follow_link_dotl,
1027 .getattr = v9fs_vfs_getattr_dotl,