Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 2/2] fs/btrfs: Introducing btrfs rootfs support.
@ 2018-08-23 20:26 Robert J. Heywood
  2018-08-23 21:27 ` Yann E. MORIN
  0 siblings, 1 reply; 5+ messages in thread
From: Robert J. Heywood @ 2018-08-23 20:26 UTC (permalink / raw)
  To: buildroot

This patch makes it possible to format the rootfs using btrfs.
It introduces the option; BR2_TARGET_ROOTFS_BTRFS

When selected, the user is able to specify the filesystem size,
label, options, and node and sector sizes.
The new files are based on fs/ext2/{Config.in,ext2.mk}

Signed-off-by: Robert J. Heywood <robert.heywood@codethink.co.uk>
---
 fs/Config.in       |  1 +
 fs/btrfs/Config.in | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/btrfs/btrfs.mk  | 39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 94 insertions(+)
 create mode 100644 fs/btrfs/Config.in
 create mode 100644 fs/btrfs/btrfs.mk

diff --git a/fs/Config.in b/fs/Config.in
index c25b01c3de..24f22fd7e3 100644
--- a/fs/Config.in
+++ b/fs/Config.in
@@ -1,6 +1,7 @@
 menu "Filesystem images"
 
 source "fs/axfs/Config.in"
+source "fs/btrfs/Config.in"
 source "fs/cloop/Config.in"
 source "fs/cpio/Config.in"
 source "fs/cramfs/Config.in"
diff --git a/fs/btrfs/Config.in b/fs/btrfs/Config.in
new file mode 100644
index 0000000000..6537c85fdb
--- /dev/null
+++ b/fs/btrfs/Config.in
@@ -0,0 +1,54 @@
+config BR2_TARGET_ROOTFS_BTRFS
+	bool "btrfs root filesystem"
+	select BR2_PACKAGE_HOST_BTRFS_PROGS
+	help
+	  Build a btrfs root filesystem. If you enable this option, you
+	  probably want to enable the btrfs-progs package too.
+
+
+if BR2_TARGET_ROOTFS_BTRFS
+
+config BR2_TARGET_ROOTFS_BTRFS_LABEL
+	string "filesystem label"
+
+config BR2_TARGET_ROOTFS_BTRFS_SIZE
+	string "filesystem size"
+	default "100M"
+	help
+	  The size of the filesystem image. If it does not have a
+	  suffix, it is interpreted as power-of-two kilobytes. If it is
+	  suffixed by 'k', 'm', 'g', 't' (either upper-case or
+	  lower-case), then it is interpreted in power-of-two kilobytes,
+	  megabytes, gigabytes, terabytes, etc.
+
+config BR2_TARGET_ROOTFS_BTRFS_SIZE_NODE
+	string "btree node size"
+	default 16384
+	help
+	  The tree block size in which btrfs stores metadata. This must
+	  be a multiple of the sectorsize, but not larger than 64KiB.
+	  (65536).
+	  If it is suffixed by 'k' (either upper-case or lower-case),
+	  then it is interpreted in power-of-two kilobytes.
+
+config BR2_TARGET_ROOTFS_BTRFS_SIZE_SECTOR
+	string "sector size"
+	default 4096
+	help
+	  This value should be set to the page size. The default value of
+	  4096 is the the most common page size for most systems.
+	  If the sectorsize differs from the page size, the created
+	  filesystem may not be mountable by the kernel.
+	  Therefore it is recommended to leave this value at 4096.
+	  If it is suffixed by 'k' (either upper-case or lower-case),
+	  then it is interpreted in power-of-two kilobytes.
+
+config BR2_TARGET_ROOTFS_BTRFS_FEATURES
+	string "Filesystem Features"
+	help
+	  A comma separated string of features that can be enabled
+	  during creation time.
+	  For a list of available options, use;
+	    `.../host/bin/mkfs.btrfs -O list-all`
+
+endif # BR2_TARGET_ROOTFS_BTRFS
diff --git a/fs/btrfs/btrfs.mk b/fs/btrfs/btrfs.mk
new file mode 100644
index 0000000000..37b2937825
--- /dev/null
+++ b/fs/btrfs/btrfs.mk
@@ -0,0 +1,39 @@
+################################################################################
+#
+# Build the btrfs root filesystem image
+#
+################################################################################
+
+BTRFS_SIZE = $(call qstrip,$(BR2_TARGET_ROOTFS_BTRFS_SIZE))
+ifeq ($(BR2_TARGET_ROOTFS_BTRFS)-$(BTRFS_SIZE),y-)
+$(error BR2_TARGET_ROOTFS_BTRFS_SIZE cannot be empty)
+endif
+
+BTRFS_SIZE_NODE = $(call qstrip,$(BR2_TARGET_ROOTFS_BTRFS_SIZE_NODE))
+BTRFS_SIZE_SECTOR = $(call qstrip,$(BR2_TARGET_ROOTFS_BTRFS_SIZE_SECTOR))
+BTRFS_FEATURES = $(call qstrip,$(BR2_TARGET_ROOTFS_BTRFS_FEATURES))
+# 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.
+BTRFS_LABEL := $(subst ",,$(BR2_TARGET_ROOTFS_BTRFS_LABEL))
+# ")
+
+BTRFS_OPTS = \
+	-r '$(TARGET_DIR)' \
+	-L '$(BTRFS_LABEL)' \
+	$(if $(BTRFS_SIZE_NODE),--nodesize '$(BTRFS_SIZE_NODE)') \
+	$(if $(BTRFS_SIZE_SECTOR),--sectorsize '$(BTRFS_SIZE_SECTOR)') \
+	$(if $(BTRFS_FEATURES),--features '$(BTRFS_FEATURES)')
+
+ROOTFS_BTRFS_DEPENDENCIES = host-btrfs-progs
+
+define ROOTFS_BTRFS_CMD
+	rm -f $@
+	truncate -s $(BTRFS_SIZE) $@
+	$(HOST_DIR)/bin/mkfs.btrfs $(BTRFS_OPTS) $@ \
+	|| { ret=$$?; \
+	     echo "*** Maybe you need to increase the filesystem size (BR2_TARGET_ROOTFS_BTRFS_SIZE)" 1>&2; \
+	     exit $$ret; \
+	}
+endef
+
+$(eval $(rootfs))
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Buildroot] [PATCH 2/2] fs/btrfs: Introducing btrfs rootfs support.
  2018-08-23 20:26 Robert J. Heywood
@ 2018-08-23 21:27 ` Yann E. MORIN
  0 siblings, 0 replies; 5+ messages in thread
