* [PATCHSET] xfsprogs: do not depend on deprecated libattr
@ 2024-09-19 23:52 Darrick J. Wong
2024-09-19 23:53 ` [PATCH 1/2] misc: clean up code around attr_list_by_handle calls Darrick J. Wong
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Darrick J. Wong @ 2024-09-19 23:52 UTC (permalink / raw)
To: djwong, cem; +Cc: linux-xfs, hch
Hi all,
Remove xfsprogs dependence on libattr for certain attr_list_by_handle support
macros because libattr is deprecated. The code in that library came from XFS
originally anyway, so we can do a special one-off for ourselves.
This has been running on the djcloud for months with no problems. Enjoy!
Comments and questions are, as always, welcome.
--D
---
Commits in this patchset:
* misc: clean up code around attr_list_by_handle calls
* libfrog: emulate deprecated attrlist functionality in libattr
---
configure.ac | 2 --
debian/control | 2 +-
include/builddefs.in | 1 -
libfrog/Makefile | 8 ++-----
libfrog/fakelibattr.h | 36 ++++++++++++++++++++++++++++++
libfrog/fsprops.c | 22 ++++++++++--------
m4/package_attr.m4 | 25 ---------------------
scrub/Makefile | 4 ---
scrub/phase5.c | 59 +++++++++++++++++++++++++++----------------------
9 files changed, 85 insertions(+), 74 deletions(-)
create mode 100644 libfrog/fakelibattr.h
delete mode 100644 m4/package_attr.m4
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 1/2] misc: clean up code around attr_list_by_handle calls 2024-09-19 23:52 [PATCHSET] xfsprogs: do not depend on deprecated libattr Darrick J. Wong @ 2024-09-19 23:53 ` Darrick J. Wong 2024-09-20 11:26 ` Christoph Hellwig 2024-09-19 23:53 ` [PATCH 2/2] libfrog: emulate deprecated attrlist functionality in libattr Darrick J. Wong 2024-09-23 17:10 ` [PATCHSET] xfsprogs: do not depend on deprecated libattr Carlos Maiolino 2 siblings, 1 reply; 7+ messages in thread From: Darrick J. Wong @ 2024-09-19 23:53 UTC (permalink / raw) To: djwong, cem; +Cc: linux-xfs, hch From: Darrick J. Wong <djwong@kernel.org> Reduce stack usage of the attr_list_by_handle calls by allocating the buffers dynamically. Remove some redundant bits while we're at it. Signed-off-by: Darrick J. Wong <djwong@kernel.org> --- libfrog/fsprops.c | 10 ++++++---- scrub/phase5.c | 46 +++++++++++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/libfrog/fsprops.c b/libfrog/fsprops.c index 88046b7a0738..a25c2726cd58 100644 --- a/libfrog/fsprops.c +++ b/libfrog/fsprops.c @@ -69,13 +69,14 @@ fsprops_walk_names( void *priv) { struct attrlist_cursor cur = { }; - char attrbuf[XFS_XATTR_LIST_MAX]; - struct attrlist *attrlist = (struct attrlist *)attrbuf; + struct attrlist *attrlist; int ret; - memset(attrbuf, 0, XFS_XATTR_LIST_MAX); + attrlist = calloc(XFS_XATTR_LIST_MAX, 1); + if (!attrlist) + return -1; - while ((ret = attr_list_by_handle(fph->hanp, fph->hlen, attrbuf, + while ((ret = attr_list_by_handle(fph->hanp, fph->hlen, attrlist, XFS_XATTR_LIST_MAX, XFS_IOC_ATTR_ROOT, &cur)) == 0) { unsigned int i; @@ -96,6 +97,7 @@ fsprops_walk_names( break; } + free(attrlist); return ret; } diff --git a/scrub/phase5.c b/scrub/phase5.c index f6c295c64ada..d298d628a998 100644 --- a/scrub/phase5.c +++ b/scrub/phase5.c @@ -190,30 +190,40 @@ check_xattr_ns_names( struct xfs_bulkstat *bstat, const struct attrns_decode *attr_ns) { - struct 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 attrlist_cursor cur = { }; + char *keybuf; + struct attrlist *attrlist; struct unicrash *uc = NULL; int i; int error; + attrlist = calloc(XFS_XATTR_LIST_MAX, 1); + if (!attrlist) { + error = errno; + str_errno(ctx, descr_render(dsc)); + return error; + } + + keybuf = calloc(XATTR_NAME_MAX + 1, 1); + if (!keybuf) { + error = errno; + str_errno(ctx, descr_render(dsc)); + goto out_attrlist; + } + error = unicrash_xattr_init(&uc, ctx, bstat); if (error) { str_liberror(ctx, error, descr_render(dsc)); - return error; + goto out_keybuf; } - memset(attrbuf, 0, XFS_XATTR_LIST_MAX); - memset(&cur, 0, sizeof(cur)); - memset(keybuf, 0, XATTR_NAME_MAX + 1); - error = attr_list_by_handle(handle, sizeof(*handle), attrbuf, - XFS_XATTR_LIST_MAX, attr_ns->flags, &cur); - while (!error) { + while ((error = attr_list_by_handle(handle, sizeof(*handle), attrlist, + XFS_XATTR_LIST_MAX, attr_ns->flags, + &cur)) == 0) { /* Examine the xattrs. */ for (i = 0; i < attrlist->al_count; i++) { - ent = ATTR_ENTRY(attrlist, i); + struct attrlist_ent *ent = ATTR_ENTRY(attrlist, i); + snprintf(keybuf, XATTR_NAME_MAX, "%s.%s", attr_ns->name, ent->a_name); if (uc) @@ -225,14 +235,12 @@ check_xattr_ns_names( keybuf); if (error) { str_liberror(ctx, error, descr_render(dsc)); - goto out; + goto out_uc; } } if (!attrlist->al_more) break; - error = attr_list_by_handle(handle, sizeof(*handle), attrbuf, - XFS_XATTR_LIST_MAX, attr_ns->flags, &cur); } if (error) { if (errno == ESTALE) @@ -241,8 +249,12 @@ check_xattr_ns_names( if (errno) str_errno(ctx, descr_render(dsc)); } -out: +out_uc: unicrash_free(uc); +out_keybuf: + free(keybuf); +out_attrlist: + free(attrlist); return error; } ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] misc: clean up code around attr_list_by_handle calls 2024-09-19 23:53 ` [PATCH 1/2] misc: clean up code around attr_list_by_handle calls Darrick J. Wong @ 2024-09-20 11:26 ` Christoph Hellwig 0 siblings, 0 replies; 7+ messages in thread From: Christoph Hellwig @ 2024-09-20 11:26 UTC (permalink / raw) To: Darrick J. Wong; +Cc: cem, linux-xfs, hch Looks good: Reviewed-by: Christoph Hellwig <hch@lst.de> ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] libfrog: emulate deprecated attrlist functionality in libattr 2024-09-19 23:52 [PATCHSET] xfsprogs: do not depend on deprecated libattr Darrick J. Wong 2024-09-19 23:53 ` [PATCH 1/2] misc: clean up code around attr_list_by_handle calls Darrick J. Wong @ 2024-09-19 23:53 ` Darrick J. Wong 2024-09-20 11:26 ` Christoph Hellwig 2024-09-23 17:10 ` [PATCHSET] xfsprogs: do not depend on deprecated libattr Carlos Maiolino 2 siblings, 1 reply; 7+ messages in thread From: Darrick J. Wong @ 2024-09-19 23:53 UTC (permalink / raw) To: djwong, cem; +Cc: linux-xfs, hch From: Darrick J. Wong <djwong@kernel.org> Break our dependence on the (deprecated) libattr by emulating the necessary pieces in libfrog. It's a little sketchy to open-code these symbols, but they're originally from XFS so we trust ourselves. Signed-off-by: Darrick J. Wong <djwong@kernel.org> --- configure.ac | 2 -- debian/control | 2 +- include/builddefs.in | 1 - libfrog/Makefile | 8 +++----- libfrog/fakelibattr.h | 36 ++++++++++++++++++++++++++++++++++++ libfrog/fsprops.c | 16 ++++++++-------- m4/package_attr.m4 | 25 ------------------------- scrub/Makefile | 4 ---- scrub/phase5.c | 23 +++++++++-------------- 9 files changed, 57 insertions(+), 60 deletions(-) create mode 100644 libfrog/fakelibattr.h delete mode 100644 m4/package_attr.m4 diff --git a/configure.ac b/configure.ac index 33b01399ae3b..d021c519d538 100644 --- a/configure.ac +++ b/configure.ac @@ -152,8 +152,6 @@ AC_HAVE_DEVMAPPER AC_HAVE_MALLINFO AC_HAVE_MALLINFO2 AC_HAVE_MEMFD_CREATE -AC_PACKAGE_WANT_ATTRIBUTES_H -AC_HAVE_LIBATTR if test "$enable_scrub" = "yes"; then if test "$enable_libicu" = "yes" || test "$enable_libicu" = "probe"; then AC_HAVE_LIBICU diff --git a/debian/control b/debian/control index 3f05d4e3797c..66b0a47a36ee 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: admin Priority: optional Maintainer: XFS Development Team <linux-xfs@vger.kernel.org> Uploaders: Nathan Scott <nathans@debian.org>, Anibal Monsalve Salazar <anibal@debian.org>, Bastian Germann <bage@debian.org> -Build-Depends: libinih-dev (>= 53), uuid-dev, debhelper (>= 12), gettext, libtool, libedit-dev, libblkid-dev (>= 2.17), linux-libc-dev, libdevmapper-dev, libattr1-dev, libicu-dev, pkg-config, liburcu-dev, systemd-dev | systemd (<< 253-2~) +Build-Depends: libinih-dev (>= 53), uuid-dev, debhelper (>= 12), gettext, libtool, libedit-dev, libblkid-dev (>= 2.17), linux-libc-dev, libdevmapper-dev, libicu-dev, pkg-config, liburcu-dev, systemd-dev | systemd (<< 253-2~) Standards-Version: 4.0.0 Homepage: https://xfs.wiki.kernel.org/ diff --git a/include/builddefs.in b/include/builddefs.in index 1647d2cd1690..07c4a43f78a0 100644 --- a/include/builddefs.in +++ b/include/builddefs.in @@ -102,7 +102,6 @@ HAVE_DEVMAPPER = @have_devmapper@ HAVE_MALLINFO = @have_mallinfo@ HAVE_MALLINFO2 = @have_mallinfo2@ HAVE_MEMFD_CREATE = @have_memfd_create@ -HAVE_LIBATTR = @have_libattr@ HAVE_LIBICU = @have_libicu@ HAVE_SYSTEMD = @have_systemd@ SYSTEMD_SYSTEM_UNIT_DIR = @systemd_system_unit_dir@ diff --git a/libfrog/Makefile b/libfrog/Makefile index acddc894ee93..4da427789411 100644 --- a/libfrog/Makefile +++ b/libfrog/Makefile @@ -21,6 +21,7 @@ crc32.c \ file_exchange.c \ fsgeom.c \ fsproperties.c \ +fsprops.c \ getparents.c \ histogram.c \ list_sort.c \ @@ -46,9 +47,11 @@ crc32defs.h \ crc32table.h \ dahashselftest.h \ div64.h \ +fakelibattr.h \ file_exchange.h \ fsgeom.h \ fsproperties.h \ +fsprops.h \ getparents.h \ histogram.h \ logging.h \ @@ -62,11 +65,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) diff --git a/libfrog/fakelibattr.h b/libfrog/fakelibattr.h new file mode 100644 index 000000000000..30e0e51466d8 --- /dev/null +++ b/libfrog/fakelibattr.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2024 Oracle. All Rights Reserved. + * Author: Darrick J. Wong <djwong@kernel.org> + */ +#ifndef __LIBFROG_FAKELIBATTR_H__ +#define __LIBFROG_FAKELIBATTR_H__ + +/* This file emulates APIs from the deprecated libattr. */ + +struct attrlist_cursor; + +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); +} + +#endif /* __LIBFROG_FAKELIBATTR_H__ */ diff --git a/libfrog/fsprops.c b/libfrog/fsprops.c index a25c2726cd58..f59fbd9c2165 100644 --- a/libfrog/fsprops.c +++ b/libfrog/fsprops.c @@ -10,8 +10,7 @@ #include "libfrog/bulkstat.h" #include "libfrog/fsprops.h" #include "libfrog/fsproperties.h" - -#include <attr/attributes.h> +#include "libfrog/fakelibattr.h" /* * Given an xfd and a mount table path, get us the handle for the root dir so @@ -68,21 +67,22 @@ fsprops_walk_names( fsprops_name_walk_fn walk_fn, void *priv) { - struct attrlist_cursor cur = { }; - struct attrlist *attrlist; + struct xfs_attrlist_cursor cur = { }; + struct xfs_attrlist *attrlist; int ret; attrlist = calloc(XFS_XATTR_LIST_MAX, 1); if (!attrlist) return -1; - while ((ret = attr_list_by_handle(fph->hanp, fph->hlen, attrlist, - XFS_XATTR_LIST_MAX, XFS_IOC_ATTR_ROOT, - &cur)) == 0) { + while ((ret = libfrog_attr_list_by_handle(fph->hanp, fph->hlen, + attrlist, XFS_XATTR_LIST_MAX, + XFS_IOC_ATTR_ROOT, &cur)) == 0) { unsigned int i; for (i = 0; i < attrlist->al_count; i++) { - struct attrlist_ent *ent = ATTR_ENTRY(attrlist, i); + struct xfs_attrlist_ent *ent = + libfrog_attr_entry(attrlist, i); const char *p = attr_name_to_fsprop_name(ent->a_name); diff --git a/m4/package_attr.m4 b/m4/package_attr.m4 deleted file mode 100644 index 05e02b38fb5a..000000000000 --- a/m4/package_attr.m4 +++ /dev/null @@ -1,25 +0,0 @@ -AC_DEFUN([AC_PACKAGE_WANT_ATTRIBUTES_H], - [ - AC_CHECK_HEADERS(attr/attributes.h) - ]) - -# -# Check if we have a ATTR_ROOT flag and libattr structures -# -AC_DEFUN([AC_HAVE_LIBATTR], - [ AC_MSG_CHECKING([for struct attrlist_cursor]) - AC_COMPILE_IFELSE( - [ AC_LANG_PROGRAM([[ -#include <sys/types.h> -#include <attr/attributes.h> - ]], [[ -struct attrlist_cursor *cur; -struct attrlist *list; -struct attrlist_ent *ent; -int flags = ATTR_ROOT; - ]]) - ], have_libattr=yes - AC_MSG_RESULT(yes), - AC_MSG_RESULT(no)) - AC_SUBST(have_libattr) - ]) diff --git a/scrub/Makefile b/scrub/Makefile index 53e8cb02a926..1e1109048c2a 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 d298d628a998..e1d94f9a3568 100644 --- a/scrub/phase5.c +++ b/scrub/phase5.c @@ -8,9 +8,6 @@ #include <dirent.h> #include <sys/types.h> #include <sys/statvfs.h> -#ifdef HAVE_LIBATTR -# include <attr/attributes.h> -#endif #include <linux/fs.h> #include "handle.h" #include "list.h" @@ -20,6 +17,7 @@ #include "libfrog/scrub.h" #include "libfrog/bitmap.h" #include "libfrog/bulkstat.h" +#include "libfrog/fakelibattr.h" #include "xfs_scrub.h" #include "common.h" #include "inodes.h" @@ -164,7 +162,6 @@ check_dirent_names( return ret; } -#ifdef HAVE_LIBATTR /* Routines to scan all of an inode's xattrs for name problems. */ struct attrns_decode { int flags; @@ -173,8 +170,8 @@ struct attrns_decode { static const struct attrns_decode attr_ns[] = { {0, "user"}, - {ATTR_ROOT, "system"}, - {ATTR_SECURE, "secure"}, + {XFS_IOC_ATTR_ROOT, "system"}, + {XFS_IOC_ATTR_SECURE, "secure"}, {0, NULL}, }; @@ -190,9 +187,9 @@ check_xattr_ns_names( struct xfs_bulkstat *bstat, const struct attrns_decode *attr_ns) { - struct attrlist_cursor cur = { }; + struct xfs_attrlist_cursor cur = { }; char *keybuf; - struct attrlist *attrlist; + struct xfs_attrlist *attrlist; struct unicrash *uc = NULL; int i; int error; @@ -217,12 +214,13 @@ check_xattr_ns_names( goto out_keybuf; } - while ((error = attr_list_by_handle(handle, sizeof(*handle), attrlist, - XFS_XATTR_LIST_MAX, attr_ns->flags, + while ((error = libfrog_attr_list_by_handle(handle, sizeof(*handle), + attrlist, XFS_XATTR_LIST_MAX, attr_ns->flags, &cur)) == 0) { /* Examine the xattrs. */ for (i = 0; i < attrlist->al_count; i++) { - struct attrlist_ent *ent = ATTR_ENTRY(attrlist, i); + struct xfs_attrlist_ent *ent = + libfrog_attr_entry(attrlist, i); snprintf(keybuf, XATTR_NAME_MAX, "%s.%s", attr_ns->name, ent->a_name); @@ -279,9 +277,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( ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] libfrog: emulate deprecated attrlist functionality in libattr 2024-09-19 23:53 ` [PATCH 2/2] libfrog: emulate deprecated attrlist functionality in libattr Darrick J. Wong @ 2024-09-20 11:26 ` Christoph Hellwig 0 siblings, 0 replies; 7+ messages in thread From: Christoph Hellwig @ 2024-09-20 11:26 UTC (permalink / raw) To: Darrick J. Wong; +Cc: cem, linux-xfs, hch Looks good: Reviewed-by: Christoph Hellwig <hch@lst.de> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCHSET] xfsprogs: do not depend on deprecated libattr 2024-09-19 23:52 [PATCHSET] xfsprogs: do not depend on deprecated libattr Darrick J. Wong 2024-09-19 23:53 ` [PATCH 1/2] misc: clean up code around attr_list_by_handle calls Darrick J. Wong 2024-09-19 23:53 ` [PATCH 2/2] libfrog: emulate deprecated attrlist functionality in libattr Darrick J. Wong @ 2024-09-23 17:10 ` Carlos Maiolino 2 siblings, 0 replies; 7+ messages in thread From: Carlos Maiolino @ 2024-09-23 17:10 UTC (permalink / raw) To: Darrick J. Wong; +Cc: linux-xfs, hch On Thu, Sep 19, 2024 at 04:52:59PM GMT, Darrick J. Wong wrote: > Hi all, > > Remove xfsprogs dependence on libattr for certain attr_list_by_handle support > macros because libattr is deprecated. The code in that library came from XFS > originally anyway, so we can do a special one-off for ourselves. > > This has been running on the djcloud for months with no problems. Enjoy! > Comments and questions are, as always, welcome. For the series: Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Carlos > > --D > --- > Commits in this patchset: > * misc: clean up code around attr_list_by_handle calls > * libfrog: emulate deprecated attrlist functionality in libattr > --- > configure.ac | 2 -- > debian/control | 2 +- > include/builddefs.in | 1 - > libfrog/Makefile | 8 ++----- > libfrog/fakelibattr.h | 36 ++++++++++++++++++++++++++++++ > libfrog/fsprops.c | 22 ++++++++++-------- > m4/package_attr.m4 | 25 --------------------- > scrub/Makefile | 4 --- > scrub/phase5.c | 59 +++++++++++++++++++++++++++---------------------- > 9 files changed, 85 insertions(+), 74 deletions(-) > create mode 100644 libfrog/fakelibattr.h > delete mode 100644 m4/package_attr.m4 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCHSET 2/6] xfsprogs: do not depend on libattr @ 2024-10-02 1:04 Darrick J. Wong 2024-10-02 1:07 ` [PATCH 2/2] libfrog: emulate deprecated attrlist functionality in libattr Darrick J. Wong 0 siblings, 1 reply; 7+ messages in thread From: Darrick J. Wong @ 2024-10-02 1:04 UTC (permalink / raw) To: aalbersh, djwong, cem; +Cc: Carlos Maiolino, Christoph Hellwig, linux-xfs Hi all, Remove xfsprogs dependence on libattr because libattr is deprecated. The code in that library came from XFS, so we can make our own shims. If you're going to start using this code, I strongly recommend pulling from my git trees, which are linked below. Comments and questions are, as always, welcome. xfsprogs git tree: https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=libattr-remove-6.11 --- Commits in this patchset: * misc: clean up code around attr_list_by_handle calls * libfrog: emulate deprecated attrlist functionality in libattr --- configure.ac | 2 -- debian/control | 2 +- include/builddefs.in | 1 - libfrog/Makefile | 8 ++----- libfrog/fakelibattr.h | 36 ++++++++++++++++++++++++++++++ libfrog/fsprops.c | 22 ++++++++++-------- m4/package_attr.m4 | 25 --------------------- scrub/Makefile | 4 --- scrub/phase5.c | 59 +++++++++++++++++++++++++++---------------------- 9 files changed, 85 insertions(+), 74 deletions(-) create mode 100644 libfrog/fakelibattr.h delete mode 100644 m4/package_attr.m4 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] libfrog: emulate deprecated attrlist functionality in libattr 2024-10-02 1:04 [PATCHSET 2/6] xfsprogs: do not depend on libattr Darrick J. Wong @ 2024-10-02 1:07 ` Darrick J. Wong 0 siblings, 0 replies; 7+ messages in thread From: Darrick J. Wong @ 2024-10-02 1:07 UTC (permalink / raw) To: aalbersh, djwong, cem; +Cc: Christoph Hellwig, Carlos Maiolino, linux-xfs From: Darrick J. Wong <djwong@kernel.org> Break our dependence on the (deprecated) libattr by emulating the necessary pieces in libfrog. It's a little sketchy to open-code these symbols, but they're originally from XFS so we trust ourselves. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> --- configure.ac | 2 -- debian/control | 2 +- include/builddefs.in | 1 - libfrog/Makefile | 8 +++----- libfrog/fakelibattr.h | 36 ++++++++++++++++++++++++++++++++++++ libfrog/fsprops.c | 16 ++++++++-------- m4/package_attr.m4 | 25 ------------------------- scrub/Makefile | 4 ---- scrub/phase5.c | 23 +++++++++-------------- 9 files changed, 57 insertions(+), 60 deletions(-) create mode 100644 libfrog/fakelibattr.h delete mode 100644 m4/package_attr.m4 diff --git a/configure.ac b/configure.ac index 33b01399a..d021c519d 100644 --- a/configure.ac +++ b/configure.ac @@ -152,8 +152,6 @@ AC_HAVE_DEVMAPPER AC_HAVE_MALLINFO AC_HAVE_MALLINFO2 AC_HAVE_MEMFD_CREATE -AC_PACKAGE_WANT_ATTRIBUTES_H -AC_HAVE_LIBATTR if test "$enable_scrub" = "yes"; then if test "$enable_libicu" = "yes" || test "$enable_libicu" = "probe"; then AC_HAVE_LIBICU diff --git a/debian/control b/debian/control index 3f05d4e37..66b0a47a3 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: admin Priority: optional Maintainer: XFS Development Team <linux-xfs@vger.kernel.org> Uploaders: Nathan Scott <nathans@debian.org>, Anibal Monsalve Salazar <anibal@debian.org>, Bastian Germann <bage@debian.org> -Build-Depends: libinih-dev (>= 53), uuid-dev, debhelper (>= 12), gettext, libtool, libedit-dev, libblkid-dev (>= 2.17), linux-libc-dev, libdevmapper-dev, libattr1-dev, libicu-dev, pkg-config, liburcu-dev, systemd-dev | systemd (<< 253-2~) +Build-Depends: libinih-dev (>= 53), uuid-dev, debhelper (>= 12), gettext, libtool, libedit-dev, libblkid-dev (>= 2.17), linux-libc-dev, libdevmapper-dev, libicu-dev, pkg-config, liburcu-dev, systemd-dev | systemd (<< 253-2~) Standards-Version: 4.0.0 Homepage: https://xfs.wiki.kernel.org/ diff --git a/include/builddefs.in b/include/builddefs.in index 1647d2cd1..07c4a43f7 100644 --- a/include/builddefs.in +++ b/include/builddefs.in @@ -102,7 +102,6 @@ HAVE_DEVMAPPER = @have_devmapper@ HAVE_MALLINFO = @have_mallinfo@ HAVE_MALLINFO2 = @have_mallinfo2@ HAVE_MEMFD_CREATE = @have_memfd_create@ -HAVE_LIBATTR = @have_libattr@ HAVE_LIBICU = @have_libicu@ HAVE_SYSTEMD = @have_systemd@ SYSTEMD_SYSTEM_UNIT_DIR = @systemd_system_unit_dir@ diff --git a/libfrog/Makefile b/libfrog/Makefile index acddc894e..4da427789 100644 --- a/libfrog/Makefile +++ b/libfrog/Makefile @@ -21,6 +21,7 @@ crc32.c \ file_exchange.c \ fsgeom.c \ fsproperties.c \ +fsprops.c \ getparents.c \ histogram.c \ list_sort.c \ @@ -46,9 +47,11 @@ crc32defs.h \ crc32table.h \ dahashselftest.h \ div64.h \ +fakelibattr.h \ file_exchange.h \ fsgeom.h \ fsproperties.h \ +fsprops.h \ getparents.h \ histogram.h \ logging.h \ @@ -62,11 +65,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) diff --git a/libfrog/fakelibattr.h b/libfrog/fakelibattr.h new file mode 100644 index 000000000..30e0e5146 --- /dev/null +++ b/libfrog/fakelibattr.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2024 Oracle. All Rights Reserved. + * Author: Darrick J. Wong <djwong@kernel.org> + */ +#ifndef __LIBFROG_FAKELIBATTR_H__ +#define __LIBFROG_FAKELIBATTR_H__ + +/* This file emulates APIs from the deprecated libattr. */ + +struct attrlist_cursor; + +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); +} + +#endif /* __LIBFROG_FAKELIBATTR_H__ */ diff --git a/libfrog/fsprops.c b/libfrog/fsprops.c index a25c2726c..f59fbd9c2 100644 --- a/libfrog/fsprops.c +++ b/libfrog/fsprops.c @@ -10,8 +10,7 @@ #include "libfrog/bulkstat.h" #include "libfrog/fsprops.h" #include "libfrog/fsproperties.h" - -#include <attr/attributes.h> +#include "libfrog/fakelibattr.h" /* * Given an xfd and a mount table path, get us the handle for the root dir so @@ -68,21 +67,22 @@ fsprops_walk_names( fsprops_name_walk_fn walk_fn, void *priv) { - struct attrlist_cursor cur = { }; - struct attrlist *attrlist; + struct xfs_attrlist_cursor cur = { }; + struct xfs_attrlist *attrlist; int ret; attrlist = calloc(XFS_XATTR_LIST_MAX, 1); if (!attrlist) return -1; - while ((ret = attr_list_by_handle(fph->hanp, fph->hlen, attrlist, - XFS_XATTR_LIST_MAX, XFS_IOC_ATTR_ROOT, - &cur)) == 0) { + while ((ret = libfrog_attr_list_by_handle(fph->hanp, fph->hlen, + attrlist, XFS_XATTR_LIST_MAX, + XFS_IOC_ATTR_ROOT, &cur)) == 0) { unsigned int i; for (i = 0; i < attrlist->al_count; i++) { - struct attrlist_ent *ent = ATTR_ENTRY(attrlist, i); + struct xfs_attrlist_ent *ent = + libfrog_attr_entry(attrlist, i); const char *p = attr_name_to_fsprop_name(ent->a_name); diff --git a/m4/package_attr.m4 b/m4/package_attr.m4 deleted file mode 100644 index 05e02b38f..000000000 --- a/m4/package_attr.m4 +++ /dev/null @@ -1,25 +0,0 @@ -AC_DEFUN([AC_PACKAGE_WANT_ATTRIBUTES_H], - [ - AC_CHECK_HEADERS(attr/attributes.h) - ]) - -# -# Check if we have a ATTR_ROOT flag and libattr structures -# -AC_DEFUN([AC_HAVE_LIBATTR], - [ AC_MSG_CHECKING([for struct attrlist_cursor]) - AC_COMPILE_IFELSE( - [ AC_LANG_PROGRAM([[ -#include <sys/types.h> -#include <attr/attributes.h> - ]], [[ -struct attrlist_cursor *cur; -struct attrlist *list; -struct attrlist_ent *ent; -int flags = ATTR_ROOT; - ]]) - ], have_libattr=yes - AC_MSG_RESULT(yes), - AC_MSG_RESULT(no)) - AC_SUBST(have_libattr) - ]) 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 d298d628a..e1d94f9a3 100644 --- a/scrub/phase5.c +++ b/scrub/phase5.c @@ -8,9 +8,6 @@ #include <dirent.h> #include <sys/types.h> #include <sys/statvfs.h> -#ifdef HAVE_LIBATTR -# include <attr/attributes.h> -#endif #include <linux/fs.h> #include "handle.h" #include "list.h" @@ -20,6 +17,7 @@ #include "libfrog/scrub.h" #include "libfrog/bitmap.h" #include "libfrog/bulkstat.h" +#include "libfrog/fakelibattr.h" #include "xfs_scrub.h" #include "common.h" #include "inodes.h" @@ -164,7 +162,6 @@ check_dirent_names( return ret; } -#ifdef HAVE_LIBATTR /* Routines to scan all of an inode's xattrs for name problems. */ struct attrns_decode { int flags; @@ -173,8 +170,8 @@ struct attrns_decode { static const struct attrns_decode attr_ns[] = { {0, "user"}, - {ATTR_ROOT, "system"}, - {ATTR_SECURE, "secure"}, + {XFS_IOC_ATTR_ROOT, "system"}, + {XFS_IOC_ATTR_SECURE, "secure"}, {0, NULL}, }; @@ -190,9 +187,9 @@ check_xattr_ns_names( struct xfs_bulkstat *bstat, const struct attrns_decode *attr_ns) { - struct attrlist_cursor cur = { }; + struct xfs_attrlist_cursor cur = { }; char *keybuf; - struct attrlist *attrlist; + struct xfs_attrlist *attrlist; struct unicrash *uc = NULL; int i; int error; @@ -217,12 +214,13 @@ check_xattr_ns_names( goto out_keybuf; } - while ((error = attr_list_by_handle(handle, sizeof(*handle), attrlist, - XFS_XATTR_LIST_MAX, attr_ns->flags, + while ((error = libfrog_attr_list_by_handle(handle, sizeof(*handle), + attrlist, XFS_XATTR_LIST_MAX, attr_ns->flags, &cur)) == 0) { /* Examine the xattrs. */ for (i = 0; i < attrlist->al_count; i++) { - struct attrlist_ent *ent = ATTR_ENTRY(attrlist, i); + struct xfs_attrlist_ent *ent = + libfrog_attr_entry(attrlist, i); snprintf(keybuf, XATTR_NAME_MAX, "%s.%s", attr_ns->name, ent->a_name); @@ -279,9 +277,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( ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-10-02 1:07 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-09-19 23:52 [PATCHSET] xfsprogs: do not depend on deprecated libattr Darrick J. Wong 2024-09-19 23:53 ` [PATCH 1/2] misc: clean up code around attr_list_by_handle calls Darrick J. Wong 2024-09-20 11:26 ` Christoph Hellwig 2024-09-19 23:53 ` [PATCH 2/2] libfrog: emulate deprecated attrlist functionality in libattr Darrick J. Wong 2024-09-20 11:26 ` Christoph Hellwig 2024-09-23 17:10 ` [PATCHSET] xfsprogs: do not depend on deprecated libattr Carlos Maiolino -- strict thread matches above, loose matches on Subject: below -- 2024-10-02 1:04 [PATCHSET 2/6] xfsprogs: do not depend on libattr Darrick J. Wong 2024-10-02 1:07 ` [PATCH 2/2] libfrog: emulate deprecated attrlist functionality in libattr Darrick J. Wong
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox