Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Sep 2023 08:14:39 GMT
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 6b46ec66129d - main - linux(4): Merge getxattr for future error recode
Message-ID:  <202309010814.3818EdQw008273@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=6b46ec66129d9490c91876f72d98e514121996a6

commit 6b46ec66129d9490c91876f72d98e514121996a6
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-09-01 08:09:49 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-09-01 08:09:49 +0000

    linux(4): Merge getxattr for future error recode
    
    Tested by:              zirias
    MFC after:              1 week
---
 sys/compat/linux/linux_xattr.c | 62 ++++++++++++++++++++++++++++++------------
 1 file changed, 45 insertions(+), 17 deletions(-)

diff --git a/sys/compat/linux/linux_xattr.c b/sys/compat/linux/linux_xattr.c
index b54a0d2f89ad..901123684154 100644
--- a/sys/compat/linux/linux_xattr.c
+++ b/sys/compat/linux/linux_xattr.c
@@ -68,6 +68,15 @@ struct setxattr_args {
 	int		follow;
 };
 
+struct getxattr_args {
+	int		fd;
+	const char	*path;
+	const char	*name;
+	void 		*value;
+	l_size_t	size;
+	int		follow;
+};
+
 static char *extattr_namespace_names[] = EXTATTR_NAMESPACE_NAMES;
 
 
@@ -262,47 +271,66 @@ linux_fremovexattr(struct thread *td, struct linux_fremovexattr_args *args)
 }
 
 static int
-linux_path_getxattr(struct thread *td, const char *upath, const char *uname,
-    void *value, l_size_t size, int follow)
+getxattr(struct thread *td, struct getxattr_args *args)
 {
 	char attrname[LINUX_XATTR_NAME_MAX + 1];
 	int attrnamespace, error;
 
-	error = xatrr_to_extattr(uname, &attrnamespace, attrname);
+	error = xatrr_to_extattr(args->name, &attrnamespace, attrname);
 	if (error != 0)
 		return (error);
-
-	return (kern_extattr_get_path(td, upath, attrnamespace,
-	    attrname, value, size, follow, UIO_USERSPACE));
+	if (args->path != NULL)
+		error = kern_extattr_get_path(td, args->path, attrnamespace,
+		    attrname, args->value, args->size, args->follow, UIO_USERSPACE);
+	else
+		error = kern_extattr_get_fd(td, args->fd, attrnamespace,
+		    attrname, args->value, args->size);
+	return (error);
 }
 
 int
 linux_getxattr(struct thread *td, struct linux_getxattr_args *args)
 {
+	struct getxattr_args eargs = {
+		.fd = -1,
+		.path = args->path,
+		.name = args->name,
+		.value = args->value,
+		.size = args->size,
+		.follow = FOLLOW,
+	};
 
-	return (linux_path_getxattr(td, args->path, args->name,
-	    args->value, args->size, FOLLOW));
+	return (getxattr(td, &eargs));
 }
 
 int
 linux_lgetxattr(struct thread *td, struct linux_lgetxattr_args *args)
 {
+	struct getxattr_args eargs = {
+		.fd = -1,
+		.path = args->path,
+		.name = args->name,
+		.value = args->value,
+		.size = args->size,
+		.follow = NOFOLLOW,
+	};
 
-	return (linux_path_getxattr(td, args->path, args->name,
-	    args->value, args->size, NOFOLLOW));
+	return (getxattr(td, &eargs));
 }
 
 int
 linux_fgetxattr(struct thread *td, struct linux_fgetxattr_args *args)
 {
-	char attrname[LINUX_XATTR_NAME_MAX + 1];
-	int attrnamespace, error;
+	struct getxattr_args eargs = {
+		.fd = args->fd,
+		.path = NULL,
+		.name = args->name,
+		.value = args->value,
+		.size = args->size,
+		.follow = 0,
+	};
 
-	error = xatrr_to_extattr(args->name, &attrnamespace, attrname);
-	if (error != 0)
-		return (error);
-	return (kern_extattr_get_fd(td, args->fd, attrnamespace,
-	    attrname, args->value, args->size));
+	return (getxattr(td, &eargs));
 }
 
 static int



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202309010814.3818EdQw008273>