Skip to contentSkip to conversation

Get rid of libattr dependency

PATCH In review [email protected] 3 participants 16 messages Aug 27, 2024 – Aug 29, 2024

lore
Share & tools
lore
#0 lore raw

cover Get rid of libattr dependency

From: Carlos Maiolino <[email protected]>

libxfs already defines most of the structs used by xfsprogs, so we don't really need to link against libattr.

To make things more organized, and smaller easy to review patches, remove it in steps,

This is only compile-tested so far. I just sent the patches for testing, but giving it might take a while, I'm sending it to the list for review.

Carlos Maiolino (3):
libhandle: Remove libattr dependency
libfrog: remove libattr dependency
scrub: Remove libattr dependency

 include/handle.h   |  3 +--
 include/jdm.h      |  5 ++---
 libfrog/Makefile   |  7 ++-----
 libfrog/attr.h     | 23 +++++++++++++++++++++++
 libfrog/fsprops.c  | 13 ++++++-------
 libhandle/handle.c |  2 +-
 libhandle/jdm.c    | 14 +++++++-------
 scrub/Makefile     |  4 ----
 scrub/phase5.c     | 11 ++++-------
 9 files changed, 46 insertions(+), 36 deletions(-)
 create mode 100644 libfrog/attr.h
Signature · 1 line
2.46.0
#1 lore raw

PATCH 1/3 libhandle: Remove libattr dependency

From: Carlos Maiolino <[email protected]>

Aiming torwards removing xfsprogs libattr dependency, getting rid of libattr_cursor is the first step.

libxfs already has our own definition of xfs_libattr_cursor, so we can simply use it.

---
 include/handle.h   |  3 +--
 include/jdm.h      |  5 ++---
 libfrog/fsprops.c  |  8 ++++----
 libhandle/handle.c |  2 +-
 libhandle/jdm.c    | 14 +++++++-------
 scrub/phase5.c     |  2 +-
 6 files changed, 16 insertions(+), 18 deletions(-)
include/handle.h +1 -2
index ba0650051..991bd5d01 100644
@@ -11,7 +11,6 @@ extern "C" {
 #endif
 
 struct fsdmidata;
-struct attrlist_cursor;
 struct parent;
 
 extern int  path_to_handle (char *__path, void **__hanp, size_t *__hlen);
@@ -29,7 +28,7 @@ extern int  attr_multi_by_handle (void *__hanp, size_t __hlen, void *__buf,
 				  int __rtrvcnt, int __flags);
 extern int  attr_list_by_handle (void *__hanp, size_t __hlen, void *__buf,
 				 size_t __bufsize, int __flags,
-				 struct attrlist_cursor *__cursor);
+				 struct xfs_attrlist_cursor *__cursor);
 extern int  parents_by_handle(void *__hanp, size_t __hlen,
 			      struct parent *__buf, size_t __bufsize,
 			      unsigned int *__count);
include/jdm.h +2 -3
index 50c2296b4..669ee75ce 100644
@@ -12,7 +12,6 @@ typedef void	jdm_filehandle_t;	/* filehandle */
 
 struct xfs_bstat;
 struct xfs_bulkstat;
-struct attrlist_cursor;
 struct parent;
 
 extern jdm_fshandle_t *
