blob: 2bbae2dcb5a831dc446033600848d6d953cbfe0a [file] [log] [blame]
Aneesh Kumar K.Vfc221182010-10-18 15:28:16 +05301/*
2 * Virtio 9p
3 *
4 * Copyright IBM, Corp. 2010
5 *
6 * Authors:
7 * Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
11 *
12 */
13#ifndef _QEMU_VIRTIO_9P_XATTR_H
14#define _QEMU_VIRTIO_9P_XATTR_H
15
16#include <attr/xattr.h>
17
18typedef struct xattr_operations
19{
20 const char *name;
21 ssize_t (*getxattr)(FsContext *ctx, const char *path,
22 const char *name, void *value, size_t size);
23 ssize_t (*listxattr)(FsContext *ctx, const char *path,
24 char *name, void *value, size_t size);
25 int (*setxattr)(FsContext *ctx, const char *path, const char *name,
26 void *value, size_t size, int flags);
27 int (*removexattr)(FsContext *ctx,
28 const char *path, const char *name);
29} XattrOperations;
30
31
32extern XattrOperations mapped_user_xattr;
33extern XattrOperations passthrough_user_xattr;
34
Aneesh Kumar K.V70fc55e2010-10-18 15:28:16 +053035extern XattrOperations mapped_pacl_xattr;
36extern XattrOperations mapped_dacl_xattr;
37extern XattrOperations passthrough_acl_xattr;
38extern XattrOperations none_acl_xattr;
39
Aneesh Kumar K.Vfc221182010-10-18 15:28:16 +053040extern XattrOperations *mapped_xattr_ops[];
41extern XattrOperations *passthrough_xattr_ops[];
42extern XattrOperations *none_xattr_ops[];
43
Blue Swirl64b85a82011-01-23 16:21:20 +000044ssize_t v9fs_get_xattr(FsContext *ctx, const char *path, const char *name,
45 void *value, size_t size);
46ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, void *value,
47 size_t vsize);
48int v9fs_set_xattr(FsContext *ctx, const char *path, const char *name,
Aneesh Kumar K.Vfc221182010-10-18 15:28:16 +053049 void *value, size_t size, int flags);
Blue Swirl64b85a82011-01-23 16:21:20 +000050int v9fs_remove_xattr(FsContext *ctx, const char *path, const char *name);
51ssize_t pt_listxattr(FsContext *ctx, const char *path, char *name, void *value,
52 size_t size);
Aneesh Kumar K.Vfc221182010-10-18 15:28:16 +053053
54static inline ssize_t pt_getxattr(FsContext *ctx, const char *path,
55 const char *name, void *value, size_t size)
56{
57 return lgetxattr(rpath(ctx, path), name, value, size);
58}
59
60static inline int pt_setxattr(FsContext *ctx, const char *path,
61 const char *name, void *value,
62 size_t size, int flags)
63{
64 return lsetxattr(rpath(ctx, path), name, value, size, flags);
65}
66
67static inline int pt_removexattr(FsContext *ctx,
68 const char *path, const char *name)
69{
70 return lremovexattr(rpath(ctx, path), name);
71}
72
Aneesh Kumar K.V70fc55e2010-10-18 15:28:16 +053073static inline ssize_t notsup_getxattr(FsContext *ctx, const char *path,
74 const char *name, void *value,
75 size_t size)
76{
77 errno = ENOTSUP;
78 return -1;
79}
80
81static inline int notsup_setxattr(FsContext *ctx, const char *path,
82 const char *name, void *value,
83 size_t size, int flags)
84{
85 errno = ENOTSUP;
86 return -1;
87}
88
89static inline ssize_t notsup_listxattr(FsContext *ctx, const char *path,
90 char *name, void *value, size_t size)
91{
92 return 0;
93}
94
95static inline int notsup_removexattr(FsContext *ctx,
96 const char *path, const char *name)
97{
98 errno = ENOTSUP;
99 return -1;
100}
101
Aneesh Kumar K.Vfc221182010-10-18 15:28:16 +0530102#endif