summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* libblkid-tiny: add exfat superblock supportHEADmasterRafał Miłecki2023-02-284-0/+178
| | | | | | | | exFAT became very popular over last years and also well supported with Linux kernel driver and macOS support. It's commonly used for USB drivers. Port a simple support for it from util-linux / libblkid. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* libfstools: use class interface to iterate over ubi devicesDaniel Golle2023-02-151-5/+5
| | | | | | | Instead of relying on /sys/devices/virtual/ubi/* better use /sys/class/ubi/* which makes things more straight forward. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* partname: Correct fstools_partname_fallback_scan comparisonBrian Norris2023-02-041-12/+20
| | | | | | | | | | | | | | | | | | Commit 1ea5855e980c ("partname: Introduce fstools_partname_fallback_scan option") had two problems: 1. The strcmp() aborted when the param *matched* 1; we wanted the inverse 2. It was too aggressive about skipping the fallback behavior. For devices that had no root= parameter, they would always attempt the fallback scan. Fix both of those. Fixes: 1ea5855e980c ("partname: Introduce fstools_partname_fallback_scan option") Signed-off-by: Brian Norris <computersforpeace@gmail.com> [ add extra spacing between function ] Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
* partname: Introduce fstools_partname_fallback_scan optionChristian Marangi2023-01-221-0/+13
| | | | | | | | | | | | | | Some device may contains a GPT partition named rootfs_data that may not be suitable. To save from regression with old implementation that doesn't use fstools_ignore_partname to explicitly say that that parname scan should be ignored, make explicit that scanning each partition should be done by providing fstools_partname_fallback_scan=1 and skip partname scan in every other case. Fixes: e9b59f063bb3 ("partname: Ignore root=PARTUUID...") Tested-by: Dirk Buchwalder <buchwalder@posteo.de> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
* partname: Ignore root=PARTUUID...Brian Norris2023-01-201-2/+2
| | | | | | | | We're assuming all root= arguments are /dev/ paths, but many targets utilize root=PARTUUID=<xxx> strategies. At least allow them to fall back to scanning all block devices. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* block: try multiple NTFS filesystem implementationsRafał Miłecki2022-11-101-4/+29
| | | | | | | | | | | | | | | NTFS filesystem is supported by multiple implementations. Try mounting it using all known drivers. Trying just "ntfs" string was limiting fstools to compatibility with the read-only upstream Linux driver. This fixes: daemon.err block: No "mount.ntfs" utility available daemon.err block: mounting /dev/sda1 (ntfs) as /mnt/sda1 failed (25) - Not a tty Above errors were appearing even with ntfs3 upstrea kernel driver or ntfs-3g (user-space) installed. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* libfstools: skip JFFS2 padding on block devicesDaniel Golle2022-10-181-4/+42
| | | | | | | | | Images also used on devices with NOR flash may come with JFFS2 deadc0de marking and padding up to the largest NOR erase size. Skip that padding and take it into account when extracting sysupgrade backup from mmc/block partition. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: Do not include linux/fs.h any moreHauke Mehrtens2022-08-131-2/+0
| | | | | | | | | | | | glibc 2.36 changed the definition of enum fsconfig_command in sys/mount.h. This definition collides with the same definition from linux/fs.h now. Remove the include of linux/fs.h. This compiles still with musl too. musl and glibc provide the defines linux/fs.h was included for in sys/mount.h since some years. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
* libfstools: Rename move_mount() function to ovl_move_mount() for glibc 2.36Hauke Mehrtens2022-08-071-3/+3
| | | | | | | | glibc in version 2.36 defines an own function named move_mount() in some header. The definition from glibc collides with our definition, just rename the function in fstools. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
* libfstools: handle gzip return value in block_volume_formatChristian Marangi2022-07-171-1/+5
| | | | | | | | | | | | Fix the following compilation warning: libfstools/common.c: In function 'block_volume_format': libfstools/common.c:120:17: error: ignoring return value of 'system' declared with attribute 'warn_unused_result' [-Werror=unused-result] 120 | system(str); | ^~~~~~~~~~~ Correctly handle return value from gzip and print an error on such case. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
* Revert "fstools: remove SELinux restorecon hack"Daniel Golle2022-06-023-0/+27
| | | | | | | | | | Now that procd only relables the filesystem in case of the system beging started with initramfs we will again need to take care of labeling newly created /overlay. This reverts commit 9e11b3723ce30b9b8c94ad7d15072a10cf13c0b4. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* fstools: remove SELinux restorecon hackDaniel Golle2022-05-033-27/+0
| | | | | | | Now that procd takes care of it properly we no longer need this hack. Remove it to safe some space also on non-SELinux systems. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: don't probe mtdblock on NAND (with legacy exceptions)Daniel Golle2022-05-011-0/+53
| | | | | | | | | | | | | | | | | Recent kernels started to spill warnings on the log if a userspace process open()s an mtdblock device backed by NAND flash: mtdblock: MTD device 'foo' is NAND, please consider using UBI block devices instead. The warning itself is legitimate -- one really shouldn't be using mtdblock on NAND. Hence make fstools skip probing mtdblock devices if their underlaying mtd device is of type 'nand'. As we don't want to break boards actually using JFFS2 and squashfs directly on NAND, still probe the mtdblock device in case the mtd device name is 'rootfs' or 'rootfs_data'. This will then also trigger the kernel warning as it should. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* blockd: restore device_move semanticsDaniel Golle2022-05-011-6/+4
| | | | | | | | | | | | | | Before commit 4963db4 block device were only removed and re-added in case of device_move() returning a non-zero value. Commit 4963db4 then (supposedly) accidentally inverted that logic and also (probably to work-around the problems resulting from the now inverted logic) limited this behavior to autofs mounts, leaving the autofs codepath in a semi- broken state. Restore the original semantics as of before commit 4963db4 to fully restore functionality for autofs mounts. Fixes: 4963db4 ("blockd: use uloop_process for calling /sbin/hotplug-call mount") Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* libfstools: mtd: improve error handlingDaniel Golle2022-05-011-6/+4
| | | | | | | | Use -1 to mark invalid file descriptors as 0 can theoretically be a valid open file descriptor. Do not ignore lseek() return value and check if an error has occured. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* libfstools: avoid segfault in find_mount_pointStijn Tintel2022-02-051-0/+3
| | | | | | | | If block is NULL, find_mount_point will segfault when comparing it against the device name found in /proc/self/mountinfo. Avoid this by checking if block is NULL. Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
* libfstools: use variable for overlay mount-pointRafał Miłecki2022-01-111-9/+10
| | | | | | This avoids duplicating path over and over. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* libfstools: get rid of "extroot_prefix" global variableRafał Miłecki2022-01-114-12/+4
| | | | | | | Replace it with mount_extroot() argument. It's cleaner than a global var. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* Update / fix extroot commentsRafał Miłecki2022-01-112-5/+5
| | | | | | | | Comment in start() was invalid as mount_extroot() doesn't handle any mounting internally. It was a misunderstanding coming from block.c function called just the same. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* libfstools: check for overlay mounting errorsRafał Miłecki2022-01-111-1/+4
| | | | Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* fstools: fix a couple of minor code problemsDaniel Golle2021-11-166-19/+52
| | | | | | Improve error handling and fix a resource leak inside an error path. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* libfstools: use uevent instead of relying on custom kernel patchDaniel Golle2021-11-011-10/+13
| | | | | | | | Detect partition name based on 'uevent' instead of relying in custom kernel patch exposing 'name' in sysfs directly. This will allow to drop the custom patch again. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* libfstools: make sure file is closed on errorDaniel Golle2021-11-011-1/+3
| | | | | Coverity CID: 1330286 Resource leak Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* blockd: include missing libubox/utils.hDaniel Golle2021-08-251-0/+1
| | | | Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* libfstools: handle open() return value properly in F2FS checkDaniel Golle2021-08-251-0/+4
| | | | | | Coverity CID: 1490101 Argument cannot be negative Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: fix two resources leaks discovered by CoverityDaniel Golle2021-08-141-2/+5
| | | | | | | Coverity CID: 1412456 Resource leak Coverity CID: 1412458 Resource leak Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* ubi: fix resource leak in legacy codepathDaniel Golle2021-08-141-0/+12
| | | | | | | | | | | I'm not even sure we are even using this 'ubi' tool anywhere. Fix the resource leak reported by Coverity anyway. Coverity CID: 1330289 Resource leak Coverity CID: 1330290 Resource leak Coverity CID: 1330291 Resource leak Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* libubi: fix several issues discovered by CoverityDaniel Golle2021-08-141-5/+7
| | | | | | | | | Coverity CID: 1329896 Out-of-bounds access Coverity CID: 1330127 Resource leak Coverity CID: 1330173 Resource leak Coverity CID: 1330472 Wrong size argument Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* blockd: fix resource leak discovered by coverity scanDaniel Golle2021-08-141-0/+3
| | | | | | Fixes Coverity CID 1463265 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* blockd: also report target in notificationsDaniel Golle2021-08-051-13/+32
| | | | | | | Useful to start/stop services triggered by mountpoints. See procd.sh procd_add_mount_trigger to make use of that. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* libblkid-tiny: install header file to include dirDaniel Danzberger2021-08-031-0/+1
| | | | | | | Hence libblkid-tiny is a shared lib, it makes sense to install it's header to the system incldue/ dir for other applications to use it. Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
* libblkid-tiny: fix invalid open syscall return checkDaniel Danzberger2021-08-031-1/+1
| | | | | | open() returns -1 on error, not 0 (stdin). Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
* blockd: make most calls to 'block' asynchronousDaniel Golle2021-07-301-12/+27
| | | | | | | | | | | Don't wait for calls to 'block' to complete unless it's for an autofs event (which cannot be handled async). Use uloop for 'mount.ready' notificaion when startup has completed to avoid blocking in waitpid() while the 'block' process is calling back via ubus. This greatly reduces the amount of time blockd needs on boot. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* blockd: send mount.ready when startup has completedDaniel Golle2021-07-281-1/+4
| | | | | | Emmit mount.ready notification when 'block autofs start' has completed. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: don't add non-ubifs ubi devicesDaniel Golle2021-07-281-5/+13
| | | | | | | As they require ubiblock to be mounted, just skip ubi devices in case they don't contain a ubifs. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: support umount device basenameDaniel Golle2021-07-241-2/+11
| | | | | | | blockd calls the umount action with the basename of the device rather than the full path. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* blockd: fix length of timeout int passed to ioctlDaniel Golle2021-07-241-1/+1
| | | | | | | | AUTOFS_IOC_SETTIMEOUT expects a pointer to an 'unsigned long' which will result in out-of-bounds access when passing a pointer to an 'int'. Change type of timeout to 'unsigned long'. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: allow remove hotplug event to arrive at blockdDaniel Golle2021-07-231-13/+13
| | | | | | | | | As the hotplug event fires after the device has been removed, it will never be found by _cache_load(). Hence the 'remove' event needs to propagate in all cases and we only need to populate the cache in case of 'add' events. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: use /dev/dm-* instead of /dev/mapper/*Daniel Golle2021-07-231-1/+1
| | | | | | | This avoids a lot of problems as hotplug events also arrive for the /dev/dm-* names. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* Revert "blockd: detect mountpoint of /dev/mapper/*"Daniel Golle2021-07-231-9/+0
| | | | | | This reverts commit 4d4dcfb33c5d9fa31c9916e106bee309ec7b4b01. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* Revert "block: resolve /dev/mapper/* name for /dev/dm-0 when hotplugging"Daniel Golle2021-07-231-22/+1
| | | | | | | | | Turns out using the device nodes /dev/mapper/* turns out to be a bad idea to begin with. Will use /dev/dm-* instead. This reverts commit 2f42515977adef7c026eb380ed2423c533cf8f3d. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* blockd: create mountpoint parent folder if neededDaniel Golle2021-07-181-1/+9
| | | | Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* blockd: move to its own POSIX process groupDaniel Golle2021-07-151-0/+3
| | | | | | | | | | Not to be confused with cgroups, there are also POSIX process groups. They do matter when it comes to autofs, as all requests coming from the process group of the automounter itself will be ignored. Hence, if blockd runs in the same process group as init and all services, requests from services will be ignored. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* blockd: fix trigger nameDaniel Golle2021-07-151-1/+4
| | | | | | | Make it 'mount.add' instead of just 'add' which is more obvious when used with procd_add_raw_trigger. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* blockd: also send ubus notification on mount hotplugDaniel Golle2021-07-141-12/+34
| | | | | | | | | | Also sending a ubus notification on mount hotplug provides a useful shortcut for procd service triggers. As the /etc/hotplug.d/mount API for now doesn't have any users and also makes it hard to aggregate hotplug calls, we should consider removing it in favor of only using triggers on the block notifications in future. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: resolve /dev/mapper/* name for /dev/dm-0 when hotpluggingDaniel Golle2021-07-141-1/+22
| | | | Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* blockd: detect mountpoint of /dev/mapper/*Daniel Golle2021-07-141-2/+11
| | | | | | If a device cannot be found in /dev, also try /dev/mapper. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* blockd: add missing #define _GNU_SOURCEDaniel Golle2021-05-161-0/+1
| | | | | | asprintf requires _GNU_SOURCE to be defined. Set it. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: allow autofs and umount commands also on MTD/UBIDaniel Golle2021-05-161-2/+2
| | | | | | | | As devices with large NAND flash are becoming more common, users may use that resource for additional (UBI) volumes. To support that in fstools, allow autofs and umount also on MTD/UBI devices. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: match device path instead of assuming /dev/%sDaniel Golle2021-05-161-6/+14
| | | | | | | | | Block devices created by device mapper are in /dev/mapper/ folder, hence the assumption of the 'block' tool expecting /dev/%s being the path of a device doesn't hold true. Match device path from cache instead. Signed-off-by: Daniel Golle <daniel@makrotopia.org>