qemu/hw/9pfs/9p-util.c
<<
>>
Prefs
   1/*
   2 * 9p utilities
   3 *
   4 * Copyright IBM, Corp. 2017
   5 *
   6 * Authors:
   7 *  Greg Kurz <groug@kaod.org>
   8 *
   9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
  10 * See the COPYING file in the top-level directory.
  11 */
  12
  13#include "qemu/osdep.h"
  14#include "qemu/xattr.h"
  15#include "9p-util.h"
  16
  17ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name,
  18                             void *value, size_t size)
  19{
  20    char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename);
  21    int ret;
  22
  23    ret = lgetxattr(proc_path, name, value, size);
  24    g_free(proc_path);
  25    return ret;
  26}
  27
  28ssize_t flistxattrat_nofollow(int dirfd, const char *filename,
  29                              char *list, size_t size)
  30{
  31    char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename);
  32    int ret;
  33
  34    ret = llistxattr(proc_path, list, size);
  35    g_free(proc_path);
  36    return ret;
  37}
  38
  39ssize_t fremovexattrat_nofollow(int dirfd, const char *filename,
  40                                const char *name)
  41{
  42    char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename);
  43    int ret;
  44
  45    ret = lremovexattr(proc_path, name);
  46    g_free(proc_path);
  47    return ret;
  48}
  49
  50int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name,
  51                         void *value, size_t size, int flags)
  52{
  53    char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename);
  54    int ret;
  55
  56    ret = lsetxattr(proc_path, name, value, size, flags);
  57    g_free(proc_path);
  58    return ret;
  59}
  60