git: dfcc0237c3a9 - main - linux(4): Merge removexattr for future error recode
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 01 Sep 2023 08:14:41 UTC
The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=dfcc0237c3a97f4f7962da854389f3c5d976145a commit dfcc0237c3a97f4f7962da854389f3c5d976145a Author: Dmitry Chagin <dchagin@FreeBSD.org> AuthorDate: 2023-09-01 08:10:44 +0000 Commit: Dmitry Chagin <dchagin@FreeBSD.org> CommitDate: 2023-09-01 08:10:44 +0000 linux(4): Merge removexattr for future error recode Tested by: zirias MFC after: 1 week --- 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