From: Yann E. MORIN @ 2018-08-23 21:27 UTC (permalink / raw)
  To: buildroot

Robert, All,

On 2018-08-23 21:26 +0100, Robert J. Heywood spake thusly:
> This patch makes it possible to format the rootfs using btrfs.
> It introduces the option; BR2_TARGET_ROOTFS_BTRFS
> 
> When selected, the user is able to specify the filesystem size,
> label, options, and node and sector sizes.
> The new files are based on fs/ext2/{Config.in,ext2.mk}
> 
> Signed-off-by: Robert J. Heywood <robert.heywood@codethink.co.uk>
[--SNIP--]
> diff --git a/fs/btrfs/Config.in b/fs/btrfs/Config.in
> new file mode 100644
> index 0000000000..6537c85fdb
> --- /dev/null
> +++ b/fs/btrfs/Config.in
> @@ -0,0 +1,54 @@
> +config BR2_TARGET_ROOTFS_BTRFS
> +	bool "btrfs root filesystem"
> +	select BR2_PACKAGE_HOST_BTRFS_PROGS
> +	help
> +	  Build a btrfs root filesystem. If you enable this option, you
> +	  probably want to enable the btrfs-progs package too.
> +
> +
> +if BR2_TARGET_ROOTFS_BTRFS
> +
> +config BR2_TARGET_ROOTFS_BTRFS_LABEL
> +	string "filesystem label"
> +
> +config BR2_TARGET_ROOTFS_BTRFS_SIZE
> +	string "filesystem size"
> +	default "100M"
> +	help
> +	  The size of the filesystem image. If it does not have a
> +	  suffix, it is interpreted as power-of-two kilobytes. If it is

