diff options
author | Lachlan McIlroy <lachlan@redback.melbourne.sgi.com> | 2008-06-22 23:23:01 -0400 |
---|---|---|
committer | Niv Sardi <xaiki@debian.org> | 2008-07-28 02:58:49 -0400 |
commit | 0ec585163ac81e329bde25fb6311a043a1c63952 (patch) | |
tree | 304193ab41f88e5d82e51053bbd7d21fbfb7a83f /fs/xfs/linux-2.6/xfs_iops.c | |
parent | d532506cd8b59543b376e155508f88a03a81dad1 (diff) |
[XFS] Use the generic xattr methods.
Use the generic set, get and removexattr methods and supply the s_xattr
array with fine-grained handlers. All XFS/Linux highlevel attr handling is
rewritten from scratch and placed into fs/xfs/linux-2.6/xfs_xattr.c so
that it's separated from the generic low-level code.
SGI-PV: 982343
SGI-Modid: xfs-linux-melb:xfs-kern:31234a
Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Tim Shimmin <tes@sgi.com>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_iops.c')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_iops.c | 118 |
1 files changed, 13 insertions, 105 deletions
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c index 190ed61bcd42..3ae80155de3a 100644 --- a/fs/xfs/linux-2.6/xfs_iops.c +++ b/fs/xfs/linux-2.6/xfs_iops.c | |||
@@ -275,7 +275,7 @@ xfs_vn_mknod( | |||
275 | struct xfs_inode *ip = NULL; | 275 | struct xfs_inode *ip = NULL; |
276 | xfs_acl_t *default_acl = NULL; | 276 | xfs_acl_t *default_acl = NULL; |
277 | struct xfs_name name; | 277 | struct xfs_name name; |
278 | attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS; | 278 | int (*test_default_acl)(struct inode *) = _ACL_DEFAULT_EXISTS; |
279 | int error; | 279 | int error; |
280 | 280 | ||
281 | /* | 281 | /* |
@@ -781,98 +781,6 @@ xfs_vn_truncate( | |||
781 | WARN_ON(error); | 781 | WARN_ON(error); |
782 | } | 782 | } |
783 | 783 | ||
784 | STATIC int | ||
785 | xfs_vn_setxattr( | ||
786 | struct dentry *dentry, | ||
787 | const char *name, | ||
788 | const void *data, | ||
789 | size_t size, | ||
790 | int flags) | ||
791 | { | ||
792 | bhv_vnode_t *vp = vn_from_inode(dentry->d_inode); | ||
793 | char *attr = (char *)name; | ||
794 | attrnames_t *namesp; | ||
795 | int xflags = 0; | ||
796 | |||
797 | namesp = attr_lookup_namespace(attr, attr_namespaces, ATTR_NAMECOUNT); | ||
798 | if (!namesp) | ||
799 | return -EOPNOTSUPP; | ||
800 | attr += namesp->attr_namelen; | ||
801 | |||
802 | /* Convert Linux syscall to XFS internal ATTR flags */ | ||
803 | if (flags & XATTR_CREATE) | ||
804 | xflags |= ATTR_CREATE; | ||
805 | if (flags & XATTR_REPLACE) | ||
806 | xflags |= ATTR_REPLACE; | ||
807 | xflags |= namesp->attr_flag; | ||
808 | return namesp->attr_set(vp, attr, (void *)data, size, xflags); | ||
809 | } | ||
810 | |||
811 | STATIC ssize_t | ||
812 | xfs_vn_getxattr( | ||
813 | struct dentry *dentry, | ||
814 | const char *name, | ||
815 | void *data, | ||
816 | size_t size) | ||
817 | { | ||
818 | bhv_vnode_t *vp = vn_from_inode(dentry->d_inode); | ||
819 | char *attr = (char *)name; | ||
820 | attrnames_t *namesp; | ||
821 | int xflags = 0; | ||
822 | |||
823 | namesp = attr_lookup_namespace(attr, attr_namespaces, ATTR_NAMECOUNT); | ||
824 | if (!namesp) | ||
825 | return -EOPNOTSUPP; | ||
826 | attr += namesp->attr_namelen; | ||
827 | |||
828 | /* Convert Linux syscall to XFS internal ATTR flags */ | ||
829 | if (!size) { | ||
830 | xflags |= ATTR_KERNOVAL; | ||
831 | data = NULL; | ||
832 | } | ||
833 | xflags |= namesp->attr_flag; | ||
834 | return namesp->attr_get(vp, attr, (void *)data, size, xflags); | ||
835 | } | ||
836 | |||
837 | STATIC ssize_t | ||
838 | xfs_vn_listxattr( | ||
839 | struct dentry *dentry, | ||
840 | char *data, | ||
841 | size_t size) | ||
842 | { | ||
843 | bhv_vnode_t *vp = vn_from_inode(dentry->d_inode); | ||
844 | int error, xflags = ATTR_KERNAMELS; | ||
845 | ssize_t result; | ||
846 | |||
847 | if (!size) | ||
848 | xflags |= ATTR_KERNOVAL; | ||
849 | xflags |= capable(CAP_SYS_ADMIN) ? ATTR_KERNFULLS : ATTR_KERNORMALS; | ||
850 | |||
851 | error = attr_generic_list(vp, data, size, xflags, &result); | ||
852 | if (error < 0) | ||
853 | return error; | ||
854 | return result; | ||
855 | } | ||
856 | |||
857 | STATIC int | ||
858 | xfs_vn_removexattr( | ||
859 | struct dentry *dentry, | ||
860 | const char *name) | ||
861 | { | ||
862 | bhv_vnode_t *vp = vn_from_inode(dentry->d_inode); | ||
863 | char *attr = (char *)name; | ||
864 | attrnames_t *namesp; | ||
865 | int xflags = 0; | ||
866 | |||
867 | namesp = attr_lookup_namespace(attr, attr_namespaces, ATTR_NAMECOUNT); | ||
868 | if (!namesp) | ||
869 | return -EOPNOTSUPP; | ||
870 | attr += namesp->attr_namelen; | ||
871 | |||
872 | xflags |= namesp->attr_flag; | ||
873 | return namesp->attr_remove(vp, attr, xflags); | ||
874 | } | ||
875 | |||
876 | STATIC long | 784 | STATIC long |
877 | xfs_vn_fallocate( | 785 | xfs_vn_fallocate( |
878 | struct inode *inode, | 786 | struct inode *inode, |
@@ -920,10 +828,10 @@ const struct inode_operations xfs_inode_operations = { | |||
920 | .truncate = xfs_vn_truncate, | 828 | .truncate = xfs_vn_truncate, |
921 | .getattr = xfs_vn_getattr, | 829 | .getattr = xfs_vn_getattr, |
922 | .setattr = xfs_vn_setattr, | 830 | .setattr = xfs_vn_setattr, |
923 | .setxattr = xfs_vn_setxattr, | 831 | .setxattr = generic_setxattr, |
924 | .getxattr = xfs_vn_getxattr, | 832 | .getxattr = generic_getxattr, |
833 | .removexattr = generic_removexattr, | ||
925 | .listxattr = xfs_vn_listxattr, | 834 | .listxattr = xfs_vn_listxattr, |
926 | .removexattr = xfs_vn_removexattr, | ||
927 | .fallocate = xfs_vn_fallocate, | 835 | .fallocate = xfs_vn_fallocate, |
928 | }; | 836 | }; |
929 | 837 | ||
@@ -940,10 +848,10 @@ const struct inode_operations xfs_dir_inode_operations = { | |||
940 | .permission = xfs_vn_permission, | 848 | .permission = xfs_vn_permission, |
941 | .getattr = xfs_vn_getattr, | 849 | .getattr = xfs_vn_getattr, |
942 | .setattr = xfs_vn_setattr, | 850 | .setattr = xfs_vn_setattr, |
943 | .setxattr = xfs_vn_setxattr, | 851 | .setxattr = generic_setxattr, |
944 | .getxattr = xfs_vn_getxattr, | 852 | .getxattr = generic_getxattr, |
853 | .removexattr = generic_removexattr, | ||
945 | .listxattr = xfs_vn_listxattr, | 854 | .listxattr = xfs_vn_listxattr, |
946 | .removexattr = xfs_vn_removexattr, | ||
947 | }; | 855 | }; |
948 | 856 | ||
949 | const struct inode_operations xfs_dir_ci_inode_operations = { | 857 | const struct inode_operations xfs_dir_ci_inode_operations = { |
@@ -959,10 +867,10 @@ const struct inode_operations xfs_dir_ci_inode_operations = { | |||
959 | .permission = xfs_vn_permission, | 867 | .permission = xfs_vn_permission, |
960 | .getattr = xfs_vn_getattr, | 868 | .getattr = xfs_vn_getattr, |
961 | .setattr = xfs_vn_setattr, | 869 | .setattr = xfs_vn_setattr, |
962 | .setxattr = xfs_vn_setxattr, | 870 | .setxattr = generic_setxattr, |
963 | .getxattr = xfs_vn_getxattr, | 871 | .getxattr = generic_getxattr, |
872 | .removexattr = generic_removexattr, | ||
964 | .listxattr = xfs_vn_listxattr, | 873 | .listxattr = xfs_vn_listxattr, |
965 | .removexattr = xfs_vn_removexattr, | ||
966 | }; | 874 | }; |
967 | 875 | ||
968 | const struct inode_operations xfs_symlink_inode_operations = { | 876 | const struct inode_operations xfs_symlink_inode_operations = { |
@@ -972,8 +880,8 @@ const struct inode_operations xfs_symlink_inode_operations = { | |||
972 | .permission = xfs_vn_permission, | 880 | .permission = xfs_vn_permission, |
973 | .getattr = xfs_vn_getattr, | 881 | .getattr = xfs_vn_getattr, |
974 | .setattr = xfs_vn_setattr, | 882 | .setattr = xfs_vn_setattr, |
975 | .setxattr = xfs_vn_setxattr, | 883 | .setxattr = generic_setxattr, |
976 | .getxattr = xfs_vn_getxattr, | 884 | .getxattr = generic_getxattr, |
885 | .removexattr = generic_removexattr, | ||
977 | .listxattr = xfs_vn_listxattr, | 886 | .listxattr = xfs_vn_listxattr, |
978 | .removexattr = xfs_vn_removexattr, | ||
979 | }; | 887 | }; |