summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* libfstools: add "const" to char pointer arguments in mount_move()lede-17.01Rafał Miłecki2018-04-162-2/+2
| | | | | | | | | | That function never modifies these strings so it can/should use consts. It makes it a bit more flexible as now callers can also pass consts. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Acked-by: John Crispin <john@phrozen.org> (cherry picked from commit 3782b59e8f6391134cf146033ebe3baa1fbc0f5a)
* libfstools: fix foreachdir() to pass dir with a trailing slashRafał Miłecki2018-04-161-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | Commit cc63723d886fd ("overlay: use lstat rather than stat and make sure there are no trailing spaces") changed behavior of foreachdir() breaking some callbacks. Before that modification all callbacks were getting directory with a trailing slash. Above commit started removing them. This broke handle_whiteout() which doesn't work at all since then. It constructs file paths incorrectly: slash is missing between directory and a file name. It seems noone noticed it for years because this issue got hidden by switch2jffs() which also handles whiteouts with its system command "cp -a" call. Fix that regression by setting trailing slash back - right after calling lstat(). Also to keep code simple just skip all entries that aren't directories. This keeps conditions for removing/setting trailing slash trivial. A side effect is not calling callbacks for files which is a free bonus optimization. Fixes: cc63723d886fd ("overlay: use lstat rather than stat and make sure there are no trailing spaces") Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Acked-by: John Crispin <john@phrozen.org> (cherry picked from commit 79721f0376974859f39699a2237dbfa691233523)
* libfstools: support file paths longer than 255 charsRafał Miłecki2018-01-051-4/+18
| | | | | | | | Alloc globdir buffer dynamically and simply use realloc when needed. This fixes e.g. segmentation fault in jffs2reset due to an infinite recurrency when dealing with longs paths. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* libfstools: fix matching device nameDaniel Golle2017-06-301-3/+2
| | | | | | | | | | compare strlen()+1 characters to make sure we match the trailing \0 as well. Otherwise things get fishy when using lvm2, see this example: /dev/mapper/data: UUID="xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxxx" MOUNT="/mnt" TYPE="LVM2_member" /dev/mapper/data-fs: UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" LABEL="xxxxxxxx" VERSION="1.0" MOUNT="/mnt" TYPE="ext4" Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* fstools: use -Wno-format-truncation instead of -Wno-error=format-truncationFelix Fietkau2017-06-301-1/+1
| | | | | | Fixes build error with older gcc Signed-off-by: Felix Fietkau <nbd@nbd.name>
* libfstools: fix multiple volume_identify usages with the same volumePieter Smith2017-06-301-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes e.g. factory-flashed startup issue with jffs2 on ubi overlay Commit ba019965 ("libfstools: accept volume as argument in most calls") broke startup for factory-flashed jffs2 on ubi systems, causing substantial slowdown in factory environments. When starting up with a factory-flashed jffs2 on ubi system, the "rootfs_data" volume contains a deadcode marker. In the start phase, mount_root then mounts a tmpfs overlay, and postpones remounting of the jffs2 overlay until the done phase of the startup. The refactoring in ba019965 eliminated an unneeded call to volume_find() when done() called jffs2_switch(). Unfortunately the refactoring did not take into account that volume_identify() does not function correctly when called twice in a row on the same struct volume when using an mtd driver. mtd_volume_identify() uses mtd_volume_load() to open an fd to the mtd device and reads a potential deadcode marker from the fd. The first time this works, and FS_DEADCODE is returned. When volume_identify() is called a second time however, mtd_volume_load() notices that we already have an open fd, does nothing further and returns 0 without resetting the file offset to 0. mtd_volume_identify() now reads past the deadcode marker and now returns FS_JFFS2 if the mtd device is a UBIVOLUME. jffs2_switch() then handles the wrong case, either pulling the root out from under user-space in Chaos Calmer, or indefinitely sticking to a tmpfs overlay in later OpenWRT builds. Signed-off-by: Pieter Smith <pieter.smith@philips.com> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* build: disable the format-truncation warning error to fix gcc 7 build errorsFelix Fietkau2017-06-301-1/+1
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* libfstools: silence mkfs.{ext4,f2fs}Daniel Golle2017-06-301-2/+2
| | | | | | | Reduce noise during firstboot when creating overlay fs on block rootdisk devices. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* libfstools: add basic documentation of mount functionsRafał Miłecki2017-06-301-0/+15
| | | | | Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Acked-by: John Crispin <john@phrozen.org>
* add missing includesFelix Fietkau2017-06-304-0/+4
| | | | | | | On glibc 2.25, sys/sysmacros.h needs to be included for makedev, major and minor. Signed-off-by: Felix Fietkau <nbd@nbd.name>
* libfstools: Check return values for fread and systemFlorian Fainelli2016-12-051-4/+10
| | | | | | | | | | | | | | | | | 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>
* fstools: added f2fs to blockAlberto Bursi2016-10-311-3/+12
| | | | | | | | added code to block so it can recognize and operate the filesystem checker of f2fs added f2fs to the filesystem whitelist of block so it can mount it on /overlay at boot. Signed-off-by: Alberto Bursi <alberto.bursi@outlook.it>
* block: fall back to external mount helperJo-Philipp Wich2016-10-211-3/+141
| | | | | | | | | | If the mount(2) syscall fails with ENOENT, attempt to mount the filesystem using an external "/sbin/mount.$fstype" command. This allows filesystems which do not have direct kernel support, like fuse- or network filesystems. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* block: fix error reportingJo-Philipp Wich2016-10-211-5/+6
| | | | | | | | | | The current block code wrongly reported the return value of the mount() and umount2() syscalls, which is always -1 in case the call failed. Use errno and strerror(errno) instead to propagate the correct error code to the user. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* libblkid-tiny: remove unused name memberJo-Philipp Wich2016-10-171-1/+0
| | | | | | | The "name" member of struct blkid_struct_probe is not used anywhere anymore so remove it from the definition to save some stack and heap space. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* probe: stop handling name propertyJo-Philipp Wich2016-10-173-16/+4
| | | | | | | | | In the full liblkid there is no tag called "NAME" and the name value reported by libblkid-tiny was just the kind of uuid passed to blkid_probe_set_uuid_as(). Strip any handling of this property to allow removing it from libblkid-tiny. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* block: remove handling of name propertyJo-Philipp Wich2016-10-171-3/+0
| | | | | | | | | | | There is no concept of a "NAME" property within libblkid, the value previously used was the name parameter of blkid_probe_set_uuid_as() which does not denote the file system name, but the kind of UUID to store. Since the value never makes sense, stop using it when reporting block information. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* libblkid-tiny: fix SquashFS version detection on different endian systemsJo-Philipp Wich2016-10-171-8/+8
| | | | Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* libblkid-tiny: avoid setting phantom UUIDsJo-Philipp Wich2016-10-171-3/+2
| | | | | | | | | | | When blkid_probe_set_uuid_as() is invoked with a non-NULL name parameter then the name parameter denotes the kind of UUID (like "EXT_JOURNAL") not the name of the file system. Only copy the UUID value to the probe uuid member if the given name is either NULL or "UUID". Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* probe: add full libblkid supportJo-Philipp Wich2016-10-174-6/+131
| | | | | | | Attempt to dlopen() libblkid.so at runtime and use it for proping filesystems if available. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* block: add probe abstraction layerJo-Philipp Wich2016-10-164-67/+157
| | | | | | | Add an abstraction layer which separates block.c from libblkid-tiny implementation details in order to prepare support for optionally using the full libblkid. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* libfstools: properly label ext4 overlayDaniel Golle2016-09-231-1/+1
| | | | Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: also probe loop devicesDaniel Golle2016-09-231-0/+1
| | | | Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: include mountpoint in info outputDaniel Golle2016-09-121-19/+28
| | | | Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* libfstools: gather mountpoints from /proc/self/mountinfoDaniel Golle2016-09-121-24/+120
| | | | | | | | | | This allows identifying /dev/root by its major:minor number which are part of /proc/self/mountinfo but aren't contained in /proc/mounts. Also fix jffs2reset when using an ext4 overlay by adding it to the list of filesystems allowed if the root_only parameter of find_mount_point is set. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* libfstools: add rootdisk overlay volume supportFelix Fietkau2016-09-083-0/+285
| | | | | | Uses either ext4 or f2fs, depending on the overlay volume size Signed-off-by: Felix Fietkau <nbd@nbd.name>
* libfstools: replace hardcoded mentions of jffs2 in a few placesFelix Fietkau2016-09-081-6/+9
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* libfstools: add ext4 filesystem typeFelix Fietkau2016-09-083-0/+6
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* libfstools: add f2fs filesystem type and simplify fs type codeFelix Fietkau2016-09-084-38/+35
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* libfstools: use container_of for volume private dataFelix Fietkau2016-09-085-64/+59
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* libfstools: call volume_init() before accessing v->blkFelix Fietkau2016-09-085-4/+12
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* libfstools: remove obsolete enumFelix Fietkau2016-09-061-5/+0
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* fix logic bug inside extroot uuid verification codeJohn Crispin2016-08-311-1/+1
| | | | Signed-off-by: John Crispin <john@phrozen.org>
* libfstools: "lowerdir" variable name in fopivotПреподобный Гомер2016-08-181-7/+7
| | | | | | | | Hi all! In fopivot in libfstools variable name "lowerdir" is confusing and doesn't make any sense. There is a patch renaming that var to "mount_options".
* fix return code of overlay_mount_fsJohn Crispin2016-08-161-1/+1
| | | | Signed-off-by: John Crispin <john@phrozen.org>
* block: best-effort in find_mount_pointDaniel Golle2016-07-241-2/+5
| | | | | | Don't immediatly fail if block device cannot be stat'ed. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: get mountpoints from /proc/self/mountinfoDaniel Golle2016-07-241-33/+67
| | | | | | | | | | | | | | | | Instead of using two different implementations reading /proc/mounts and /proc/self/mountinfo, gather all information on mountpoints from /proc/self/mountinfo. While at it, tokenize mountinfo inline instead of using strtok_r because it's hard to tell whether strtok_r allocated new memory or merely returns a pointer to the (last) token. This might later on be relevant once we want to free that memory... Tokenizing mountinfo using strchr inline works without allocating any new memory by scanning and re-writing the string returned by gets(). As a result, the returned string needs to be duplicated to be safe for use even after the fclose(). Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: print mountpoint if already mountedDaniel Golle2016-07-211-2/+4
| | | | Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: also check /proc/self/mountinfo to find mountpointDaniel Golle2016-07-211-1/+28
| | | | | | | | Matching only the device name doesn't always work, e.g. in case of /dev/root. Thus also check the device(minor,major) which can be scraped from /proc/self/mountinfo. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: don't truncate mountpoint pathDaniel Golle2016-07-211-1/+1
| | | | Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: allow block info /dev/ubi?_?Daniel Golle2016-07-211-1/+1
| | | | | | Allow querying /dev/ubi?_? devices though they are not block devices. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: avoid ubi{,block} duplicatesDaniel Golle2016-07-211-0/+10
| | | | | | Skip ubi?_? device if ubiblock?_? is present. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* block: fix ubi?_? glob patternDaniel Golle2016-07-211-1/+1
| | | | | | | | The glob pattern intended for ubi?_? devices was matching ubiblock?_? devices as well. Change the glob to actually return only ubi devices. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* cmake: Link against libjson-cFlorian Fainelli2016-07-011-2/+4
| | | | | | | | block uses libblob_msgjson which requires us to link against libjson-c. Some external toolchains would be failing to find that library unless specified explicitly. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
* cmake: Find libubox/ulog.hFlorian Fainelli2016-07-011-0/+3
| | | | | | | | Add a CMake FIND_PATH and INCLUDE_DIRECTORIES searching for libubox/ulog.h. Some external toolchains which do not include standard locations would fail to find the header otherwise. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
* block.c: Add ability to mount with ACL and XATTR supportDaniel Dickinson2016-05-191-0/+4
| | | | | | | | | | Some users will want to use OpenWrt/LEDE devices as NAS devices and have full POSIX ACL and user_xattr support (along with other possible use cases), therefore add support to mount with POSIX ACLs and/or user XATTR support. Signed-off-by: Daniel Dickinson <lede@daniel.thecshore.com>
* block.c: Use <linux/fs.h> instead of defining mount flags ourselvesDaniel Dickinson2016-05-191-12/+2
| | | | | | | Let's use the cannonical source of mount flags instead of defining the flags ourselves. Signed-off-by: Daniel Dickinson <lede@daniel.thecshore.com>
* block.c: Add support for checking vfat filesystemsDaniel Dickinson2016-05-191-5/+11
| | | | | | | | vfat is a common filesystem which users may want to mount on an OpenWrt/LEDE device, so support peforming filesystem checks before mount for vfat. Signed-off-by: Daniel Dickinson <lede@daniel.thecshore.com>
* block.c: Make static string a const char * instead char *Daniel Dickinson2016-05-191-1/+1
| | | | | | | | There is no reason for e2fsck string to be altered, and the only places where is used take const char * as parameters so make e2fsck a const char *. Signed-off-by: Daniel Dickinson <lede@daniel.thecshore.com>
* mount_root: check for preinit sentinel fileJohn Crispin2016-05-151-1/+5
| | | | Signed-off-by: John Crispin <john@phrozen.org>