vfs_inode.c (6e8dc55550273084b7fb5846df2f44439f5d03d9) | vfs_inode.c (ad77dbce567128d59b37a14c9562c8af6f63aeca) |
---|---|
1/* 2 * linux/fs/9p/vfs_inode.c 3 * 4 * This file contains vfs inode ops for the 9P2000 protocol. 5 * 6 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> 7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 8 * --- 648 unchanged lines hidden (view full) --- 657 * @dir: directory inode that is being created 658 * @dentry: dentry that is being deleted 659 * @mode: create permissions 660 * @nd: path information 661 * 662 */ 663 664static int | 1/* 2 * linux/fs/9p/vfs_inode.c 3 * 4 * This file contains vfs inode ops for the 9P2000 protocol. 5 * 6 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> 7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 8 * --- 648 unchanged lines hidden (view full) --- 657 * @dir: directory inode that is being created 658 * @dentry: dentry that is being deleted 659 * @mode: create permissions 660 * @nd: path information 661 * 662 */ 663 664static int |
665v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int mode, | 665v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode, |
666 struct nameidata *nd) 667{ 668 int err = 0; 669 char *name = NULL; 670 gid_t gid; 671 int flags; | 666 struct nameidata *nd) 667{ 668 int err = 0; 669 char *name = NULL; 670 gid_t gid; 671 int flags; |
672 mode_t mode; |
|
672 struct v9fs_session_info *v9ses; 673 struct p9_fid *fid = NULL; 674 struct p9_fid *dfid, *ofid; 675 struct file *filp; 676 struct p9_qid qid; 677 struct inode *inode; | 673 struct v9fs_session_info *v9ses; 674 struct p9_fid *fid = NULL; 675 struct p9_fid *dfid, *ofid; 676 struct file *filp; 677 struct p9_qid qid; 678 struct inode *inode; |
679 struct posix_acl *pacl = NULL, *dacl = NULL; |
|
678 679 v9ses = v9fs_inode2v9ses(dir); 680 if (nd && nd->flags & LOOKUP_OPEN) 681 flags = nd->intent.open.flags - 1; 682 else 683 flags = O_RDWR; 684 685 name = (char *) dentry->d_name.name; 686 P9_DPRINTK(P9_DEBUG_VFS, "v9fs_vfs_create_dotl: name:%s flags:0x%x " | 680 681 v9ses = v9fs_inode2v9ses(dir); 682 if (nd && nd->flags & LOOKUP_OPEN) 683 flags = nd->intent.open.flags - 1; 684 else 685 flags = O_RDWR; 686 687 name = (char *) dentry->d_name.name; 688 P9_DPRINTK(P9_DEBUG_VFS, "v9fs_vfs_create_dotl: name:%s flags:0x%x " |
687 "mode:0x%x\n", name, flags, mode); | 689 "mode:0x%x\n", name, flags, omode); |
688 689 dfid = v9fs_fid_lookup(dentry->d_parent); 690 if (IS_ERR(dfid)) { 691 err = PTR_ERR(dfid); 692 P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err); 693 return err; 694 } 695 696 /* clone a fid to use for creation */ 697 ofid = p9_client_walk(dfid, 0, NULL, 1); 698 if (IS_ERR(ofid)) { 699 err = PTR_ERR(ofid); 700 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err); 701 return err; 702 } 703 704 gid = v9fs_get_fsgid_for_create(dir); | 690 691 dfid = v9fs_fid_lookup(dentry->d_parent); 692 if (IS_ERR(dfid)) { 693 err = PTR_ERR(dfid); 694 P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err); 695 return err; 696 } 697 698 /* clone a fid to use for creation */ 699 ofid = p9_client_walk(dfid, 0, NULL, 1); 700 if (IS_ERR(ofid)) { 701 err = PTR_ERR(ofid); 702 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err); 703 return err; 704 } 705 706 gid = v9fs_get_fsgid_for_create(dir); |
707 708 mode = omode; 709 /* Update mode based on ACL value */ 710 err = v9fs_acl_mode(dir, &mode, &dacl, &pacl); 711 if (err) { 712 P9_DPRINTK(P9_DEBUG_VFS, 713 "Failed to get acl values in creat %d\n", err); 714 goto error; 715 } |
|
705 err = p9_client_create_dotl(ofid, name, flags, mode, gid, &qid); 706 if (err < 0) { 707 P9_DPRINTK(P9_DEBUG_VFS, 708 "p9_client_open_dotl failed in creat %d\n", 709 err); 710 goto error; 711 } | 716 err = p9_client_create_dotl(ofid, name, flags, mode, gid, &qid); 717 if (err < 0) { 718 P9_DPRINTK(P9_DEBUG_VFS, 719 "p9_client_open_dotl failed in creat %d\n", 720 err); 721 goto error; 722 } |
723 /* instantiate inode and assign the unopened fid to the dentry */ 724 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE || 725 (nd && nd->flags & LOOKUP_OPEN)) { 726 fid = p9_client_walk(dfid, 1, &name, 1); 727 if (IS_ERR(fid)) { 728 err = PTR_ERR(fid); 729 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", 730 err); 731 fid = NULL; 732 goto error; 733 } |
|
712 | 734 |
713 /* No need to populate the inode if we are not opening the file AND 714 * not in cached mode. 715 */ 716 if (!v9ses->cache && !(nd && nd->flags & LOOKUP_OPEN)) { 717 /* Not in cached mode. No need to populate inode with stat */ | 735 inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb); 736 if (IS_ERR(inode)) { 737 err = PTR_ERR(inode); 738 P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", 739 err); 740 goto error; 741 } 742 dentry->d_op = &v9fs_cached_dentry_operations; 743 d_instantiate(dentry, inode); 744 err = v9fs_fid_add(dentry, fid); 745 if (err < 0) 746 goto error; 747 /* The fid would get clunked via a dput */ 748 fid = NULL; 749 } else { 750 /* 751 * Not in cached mode. No need to populate 752 * inode with stat. We need to get an inode 753 * so that we can set the acl with dentry 754 */ 755 inode = v9fs_get_inode(dir->i_sb, mode); 756 if (IS_ERR(inode)) { 757 err = PTR_ERR(inode); 758 goto error; 759 } |
718 dentry->d_op = &v9fs_dentry_operations; | 760 dentry->d_op = &v9fs_dentry_operations; |
719 p9_client_clunk(ofid); 720 d_instantiate(dentry, NULL); 721 return 0; | 761 d_instantiate(dentry, inode); |
722 } | 762 } |
763 /* Now set the ACL based on the default value */ 764 v9fs_set_create_acl(dentry, dacl, pacl); |
|
723 | 765 |
724 /* Now walk from the parent so we can get an unopened fid. */ 725 fid = p9_client_walk(dfid, 1, &name, 1); 726 if (IS_ERR(fid)) { 727 err = PTR_ERR(fid); 728 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err); 729 fid = NULL; 730 goto error; 731 } 732 733 /* instantiate inode and assign the unopened fid to dentry */ 734 inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb); 735 if (IS_ERR(inode)) { 736 err = PTR_ERR(inode); 737 P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err); 738 goto error; 739 } 740 if (v9ses->cache) 741 dentry->d_op = &v9fs_cached_dentry_operations; 742 else 743 dentry->d_op = &v9fs_dentry_operations; 744 d_instantiate(dentry, inode); 745 err = v9fs_fid_add(dentry, fid); 746 if (err < 0) 747 goto error; 748 | |
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); 752 if (IS_ERR(filp)) { 753 p9_client_clunk(ofid); 754 return PTR_ERR(filp); 755 } 756 filp->private_data = ofid; --- 104 unchanged lines hidden (view full) --- 861/** 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 866 * 867 */ 868 | 766 /* if we are opening a file, assign the open fid to the file */ 767 if (nd && nd->flags & LOOKUP_OPEN) { 768 filp = lookup_instantiate_filp(nd, dentry, v9fs_open_created); 769 if (IS_ERR(filp)) { 770 p9_client_clunk(ofid); 771 return PTR_ERR(filp); 772 } 773 filp->private_data = ofid; --- 104 unchanged lines hidden (view full) --- 878/** 879 * v9fs_vfs_mkdir_dotl - VFS mkdir hook to create a directory 880 * @dir: inode that is being unlinked 881 * @dentry: dentry that is being unlinked 882 * @mode: mode for new directory 883 * 884 */ 885 |
869static int v9fs_vfs_mkdir_dotl(struct inode *dir, struct dentry *dentry, 870 int mode) | 886static int v9fs_vfs_mkdir_dotl(struct inode *dir, 887 struct dentry *dentry, int omode) |
871{ 872 int err; 873 struct v9fs_session_info *v9ses; 874 struct p9_fid *fid = NULL, *dfid = NULL; 875 gid_t gid; 876 char *name; | 888{ 889 int err; 890 struct v9fs_session_info *v9ses; 891 struct p9_fid *fid = NULL, *dfid = NULL; 892 gid_t gid; 893 char *name; |
894 mode_t mode; |
|
877 struct inode *inode; 878 struct p9_qid qid; 879 struct dentry *dir_dentry; | 895 struct inode *inode; 896 struct p9_qid qid; 897 struct dentry *dir_dentry; |
898 struct posix_acl *dacl = NULL, *pacl = NULL; |
|
880 881 P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", dentry->d_name.name); 882 err = 0; 883 v9ses = v9fs_inode2v9ses(dir); 884 | 899 900 P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", dentry->d_name.name); 901 err = 0; 902 v9ses = v9fs_inode2v9ses(dir); 903 |
885 mode |= S_IFDIR; | 904 omode |= S_IFDIR; |
886 if (dir->i_mode & S_ISGID) | 905 if (dir->i_mode & S_ISGID) |
887 mode |= S_ISGID; | 906 omode |= S_ISGID; 907 |
888 dir_dentry = v9fs_dentry_from_dir_inode(dir); 889 dfid = v9fs_fid_lookup(dir_dentry); 890 if (IS_ERR(dfid)) { 891 err = PTR_ERR(dfid); 892 P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err); 893 dfid = NULL; 894 goto error; 895 } 896 897 gid = v9fs_get_fsgid_for_create(dir); | 908 dir_dentry = v9fs_dentry_from_dir_inode(dir); 909 dfid = v9fs_fid_lookup(dir_dentry); 910 if (IS_ERR(dfid)) { 911 err = PTR_ERR(dfid); 912 P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err); 913 dfid = NULL; 914 goto error; 915 } 916 917 gid = v9fs_get_fsgid_for_create(dir); |
898 | 918 mode = omode; 919 /* Update mode based on ACL value */ 920 err = v9fs_acl_mode(dir, &mode, &dacl, &pacl); 921 if (err) { 922 P9_DPRINTK(P9_DEBUG_VFS, 923 "Failed to get acl values in mkdir %d\n", err); 924 goto error; 925 } |
899 name = (char *) dentry->d_name.name; 900 err = p9_client_mkdir_dotl(dfid, name, mode, gid, &qid); 901 if (err < 0) 902 goto error; 903 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); --- 13 unchanged lines hidden (view full) --- 920 goto error; 921 } 922 dentry->d_op = &v9fs_cached_dentry_operations; 923 d_instantiate(dentry, inode); 924 err = v9fs_fid_add(dentry, fid); 925 if (err < 0) 926 goto error; 927 fid = NULL; | 926 name = (char *) dentry->d_name.name; 927 err = p9_client_mkdir_dotl(dfid, name, mode, gid, &qid); 928 if (err < 0) 929 goto error; 930 931 /* instantiate inode and assign the unopened fid to the dentry */ 932 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { 933 fid = p9_client_walk(dfid, 1, &name, 1); --- 13 unchanged lines hidden (view full) --- 947 goto error; 948 } 949 dentry->d_op = &v9fs_cached_dentry_operations; 950 d_instantiate(dentry, inode); 951 err = v9fs_fid_add(dentry, fid); 952 if (err < 0) 953 goto error; 954 fid = NULL; |
955 } else { 956 /* 957 * Not in cached mode. No need to populate 958 * inode with stat. We need to get an inode 959 * so that we can set the acl with dentry 960 */ 961 inode = v9fs_get_inode(dir->i_sb, mode); 962 if (IS_ERR(inode)) { 963 err = PTR_ERR(inode); 964 goto error; 965 } 966 dentry->d_op = &v9fs_dentry_operations; 967 d_instantiate(dentry, inode); |
|
928 } | 968 } |
969 /* Now set the ACL based on the default value */ 970 v9fs_set_create_acl(dentry, dacl, pacl); 971 |
|
929error: 930 if (fid) 931 p9_client_clunk(fid); 932 return err; 933} 934 935/** 936 * v9fs_vfs_lookup - VFS lookup hook to "walk" to a new inode --- 919 unchanged lines hidden (view full) --- 1856 * v9fs_vfs_mknod_dotl - create a special file 1857 * @dir: inode destination for new link 1858 * @dentry: dentry for file 1859 * @mode: mode for creation 1860 * @rdev: device associated with special file 1861 * 1862 */ 1863static int | 972error: 973 if (fid) 974 p9_client_clunk(fid); 975 return err; 976} 977 978/** 979 * v9fs_vfs_lookup - VFS lookup hook to "walk" to a new inode --- 919 unchanged lines hidden (view full) --- 1899 * v9fs_vfs_mknod_dotl - create a special file 1900 * @dir: inode destination for new link 1901 * @dentry: dentry for file 1902 * @mode: mode for creation 1903 * @rdev: device associated with special file 1904 * 1905 */ 1906static int |
1864v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int mode, | 1907v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode, |
1865 dev_t rdev) 1866{ 1867 int err; 1868 char *name; | 1908 dev_t rdev) 1909{ 1910 int err; 1911 char *name; |
1912 mode_t mode; |
|
1869 struct v9fs_session_info *v9ses; 1870 struct p9_fid *fid = NULL, *dfid = NULL; 1871 struct inode *inode; 1872 gid_t gid; 1873 struct p9_qid qid; 1874 struct dentry *dir_dentry; | 1913 struct v9fs_session_info *v9ses; 1914 struct p9_fid *fid = NULL, *dfid = NULL; 1915 struct inode *inode; 1916 gid_t gid; 1917 struct p9_qid qid; 1918 struct dentry *dir_dentry; |
1919 struct posix_acl *dacl = NULL, *pacl = NULL; |
|
1875 1876 P9_DPRINTK(P9_DEBUG_VFS, 1877 " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino, | 1920 1921 P9_DPRINTK(P9_DEBUG_VFS, 1922 " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino, |
1878 dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev)); | 1923 dentry->d_name.name, omode, MAJOR(rdev), MINOR(rdev)); |
1879 1880 if (!new_valid_dev(rdev)) 1881 return -EINVAL; 1882 1883 v9ses = v9fs_inode2v9ses(dir); 1884 dir_dentry = v9fs_dentry_from_dir_inode(dir); 1885 dfid = v9fs_fid_lookup(dir_dentry); 1886 if (IS_ERR(dfid)) { 1887 err = PTR_ERR(dfid); 1888 P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err); 1889 dfid = NULL; 1890 goto error; 1891 } 1892 1893 gid = v9fs_get_fsgid_for_create(dir); | 1924 1925 if (!new_valid_dev(rdev)) 1926 return -EINVAL; 1927 1928 v9ses = v9fs_inode2v9ses(dir); 1929 dir_dentry = v9fs_dentry_from_dir_inode(dir); 1930 dfid = v9fs_fid_lookup(dir_dentry); 1931 if (IS_ERR(dfid)) { 1932 err = PTR_ERR(dfid); 1933 P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err); 1934 dfid = NULL; 1935 goto error; 1936 } 1937 1938 gid = v9fs_get_fsgid_for_create(dir); |
1894 | 1939 mode = omode; 1940 /* Update mode based on ACL value */ 1941 err = v9fs_acl_mode(dir, &mode, &dacl, &pacl); 1942 if (err) { 1943 P9_DPRINTK(P9_DEBUG_VFS, 1944 "Failed to get acl values in mknod %d\n", err); 1945 goto error; 1946 } |
1895 name = (char *) dentry->d_name.name; 1896 1897 err = p9_client_mknod_dotl(dfid, name, mode, rdev, gid, &qid); 1898 if (err < 0) 1899 goto error; 1900 1901 /* instantiate inode and assign the unopened fid to the dentry */ 1902 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { --- 27 unchanged lines hidden (view full) --- 1930 inode = v9fs_get_inode(dir->i_sb, mode); 1931 if (IS_ERR(inode)) { 1932 err = PTR_ERR(inode); 1933 goto error; 1934 } 1935 dentry->d_op = &v9fs_dentry_operations; 1936 d_instantiate(dentry, inode); 1937 } | 1947 name = (char *) dentry->d_name.name; 1948 1949 err = p9_client_mknod_dotl(dfid, name, mode, rdev, gid, &qid); 1950 if (err < 0) 1951 goto error; 1952 1953 /* instantiate inode and assign the unopened fid to the dentry */ 1954 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { --- 27 unchanged lines hidden (view full) --- 1982 inode = v9fs_get_inode(dir->i_sb, mode); 1983 if (IS_ERR(inode)) { 1984 err = PTR_ERR(inode); 1985 goto error; 1986 } 1987 dentry->d_op = &v9fs_dentry_operations; 1988 d_instantiate(dentry, inode); 1989 } |
1938 | 1990 /* Now set the ACL based on the default value */ 1991 v9fs_set_create_acl(dentry, dacl, pacl); |
1939error: 1940 if (fid) 1941 p9_client_clunk(fid); 1942 return err; 1943} 1944 1945static const struct inode_operations v9fs_dir_inode_operations_dotu = { 1946 .create = v9fs_vfs_create, --- 77 unchanged lines hidden --- | 1992error: 1993 if (fid) 1994 p9_client_clunk(fid); 1995 return err; 1996} 1997 1998static const struct inode_operations v9fs_dir_inode_operations_dotu = { 1999 .create = v9fs_vfs_create, --- 77 unchanged lines hidden --- |