This is now wrong, as 'truncate' uses bytes if there is no prefix.

> +	  suffixed by 'k', 'm', 'g', 't' (either upper-case or
> +	  lower-case), then it is interpreted in power-of-two kilobytes,
> +	  megabytes, gigabytes, terabytes, etc.

So, maybe just:

    The size of the filesystem image, in bytes. Suffix with k, m, g,
    or t for power-of-two kilo-, mega-, giga-, or terrabytes.

> +config BR2_TARGET_ROOTFS_BTRFS_SIZE_NODE
> +	string "btree node size"
> +	default 16384
> +	help
> +	  The tree block size in which btrfs stores metadata. This must
> +	  be a multiple of the sectorsize, but not larger than 64KiB.
> +	  (65536).
> +	  If it is suffixed by 'k' (either upper-case or lower-case),
> +	  then it is interpreted in power-of-two kilobytes.
> +
> +config BR2_TARGET_ROOTFS_BTRFS_SIZE_SECTOR
> +	string "sector size"
> +	default 4096
> +	help
> +	  This value should be set to the page size. The default value of
> +	  4096 is the the most common page size for most systems.
> +	  If the sectorsize differs from the page size, the created
> +	  filesystem may not be mountable by the kernel.
> +	  Therefore it is recommended to leave this value at 4096.

    ... unless you know that your kernel uses a different page size.

> +	  If it is suffixed by 'k' (either upper-case or lower-case),
> +	  then it is interpreted in power-of-two kilobytes.

I failed to note that in the previous iteration, but: the 'sector size'
option is referenced from the 'btree node size' option. So the order
should be inversed.

> +config BR2_TARGET_ROOTFS_BTRFS_FEATURES
> +	string "Filesystem Features"
> +	help
> +	  A comma separated string of features that can be enabled
> +	  during creation time.
> +	  For a list of available options, use;

Change the trailing semi-colon ';' by a colon ':'.

Otherwise, that's nice. :-)

Regards,
Yann E. MORIN.

> +	    `.../host/bin/mkfs.btrfs -O list-all`
> +
> +endif # BR2_TARGET_ROOTFS_BTRFS
> diff --git a/fs/btrfs/btrfs.mk b/fs/btrfs/btrfs.mk
> new file mode 100644
> index 0000000000..37b2937825
> --- /dev/null
> +++ b/fs/btrfs/btrfs.mk
> @@ -0,0 +1,39 @@
> +################################################################################
> +#
> +# Build the btrfs root filesystem image
> +#
> +################################################################################
> +
> +BTRFS_SIZE = $(call qstrip,$(BR2_TARGET_ROOTFS_BTRFS_SIZE))
> +ifeq ($(BR2_TARGET_ROOTFS_BTRFS)-$(BTRFS_SIZE),y-)
> +$(error BR2_TARGET_ROOTFS_BTRFS_SIZE cannot be empty)
> +endif
> +
> +BTRFS_SIZE_NODE = $(call qstrip,$(BR2_TARGET_ROOTFS_BTRFS_SIZE_NODE))
> +BTRFS_SIZE_SECTOR = $(call qstrip,$(BR2_TARGET_ROOTFS_BTRFS_SIZE_SECTOR))
> +BTRFS_FEATURES = $(call qstrip,$(BR2_TARGET_ROOTFS_BTRFS_FEATURES))
> +# 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.
> +BTRFS_LABEL := $(subst ",,$(BR2_TARGET_ROOTFS_BTRFS_LABEL))
> +# ")
> +
> +BTRFS_OPTS = \
> +	-r '$(TARGET_DIR)' \
> +	-L '$(BTRFS_LABEL)' \
> +	$(if $(BTRFS_SIZE_NODE),--nodesize '$(BTRFS_SIZE_NODE)') \
> +	$(if $(BTRFS_SIZE_SECTOR),--sectorsize '$(BTRFS_SIZE_SECTOR)') \
> +	$(if $(BTRFS_FEATURES),--features '$(BTRFS_FEATURES)')
> +
> +ROOTFS_BTRFS_DEPENDENCIES = host-btrfs-progs
> +
> +define ROOTFS_BTRFS_CMD
> +	rm -f $@
> +	truncate -s $(BTRFS_SIZE) $@
> +	$(HOST_DIR)/bin/mkfs.btrfs $(BTRFS_OPTS) $@ \
> +	|| { ret=$$?; \
> +	     echo "*** Maybe you need to increase the filesystem size (BR2_TARGET_ROOTFS_BTRFS_SIZE)" 1>&2; \
> +	     exit $$ret; \
> +	}
> +endef
> +
> +$(eval $(rootfs))
> -- 
> 2.11.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Buildroot] [PATCH 2/2] fs/btrfs: Introducing btrfs rootfs support.
@ 2018-08-23 22:01 Robert J. Heywood
  2018-08-24 21:53 ` Yann E. MORIN
  2018-08-25 12:39 ` Thomas Petazzoni
  0 siblings, 2 replies; 5+ messages in thread