@@ -60,11 +59,11 @@ extern intgen_t
 jdm_attr_list(	jdm_fshandle_t *fshp,
 		struct xfs_bstat *statp,
 		char *bufp, size_t bufsz, int flags,
-		struct attrlist_cursor *cursor);
+		struct xfs_attrlist_cursor *cursor);
 
 intgen_t jdm_attr_list_v5(jdm_fshandle_t *fshp, struct xfs_bulkstat *statp,
 		char *bufp, size_t bufsz, int flags,
-		struct attrlist_cursor *cursor);
+		struct xfs_attrlist_cursor *cursor);
 
 extern int
 jdm_parents( jdm_fshandle_t *fshp,
libfrog/fsprops.c +4 -4
index 88046b7a0..05a584a56 100644
@@ -68,10 +68,10 @@ fsprops_walk_names(
 	fsprops_name_walk_fn	walk_fn,
 	void			*priv)
 {
-	struct attrlist_cursor	cur = { };
-	char			attrbuf[XFS_XATTR_LIST_MAX];
-	struct attrlist		*attrlist = (struct attrlist *)attrbuf;
-	int			ret;
+	struct xfs_attrlist_cursor	cur = { };
+	char				attrbuf[XFS_XATTR_LIST_MAX];
+	struct attrlist			*attrlist = (struct attrlist *)attrbuf;
+	int				ret;
 
 	memset(attrbuf, 0, XFS_XATTR_LIST_MAX);
 
libhandle/handle.c +1 -1
index 1e8fe9ac5..a9a9f9534 100644
@@ -381,7 +381,7 @@ attr_list_by_handle(
 	void		*buf,
 	size_t		bufsize,
 	int		flags,
-	struct attrlist_cursor *cursor)
+	struct		xfs_attrlist_cursor *cursor)
 {
 	int		error, fd;
 	char		*path;
libhandle/jdm.c +7 -7
index e21aff2b2..9ce605ad3 100644
@@ -221,7 +221,7 @@ int
 jdm_attr_list(	jdm_fshandle_t *fshp,
 		struct xfs_bstat *statp,
 		char *bufp, size_t bufsz, int flags,
-		struct attrlist_cursor *cursor)
+		struct xfs_attrlist_cursor *cursor)
 {
 	fshandle_t *fshandlep = ( fshandle_t * )fshp;
 	filehandle_t filehandle;
@@ -240,12 +240,12 @@ jdm_attr_list(	jdm_fshandle_t *fshp,
 
 int
 jdm_attr_list_v5(
-	jdm_fshandle_t		*fshp,
-	struct xfs_bulkstat	*statp,
-	char			*bufp,
-	size_t			bufsz,
-	int			flags,
-	struct attrlist_cursor	*cursor)
+	jdm_fshandle_t			*fshp,
+	struct xfs_bulkstat		*statp,
+	char				*bufp,
+	size_t				bufsz,
+	int				flags,
+	struct xfs_attrlist_cursor	*cursor)
 {
 	struct fshandle		*fshandlep = (struct fshandle *)fshp;
 	struct filehandle	filehandle;
scrub/phase5.c +1 -1
index f6c295c64..27fa29be6 100644
@@ -190,7 +190,7 @@ check_xattr_ns_names(
 	struct xfs_bulkstat		*bstat,
 	const struct attrns_decode	*attr_ns)
 {
-	struct attrlist_cursor		cur;
+	struct xfs_attrlist_cursor	cur;
 	char				attrbuf[XFS_XATTR_LIST_MAX];
 	char				keybuf[XATTR_NAME_MAX + 1];
 	struct attrlist			*attrlist = (struct attrlist *)attrbuf;
Signature · 1 line
2.46.0
#8 lore raw

PATCH 2/3 libfrog: remove libattr dependency

In reply to [email protected]

From: Carlos Maiolino <[email protected]>

Get rid of libfrog's libattr dependency, and move the needed local definitions to a new header - libfrog/attr.h

We could keep the ATTR_ENTRY definition local to fsprops.h, but we'll add more content to it in the next patch.

---
 libfrog/Makefile  |  7 ++-----
 libfrog/attr.h    | 18 ++++++++++++++++++
 libfrog/fsprops.c |  7 +++----
 3 files changed, 23 insertions(+), 9 deletions(-)
 create mode 100644 libfrog/attr.h
libfrog/Makefile +2 -5
index acddc894e..8581c146b 100644
@@ -21,6 +21,7 @@ crc32.c \
 file_exchange.c \
 fsgeom.c \
 fsproperties.c \
+fsprops.c \
 getparents.c \
 histogram.c \
 list_sort.c \
@@ -49,6 +50,7 @@ div64.h \
 file_exchange.h \
 fsgeom.h \
 fsproperties.h \
+fsprops.h \
 getparents.h \
 histogram.h \
 logging.h \
@@ -62,11 +64,6 @@ workqueue.h
 
 LSRCFILES += gen_crc32table.c
 
-ifeq ($(HAVE_LIBATTR),yes)
-CFILES+=fsprops.c
-HFILES+=fsprops.h
-endif
-
 LDIRT = gen_crc32table crc32table.h
 
 default: ltdepend $(LTLIBRARY)
libfrog/attr.h new file +18 -0
new file mode 100644
index 000000000..9110499f2
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (c) 2024 Red Hat, Inc.  All Rights Reserved.
+ * Author: Carlos Maiolino <[email protected]>
+ */
+#ifndef __LIBFROG_ATTR_H__
+#define __LIBFROG_ATTR_H__
+
+/*
+ * Those definitions come from libattr
+ *
+ * We are redifining here so we don't need to keep libattr as a dependency anymore
+ */
+#define ATTR_ENTRY(buffer, index)		\
+	((struct xfs_attrlist_ent *)		\
+	 &((char *)buffer)[ ((struct xfs_attrlist *)(buffer))->al_offset[index] ])
+
+#endif /* __LIBFROG_ATTR_H__ */
libfrog/fsprops.c +3 -4
index 05a584a56..ea47c66ed 100644
@@ -10,8 +10,7 @@
 #include "libfrog/bulkstat.h"
 #include "libfrog/fsprops.h"
 #include "libfrog/fsproperties.h"
-
-#include <attr/attributes.h>
+#include "libfrog/attr.h"
 
 /*
  * Given an xfd and a mount table path, get us the handle for the root dir so
@@ -70,7 +69,7 @@ fsprops_walk_names(
 {
 	struct xfs_attrlist_cursor	cur = { };
 	char				attrbuf[XFS_XATTR_LIST_MAX];
-	struct attrlist			*attrlist = (struct attrlist *)attrbuf;
+	struct xfs_attrlist		*attrlist = (struct xfs_attrlist *)attrbuf;
 	int				ret;
 
 	memset(attrbuf, 0, XFS_XATTR_LIST_MAX);
@@ -81,7 +80,7 @@ fsprops_walk_names(
 		unsigned int	i;
 
 		for (i = 0; i < attrlist->al_count; i++) {
-			struct attrlist_ent	*ent = ATTR_ENTRY(attrlist, i);
+			struct xfs_attrlist_ent	*ent = ATTR_ENTRY(attrlist, i);
 			const char		*p =
 				attr_name_to_fsprop_name(ent->a_name);
 
Signature · 1 line
2.46.0
#11 lore raw

PATCH 3/3 scrub: Remove libattr dependency

In reply to [email protected]

From: Carlos Maiolino <[email protected]>

Rename all attrlist usage to xfs_attrlist, and add a couple more definitions to libfrog/attr.h

---
 libfrog/attr.h | 5 +++++
 scrub/Makefile | 4 ----
 scrub/phase5.c | 9 +++------
 3 files changed, 8 insertions(+), 10 deletions(-)
libfrog/attr.h +5 -0
index 9110499f2..f1a10b5ae 100644
@@ -11,8 +11,13 @@
  *
  * We are redifining here so we don't need to keep libattr as a dependency anymore
  */
+
 #define ATTR_ENTRY(buffer, index)		\
 	((struct xfs_attrlist_ent *)		\
 	 &((char *)buffer)[ ((struct xfs_attrlist *)(buffer))->al_offset[index] ])
 
+/* Attr flags used within xfsprogs, must match the definitions from libattr */
+#define ATTR_ROOT	0x0002	/* use root namespace attributes in op */
+#define ATTR_SECURE	0x0008	/* use security namespaces attributes in op */
+
 #endif /* __LIBFROG_ATTR_H__ */
scrub/Makefile +0 -4
index 53e8cb02a..1e1109048 100644
@@ -100,10 +100,6 @@ ifeq ($(HAVE_MALLINFO2),yes)
 LCFLAGS += -DHAVE_MALLINFO2
 endif
 
-ifeq ($(HAVE_LIBATTR),yes)
-LCFLAGS += -DHAVE_LIBATTR
-endif
-
 ifeq ($(HAVE_LIBICU),yes)
 CFILES += unicrash.c
 LCFLAGS += -DHAVE_LIBICU $(LIBICU_CFLAGS)
scrub/phase5.c +3 -6
index 27fa29be6..2e495643f 100644
@@ -20,6 +20,7 @@
 #include "libfrog/scrub.h"
 #include "libfrog/bitmap.h"
 #include "libfrog/bulkstat.h"
+#include "libfrog/attr.h"
 #include "xfs_scrub.h"
 #include "common.h"
 #include "inodes.h"
@@ -164,7 +165,6 @@ out_unicrash:
 	return ret;
 }
 
-#ifdef HAVE_LIBATTR
 /* Routines to scan all of an inode's xattrs for name problems. */
 struct attrns_decode {
 	int			flags;
@@ -193,8 +193,8 @@ check_xattr_ns_names(
 	struct xfs_attrlist_cursor	cur;
 	char				attrbuf[XFS_XATTR_LIST_MAX];
 	char				keybuf[XATTR_NAME_MAX + 1];
-	struct attrlist			*attrlist = (struct attrlist *)attrbuf;
-	struct attrlist_ent		*ent;
+	struct xfs_attrlist		*attrlist = (struct xfs_attrlist *)attrbuf;
+	struct xfs_attrlist_ent		*ent;
 	struct unicrash			*uc = NULL;
 	int				i;
 	int				error;
@@ -267,9 +267,6 @@ check_xattr_names(
 	}
 	return ret;
 }
-#else
-# define check_xattr_names(c, d, h, b)	(0)
-#endif /* HAVE_LIBATTR */
 
 static int
 render_ino_from_handle(
Signature · 1 line
2.46.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] libhandle: Remove libattr dependency

In reply to [email protected]

libfrog/fsprops.c fsprops_walk_names( · line 73

Quoted 3 lines · On Tue, Aug 27, 2024 at 01:50:22PM +0200, [email protected] wrote:
libfrog/fsprops.c +3 -0
+	struct xfs_attrlist_cursor	cur = { };
+	char				attrbuf[XFS_XATTR_LIST_MAX];
+	struct attrlist			*attrlist = (struct attrlist *)attrbuf;

Not really changed by this patch, but XFS_XATTR_LIST_MAX feels pretty large for an on-stack allocation. Maybe this should use a dynamic allocation, which would also remove the need for the cast?

Same in few other spots.

Not really something to worry about for this patch, so:

#9 lore raw

Re: [PATCH 2/3] libfrog: remove libattr dependency

In reply to [email protected]
Quoted 3 lines

+ * We are redifining here so we don't need to keep libattr as a dependency anymore

+#define ATTR_ENTRY(buffer, index) \

Maybe add a XFS_ prefix to distinguish this from the attrlist one and match the other xfs_ prefixes?

libfrog/attr.h line 16

Quoted 2 lines
libfrog/attr.h new file +2 -0
+	((struct xfs_attrlist_ent *)		\
+	 &((char *)buffer)[ ((struct xfs_attrlist *)(buffer))->al_offset[index] ])

And maybe this really should be an inline function as well.

libfrog/fsprops.c fsprops_walk_names( · line 72

Quoted 1 line
libfrog/fsprops.c +1 -0
+	struct xfs_attrlist		*attrlist = (struct xfs_attrlist *)attrbuf;

Overly long line

Otherwise this looks good.

#12 lore raw

Re: [PATCH 3/3] scrub: Remove libattr dependency

In reply to [email protected]
Quoted 3 lines

*/
+
#define ATTR_ENTRY(buffer, index) \

Spurious whitespace change.

libfrog/attr.h line 21

Quoted 6 lines
libfrog/attr.h +3 -0
 	((struct xfs_attrlist_ent *)		\
 	 &((char *)buffer)[ ((struct xfs_attrlist *)(buffer))->al_offset[index] ])
 
+/* Attr flags used within xfsprogs, must match the definitions from libattr */
+#define ATTR_ROOT	0x0002	/* use root namespace attributes in op */
+#define ATTR_SECURE	0x0008	/* use security namespaces attributes in op */

Why do we need these vs just using XFS_ATTR_ROOT/XFS_ATTR_SECURE from xfs_da_format.h?

scrub/phase5.c check_xattr_ns_names( · line 196

Quoted 1 line
scrub/phase5.c +1 -0
+	struct xfs_attrlist		*attrlist = (struct xfs_attrlist *)attrbuf;

Overly long line.

#10 lore raw

Re: [PATCH 2/3] libfrog: remove libattr dependency

In reply to Christoph Hellwig
Quoted 6 lines · Christoph Hellwig
Quoted 3 lines

+ * We are redifining here so we don't need to keep libattr as a dependency anymore

+#define ATTR_ENTRY(buffer, index) \

Maybe add a XFS_ prefix to distinguish this from the attrlist one and match the other xfs_ prefixes?

Sounds good, will update it.

Quoted 11 lines

libfrog/attr.h line 16

Quoted 3 lines
libfrog/attr.h new file +2 -0
+	((struct xfs_attrlist_ent *)		\
+	 &((char *)buffer)[ ((struct xfs_attrlist *)(buffer))->al_offset[index] ])

And maybe this really should be an inline function as well.

libfrog/fsprops.c fsprops_walk_names( · line 72

Quoted 1 line
libfrog/fsprops.c +1 -0
+	struct xfs_attrlist		*attrlist = (struct xfs_attrlist *)attrbuf;

Overly long line

Otherwise this looks good.

Thanks for the review, I'll wait for darrick to take a look and will send a V2

Carlos

#13 lore raw

Re: [PATCH 3/3] scrub: Remove libattr dependency

In reply to Christoph Hellwig
Quoted 9 lines · Christoph Hellwig
Quoted 3 lines

*/
+
#define ATTR_ENTRY(buffer, index) \

Spurious whitespace change.

Quoted 3 lines
libfrog/attr.h +0 -0
 	((struct xfs_attrlist_ent *)		\
 	 &((char *)buffer)[ ((struct xfs_attrlist *)(buffer))->al_offset[index] ])
Quoted 6 lines

libfrog/attr.h line 21

Quoted 3 lines
libfrog/attr.h +3 -0
+/* Attr flags used within xfsprogs, must match the definitions from libattr */
+#define ATTR_ROOT	0x0002	/* use root namespace attributes in op */
+#define ATTR_SECURE	0x0008	/* use security namespaces attributes in op */

Why do we need these vs just using XFS_ATTR_ROOT/XFS_ATTR_SECURE from xfs_da_format.h?

Because I didn't see XFS_ATTR_ROOT and XFS_ATTR_SECURE exists :)

I'll take a look on it, and if we don't really need to define ATTR_ROOT/SECURE, I'll just keep ATTR_ENTRY locally to fsprops.h, we don't need a header file for just a single definition IMO.

Quoted 4 lines

scrub/phase5.c check_xattr_ns_names( · line 196

Quoted 2 lines
scrub/phase5.c +1 -0
+	struct xfs_attrlist		*attrlist = (struct xfs_attrlist *)attrbuf;

Overly long line.

Ok, Thanks!

Carlos

#14 lore raw

Re: [PATCH 3/3] scrub: Remove libattr dependency

Quoted 10 lines · Carlos Maiolino
Quoted 9 lines · Christoph Hellwig
Quoted 3 lines

*/
+
#define ATTR_ENTRY(buffer, index) \

Spurious whitespace change.

Quoted 3 lines
libfrog/attr.h +0 -0
 	((struct xfs_attrlist_ent *)		\
 	 &((char *)buffer)[ ((struct xfs_attrlist *)(buffer))->al_offset[index] ])
Quoted 8 lines
Quoted 6 lines

libfrog/attr.h line 21

Quoted 3 lines
libfrog/attr.h +3 -0
+/* Attr flags used within xfsprogs, must match the definitions from libattr */
+#define ATTR_ROOT	0x0002	/* use root namespace attributes in op */
+#define ATTR_SECURE	0x0008	/* use security namespaces attributes in op */

Why do we need these vs just using XFS_ATTR_ROOT/XFS_ATTR_SECURE from xfs_da_format.h?

Because I didn't see XFS_ATTR_ROOT and XFS_ATTR_SECURE exists :)

Well if we're reusing symbols from xfs_fs.h then change these to XFS_IOC_ATTR_ROOT and XFS_IOC_ATTR_SECURE.

Quoted 3 lines

I'll take a look on it, and if we don't really need to define ATTR_ROOT/SECURE, I'll just keep ATTR_ENTRY locally to fsprops.h, we don't need a header file for just a single definition IMO.

<shrug> I'd have turned them into namespaced libfrog functions in libfrog/attr.h, and demacro'd ATTR_ENTRY too:

static inline struct xfs_attrlist_ent *
libfrog_attr_entry(
struct xfs_attrlist *list,
unsigned int index)

{
	char			*buffer = (char *)list;

	return (struct xfs_attrlist_ent *)&buffer[list->al_offset[index]];
}

static inline int
libfrog_attr_list_by_handle(

	void				*hanp,
	size_t				hlen,
	void				*buf,
	size_t				bufsize,
	int				flags,
	struct xfs_attrlist_cursor	*cursor)
{
	return attr_list_by_handle(hanp, hlen, buf, bufsize, flags,
			(struct attrlist_cursor *)cursor);
}

--D

Quoted 10 lines
Quoted 5 lines

scrub/phase5.c check_xattr_ns_names( · line 196

Quoted 3 lines
scrub/phase5.c +1 -0
+	struct xfs_attrlist		*attrlist = (struct xfs_attrlist *)attrbuf;

Overly long line.

Ok, Thanks!

Carlos

#5 lore raw

Re: [PATCH 1/3] libhandle: Remove libattr dependency

In reply to [email protected]
Quoted 52 lines · On Tue, Aug 27, 2024 at 01:50:22PM +0200, [email protected] wrote:

From: Carlos Maiolino <[email protected]>

Aiming torwards removing xfsprogs libattr dependency, getting rid of libattr_cursor is the first step.

libxfs already has our own definition of xfs_libattr_cursor, so we can simply use it.

---
 include/handle.h   |  3 +--
 include/jdm.h      |  5 ++---
 libfrog/fsprops.c  |  8 ++++----
 libhandle/handle.c |  2 +-
 libhandle/jdm.c    | 14 +++++++-------
 scrub/phase5.c     |  2 +-
 6 files changed, 16 insertions(+), 18 deletions(-)
include/handle.h +1 -2
index ba0650051..991bd5d01 100644
@@ -11,7 +11,6 @@ extern "C" {
 #endif
 
 struct fsdmidata;
-struct attrlist_cursor;
 struct parent;
 
 extern int  path_to_handle (char *__path, void **__hanp, size_t *__hlen);
@@ -29,7 +28,7 @@ extern int  attr_multi_by_handle (void *__hanp, size_t __hlen, void *__buf,
 				  int __rtrvcnt, int __flags);
 extern int  attr_list_by_handle (void *__hanp, size_t __hlen, void *__buf,
 				 size_t __bufsize, int __flags,
-				 struct attrlist_cursor *__cursor);
+				 struct xfs_attrlist_cursor *__cursor);
 extern int  parents_by_handle(void *__hanp, size_t __hlen,
 			      struct parent *__buf, size_t __bufsize,
 			      unsigned int *__count);
include/jdm.h +0 -1
index 50c2296b4..669ee75ce 100644
@@ -12,7 +12,6 @@ typedef void	jdm_filehandle_t;	/* filehandle */
 
 struct xfs_bstat;
 struct xfs_bulkstat;
-struct attrlist_cursor;
 struct parent;
 
 extern jdm_fshandle_t *

include/jdm.h extern intgen_t · line 66

Quoted 10 lines
include/jdm.h +2 -2
@@ -60,11 +59,11 @@ extern intgen_t
 jdm_attr_list(	jdm_fshandle_t *fshp,
 		struct xfs_bstat *statp,
 		char *bufp, size_t bufsz, int flags,
-		struct attrlist_cursor *cursor);
+		struct xfs_attrlist_cursor *cursor);
 
 intgen_t jdm_attr_list_v5(jdm_fshandle_t *fshp, struct xfs_bulkstat *statp,
 		char *bufp, size_t bufsz, int flags,
-		struct attrlist_cursor *cursor);
+		struct xfs_attrlist_cursor *cursor);

Hmm. Here you're changing function signatures for a public library. attrlist_cursor and xfs_attrlist_cursor are the same object, but I wonder if this is going to cause downstream compilation errors for programs that include libattr but not xfs_fs.h?

I simply made a shim libfrog/fakelibattr.h that wraps the libhandle stuff (albeit in a fragile manner, but I don't expect any further libattr updates) so that we don't have to change libhandle itself.

Quoted 26 lines
include/jdm.h +0 -0
 extern int
 jdm_parents( jdm_fshandle_t *fshp,
libfrog/fsprops.c +4 -4
index 88046b7a0..05a584a56 100644
@@ -68,10 +68,10 @@ fsprops_walk_names(
 	fsprops_name_walk_fn	walk_fn,
 	void			*priv)
 {
-	struct attrlist_cursor	cur = { };
-	char			attrbuf[XFS_XATTR_LIST_MAX];
-	struct attrlist		*attrlist = (struct attrlist *)attrbuf;
-	int			ret;
+	struct xfs_attrlist_cursor	cur = { };
+	char				attrbuf[XFS_XATTR_LIST_MAX];
+	struct attrlist			*attrlist = (struct attrlist *)attrbuf;
+	int				ret;
 
 	memset(attrbuf, 0, XFS_XATTR_LIST_MAX);
 
libhandle/handle.c +0 -0
index 1e8fe9ac5..a9a9f9534 100644

libhandle/handle.c attr_list_by_handle( · line 384

Quoted 5 lines
libhandle/handle.c +1 -1
@@ -381,7 +381,7 @@ attr_list_by_handle(
 	void		*buf,
 	size_t		bufsize,
 	int		flags,
-	struct attrlist_cursor *cursor)
+	struct		xfs_attrlist_cursor *cursor)

Odd indenting here.

--D

Quoted 52 lines
libhandle/handle.c +0 -0
 {
 	int		error, fd;
 	char		*path;
libhandle/jdm.c +7 -7
index e21aff2b2..9ce605ad3 100644
@@ -221,7 +221,7 @@ int
 jdm_attr_list(	jdm_fshandle_t *fshp,
 		struct xfs_bstat *statp,
 		char *bufp, size_t bufsz, int flags,
-		struct attrlist_cursor *cursor)
+		struct xfs_attrlist_cursor *cursor)
 {
 	fshandle_t *fshandlep = ( fshandle_t * )fshp;
 	filehandle_t filehandle;
@@ -240,12 +240,12 @@ jdm_attr_list(	jdm_fshandle_t *fshp,
 
 int
 jdm_attr_list_v5(
-	jdm_fshandle_t		*fshp,
-	struct xfs_bulkstat	*statp,
-	char			*bufp,
-	size_t			bufsz,
-	int			flags,
-	struct attrlist_cursor	*cursor)
+	jdm_fshandle_t			*fshp,
+	struct xfs_bulkstat		*statp,
+	char				*bufp,
+	size_t				bufsz,
+	int				flags,
+	struct xfs_attrlist_cursor	*cursor)
 {
 	struct fshandle		*fshandlep = (struct fshandle *)fshp;
 	struct filehandle	filehandle;
scrub/phase5.c +1 -1
index f6c295c64..27fa29be6 100644
@@ -190,7 +190,7 @@ check_xattr_ns_names(
 	struct xfs_bulkstat		*bstat,
 	const struct attrns_decode	*attr_ns)
 {
-	struct attrlist_cursor		cur;
+	struct xfs_attrlist_cursor	cur;
 	char				attrbuf[XFS_XATTR_LIST_MAX];
 	char				keybuf[XATTR_NAME_MAX + 1];
 	struct attrlist			*attrlist = (struct attrlist *)attrbuf;
Signature · 1 line
2.46.0
#3 lore raw

Re: [PATCH 1/3] libhandle: Remove libattr dependency

In reply to Christoph Hellwig
Quoted 10 lines · Christoph Hellwig

libfrog/fsprops.c fsprops_walk_names( · line 73

Quoted 3 lines · On Tue, Aug 27, 2024 at 01:50:22PM +0200, [email protected] wrote:
libfrog/fsprops.c +3 -0
+	struct xfs_attrlist_cursor	cur = { };
+	char				attrbuf[XFS_XATTR_LIST_MAX];
+	struct attrlist			*attrlist = (struct attrlist *)attrbuf;

Not really changed by this patch, but XFS_XATTR_LIST_MAX feels pretty large for an on-stack allocation. Maybe this should use a dynamic allocation, which would also remove the need for the cast?

Same in few other spots.

Yeah, the name list buffer here and in scrub could also be reduced in size to 4k or something like that. Long ago the attrlist ioctl had a bug in it where it would loop forever, which is why scrub allocated such a huge buffer to try to avoid falling into that trap. But that was ~2017, those kernels should have been retired or patched by now.

--D

Quoted 5 lines

Not really something to worry about for this patch, so:

#4 lore raw

Re: [PATCH 1/3] libhandle: Remove libattr dependency

Quoted 10 lines · Darrick J. Wong
Quoted 9 lines · Christoph Hellwig

libfrog/fsprops.c fsprops_walk_names( · line 73

Quoted 3 lines · On Tue, Aug 27, 2024 at 01:50:22PM +0200, [email protected] wrote:
libfrog/fsprops.c +3 -0
+	struct xfs_attrlist_cursor	cur = { };
+	char				attrbuf[XFS_XATTR_LIST_MAX];
+	struct attrlist			*attrlist = (struct attrlist *)attrbuf;

Not really changed by this patch, but XFS_XATTR_LIST_MAX feels pretty large for an on-stack allocation. Maybe this should use a dynamic allocation, which would also remove the need for the cast?

Quoted 7 lines
Quoted 1 line

Same in few other spots.

Yeah, the name list buffer here and in scrub could also be reduced in size to 4k or something like that. Long ago the attrlist ioctl had a bug in it where it would loop forever, which is why scrub allocated such a huge buffer to try to avoid falling into that trap. But that was ~2017, those kernels should have been retired or patched by now.

One nice thing about the dynamic allocation is that we can get rid of the silly char buffer and the casting..

#6 lore raw

Re: [PATCH 1/3] libhandle: Remove libattr dependency

In reply to Darrick J. Wong
Quoted 4 lines · Darrick J. Wong

Hmm. Here you're changing function signatures for a public library. attrlist_cursor and xfs_attrlist_cursor are the same object, but I wonder if this is going to cause downstream compilation errors for programs that include libattr but not xfs_fs.h?

Oh, I forgot that jdm.h is public. Yes, this will cause the compiler to complain, so we can't do that.

#15 lore raw

Re: [PATCH 3/3] scrub: Remove libattr dependency

In reply to Darrick J. Wong
Quoted 4 lines · Darrick J. Wong
Quoted 1 line

Because I didn't see XFS_ATTR_ROOT and XFS_ATTR_SECURE exists :)

Well if we're reusing symbols from xfs_fs.h then change these to XFS_IOC_ATTR_ROOT and XFS_IOC_ATTR_SECURE.

Ah, yes. We've got yet another name for those..

#7 lore raw

Re: [PATCH 1/3] libhandle: Remove libattr dependency

In reply to Christoph Hellwig

Sorry, came back late for the party...

Quoted 8 lines · Christoph Hellwig
Quoted 4 lines · Darrick J. Wong

Hmm. Here you're changing function signatures for a public library. attrlist_cursor and xfs_attrlist_cursor are the same object, but I wonder if this is going to cause downstream compilation errors for programs that include libattr but not xfs_fs.h?

Oh, I forgot that jdm.h is public. Yes, this will cause the compiler to complain, so we can't do that.

I spoke with darrick on Tuesday, and it seemed IMO that libhandle is supposed to be a xfsprogs thing, not something that should be packaged separated, but I might be totally wrong here.

If we ought to maintain jdm.h intact, then I'd come back to pack definitions into libfrog/attr.h, but what I don't like about this, is we'll end up with two definitions for virtually the same thing, xfs_attrlist in libfrog and attrlist in xfs_fs.h, unless we do use Darrick's idea and mimic libxfs behavior in libfrog/attr.h, something like:

#define xfs_attrlist_cursor attrlist_cursor

So we could use it within libfrog, without messing up with public libhandle interface?!

Carlos