aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p
diff options
context:
space:
mode:
authorM. Mohan Kumar <mohan@in.ibm.com>2010-06-16 04:57:22 -0400
committerEric Van Hensbergen <ericvh@gmail.com>2010-08-02 15:28:31 -0400
commit01a622bd7409bb7af38e784cff814e5e723f7951 (patch)
tree1b6e0d9806e560d7f89e0efa8981cfba4c213361 /fs/9p
parent4b43516ab19b748b48322937fd9307af17541c4d (diff)
9p: Implement TMKDIR
Implement TMKDIR as part of 2000.L Work Synopsis size[4] Tmkdir tag[2] fid[4] name[s] mode[4] gid[4] size[4] Rmkdir tag[2] qid[13] Description mkdir asks the file server to create a directory with given name, mode and gid. The qid for the new directory is returned with the mkdir reply message. Note: 72 is selected as the opcode for TMKDIR from the reserved list. Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com> Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'fs/9p')
-rw-r--r--fs/9p/vfs_inode.c83
1 files changed, 80 insertions, 3 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 4d9f45ec6126..39dc79567322 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -731,6 +731,83 @@ static int v9fs_vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
731 return err; 731 return err;
732} 732}
733 733
734
735/**
736 * v9fs_vfs_mkdir_dotl - VFS mkdir hook to create a directory
737 * @dir: inode that is being unlinked
738 * @dentry: dentry that is being unlinked
739 * @mode: mode for new directory
740 *
741 */
742
743static int v9fs_vfs_mkdir_dotl(struct inode *dir, struct dentry *dentry,
744 int mode)
745{
746 int err;
747 struct v9fs_session_info *v9ses;
748 struct p9_fid *fid = NULL, *dfid = NULL;
749 gid_t gid;
750 char *name;
751 struct inode *inode;
752 struct p9_qid qid;
753 struct dentry *dir_dentry;
754
755 P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", dentry->d_name.name);
756 err = 0;
757 v9ses = v9fs_inode2v9ses(dir);
758
759 mode |= S_IFDIR;
760 dir_dentry = v9fs_dentry_from_dir_inode(dir);
761 dfid = v9fs_fid_lookup(dir_dentry);
762 if (IS_ERR(dfid)) {
763 err = PTR_ERR(dfid);
764 P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
765 dfid = NULL;
766 goto error;
767 }
768
769 gid = v9fs_get_fsgid_for_create(dir);
770 if (gid < 0) {
771 P9_DPRINTK(P9_DEBUG_VFS, "v9fs_get_fsgid_for_create failed\n");
772 goto error;
773 }
774
775 name = (char *) dentry->d_name.name;
776 err = p9_client_mkdir_dotl(dfid, name, mode, gid, &qid);
777 if (err < 0)
778 goto error;
779
780 /* instantiate inode and assign the unopened fid to the dentry */
781 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
782 fid = p9_client_walk(dfid, 1, &name, 1);
783 if (IS_ERR(fid)) {
784 err = PTR_ERR(fid);
785 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n",
786 err);
787 fid = NULL;
788 goto error;
789 }
790
791 inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb);
792 if (IS_ERR(inode)) {
793 err = PTR_ERR(inode);
794 P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n",
795 err);
796 goto error;
797 }
798 dentry->d_op = &v9fs_cached_dentry_operations;
799 d_instantiate(dentry, inode);
800 err = v9fs_fid_add(dentry, fid);
801 if (err < 0)
802 goto error;
803 fid = NULL;
804 }
805error:
806 if (fid)
807 p9_client_clunk(fid);
808 return err;
809}
810
734/** 811/**
735 * v9fs_vfs_lookup - VFS lookup hook to "walk" to a new inode 812 * v9fs_vfs_lookup - VFS lookup hook to "walk" to a new inode
736 * @dir: inode that is being walked from 813 * @dir: inode that is being walked from
@@ -1641,7 +1718,7 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int mode,
1641 struct inode *inode; 1718 struct inode *inode;
1642 gid_t gid; 1719 gid_t gid;
1643 struct p9_qid qid; 1720 struct p9_qid qid;
1644 struct dentry *dir_entry; 1721 struct dentry *dir_dentry;
1645 1722
1646 P9_DPRINTK(P9_DEBUG_VFS, 1723 P9_DPRINTK(P9_DEBUG_VFS,
1647 " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino, 1724 " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino,
@@ -1652,7 +1729,7 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int mode,
1652 1729
1653 v9ses = v9fs_inode2v9ses(dir); 1730 v9ses = v9fs_inode2v9ses(dir);
1654 dir_dentry = v9fs_dentry_from_dir_inode(dir); 1731 dir_dentry = v9fs_dentry_from_dir_inode(dir);
1655 dfid = v9fs_fid_lookup(dir_entry); 1732 dfid = v9fs_fid_lookup(dir_dentry);
1656 if (IS_ERR(dfid)) { 1733 if (IS_ERR(dfid)) {
1657 err = PTR_ERR(dfid); 1734 err = PTR_ERR(dfid);
1658 P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err); 1735 P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
@@ -1736,7 +1813,7 @@ static const struct inode_operations v9fs_dir_inode_operations_dotl = {
1736 .link = v9fs_vfs_link_dotl, 1813 .link = v9fs_vfs_link_dotl,
1737 .symlink = v9fs_vfs_symlink_dotl, 1814 .symlink = v9fs_vfs_symlink_dotl,
1738 .unlink = v9fs_vfs_unlink, 1815 .unlink = v9fs_vfs_unlink,
1739 .mkdir = v9fs_vfs_mkdir, 1816 .mkdir = v9fs_vfs_mkdir_dotl,
1740 .rmdir = v9fs_vfs_rmdir, 1817 .rmdir = v9fs_vfs_rmdir,
1741 .mknod = v9fs_vfs_mknod_dotl, 1818 .mknod = v9fs_vfs_mknod_dotl,
1742 .rename = v9fs_vfs_rename, 1819 .rename = v9fs_vfs_rename,