From: Robert J. Heywood @ 2018-08-23 22:01 UTC (permalink / raw)
  To: buildroot

This patch makes it possible to format the rootfs using btrfs.
It introduces the option; BR2_TARGET_ROOTFS_BTRFS

When selected, the user is able to specify the filesystem size,
label, options, and node and sector sizes.
The new files are based on fs/ext2/{Config.in,ext2.mk}

Signed-off-by: Robert J. Heywood <robert.heywood@codethink.co.uk>
---
 fs/Config.in       |  1 +
 fs/btrfs/Config.in | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/btrfs/btrfs.mk  | 39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+)
 create mode 100644 fs/btrfs/Config.in
 create mode 100644 fs/btrfs/btrfs.mk

diff --git a/fs/Config.in b/fs/Config.in
index c25b01c3de..24f22fd7e3 100644
--- a/fs/Config.in
+++ b/fs/Config.in
@@ -1,6 +1,7 @@
 menu "Filesystem images"
 
 source "fs/axfs/Config.in"
+source "fs/btrfs/Config.in"
 source "fs/cloop/Config.in"
 source "fs/cpio/Config.in"
 source "fs/cramfs/Config.in"
diff --git a/fs/btrfs/Config.in b/fs/btrfs/Config.in
new file mode 100644
index 0000000000..52fbfd983a
--- /dev/null
+++ b/fs/btrfs/Config.in
@@ -0,0 +1,51 @@
+config BR2_TARGET_ROOTFS_BTRFS
+	bool "btrfs root filesystem"
+	select BR2_PACKAGE_HOST_BTRFS_PROGS
+	help
+	  Build a btrfs root filesystem. If you enable this option, you
+	  probably want to enable the btrfs-progs package too.
+
+
+if BR2_TARGET_ROOTFS_BTRFS
+
+config BR2_TARGET_ROOTFS_BTRFS_LABEL
+	string "filesystem label"
+
+config BR2_TARGET_ROOTFS_BTRFS_SIZE
+	string "filesystem size"
+	default "100m"
+	help
+	  The size of the filesystem image in bytes.
+	  Suffix with k, m, g or t for power-of-two kilo-, mega-, giga-
+	  or terabytes.
+
+config BR2_TARGET_ROOTFS_BTRFS_SIZE_SECTOR
+	string "sector size"
+	default 4096
+	help
+	  This value should be set to the page size in bytes. The default
+	  value of 4096 is the the most common page size for most systems.
+	  If the sectorsize differs from the page size, the created
+	  filesystem may not be mountable by the kernel.
+	  Therefore it is recommended to leave this value at 4096. Unless
+	  you know that your kernel uses a different page size.
+	  Suffix with k for power-of-two kilobytes.
+
+config BR2_TARGET_ROOTFS_BTRFS_SIZE_NODE
+	string "btree node size"
+	default 16384
+	help
+	  The tree block size in which btrfs stores metadata in bytes.
+	  This must be a multiple of the sectorsize, but not larger than
+	  64KiB (65536).
+	  Suffix with k for power-of-two kilobytes.
+
+config BR2_TARGET_ROOTFS_BTRFS_FEATURES
+	string "Filesystem Features"
+	help
+	  A comma separated string of features that can be enabled
+	  during creation time.
+	  For a list of available options, use:
+	    `.../host/bin/mkfs.btrfs -O list-all`
+
+endif # BR2_TARGET_ROOTFS_BTRFS
diff --git a/fs/btrfs/btrfs.mk b/fs/btrfs/btrfs.mk
new file mode 100644
index 0000000000..37b2937825
--- /dev/null
+++ b/fs/btrfs/btrfs.mk
@@ -0,0 +1,39 @@
+################################################################################
+#
+# Build the btrfs root filesystem image
+#
+################################################################################
+
+BTRFS_SIZE = $(call qstrip,$(BR2_TARGET_ROOTFS_BTRFS_SIZE))
+ifeq ($(BR2_TARGET_ROOTFS_BTRFS)-$(BTRFS_SIZE),y-)
+$(error BR2_TARGET_ROOTFS_BTRFS_SIZE cannot be empty)
+endif
+
+BTRFS_SIZE_NODE = $(call qstrip,$(BR2_TARGET_ROOTFS_BTRFS_SIZE_NODE))
+BTRFS_SIZE_SECTOR = $(call qstrip,$(BR2_TARGET_ROOTFS_BTRFS_SIZE_SECTOR))
+BTRFS_FEATURES = $(call qstrip,$(BR2_TARGET_ROOTFS_BTRFS_FEATURES))
+# 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.
+BTRFS_LABEL := $(subst ",,$(BR2_TARGET_ROOTFS_BTRFS_LABEL))
+# ")
+
+BTRFS_OPTS = \
+	-r '$(TARGET_DIR)' \
+	-L '$(BTRFS_LABEL)' \
+	$(if $(BTRFS_SIZE_NODE),--nodesize '$(BTRFS_SIZE_NODE)') \
+	$(if $(BTRFS_SIZE_SECTOR),--sectorsize '$(BTRFS_SIZE_SECTOR)') \
+	$(if $(BTRFS_FEATURES),--features '$(BTRFS_FEATURES)')
+
+ROOTFS_BTRFS_DEPENDENCIES = host-btrfs-progs
+
+define ROOTFS_BTRFS_CMD
+	rm -f $@
+	truncate -s $(BTRFS_SIZE) $@
+	$(HOST_DIR)/bin/mkfs.btrfs $(BTRFS_OPTS) $@ \
+	|| { ret=$$?; \
+	     echo "*** Maybe you need to increase the filesystem size (BR2_TARGET_ROOTFS_BTRFS_SIZE)" 1>&2; \
+	     exit $$ret; \
+	}
+endef
+
+$(eval $(rootfs))
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Buildroot] [PATCH 2/2] fs/btrfs: Introducing btrfs rootfs support.
  2018-08-23 22:01 [Buildroot] [PATCH 2/2] fs/btrfs: Introducing btrfs rootfs support Robert J. Heywood
