[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 07/20] 9p: Move a couple xattr functions to 9p-ut
From: |
Keno Fischer |
Subject: |
[Qemu-devel] [PATCH v2 07/20] 9p: Move a couple xattr functions to 9p-util |
Date: |
Thu, 31 May 2018 21:26:02 -0400 |
These functions will need custom implementations on Darwin. Since the
implementation is very similar among all of them, and 9p-util already
has the _nofollow version of fgetxattrat, let's move them all there.
Signed-off-by: Keno Fischer <address@hidden>
---
Changes since v1:
* fgetxattr_follow is dropped in favor of a different approach
later in the series.
hw/9pfs/9p-util.c | 33 +++++++++++++++++++++++++++++++++
hw/9pfs/9p-util.h | 4 ++++
hw/9pfs/9p-xattr.c | 33 ---------------------------------
3 files changed, 37 insertions(+), 33 deletions(-)
diff --git a/hw/9pfs/9p-util.c b/hw/9pfs/9p-util.c
index f709c27..614b7fc 100644
--- a/hw/9pfs/9p-util.c
+++ b/hw/9pfs/9p-util.c
@@ -24,3 +24,36 @@ ssize_t fgetxattrat_nofollow(int dirfd, const char
*filename, const char *name,
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.h b/hw/9pfs/9p-util.h
index dc0d2e2..79ed6b2 100644
--- a/hw/9pfs/9p-util.h
+++ b/hw/9pfs/9p-util.h
@@ -60,5 +60,9 @@ ssize_t fgetxattrat_nofollow(int dirfd, const char *path,
const char *name,
void *value, size_t size);
int fsetxattrat_nofollow(int dirfd, const char *path, const char *name,
void *value, size_t size, int flags);
+ssize_t flistxattrat_nofollow(int dirfd, const char *filename,
+ char *list, size_t size);
+ssize_t fremovexattrat_nofollow(int dirfd, const char *filename,
+ const char *name);
#endif
diff --git a/hw/9pfs/9p-xattr.c b/hw/9pfs/9p-xattr.c
index d05c1a1..c696d8f 100644
--- a/hw/9pfs/9p-xattr.c
+++ b/hw/9pfs/9p-xattr.c
@@ -60,17 +60,6 @@ ssize_t pt_listxattr(FsContext *ctx, const char *path,
return name_size;
}
-static 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;
-}
-
/*
* Get the list and pass to each layer to find out whether
* to send the data or not
@@ -196,17 +185,6 @@ ssize_t pt_getxattr(FsContext *ctx, const char *path,
const char *name,
return local_getxattr_nofollow(ctx, path, name, value, size);
}
-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;
-}
-
ssize_t local_setxattr_nofollow(FsContext *ctx, const char *path,
const char *name, void *value, size_t size,
int flags)
@@ -235,17 +213,6 @@ int pt_setxattr(FsContext *ctx, const char *path, const
char *name, void *value,
return local_setxattr_nofollow(ctx, path, name, value, size, flags);
}
-static 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;
-}
-
ssize_t local_removexattr_nofollow(FsContext *ctx, const char *path,
const char *name)
{
--
2.8.1
- [Qemu-devel] [PATCH v2 00/20] 9p: Add support for Darwin, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 01/20] cutils: Provide strchrnul, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 02/20] 9p: proxy: Fix size passed to `connect`, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 06/20] 9p: Avoid warning if FS_IOC_GETVERSION is not defined, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 03/20] 9p: xattr: Fix crash due to free of uninitialized value, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 05/20] 9p: Properly set errp in fstatfs error path, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 04/20] 9p: linux: Fix a couple Linux assumptions, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 07/20] 9p: Move a couple xattr functions to 9p-util,
Keno Fischer <=
- [Qemu-devel] [PATCH v2 11/20] 9p: darwin: Handle struct dirent differences, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 08/20] 9p: Rename 9p-util -> 9p-util-linux, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 09/20] 9p: Properly check/translate flags in unlinkat, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 10/20] 9p: darwin: Handle struct stat(fs) differences, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 12/20] 9p: darwin: Explicitly cast comparisons of mode_t with -1, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 14/20] 9p: darwin: Provide a compatibility definition for XATTR_SIZE_MAX, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 13/20] 9p: darwin: Ignore O_{NOATIME, DIRECT}, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 18/20] 9p: darwin: Implement compatibility for mknodat, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 19/20] 9p: darwin: virtfs-proxy: Implement setuid code for darwin, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 15/20] 9p: darwin: *xattr_nofollow implementations, Keno Fischer, 2018/05/31