From 6450084a66b6cf72b9126a8c8ecead7ddca896e9 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Sun, 27 Feb 2022 17:35:13 -0500 Subject: 9p: Rename 9p-util -> 9p-util-linux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current file only has the Linux versions of these functions. Rename the file accordingly and update the Makefile to only build it on Linux. A Darwin version of these will follow later in the series. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch Signed-off-by: Will Cohen Reviewed-by: Greg Kurz Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20220227223522.91937-3-wwcohen@gmail.com> Signed-off-by: Christian Schoenebeck --- hw/9pfs/9p-util-linux.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ hw/9pfs/9p-util.c | 64 ------------------------------------------------- hw/9pfs/meson.build | 2 +- 3 files changed, 65 insertions(+), 65 deletions(-) create mode 100644 hw/9pfs/9p-util-linux.c delete mode 100644 hw/9pfs/9p-util.c diff --git a/hw/9pfs/9p-util-linux.c b/hw/9pfs/9p-util-linux.c new file mode 100644 index 0000000000..398614a5d0 --- /dev/null +++ b/hw/9pfs/9p-util-linux.c @@ -0,0 +1,64 @@ +/* + * 9p utilities (Linux Implementation) + * + * Copyright IBM, Corp. 2017 + * + * Authors: + * Greg Kurz + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +/* + * Not so fast! You might want to read the 9p developer docs first: + * https://wiki.qemu.org/Documentation/9p + */ + +#include "qemu/osdep.h" +#include "qemu/xattr.h" +#include "9p-util.h" + +ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name, + void *value, size_t size) +{ + char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); + int ret; + + ret = lgetxattr(proc_path, name, value, size); + g_free(proc_path); + return ret; +} + +ssize_t flistxattrat_nofollow(int dirfd, const char *filename, + char *list, size_t size) +{ + char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); + int ret; + + ret = llistxattr(proc_path, list, size); + g_free(proc_path); + return ret; +} + +ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, + const char *name) +{ + char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); + int ret; + + ret = lremovexattr(proc_path, name); + g_free(proc_path); + return ret; +} + +int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, + void *value, size_t size, int flags) +{ + char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); + int ret; + + ret = lsetxattr(proc_path, name, value, size, flags); + g_free(proc_path); + return ret; +} diff --git a/hw/9pfs/9p-util.c b/hw/9pfs/9p-util.c deleted file mode 100644 index 3221d9b498..0000000000 --- a/hw/9pfs/9p-util.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 9p utilities - * - * Copyright IBM, Corp. 2017 - * - * Authors: - * Greg Kurz - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -/* - * Not so fast! You might want to read the 9p developer docs first: - * https://wiki.qemu.org/Documentation/9p - */ - -#include "qemu/osdep.h" -#include "qemu/xattr.h" -#include "9p-util.h" - -ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name, - void *value, size_t size) -{ - char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); - int ret; - - ret = lgetxattr(proc_path, name, value, size); - g_free(proc_path); - return ret; -} - -ssize_t flistxattrat_nofollow(int dirfd, const char *filename, - char *list, size_t size) -{ - char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); - int ret; - - ret = llistxattr(proc_path, list, size); - g_free(proc_path); - return ret; -} - -ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, - const char *name) -{ - char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); - int ret; - - ret = lremovexattr(proc_path, name); - g_free(proc_path); - return ret; -} - -int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, - void *value, size_t size, int flags) -{ - char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); - int ret; - - ret = lsetxattr(proc_path, name, value, size, flags); - g_free(proc_path); - return ret; -} diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build index 99be5d9119..1b28e70040 100644 --- a/hw/9pfs/meson.build +++ b/hw/9pfs/meson.build @@ -4,7 +4,6 @@ fs_ss.add(files( '9p-posix-acl.c', '9p-proxy.c', '9p-synth.c', - '9p-util.c', '9p-xattr-user.c', '9p-xattr.c', '9p.c', @@ -14,6 +13,7 @@ fs_ss.add(files( 'coth.c', 'coxattr.c', )) +fs_ss.add(when: 'CONFIG_LINUX', if_true: files('9p-util-linux.c')) fs_ss.add(when: 'CONFIG_XEN', if_true: files('xen-9p-backend.c')) softmmu_ss.add_all(when: 'CONFIG_FSDEV_9P', if_true: fs_ss) -- cgit v1.2.3