diff mbox series

[3/3] scrub: Remove libattr dependency

Message ID 20240827115032.406321-4-cem@kernel.org (mailing list archive)
State New
Headers show
Series Get rid of libattr dependency | expand

Commit Message

Carlos Maiolino Aug. 27, 2024, 11:50 a.m. UTC
From: Carlos Maiolino <cem@kernel.org>

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

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
 libfrog/attr.h | 5 +++++
 scrub/Makefile | 4 ----
 scrub/phase5.c | 9 +++------
 3 files changed, 8 insertions(+), 10 deletions(-)

Comments

Christoph Hellwig Aug. 27, 2024, 12:16 p.m. UTC | #1
>   */
> +
>  #define ATTR_ENTRY(buffer, index)		\

Spurious whitespace change.

>  	((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?

> +	struct xfs_attrlist		*attrlist = (struct xfs_attrlist *)attrbuf;

Overly long line.
Carlos Maiolino Aug. 27, 2024, 12:27 p.m. UTC | #2
On Tue, Aug 27, 2024 at 05:16:47AM GMT, Christoph Hellwig wrote:
> >   */
> > +
> >  #define ATTR_ENTRY(buffer, index)		\
> 
> Spurious whitespace change.
> 
> >  	((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?

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.

> 
> > +	struct xfs_attrlist		*attrlist = (struct xfs_attrlist *)attrbuf;
> 
> Overly long line.

Ok, Thanks!

Carlos
Darrick J. Wong Aug. 27, 2024, 2:36 p.m. UTC | #3
On Tue, Aug 27, 2024 at 02:27:07PM +0200, Carlos Maiolino wrote:
> On Tue, Aug 27, 2024 at 05:16:47AM GMT, Christoph Hellwig wrote:
> > >   */
> > > +
> > >  #define ATTR_ENTRY(buffer, index)		\
> > 
> > Spurious whitespace change.
> > 
> > >  	((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?
> 
> 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.

> 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

> 
> > 
> > > +	struct xfs_attrlist		*attrlist = (struct xfs_attrlist *)attrbuf;
> > 
> > Overly long line.
> 
> Ok, Thanks!
> 
> Carlos
>
Christoph Hellwig Aug. 28, 2024, 4:35 a.m. UTC | #4
On Tue, Aug 27, 2024 at 07:36:15AM -0700, Darrick J. Wong wrote:
> > 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..
diff mbox series

Patch

diff --git a/libfrog/attr.h b/libfrog/attr.h
index 9110499f2..f1a10b5ae 100644
--- a/libfrog/attr.h
+++ b/libfrog/attr.h
@@ -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__ */
diff --git a/scrub/Makefile b/scrub/Makefile
index 53e8cb02a..1e1109048 100644
--- a/scrub/Makefile
+++ b/scrub/Makefile
@@ -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)
diff --git a/scrub/phase5.c b/scrub/phase5.c
index 27fa29be6..2e495643f 100644
--- a/scrub/phase5.c
+++ b/scrub/phase5.c
@@ -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(