aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Chagin <dchagin@FreeBSD.org>2023-09-01 08:10:44 +0000
committerDmitry Chagin <dchagin@FreeBSD.org>2023-09-12 16:42:41 +0000
commited3248554e5f4806cbda5198c7af8d3b112518c7 (patch)
tree574bbe11cd0ead8e5d7ede27b5723db50a5ac81a
parent01d9f0eebf8dceddc465fecac919c1e9d7a586a2 (diff)
downloadsrc-ed3248554e5f4806cbda5198c7af8d3b112518c7.tar.gz
src-ed3248554e5f4806cbda5198c7af8d3b112518c7.zip
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)
-rw-r--r--sys/compat/linux/linux_xattr.c54
1 files 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