From ffaccc4cccb57ee7a34a5c1288e2ca76da944aaa Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Fri, 13 Mar 2026 22:50:42 +0100 Subject: [PATCH] fs/xfs: add support for generating a xfs image mkfs.xfs is able to populate a filesystem from a directory since upstream commit [1], included since v6.17. With this option, it is now possible to create XFS rootfs in Buildroot. This commit adds this new feature. [1] https://git.kernel.org/pub/scm/fs/xfs/xfsprogs-dev.git/commit/?id=8a4ea72724930cfe262ccda03028264e1a81b145 Signed-off-by: Julien Olivain Signed-off-by: Romain Naour --- fs/Config.in | 1 + fs/xfs/Config.in | 34 ++++++++++++++++++++++++++++++++++ fs/xfs/xfs.mk | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 fs/xfs/Config.in create mode 100644 fs/xfs/xfs.mk diff --git a/fs/Config.in b/fs/Config.in index 42b0e608ac..be2a47b855 100644 --- a/fs/Config.in +++ b/fs/Config.in @@ -15,6 +15,7 @@ source "fs/squashfs/Config.in" source "fs/tar/Config.in" source "fs/ubi/Config.in" source "fs/ubifs/Config.in" +source "fs/xfs/Config.in" source "fs/yaffs2/Config.in" endmenu diff --git a/fs/xfs/Config.in b/fs/xfs/Config.in new file mode 100644 index 0000000000..49dd5ed4aa --- /dev/null +++ b/fs/xfs/Config.in @@ -0,0 +1,34 @@ +config BR2_TARGET_ROOTFS_XFS + bool "xfs root filesystem" + select BR2_PACKAGE_HOST_XFSPROGS + help + Build a xfs root filesystem. If you enable this option, you + probably want to enable the xfsprogs package too. + +if BR2_TARGET_ROOTFS_XFS + +config BR2_TARGET_ROOTFS_XFS_LABEL + string "filesystem label" + default "rootfs" + +config BR2_TARGET_ROOTFS_XFS_SIZE + string "exact size" + default "300M" + help + The size of the filesystem image. This size is passed to the + "truncate -s", so this option recognizes unit suffixes such + as K,M,G (see the manual page truncate(1)). Note the XFS + minimal filesystem size is 300M. + +config BR2_TARGET_ROOTFS_XFS_MKFS_OPTIONS + string "additional mkfs.xfs options" + help + Specify a space-separated list of mkfs.xfs options. + + For more information about the mke2fs options, see the + manual page mkfs.xfs(8). + + For more information about the XFS features which can be + set, see also the manual page xfs(5). + +endif # BR2_TARGET_ROOTFS_XFS diff --git a/fs/xfs/xfs.mk b/fs/xfs/xfs.mk new file mode 100644 index 0000000000..2706822550 --- /dev/null +++ b/fs/xfs/xfs.mk @@ -0,0 +1,33 @@ +################################################################################ +# +# Build the xfs root filesystem image +# +################################################################################ + +ROOTFS_XFS_SIZE = $(call qstrip,$(BR2_TARGET_ROOTFS_XFS_SIZE)) +ifeq ($(BR2_TARGET_ROOTFS_XFS)-$(ROOTFS_XFS_SIZE),y-) +$(error BR2_TARGET_ROOTFS_XFS_SIZE cannot be empty) +endif + +ROOTFS_XFS_MKFS_OPTS = $(call qstrip,$(BR2_TARGET_ROOTFS_XFS_MKFS_OPTIONS)) + +# qstrip results in stripping consecutive spaces into a single one. So the +# variable is not qstrip-ed to preserve the integrity of the string value. +ROOTFS_XFS_LABEL = $(subst ",,$(BR2_TARGET_ROOTFS_XFS_LABEL)) +#" comment to balance quotes/parenthesis for syntax highlighting) + +ROOTFS_XFS_OPTS = \ + -f \ + -p '$(TARGET_DIR)' \ + -L '$(ROOTFS_XFS_LABEL)' \ + $(ROOTFS_XFS_MKFS_OPTS) + +ROOTFS_XFS_DEPENDENCIES = host-xfsprogs + +define ROOTFS_XFS_CMD + $(RM) -f $@ + truncate -s $(ROOTFS_XFS_SIZE) $@ + $(HOST_DIR)/sbin/mkfs.xfs $(ROOTFS_XFS_OPTS) $@ +endef + +$(eval $(rootfs))