@ 2018-08-24 21:53 ` Yann E. MORIN
  2018-08-25 12:39 ` Thomas Petazzoni
  1 sibling, 0 replies; 5+ messages in thread
From: Yann E. MORIN @ 2018-08-24 21:53 UTC (permalink / raw)
  To: buildroot

Robert, All,

On 2018-08-23 23:01 +0100, Robert J. Heywood spake thusly:
> This patch makes it possible to format the rootfs using btrfs.
> It introduces the option; BR2_TARGET_ROOTFS_BTRFS
> 
> When selected, the user is able to specify the filesystem size,
> label, options, and node and sector sizes.
> The new files are based on fs/ext2/{Config.in,ext2.mk}
> 
> Signed-off-by: Robert J. Heywood <robert.heywood@codethink.co.uk>

Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>

However, two very minor comments, which a maintainer can fix while
applying, and that escape my tired eye the previous iterations, see
below...

> diff --git a/fs/btrfs/Config.in b/fs/btrfs/Config.in
> new file mode 100644
> index 0000000000..52fbfd983a
> --- /dev/null
> +++ b/fs/btrfs/Config.in
> @@ -0,0 +1,51 @@
> +config BR2_TARGET_ROOTFS_BTRFS
> +	bool "btrfs root filesystem"
> +	select BR2_PACKAGE_HOST_BTRFS_PROGS
> +	help
> +	  Build a btrfs root filesystem. If you enable this option, you
> +	  probably want to enable the btrfs-progs package too.
> +
> +

