qemu/hw/9pfs/9p-xattr.h
<<
>>
Prefs
   1/*
   2 * 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
  14#ifndef QEMU_9P_XATTR_H
  15#define QEMU_9P_XATTR_H
  16
  17#include "qemu/xattr.h"
  18
  19typedef struct xattr_operations
  20{
  21    const char *name;
  22    ssize_t (*getxattr)(FsContext *ctx, const char *path,
  23                        const char *name, void *value, size_t size);
  24    ssize_t (*listxattr)(FsContext *ctx, const char *path,
  25                         char *name, void *value, size_t size);
  26    int (*setxattr)(FsContext *ctx, const char *path, const char *name,
  27                    void *value, size_t size, int flags);
  28    int (*removexattr)(FsContext *ctx,
  29                       const char *path, const char *name);
  30} XattrOperations;
  31
  32
  33extern XattrOperations mapped_user_xattr;
  34extern XattrOperations passthrough_user_xattr;
  35
  36extern XattrOperations mapped_pacl_xattr;
  37extern XattrOperations mapped_dacl_xattr;
  38extern XattrOperations passthrough_acl_xattr;
  39extern XattrOperations none_acl_xattr;
  40
  41extern XattrOperations *mapped_xattr_ops[];
  42extern XattrOperations *passthrough_xattr_ops[];
  43extern XattrOperations *none_xattr_ops[];
  44
  45ssize_t v9fs_get_xattr(FsContext *ctx, const char *path, const char *name,
  46                       void *value, size_t size);
  47ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, void *value,
  48                        size_t vsize);
  49int v9fs_set_xattr(FsContext *ctx, const char *path, const char *name,
  50                          void *value, size_t size, int flags);
  51int v9fs_remove_xattr(FsContext *ctx, const char *path, const char *name);
  52ssize_t pt_listxattr(FsContext *ctx, const char *path, char *name, void *value,
  53                     size_t size);
  54
  55static inline ssize_t pt_getxattr(FsContext *ctx, const char *path,
  56                                  const char *name, void *value, size_t size)
  57{
  58    char *buffer;
  59    ssize_t ret;
  60
  61    buffer = rpath(ctx, path);
  62    ret = lgetxattr(buffer, name, value, size);
  63    g_free(buffer);
  64    return ret;
  65}
  66
  67static inline int pt_setxattr(FsContext *ctx, const char *path,
  68                              const char *name, void *value,
  69                              size_t size, int flags)
  70{
  71    char *buffer;
  72    int ret;
  73
  74    buffer = rpath(ctx, path);
  75    ret = lsetxattr(buffer, name, value, size, flags);
  76    g_free(buffer);
  77    return ret;
  78}
  79
  80static inline int pt_removexattr(FsContext *ctx,
  81                                 const char *path, const char *name)
  82{
  83    char *buffer;
  84    int ret;
  85
  86    buffer = rpath(ctx, path);
  87    ret = lremovexattr(path, name);
  88    g_free(buffer);
  89    return ret;
  90}
  91
  92static inline ssize_t notsup_getxattr(FsContext *ctx, const char *path,
  93                                      const char *name, void *value,
  94                                      size_t size)
  95{
  96    errno = ENOTSUP;
  97    return -1;
  98}
  99
 100static inline int notsup_setxattr(FsContext *ctx, const char *path,
 101                                  const char *name, void *value,
 102                                  size_t size, int flags)
 103{
 104    errno = ENOTSUP;
 105    return -1;
 106}
 107
 108static inline ssize_t notsup_listxattr(FsContext *ctx, const char *path,
 109                                       char *name, void *value, size_t size)
 110{
 111    return 0;
 112}
 113
 114static inline int notsup_removexattr(FsContext *ctx,
 115                                     const char *path, const char *name)
 116{
 117    errno = ENOTSUP;
 118    return -1;
 119}
 120
 121#endif
 122