9p-xattr.h 3.5 KB
Newer Older
1
/*
2
 * 9p
3 4 5 6 7 8 9 10 11 12
 *
 * Copyright IBM, Corp. 2010
 *
 * Authors:
 *  Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2.  See
 * the COPYING file in the top-level directory.
 *
 */
13 14 15

#ifndef QEMU_9P_XATTR_H
#define QEMU_9P_XATTR_H
16

17
#include "qemu/xattr.h"
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

typedef struct xattr_operations
{
    const char *name;
    ssize_t (*getxattr)(FsContext *ctx, const char *path,
                        const char *name, void *value, size_t size);
    ssize_t (*listxattr)(FsContext *ctx, const char *path,
                         char *name, void *value, size_t size);
    int (*setxattr)(FsContext *ctx, const char *path, const char *name,
                    void *value, size_t size, int flags);
    int (*removexattr)(FsContext *ctx,
                       const char *path, const char *name);
} XattrOperations;


extern XattrOperations mapped_user_xattr;
extern XattrOperations passthrough_user_xattr;

36 37 38 39 40
extern XattrOperations mapped_pacl_xattr;
extern XattrOperations mapped_dacl_xattr;
extern XattrOperations passthrough_acl_xattr;
extern XattrOperations none_acl_xattr;

41 42 43 44
extern XattrOperations *mapped_xattr_ops[];
extern XattrOperations *passthrough_xattr_ops[];
extern XattrOperations *none_xattr_ops[];

45 46 47 48 49
ssize_t v9fs_get_xattr(FsContext *ctx, const char *path, const char *name,
                       void *value, size_t size);
ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, void *value,
                        size_t vsize);
int v9fs_set_xattr(FsContext *ctx, const char *path, const char *name,
50
                          void *value, size_t size, int flags);
51 52 53
int v9fs_remove_xattr(FsContext *ctx, const char *path, const char *name);
ssize_t pt_listxattr(FsContext *ctx, const char *path, char *name, void *value,
                     size_t size);
54 55 56 57

static inline ssize_t pt_getxattr(FsContext *ctx, const char *path,
                                  const char *name, void *value, size_t size)
{
58 59 60 61 62 63 64
    char *buffer;
    ssize_t ret;

    buffer = rpath(ctx, path);
    ret = lgetxattr(buffer, name, value, size);
    g_free(buffer);
    return ret;
65 66 67 68 69 70
}

static inline int pt_setxattr(FsContext *ctx, const char *path,
                              const char *name, void *value,
                              size_t size, int flags)
{
71 72 73 74 75 76 77
    char *buffer;
    int ret;

    buffer = rpath(ctx, path);
    ret = lsetxattr(buffer, name, value, size, flags);
    g_free(buffer);
    return ret;
78 79 80 81 82
}

static inline int pt_removexattr(FsContext *ctx,
                                 const char *path, const char *name)
{
83 84 85 86 87 88 89
    char *buffer;
    int ret;

    buffer = rpath(ctx, path);
    ret = lremovexattr(path, name);
    g_free(buffer);
    return ret;
90 91
}

92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
static inline ssize_t notsup_getxattr(FsContext *ctx, const char *path,
                                      const char *name, void *value,
                                      size_t size)
{
    errno = ENOTSUP;
    return -1;
}

static inline int notsup_setxattr(FsContext *ctx, const char *path,
                                  const char *name, void *value,
                                  size_t size, int flags)
{
    errno = ENOTSUP;
    return -1;
}

static inline ssize_t notsup_listxattr(FsContext *ctx, const char *path,
                                       char *name, void *value, size_t size)
{
    return 0;
}

static inline int notsup_removexattr(FsContext *ctx,
                                     const char *path, const char *name)
{
    errno = ENOTSUP;
    return -1;
}

121
#endif