| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
| |
This avoids duplicating path over and over.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
| |
Replace it with mount_extroot() argument. It's cleaner than a global
var.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
| |
Improve error handling and fix a resource leak inside an error path.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
| |
Coverity CID: 1330286 Resource leak
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
| |
Coverity CID: 1490101 Argument cannot be negative
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
| |
So it's now correct `synchronizing`.
Signed-off-by: Petr Štetiar <ynezz@true.cz>
|
|
|
|
|
|
|
|
|
|
|
|
| |
Apparently some devices with eMMC (e.g. ZyXEL NBG6817) got an exsiting
GPT partition called 'rootfs_data'. This partition is then selected
as rootfs_data eventhough it may not be suitable for that (too small)
or serve another purpose (ie. used by vendor firmware).
To avoid this, check if the kernel cmdline contains a variable
fstools_ignore_partname=1 and if so, skip partname detection of volumes
alltogether.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
|
| |
Turns out C header file <stropts.h> is unneeded after all.
Remove it.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
|
|
|
| |
stropts.h which is unavailable under glibc (and not needed
when building against glibc). Include it only if not building
against glibc.
Reported by: @DazzyWalkman
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
|
|
|
|
|
| |
partname driver didn't allow mount_root to identify the filesystem
and hence the overlay filesystem state remained PENDING which lead
to overlay being cleared again at every reboot.
Fix that by setting v->blk early and, while at it, eliminate unneeded
strdup's by storing the full device paths in a union allowing accessing
the full path or the device name only.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
| |
In the current implementation, in case of execl("/sbin/restorecon")
failing, the child process will also return and that will lead to
even more disasterous effects.
Though it seems unlikely that execl() would fail given that the file
exists, simply catch that case by exiting in case execl() returns.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
| |
Use restorecon to apply SELinux labels if applicable.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
| |
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
| |
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
|
| |
overlayfs has been in mainline since Linux v3.18 (OpenWrt CC 15.05).
Remove support for pre-mainline overlayfs.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
When using jffs2 on NAND flash, it stores its magic in the OOB data on
newly erased blocks. This change fixes identifying the filesystem type.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit f5c7c1813f52e6d7b59ecfb2f9f95e69b05b1980 which needs
more work and testing as it broke at least jffs2 overlays at least on
ath79 platform, marking them as read-only, thus unusable:
jffs2_build_filesystem(): erasing all blocks after the end marker...
jffs2: Erase at 0x009e0000 failed immediately: -EROFS. Is the sector locked?
Ref: http://lists.infradead.org/pipermail/openwrt-devel/2020-January/021344.html
Reported-by: Steve Brown <sbrown@ewol.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch enables fstools to open read-only MTD partitions, which in
turn also enables OpenWrt to boot from read-only partitions.
The use of read-only partitions is of special importance for WiFi-only
devices, where a protected read-only recovery image can be used in case
something goes wrong with the main firmware (eg. user gets locked out
due to bad settings, flash of an unbootable dev firmware, etc).
Signed-off-by: Bruno Pena <brunompena@gmail.com>
|
|
|
|
|
|
|
|
| |
Revise matching code using strncmp() in order to avoid returning wrong
items, e.g. /dev/sda1 when /dev/sda was requested.
Ref: https://bugs.openwrt.org/index.php?do=details&task_id=2196
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
| |
Saves 1472 bytes under glibc. No other difference.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
Reduce noise during firstboot when creating overlay fs on block
rootdisk devices.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
| |
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: John Crispin <john@phrozen.org>
|
|
|
|
|
|
|
| |
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/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>
|
|
|
|
| |
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|