Skip to contentSkip to conversation

fs/btrfs: remove destination file before generation

PATCH New Yann E. MORIN 2 participants 2 messages Aug 25, 2018 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/btrfs: remove destination file before generation

btrfs will happily use an existing destination file if it already exists, increasing its size if needed. Hoever, it will never decrease the size, even if the requested size is smaller than the existing file.

So, remove any previously existing destination file before generating the new filesystem.

Note: the original submission by Robert did that, but as this case was not obvious, the removal was dropped by a refactoring when the patch was initially applied.

Cc Robert J. Heywood <[email protected]>
Cc Thomas Petazzoni <[email protected]>
---
 fs/btrfs/btrfs.mk | 1 +
 1 file changed, 1 insertion(+)
fs/btrfs/btrfs.mk +1 -0
index ad00153c26..94bc499084 100644
@@ -29,6 +29,7 @@ BTRFS_OPTS = \
 ROOTFS_BTRFS_DEPENDENCIES = host-btrfs-progs
 
 define ROOTFS_BTRFS_CMD
+	rm -f $(@)
 	$(HOST_DIR)/bin/mkfs.btrfs $(BTRFS_OPTS) $@
 endef
 
Signature · 1 line
2.14.1
#1 lore raw

PATCH 1/1 fs/btrfs: remove destination file before generation

Hello,

fs/btrfs/btrfs.mk BTRFS_OPTS = \ · line 32

Quoted 2 lines · Yann E. MORIN

define ROOTFS_BTRFS_CMD

fs/btrfs/btrfs.mk +1 -0
+	rm -f $(@)

I changed to use $(RM) instead of rm, and $@ instead of $(@), since we use $@ everywhere.

With those changes: applied to next. Thanks for noticing this mistake in my changes to Robert's patch!

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com