summaryrefslogtreecommitdiff
path: root/libfstools/overlay.c
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* Revert "fstools: remove SELinux restorecon hack"Daniel Golle2022-06-021-0/+1
| | | | | | | | | | 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-031-1/+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>
* 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-111-2/+1
| | | | | | | 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-111-0/+4
| | | | | | | | 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-161-2/+8
| | | | | | Improve error handling and fix a resource leak inside an error path. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* overlay: fix syncronizing typoPetr Štetiar2021-04-071-1/+1
| | | | | | So it's now correct `synchronizing`. Signed-off-by: Petr Štetiar <ynezz@true.cz>
* mount: apply SELinux labels before overlayfs mountDaniel Golle2020-10-161-0/+1
| | | | | | Use restorecon to apply SELinux labels if applicable. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* overlay: use precompiler macros for reoccuring path namesDaniel Golle2020-10-161-4/+5
| | | | Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* fstoools: add define for GLOB_ONLYDIRRosen Penev2020-07-111-0/+4
| | | | | | | | | This was originally a patch for musl. It is not present in musl as it is a GNU extension. Place it here where it belongs. Signed-off-by: Rosen Penev <rosenp@gmail.com>
* fstools: allow the mounting with full access time accountingPierre Lebleu2018-05-241-1/+6
| | | | | | | | In order to allow the mounting of the filesystem with full access time accounting, a new CMake option (eg: CMAKE_OVL_MOUNT_FULL_ACCESS_TIME) has been added. Signed-off-by: Pierre Lebleu <pme.lebleu@gmail.com>
* fstools: allow to compress the filesystemPierre Lebleu2018-05-241-1/+7
| | | | | | | In order to allow the mounting of the filesystem with the zlib compression, a new CMake option (eg: CMAKE_OVL_MOUNT_COMPRESS_ZLIB) has been added. Signed-off-by: Pierre Lebleu <pme.lebleu@gmail.com>
* libfstools: move mount points when switching to JFFS2Rafał Miłecki2018-04-161-1/+45
| | | | | | | | | | | | | | | Switching from "tmpfs" to "jffs2" happens after JFFS2 formatting is done. During that time user can use filesystem (thanks to RAM) and the role of switch2jffs() is to copy all changes to the JFFS2 overlay partition. What wasn't handled so far was moving mount points. User can create custom mounts, cp command won't copy them and umounting "tmpfs" will cause these mounts to go away. To preserve them switch2jffs() has to find all custom mount points and move them to the new filesystem. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Acked-by: John Crispin <john@phrozen.org>
* 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>
* overlay: fix compilation with glibcRoman Yeryomin2018-01-131-1/+2
| | | | | | | | | | | | | glibc fails with: warn_unused_result [-Wunused-result] system("cp -a /tmp/root/upper/* / 2>/dev/null"); Regression intoroduced with 11efbf3b90f031ce634fc38cad07a4aef2985777 Reported here: https://www.mail-archive.com/lede-dev@lists.infradead.org/msg10502.html Signed-off-by: Roman Yeryomin <roman@advem.lv> Acked-by: Florian Fainelli <f.fainelli@gmail.com>
* libfstools: optimize building directory string for globRafał Miłecki2018-01-071-4/+1
| | | | | | | glob should handle paths like /foo/bar//* so we probably don't need this extra check & code. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* 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>
* overlay: fix race condition when switching to jffs2Roman Yeryomin2018-01-021-0/+4
| | | | | | | | | | | | | | | | There is a race between `cp -a /tmp/root/* /rom/overlay` from libfstools/overlay.c and a process creating new file(s) before pivot(/rom, /mnt) occured. That is a process can create a file and it will not be copied. To workaround this, do additional copy after jffs2 is ready. This doesn't completely solve the problem but since there was no other fix provided since original RFC [1], it is better than nothiing. [1] https://www.mail-archive.com/openwrt-devel@lists.openwrt.org/msg38218.html Signed-off-by: Roman Yeryomin <roman@advem.lv>
* fstools: Replace strerror(errno) with %m format.Rosen Penev2017-12-121-10/+10
| | | | | | Saves 1472 bytes under glibc. No other difference. Signed-off-by: Rosen Penev <rosenp@gmail.com>
* 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-081-0/+3
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* libfstools: add f2fs filesystem type and simplify fs type codeFelix Fietkau2016-09-081-35/+28
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* libfstools: call volume_init() before accessing v->blkFelix Fietkau2016-09-081-3/+2
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* fix return code of overlay_mount_fsJohn Crispin2016-08-161-1/+1
| | | | Signed-off-by: John Crispin <john@phrozen.org>
* Revert "fstools: support for ext4fs overlay"John Crispin2016-05-111-14/+0
| | | | | | | | This reverts commit bf4f08af9b8fe991216023a906182744eb1e4645. this patch was breaking devices that have a normal ext4 rootfs Signed-off-by: John Crispin <john@phrozen.org>
* fstools: support for ext4fs overlayRam Chandra Jangir2016-04-221-0/+14
| | | | | | | | | This change will enables eMMC (ext4 fs) boot support, when we try to boot from eMMC card then it will read partition names from /sys/block/mmcblkX/mmcblkXY/uevent file and will mount the rootfs_data partition as ext4fs overlay. Signed-off-by: Ram Chandra Jangir <rjangi@codeaurora.org>
* fstools: check existing filesystem state before writing the new oneFelix Fietkau2016-01-101-0/+3
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* overlay: use lstat rather than stat and make sure there are no trailing spacesJohn Crispin2015-08-261-3/+9
| | | | | | with this patch even uclibc wont deleted symlinked folders Signed-off-by: John Crispin <blogic@openwrt.org>
* make jffs2reset not iterate over symlinked foldersJohn Crispin2015-08-261-1/+3
| | | | Signed-off-by: John Crispin <blogic@openwrt.org>
* mount_root: use symlink instead of xattr to store initialization stateFelix Fietkau2015-05-251-16/+18
| | | | | | xattr seems to be unreliable with jffs2 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* properly handle return codesJohn Crispin2015-03-281-1/+4
| | | | Signed-off-by: John Crispin <blogic@openwrt.org>
* mount_root: keep track of overlay initialization state (via xattr)Felix Fietkau2015-03-221-1/+57
| | | | | | Remove all files (except sysupgrade.tgz) if /etc/init.d/done was not called Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* overlay: call volume_init() before mountFelix Fietkau2015-03-221-2/+2
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* overlay: create a common function for deleting all overlay data (optionally ↵Felix Fietkau2015-03-221-0/+39
| | | | | | excluding sysupgrade.tgz) Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* libfstools: clarify message when switching to internal overlayJo-Philipp Wich2015-02-251-1/+1
| | | | Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* libfstools: convert to ulog() apiJo-Philipp Wich2015-02-251-22/+22
| | | | Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* libfstools: accept volume as argument in most callsRafał Miłecki2014-12-141-14/+4
| | | | | | This optimizes code: drops unneeded calls to the volume_find and checks. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
* fix jffs2reset on ubifs overlayDaniel Golle2014-06-221-2/+2
| | | | | | | | | | | | change find_mount_point parameter to match either all or only jffs2 and ubifs, which are typically used on embedded mtd devices. For now, find_mount_point was used without the fstype parameter except for a single occurance in jffs2reset. There it is desireable to apply the same logic as previously hard-coded to jffs2 also in the case of a ubifs overlay, so firstboot aka. factory-reset works as expected. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* cosmetic: fix indentationLuka Perkov2014-05-211-1/+1
| | | | Signed-off-by: Luka Perkov <luka@openwrt.org>
* support for ubifs overlaydaniel2014-05-131-5/+23
| | | | Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* split fs-state back into seperate toolsJohn Crispin2014-04-071-23/+5
| | | | Signed-off-by: John Crispin <blogic@openwrt.org>
* move files aroundJohn Crispin2014-04-031-0/+268
Signed-off-by: John Crispin <blogic@openwrt.org>