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 | |
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')
-rw-r--r-- | fs/xfs/Makefile | 3 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_iops.c | 118 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_iops.h | 1 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_super.c | 1 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_super.h | 1 | ||||
-rw-r--r-- | fs/xfs/xfs_attr.c | 272 | ||||
-rw-r--r-- | fs/xfs/xfs_attr.h | 17 |
7 files changed, 18 insertions, 395 deletions
diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index 36ec614e699a..737c9a425361 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile | |||
@@ -106,7 +106,8 @@ xfs-y += $(addprefix $(XFS_LINUX)/, \ | |||
106 | xfs_iops.o \ | 106 | xfs_iops.o \ |
107 | xfs_lrw.o \ | 107 | xfs_lrw.o \ |
108 | xfs_super.o \ | 108 | xfs_super.o \ |
109 | xfs_vnode.o) | 109 | xfs_vnode.o \ |
110 | xfs_xattr.o) | ||
110 | 111 | ||
111 | # Objects in support/ | 112 | # Objects in support/ |
112 | xfs-y += $(addprefix support/, \ | 113 | xfs-y += $(addprefix support/, \ |
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 | }; |
diff --git a/fs/xfs/linux-2.6/xfs_iops.h b/fs/xfs/linux-2.6/xfs_iops.h index 3b4df5863e4a..d97ba934a2ac 100644 --- a/fs/xfs/linux-2.6/xfs_iops.h +++ b/fs/xfs/linux-2.6/xfs_iops.h | |||
@@ -27,6 +27,7 @@ extern const struct file_operations xfs_file_operations; | |||
27 | extern const struct file_operations xfs_dir_file_operations; | 27 | extern const struct file_operations xfs_dir_file_operations; |
28 | extern const struct file_operations xfs_invis_file_operations; | 28 | extern const struct file_operations xfs_invis_file_operations; |
29 | 29 | ||
30 | extern ssize_t xfs_vn_listxattr(struct dentry *, char *data, size_t size); | ||
30 | 31 | ||
31 | struct xfs_inode; | 32 | struct xfs_inode; |
32 | extern void xfs_ichgtime(struct xfs_inode *, int); | 33 | extern void xfs_ichgtime(struct xfs_inode *, int); |
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c index cce59cc6e748..967603c46998 100644 --- a/fs/xfs/linux-2.6/xfs_super.c +++ b/fs/xfs/linux-2.6/xfs_super.c | |||
@@ -1766,6 +1766,7 @@ xfs_fs_fill_super( | |||
1766 | goto out_free_mp; | 1766 | goto out_free_mp; |
1767 | 1767 | ||
1768 | sb_min_blocksize(sb, BBSIZE); | 1768 | sb_min_blocksize(sb, BBSIZE); |
1769 | sb->s_xattr = xfs_xattr_handlers; | ||
1769 | sb->s_export_op = &xfs_export_operations; | 1770 | sb->s_export_op = &xfs_export_operations; |
1770 | sb->s_qcop = &xfs_quotactl_operations; | 1771 | sb->s_qcop = &xfs_quotactl_operations; |
1771 | sb->s_op = &xfs_super_operations; | 1772 | sb->s_op = &xfs_super_operations; |
diff --git a/fs/xfs/linux-2.6/xfs_super.h b/fs/xfs/linux-2.6/xfs_super.h index 212bdc7a7897..b7d13da01bd6 100644 --- a/fs/xfs/linux-2.6/xfs_super.h +++ b/fs/xfs/linux-2.6/xfs_super.h | |||
@@ -110,6 +110,7 @@ extern void xfs_flush_device(struct xfs_inode *); | |||
110 | extern void xfs_blkdev_issue_flush(struct xfs_buftarg *); | 110 | extern void xfs_blkdev_issue_flush(struct xfs_buftarg *); |
111 | 111 | ||
112 | extern const struct export_operations xfs_export_operations; | 112 | extern const struct export_operations xfs_export_operations; |
113 | extern struct xattr_handler *xfs_xattr_handlers[]; | ||
113 | 114 | ||
114 | #define XFS_M(sb) ((struct xfs_mount *)((sb)->s_fs_info)) | 115 | #define XFS_M(sb) ((struct xfs_mount *)((sb)->s_fs_info)) |
115 | 116 | ||
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c index 557dad611de0..9d91af4929b1 100644 --- a/fs/xfs/xfs_attr.c +++ b/fs/xfs/xfs_attr.c | |||
@@ -57,11 +57,6 @@ | |||
57 | * Provide the external interfaces to manage attribute lists. | 57 | * Provide the external interfaces to manage attribute lists. |
58 | */ | 58 | */ |
59 | 59 | ||
60 | #define ATTR_SYSCOUNT 2 | ||
61 | static struct attrnames posix_acl_access; | ||
62 | static struct attrnames posix_acl_default; | ||
63 | static struct attrnames *attr_system_names[ATTR_SYSCOUNT]; | ||
64 | |||
65 | /*======================================================================== | 60 | /*======================================================================== |
66 | * Function prototypes for the kernel. | 61 | * Function prototypes for the kernel. |
67 | *========================================================================*/ | 62 | *========================================================================*/ |
@@ -2378,270 +2373,3 @@ xfs_attr_trace_enter(int type, char *where, | |||
2378 | (void *)a13, (void *)a14, (void *)a15); | 2373 | (void *)a13, (void *)a14, (void *)a15); |
2379 | } | 2374 | } |
2380 | #endif /* XFS_ATTR_TRACE */ | 2375 | #endif /* XFS_ATTR_TRACE */ |
2381 | |||
2382 | |||
2383 | /*======================================================================== | ||
2384 | * System (pseudo) namespace attribute interface routines. | ||
2385 | *========================================================================*/ | ||
2386 | |||
2387 | STATIC int | ||
2388 | posix_acl_access_set( | ||
2389 | bhv_vnode_t *vp, char *name, void *data, size_t size, int xflags) | ||
2390 | { | ||
2391 | return xfs_acl_vset(vp, data, size, _ACL_TYPE_ACCESS); | ||
2392 | } | ||
2393 | |||
2394 | STATIC int | ||
2395 | posix_acl_access_remove( | ||
2396 | bhv_vnode_t *vp, char *name, int xflags) | ||
2397 | { | ||
2398 | return xfs_acl_vremove(vp, _ACL_TYPE_ACCESS); | ||
2399 | } | ||
2400 | |||
2401 | STATIC int | ||
2402 | posix_acl_access_get( | ||
2403 | bhv_vnode_t *vp, char *name, void *data, size_t size, int xflags) | ||
2404 | { | ||
2405 | return xfs_acl_vget(vp, data, size, _ACL_TYPE_ACCESS); | ||
2406 | } | ||
2407 | |||
2408 | STATIC int | ||
2409 | posix_acl_access_exists( | ||
2410 | bhv_vnode_t *vp) | ||
2411 | { | ||
2412 | return xfs_acl_vhasacl_access(vp); | ||
2413 | } | ||
2414 | |||
2415 | STATIC int | ||
2416 | posix_acl_default_set( | ||
2417 | bhv_vnode_t *vp, char *name, void *data, size_t size, int xflags) | ||
2418 | { | ||
2419 | return xfs_acl_vset(vp, data, size, _ACL_TYPE_DEFAULT); | ||
2420 | } | ||
2421 | |||
2422 | STATIC int | ||
2423 | posix_acl_default_get( | ||
2424 | bhv_vnode_t *vp, char *name, void *data, size_t size, int xflags) | ||
2425 | { | ||
2426 | return xfs_acl_vget(vp, data, size, _ACL_TYPE_DEFAULT); | ||
2427 | } | ||
2428 | |||
2429 | STATIC int | ||
2430 | posix_acl_default_remove( | ||
2431 | bhv_vnode_t *vp, char *name, int xflags) | ||
2432 | { | ||
2433 | return xfs_acl_vremove(vp, _ACL_TYPE_DEFAULT); | ||
2434 | } | ||
2435 | |||
2436 | STATIC int | ||
2437 | posix_acl_default_exists( | ||
2438 | bhv_vnode_t *vp) | ||
2439 | { | ||
2440 | return xfs_acl_vhasacl_default(vp); | ||
2441 | } | ||
2442 | |||
2443 | static struct attrnames posix_acl_access = { | ||
2444 | .attr_name = "posix_acl_access", | ||
2445 | .attr_namelen = sizeof("posix_acl_access") - 1, | ||
2446 | .attr_get = posix_acl_access_get, | ||
2447 | .attr_set = posix_acl_access_set, | ||
2448 | .attr_remove = posix_acl_access_remove, | ||
2449 | .attr_exists = posix_acl_access_exists, | ||
2450 | }; | ||
2451 | |||
2452 | static struct attrnames posix_acl_default = { | ||
2453 | .attr_name = "posix_acl_default", | ||
2454 | .attr_namelen = sizeof("posix_acl_default") - 1, | ||
2455 | .attr_get = posix_acl_default_get, | ||
2456 | .attr_set = posix_acl_default_set, | ||
2457 | .attr_remove = posix_acl_default_remove, | ||
2458 | .attr_exists = posix_acl_default_exists, | ||
2459 | }; | ||
2460 | |||
2461 | static struct attrnames *attr_system_names[] = | ||
2462 | { &posix_acl_access, &posix_acl_default }; | ||
2463 | |||
2464 | |||
2465 | /*======================================================================== | ||
2466 | * Namespace-prefix-style attribute name interface routines. | ||
2467 | *========================================================================*/ | ||
2468 | |||
2469 | STATIC int | ||
2470 | attr_generic_set( | ||
2471 | bhv_vnode_t *vp, char *name, void *data, size_t size, int xflags) | ||
2472 | { | ||
2473 | return -xfs_attr_set(xfs_vtoi(vp), name, data, size, xflags); | ||
2474 | } | ||
2475 | |||
2476 | STATIC int | ||
2477 | attr_generic_get( | ||
2478 | bhv_vnode_t *vp, char *name, void *data, size_t size, int xflags) | ||
2479 | { | ||
2480 | int error, asize = size; | ||
2481 | |||
2482 | error = xfs_attr_get(xfs_vtoi(vp), name, data, &asize, xflags); | ||
2483 | if (!error) | ||
2484 | return asize; | ||
2485 | return -error; | ||
2486 | } | ||
2487 | |||
2488 | STATIC int | ||
2489 | attr_generic_remove( | ||
2490 | bhv_vnode_t *vp, char *name, int xflags) | ||
2491 | { | ||
2492 | return -xfs_attr_remove(xfs_vtoi(vp), name, xflags); | ||
2493 | } | ||
2494 | |||
2495 | STATIC int | ||
2496 | attr_generic_listadd( | ||
2497 | attrnames_t *prefix, | ||
2498 | attrnames_t *namesp, | ||
2499 | void *data, | ||
2500 | size_t size, | ||
2501 | ssize_t *result) | ||
2502 | { | ||
2503 | char *p = data + *result; | ||
2504 | |||
2505 | *result += prefix->attr_namelen; | ||
2506 | *result += namesp->attr_namelen + 1; | ||
2507 | if (!size) | ||
2508 | return 0; | ||
2509 | if (*result > size) | ||
2510 | return -ERANGE; | ||
2511 | strcpy(p, prefix->attr_name); | ||
2512 | p += prefix->attr_namelen; | ||
2513 | strcpy(p, namesp->attr_name); | ||
2514 | p += namesp->attr_namelen + 1; | ||
2515 | return 0; | ||
2516 | } | ||
2517 | |||
2518 | STATIC int | ||
2519 | attr_system_list( | ||
2520 | bhv_vnode_t *vp, | ||
2521 | void *data, | ||
2522 | size_t size, | ||
2523 | ssize_t *result) | ||
2524 | { | ||
2525 | attrnames_t *namesp; | ||
2526 | int i, error = 0; | ||
2527 | |||
2528 | for (i = 0; i < ATTR_SYSCOUNT; i++) { | ||
2529 | namesp = attr_system_names[i]; | ||
2530 | if (!namesp->attr_exists || !namesp->attr_exists(vp)) | ||
2531 | continue; | ||
2532 | error = attr_generic_listadd(&attr_system, namesp, | ||
2533 | data, size, result); | ||
2534 | if (error) | ||
2535 | break; | ||
2536 | } | ||
2537 | return error; | ||
2538 | } | ||
2539 | |||
2540 | int | ||
2541 | attr_generic_list( | ||
2542 | bhv_vnode_t *vp, void *data, size_t size, int xflags, ssize_t *result) | ||
2543 | { | ||
2544 | attrlist_cursor_kern_t cursor = { 0 }; | ||
2545 | int error; | ||
2546 | |||
2547 | error = xfs_attr_list(xfs_vtoi(vp), data, size, xflags, &cursor); | ||
2548 | if (error > 0) | ||
2549 | return -error; | ||
2550 | *result = -error; | ||
2551 | return attr_system_list(vp, data, size, result); | ||
2552 | } | ||
2553 | |||
2554 | attrnames_t * | ||
2555 | attr_lookup_namespace( | ||
2556 | char *name, | ||
2557 | struct attrnames **names, | ||
2558 | int nnames) | ||
2559 | { | ||
2560 | int i; | ||
2561 | |||
2562 | for (i = 0; i < nnames; i++) | ||
2563 | if (!strncmp(name, names[i]->attr_name, names[i]->attr_namelen)) | ||
2564 | return names[i]; | ||
2565 | return NULL; | ||
2566 | } | ||
2567 | |||
2568 | STATIC int | ||
2569 | attr_system_set( | ||
2570 | bhv_vnode_t *vp, char *name, void *data, size_t size, int xflags) | ||
2571 | { | ||
2572 | attrnames_t *namesp; | ||
2573 | int error; | ||
2574 | |||
2575 | if (xflags & ATTR_CREATE) | ||
2576 | return -EINVAL; | ||
2577 | |||
2578 | namesp = attr_lookup_namespace(name, attr_system_names, ATTR_SYSCOUNT); | ||
2579 | if (!namesp) | ||
2580 | return -EOPNOTSUPP; | ||
2581 | error = namesp->attr_set(vp, name, data, size, xflags); | ||
2582 | if (!error) | ||
2583 | error = vn_revalidate(vp); | ||
2584 | return error; | ||
2585 | } | ||
2586 | |||
2587 | STATIC int | ||
2588 | attr_system_get( | ||
2589 | bhv_vnode_t *vp, char *name, void *data, size_t size, int xflags) | ||
2590 | { | ||
2591 | attrnames_t *namesp; | ||
2592 | |||
2593 | namesp = attr_lookup_namespace(name, attr_system_names, ATTR_SYSCOUNT); | ||
2594 | if (!namesp) | ||
2595 | return -EOPNOTSUPP; | ||
2596 | return namesp->attr_get(vp, name, data, size, xflags); | ||
2597 | } | ||
2598 | |||
2599 | STATIC int | ||
2600 | attr_system_remove( | ||
2601 | bhv_vnode_t *vp, char *name, int xflags) | ||
2602 | { | ||
2603 | attrnames_t *namesp; | ||
2604 | |||
2605 | namesp = attr_lookup_namespace(name, attr_system_names, ATTR_SYSCOUNT); | ||
2606 | if (!namesp) | ||
2607 | return -EOPNOTSUPP; | ||
2608 | return namesp->attr_remove(vp, name, xflags); | ||
2609 | } | ||
2610 | |||
2611 | struct attrnames attr_system = { | ||
2612 | .attr_name = "system.", | ||
2613 | .attr_namelen = sizeof("system.") - 1, | ||
2614 | .attr_flag = ATTR_SYSTEM, | ||
2615 | .attr_get = attr_system_get, | ||
2616 | .attr_set = attr_system_set, | ||
2617 | .attr_remove = attr_system_remove, | ||
2618 | }; | ||
2619 | |||
2620 | struct attrnames attr_trusted = { | ||
2621 | .attr_name = "trusted.", | ||
2622 | .attr_namelen = sizeof("trusted.") - 1, | ||
2623 | .attr_flag = ATTR_ROOT, | ||
2624 | .attr_get = attr_generic_get, | ||
2625 | .attr_set = attr_generic_set, | ||
2626 | .attr_remove = attr_generic_remove, | ||
2627 | }; | ||
2628 | |||
2629 | struct attrnames attr_secure = { | ||
2630 | .attr_name = "security.", | ||
2631 | .attr_namelen = sizeof("security.") - 1, | ||
2632 | .attr_flag = ATTR_SECURE, | ||
2633 | .attr_get = attr_generic_get, | ||
2634 | .attr_set = attr_generic_set, | ||
2635 | .attr_remove = attr_generic_remove, | ||
2636 | }; | ||
2637 | |||
2638 | struct attrnames attr_user = { | ||
2639 | .attr_name = "user.", | ||
2640 | .attr_namelen = sizeof("user.") - 1, | ||
2641 | .attr_get = attr_generic_get, | ||
2642 | .attr_set = attr_generic_set, | ||
2643 | .attr_remove = attr_generic_remove, | ||
2644 | }; | ||
2645 | |||
2646 | struct attrnames *attr_namespaces[] = | ||
2647 | { &attr_system, &attr_trusted, &attr_secure, &attr_user }; | ||
diff --git a/fs/xfs/xfs_attr.h b/fs/xfs/xfs_attr.h index 9b96d171b75c..c1f7d43e5ecf 100644 --- a/fs/xfs/xfs_attr.h +++ b/fs/xfs/xfs_attr.h | |||
@@ -38,30 +38,14 @@ | |||
38 | struct cred; | 38 | struct cred; |
39 | struct xfs_attr_list_context; | 39 | struct xfs_attr_list_context; |
40 | 40 | ||
41 | typedef int (*attrset_t)(bhv_vnode_t *, char *, void *, size_t, int); | ||
42 | typedef int (*attrget_t)(bhv_vnode_t *, char *, void *, size_t, int); | ||
43 | typedef int (*attrremove_t)(bhv_vnode_t *, char *, int); | ||
44 | typedef int (*attrexists_t)(bhv_vnode_t *); | ||
45 | |||
46 | typedef struct attrnames { | 41 | typedef struct attrnames { |
47 | char * attr_name; | 42 | char * attr_name; |
48 | unsigned int attr_namelen; | 43 | unsigned int attr_namelen; |
49 | unsigned int attr_flag; | ||
50 | attrget_t attr_get; | ||
51 | attrset_t attr_set; | ||
52 | attrremove_t attr_remove; | ||
53 | attrexists_t attr_exists; | ||
54 | } attrnames_t; | 44 | } attrnames_t; |
55 | 45 | ||
56 | #define ATTR_NAMECOUNT 4 | ||
57 | extern struct attrnames attr_user; | 46 | extern struct attrnames attr_user; |
58 | extern struct attrnames attr_secure; | 47 | extern struct attrnames attr_secure; |
59 | extern struct attrnames attr_system; | ||
60 | extern struct attrnames attr_trusted; | 48 | extern struct attrnames attr_trusted; |
61 | extern struct attrnames *attr_namespaces[ATTR_NAMECOUNT]; | ||
62 | |||
63 | extern attrnames_t *attr_lookup_namespace(char *, attrnames_t **, int); | ||
64 | extern int attr_generic_list(bhv_vnode_t *, void *, size_t, int, ssize_t *); | ||
65 | 49 | ||
66 | #define ATTR_DONTFOLLOW 0x0001 /* -- unused, from IRIX -- */ | 50 | #define ATTR_DONTFOLLOW 0x0001 /* -- unused, from IRIX -- */ |
67 | #define ATTR_ROOT 0x0002 /* use attrs in root (trusted) namespace */ | 51 | #define ATTR_ROOT 0x0002 /* use attrs in root (trusted) namespace */ |
@@ -69,7 +53,6 @@ extern int attr_generic_list(bhv_vnode_t *, void *, size_t, int, ssize_t *); | |||
69 | #define ATTR_SECURE 0x0008 /* use attrs in security namespace */ | 53 | #define ATTR_SECURE 0x0008 /* use attrs in security namespace */ |
70 | #define ATTR_CREATE 0x0010 /* pure create: fail if attr already exists */ | 54 | #define ATTR_CREATE 0x0010 /* pure create: fail if attr already exists */ |
71 | #define ATTR_REPLACE 0x0020 /* pure set: fail if attr does not exist */ | 55 | #define ATTR_REPLACE 0x0020 /* pure set: fail if attr does not exist */ |
72 | #define ATTR_SYSTEM 0x0100 /* use attrs in system (pseudo) namespace */ | ||
73 | 56 | ||
74 | #define ATTR_KERNACCESS 0x0400 /* [kernel] iaccess, inode held io-locked */ | 57 | #define ATTR_KERNACCESS 0x0400 /* [kernel] iaccess, inode held io-locked */ |
75 | #define ATTR_KERNOTIME 0x1000 /* [kernel] don't update inode timestamps */ | 58 | #define ATTR_KERNOTIME 0x1000 /* [kernel] don't update inode timestamps */ |