diff options
Diffstat (limited to 'fs/xfs/xfs_attr.c')
-rw-r--r-- | fs/xfs/xfs_attr.c | 272 |
1 files changed, 0 insertions, 272 deletions
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 }; | ||