From 3a79e8e7721fbc40b8c63cf4473d92793be73a1a Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Fri, 16 Aug 2019 05:06:54 +0000 Subject: [PATCH] fusefs: don't send the namespace during listextattr The FUSE_LISTXATTR operation always returns the full list of a file's extended attributes, in all namespaces. There's no way to filter the list server-side. However, currently FreeBSD's fusefs driver sends a namespace string with the FUSE_LISTXATTR request. That behavior was probably copied from fuse_vnop_getextattr, which has an attribute name argument. It's been there ever since extended attribute support was added in r324620. This commit removes it. Reviewed by: cem MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21280 --- sys/fs/fuse/fuse_vnops.c | 10 +--------- tests/sys/fs/fusefs/mockfs.cc | 9 +++------ 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c index f1079b2844e7..9dc879ee961e 100644 --- a/sys/fs/fuse/fuse_vnops.c +++ b/sys/fs/fuse/fuse_vnops.c @@ -2246,9 +2246,7 @@ fuse_vnop_listextattr(struct vop_listextattr_args *ap) struct mount *mp = vnode_mount(vp); struct thread *td = ap->a_td; struct ucred *cred = ap->a_cred; - size_t len; char *prefix; - char *attr_str; char *bsd_list = NULL; char *linux_list; int bsd_list_len; @@ -2274,9 +2272,7 @@ fuse_vnop_listextattr(struct vop_listextattr_args *ap) else prefix = EXTATTR_NAMESPACE_USER_STRING; - len = strlen(prefix) + sizeof(extattr_namespace_separator) + 1; - - fdisp_init(&fdi, sizeof(*list_xattr_in) + len); + fdisp_init(&fdi, sizeof(*list_xattr_in)); fdisp_make_vp(&fdi, FUSE_LISTXATTR, vp, td, cred); /* @@ -2284,8 +2280,6 @@ fuse_vnop_listextattr(struct vop_listextattr_args *ap) */ list_xattr_in = fdi.indata; list_xattr_in->size = 0; - attr_str = (char *)fdi.indata + sizeof(*list_xattr_in); - snprintf(attr_str, len, "%s%c", prefix, extattr_namespace_separator); err = fdisp_wait_answ(&fdi); if (err != 0) { @@ -2310,8 +2304,6 @@ fuse_vnop_listextattr(struct vop_listextattr_args *ap) fdisp_refresh_vp(&fdi, FUSE_LISTXATTR, vp, td, cred); list_xattr_in = fdi.indata; list_xattr_in->size = linux_list_len + sizeof(*list_xattr_out); - attr_str = (char *)fdi.indata + sizeof(*list_xattr_in); - snprintf(attr_str, len, "%s%c", prefix, extattr_namespace_separator); err = fdisp_wait_answ(&fdi); if (err != 0) diff --git a/tests/sys/fs/fusefs/mockfs.cc b/tests/sys/fs/fusefs/mockfs.cc index c8fd601397ff..1b3f737f20ac 100644 --- a/tests/sys/fs/fusefs/mockfs.cc +++ b/tests/sys/fs/fusefs/mockfs.cc @@ -554,16 +554,13 @@ void MockFS::audit_request(const mockfs_buf_in &in) { "Missing request attribute name"; break; case FUSE_GETXATTR: - ASSERT_GE(inlen, fih + sizeof(in.body.setxattr)) << + ASSERT_GE(inlen, fih + sizeof(in.body.getxattr)) << "Missing request body"; - ASSERT_GT(inlen, fih + sizeof(in.body.setxattr)) << + ASSERT_GT(inlen, fih + sizeof(in.body.getxattr)) << "Missing request attribute name"; break; case FUSE_LISTXATTR: - ASSERT_GE(inlen, fih + sizeof(in.body.listxattr)) << - "Missing request body"; - ASSERT_GT(inlen, fih + sizeof(in.body.listxattr)) << - "Missing namespace"; + ASSERT_EQ(inlen, fih + sizeof(in.body.listxattr)); break; case FUSE_REMOVEXATTR: ASSERT_GT(inlen, fih) << "Missing request attribute name";