Statistics
| Branch: | Revision:

root / hw / 9pfs / virtio-9p-xattr.h @ a6f4e09d

History | View | Annotate | Download (3.3 kB)

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