Only one empty seprarting line is enough.

> +if BR2_TARGET_ROOTFS_BTRFS
> +
> +config BR2_TARGET_ROOTFS_BTRFS_LABEL
> +	string "filesystem label"
> +
> +config BR2_TARGET_ROOTFS_BTRFS_SIZE
> +	string "filesystem size"
> +	default "100m"
> +	help
> +	  The size of the filesystem image in bytes.
> +	  Suffix with k, m, g or t for power-of-two kilo-, mega-, giga-
> +	  or terabytes.
> +
> +config BR2_TARGET_ROOTFS_BTRFS_SIZE_SECTOR
> +	string "sector size"
> +	default 4096

Defaults for string must be quoted.

It happens to work, because there is no symbol named `4096'.

> +	help
> +	  This value should be set to the page size in bytes. The default
> +	  value of 4096 is the the most common page size for most systems.
> +	  If the sectorsize differs from the page size, the created
> +	  filesystem may not be mountable by the kernel.
> +	  Therefore it is recommended to leave this value at 4096. Unless
> +	  you know that your kernel uses a different page size.
> +	  Suffix with k for power-of-two kilobytes.
> +
> +config BR2_TARGET_ROOTFS_BTRFS_SIZE_NODE
> +	string "btree node size"
> +	default 16384

Ditto.

Regards,
Yann E. MORIN.

> +	help
> +	  The tree block size in which btrfs stores metadata in bytes.
> +	  This must be a multiple of the sectorsize, but not larger than
> +	  64KiB (65536).
> +	  Suffix with k for power-of-two kilobytes.
> +
> +config BR2_TARGET_ROOTFS_BTRFS_FEATURES
> +	string "Filesystem Features"
> +	help
> +	  A comma separated string of features that can be enabled
> +	  during creation time.
> +	  For a list of available options, use:
> +	    `.../host/bin/mkfs.btrfs -O list-all`
> +
> +endif # BR2_TARGET_ROOTFS_BTRFS
> diff --git a/fs/btrfs/btrfs.mk b/fs/btrfs/btrfs.mk
> new file mode 100644
> index 0000000000..37b2937825
> --- /dev/null
> +++ b/fs/btrfs/btrfs.mk
> @@ -0,0 +1,39 @@
> +################################################################################
> +#
> +# Build the btrfs root filesystem image
> +#
> +################################################################################
> +
> +BTRFS_SIZE = $(call qstrip,$(BR2_TARGET_ROOTFS_BTRFS_SIZE))
> +ifeq ($(BR2_TARGET_ROOTFS_BTRFS)-$(BTRFS_SIZE),y-)
> +$(error BR2_TARGET_ROOTFS_BTRFS_SIZE cannot be empty)
> +endif
> +
> +BTRFS_SIZE_NODE = $(call qstrip,$(BR2_TARGET_ROOTFS_BTRFS_SIZE_NODE))
> +BTRFS_SIZE_SECTOR = $(call qstrip,$(BR2_TARGET_ROOTFS_BTRFS_SIZE_SECTOR))
> +BTRFS_FEATURES = $(call qstrip,$(BR2_TARGET_ROOTFS_BTRFS_FEATURES))
> +# 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.
> +BTRFS_LABEL := $(subst ",,$(BR2_TARGET_ROOTFS_BTRFS_LABEL))
> +# ")
> +
> +BTRFS_OPTS = \
> +	-r '$(TARGET_DIR)' \
> +	-L '$(BTRFS_LABEL)' \
> +	$(if $(BTRFS_SIZE_NODE),--nodesize '$(BTRFS_SIZE_NODE)') \
> +	$(if $(BTRFS_SIZE_SECTOR),--sectorsize '$(BTRFS_SIZE_SECTOR)') \
> +	$(if $(BTRFS_FEATURES),--features '$(BTRFS_FEATURES)')
> +
> +ROOTFS_BTRFS_DEPENDENCIES = host-btrfs-progs
> +
> +define ROOTFS_BTRFS_CMD
> +	rm -f $@
> +	truncate -s $(BTRFS_SIZE) $@
> +	$(HOST_DIR)/bin/mkfs.btrfs $(BTRFS_OPTS) $@ \
> +	|| { ret=$$?; \
> +	     echo "*** Maybe you need to increase the filesystem size (BR2_TARGET_ROOTFS_BTRFS_SIZE)" 1>&2; \
> +	     exit $$ret; \
> +	}
> +endef
> +
> +$(eval $(rootfs))
> -- 
> 2.11.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Buildroot] [PATCH 2/2] fs/btrfs: Introducing btrfs rootfs support.
  2018-08-23 22:01 [Buildroot] [PATCH 2/2] fs/btrfs: Introducing btrfs rootfs support Robert J. Heywood
  2018-08-24 21:53 ` Yann E. MORIN
