Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Sep 2023 16:44:11 GMT
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: ed3248554e5f - releng/14.0 - linux(4): Merge removexattr for future error recode
Message-ID:  <202309121644.38CGiBUf071034@gitrepo.freebsd.org>

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

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

commit ed3248554e5f4806cbda5198c7af8d3b112518c7
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-09-01 08:10:44 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-09-12 16:42:41 +0000

    linux(4): Merge removexattr for future error recode
    
    Approved by:            re (gjb)
    Tested by:              zirias
    MFC after:              1 week
    
    (cherry picked from commit dfcc0237c3a97f4f7962da854389f3c5d976145a)
    (cherry picked from commit 0f35bf8b294e2c57ef0d9cd39f0f44e36cd4f7be)
---
 sys/compat/linux/linux_xattr.c | 54 +++++++++++++++++++++++++++++-------------
 1 file changed, 37 insertions(+), 17 deletions(-)

diff --git a/sys/compat/linux/linux_xattr.c b/sys/compat/linux/linux_xattr.c
index b9717c62133c..2b46cf708c7d 100644
--- a/sys/compat/linux/linux_xattr.c
+++ b/sys/compat/linux/linux_xattr.c
@@ -77,6 +77,13 @@ struct getxattr_args {
 	int		follow;
 };
 
+struct removexattr_args {
+	int		fd;
+	const char	*path;
+	const char	*name;
+	int		follow;
+};
+
 static char *extattr_namespace_names[] = EXTATTR_NAMESPACE_NAMES;
 
 
@@ -227,47 +234,60 @@ linux_flistxattr(struct thread *td, struct linux_flistxattr_args *args)
 }
 
 static int
-linux_path_removexattr(struct thread *td, const char *upath, const char *uname,
-    int follow)
+removexattr(struct thread *td, struct removexattr_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_delete_path(td, upath, attrnamespace,
-	    attrname, follow, UIO_USERSPACE));
+	if (args->path != NULL)
+		error = kern_extattr_delete_path(td, args->path, attrnamespace,
+		    attrname, args->follow, UIO_USERSPACE);
+	else
+		error = kern_extattr_delete_fd(td, args->fd, attrnamespace,
+		    attrname);
+	return (error);
 }
 
 int
 linux_removexattr(struct thread *td, struct linux_removexattr_args *args)
 {
+	struct removexattr_args eargs = {
+		.fd = -1,
+		.path = args->path,
+		.name = args->name,
+		.follow = FOLLOW,
+	};
 
-	return (linux_path_removexattr(td, args->path, args->name,
-	    FOLLOW));
+	return (removexattr(td, &eargs));
 }
 
 int
 linux_lremovexattr(struct thread *td, struct linux_lremovexattr_args *args)
 {
+	struct removexattr_args eargs = {
+		.fd = -1,
+		.path = args->path,
+		.name = args->name,
+		.follow = NOFOLLOW,
+	};
 
-	return (linux_path_removexattr(td, args->path, args->name,
-	    NOFOLLOW));
+	return (removexattr(td, &eargs));
 }
 
 int
 linux_fremovexattr(struct thread *td, struct linux_fremovexattr_args *args)
 {
-	char attrname[LINUX_XATTR_NAME_MAX + 1];
-	int attrnamespace, error;
+	struct removexattr_args eargs = {
+		.fd = args->fd,
+		.path = NULL,
+		.name = args->name,
+		.follow = 0,
+	};
 
-	error = xatrr_to_extattr(args->name, &attrnamespace, attrname);
-	if (error != 0)
-		return (error);
-	return (kern_extattr_delete_fd(td, args->fd, attrnamespace,
-	    attrname));
+	return (removexattr(td, &eargs));
 }
 
 static int



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