libfstools: query drivers by priority Instead of individual hacks meant to prioritize the storage backend drivers, register them with an optional priotity. If set, the higher priority driver should be considered be considered first. Prioritize UBI and MTD over the bulk of block device drivers (partname, rootdisk) which allows removing previous hacks having the same effect. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
fstools: add partname volume driver Add driver to handle block devices with (GPT) partition table which can include a partition name. If 'root=' is set on the kernel cmdline, only search for partitions on the same device. Among with other changes (ptgen, image*.mk, base-files, ...) this allows for a much more straight forward storage model on block based devices. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Use autoclear for overlay loopback device During a sysupgrade on a block-based device, the partition table might get updated. The partitions have to be completely unused by the time partx is invoked, or it fails thus: partx: /dev/mmcblk1: error deleting partition 3 partx: /dev/mmcblk1: error adding partition 3 That's cosmetic in some cases, but in others where the old root partition overlaps with the new partition where the config is stored during the reboot, it causes a sysugprade failure (resulting in the backup being lost and a completely clean system image). Although we carefully unmount the root and overlay file systems, the problem is that the loopback device used for the overlay isn't being torn down, and it still has a refcount on the root block partition (in the above case, /dev/mmcblk1p3). Installing losetup and adding 'losetup -D' to the switch_to_ramfs() function makes it work nicely. But the better option that doesn't add a new dependency is to use the autoclear flag when setting up the loop device, so it goes away automatically when the overlay file system is unmounted. To make that work sanely, we have to *not* close the fd right after configuring it — or it'll go away immediately. We could store the fd in the volume struct and either add destructor method or close it after performing the mount… but honestly it just seems simpler and saner to "leak" the fd in the knowledge that it'll get closed when the process exits in a few milliseconds anyway. We can revisit that if anyone really feels strongly about it. Dissent is best expressed in 'diff -up' form. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
libfstools: Fix overflow of F2FS_MINSIZE constant I wasn't able to to use f2fs on armvirt/32 platform and I've found out that it was due to F2FS_MINSIZE constant overflow leading to value of 13 exabytes instead of 100 megabytes. Acked-by: Jo-Philipp Wich <jo@mein.io> Signed-off-by: Petr Štetiar <ynezz@true.cz>
libfstools: Print error in case of loop blkdev failure It took me quite some time today(while fixing squashfs+overlay on armvirt) to find out, that I was missing support for loop block device in kernel, so I'm adding error message which might be helpful for someone else in the future as well. Acked-by: Jo-Philipp Wich <jo@mein.io> Signed-off-by: Petr Štetiar <ynezz@true.cz>
libfstools: silence mkfs.{ext4,f2fs} Reduce noise during firstboot when creating overlay fs on block rootdisk devices. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
libfstools: Check return values for fread and system libfstools/rootdisk.c: In function 'rootdisk_volume_identify': libfstools/rootdisk.c:172:7: error: ignoring return value of 'fread', declared with attribute warn_unused_result [-Werror=unused-result] fread(&magic, sizeof(magic), 1, f); ^ libfstools/rootdisk.c:179:7: error: ignoring return value of 'fread', declared with attribute warn_unused_result [-Werror=unused-result] fread(&magic, sizeof(magic), 1, f); ^ libfstools/rootdisk.c: In function 'rootdisk_volume_init': libfstools/rootdisk.c:268:9: error: ignoring return value of 'system', declared with attribute warn_unused_result [-Werror=unused-result] system(str); ^ cc1: all warnings being treated as errors Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
libfstools: properly label ext4 overlay Signed-off-by: Daniel Golle <daniel@makrotopia.org>
libfstools: add rootdisk overlay volume support Uses either ext4 or f2fs, depending on the overlay volume size Signed-off-by: Felix Fietkau <nbd@nbd.name>