@ 2018-08-25 12:39 ` Thomas Petazzoni
  1 sibling, 0 replies; 5+ messages in thread
From: Thomas Petazzoni @ 2018-08-25 12:39 UTC (permalink / raw)
  To: buildroot

Hello Robert,

On Thu, 23 Aug 2018 23:01:56 +0100, Robert J. Heywood wrote:
> This patch makes it possible to format the rootfs using btrfs.
> It introduces the option; BR2_TARGET_ROOTFS_BTRFS
> 
> When selected, the user is able to specify the filesystem size,
> label, options, and node and sector sizes.
> The new files are based on fs/ext2/{Config.in,ext2.mk}
> 
> Signed-off-by: Robert J. Heywood <robert.heywood@codethink.co.uk>

Thanks, I've applied, but I did a few changes. First, I fixed the
issues pointed by Yann E. Morin in the Config.in file. But more
importantly, see below.

> +define ROOTFS_BTRFS_CMD
> +	rm -f $@

This is not needed, once you add the -f option to mkfs.btrfs, so I've
done that.

> +	truncate -s $(BTRFS_SIZE) $@

mkfs.btrfs has the --byte-count option that allows to set the size of
the filesystem image to be generated, so I've used that instead and
dropped the truncate -s.

> +	$(HOST_DIR)/bin/mkfs.btrfs $(BTRFS_OPTS) $@ \
> +	|| { ret=$$?; \
> +	     echo "*** Maybe you need to increase the filesystem size (BR2_TARGET_ROOTFS_BTRFS_SIZE)" 1>&2; \
> +	     exit $$ret; \

This warning was not really useful: mkfs.btrfs automatically extends
the image size as needed. So if you specify 100m, but you need 150m,
mkfs.btrfs will anyway produce a 150m filesystem image, without bailing
out. So an error of mkfs.brtfs cannot be explained by the
BR2_TARGET_ROOTFS_BTRFS_SIZE value being too small. Therefore, I've
dropped this error handling entirely.

Applied to next with those changes:

  https://git.buildroot.org/buildroot/commit/?h=next&id=0aade4df1f80d7bff58da2b5d3dfd9d8d6ec4b7d

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-08-25 12:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-23 22:01 [Buildroot] [PATCH 2/2] fs/btrfs: Introducing btrfs rootfs support Robert J. Heywood
2018-08-24 21:53 ` Yann E. MORIN
2018-08-25 12:39 ` Thomas Petazzoni
  -- strict thread matches above, loose matches on Subject: below --
2018-08-23 20:26 Robert J. Heywood
2018-08-23 21:27 ` Yann E. MORIN

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox