| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Copying device name into a fixed-length buffer is problematic as
the name can be longer than the buffer, resulting in subsequent fields
getting corrupted and potentially even worse things.
Drop strcpy of device name and use of the copied value as it is known
anyway.
Before this fix:
/dev/mapper/owrt--volumes--e093cc66-rw_test: UUID="c66-rw_test" LABEL="test" VERSION="1.14" TYPE="f2fs"
After this fix:
/dev/mapper/owrt--volumes--e093cc66-rw_test: UUID="5eda3e52-3427-493a-a6d6-ffdb5a5836fd" LABEL="test" VERSION="1.14" TYPE="f2fs"
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
|
|
|
| |
device names can be pretty long when using LVM2, mount targets are
user defined and can potentially also be of PATH_MAX length.
Replace static buffers with dynamically allocated strings to avoid
buffer overflow with too long device names or mount targets.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
|
|
| |
Dynamically allocate string buffer for target mountpoint if needed in
order to avoid the static buffer overflowing for long (device mapper)
paths.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
|
|
|
| |
When a UCI fstab mount config doesn't contain a target option,
a 'block mount' call segfaults when comparing a mount's target (NULL)
to a found mount point returned by find_mount_point()
Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
Acked-by: Paul Spooren <mail@aparcar.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>
|
|
|
|
|
|
|
|
| |
To erase the overlay partitions on systems using UBIFS overlay,
instead of writing the jffs2-marker, truncating the UBI volume to 0
has the desired effect.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
|
| |
Drop local mkdir_p implementation in favour of using the
implementation now added to libubox.
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>
|
|
|
|
| |
Signed-off-by: John Crispin <john@phrozen.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>
|
|
|
|
|
|
|
|
|
|
| |
Program received signal SIGSEGV, Segmentation fault.
main_autofs (argv=<optimized out>, argc=<optimized out>)
at fstools-2020-05-06-eec16e2f/block.c:1193
1193: if (!m->autofs && (mp = find_mount_point(pr->dev))) {
Fixes: 9ab936d ("block(d): always call hotplug.d "mount" scripts from blockd")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
| |
It allows getting info about specified device.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This resolves problem on boot with "mount" scripts being called too
early to get blockd info. With this change "mount" scripts won't get
called until blockd starts. On startup it requests all devices info and
calls relevant scripts.
This fixes samba36-hotplug package hotplug.d script.
One downside of this change is handling "mount" evens on block restart
or crash. On restart "add" actions will get executed for mounted /
available (autofs) devices. On crash no events will be generated.
Ref: http://lists.infradead.org/pipermail/openwrt-devel/2019-December/020886.html
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As blockd uses uloop calling any script and using waitpid() can easily
result in a lock. It's enough for script to use /bin/ubus to cause that.
It's not an option to drop waitpid() as it's important to e.g. call
mount scripts with ACTION=remove before unmounting devices. So solving
this problem requires using uloop_process.
Unfortunately this means:
1. Using callbacks making code slightly more complex
2. Dropping that nice devices_update_cb()
With this change however hotplug.d "mount" scripts can safely call
"ubus".
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
According to spec the FAT filesystem label is not terminated by a
\0-byte but instead has a fixed length where the name is padded by
blanks.
Before libblkid-tiny just passed the always 11 bytes long blank padded
string through, however it makes matching for a filesystem label
inconsistent with other filesystems, which use a \0-terminated string.
Before: "foobar "
After : "foobar"
Signed-off-by: Mirko Vogt <mirko-openwrt@nanl.de>
|
|
|
|
|
|
|
|
|
| |
Use this method even if UBIFS extroot support is enabled. This is needed
on x86 systems (using F2FS for overlay) as they may still come with F2FS
enabled.
Ref: https://bugs.openwrt.org/index.php?do=details&task_id=2231
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
| |
Avoid too big code indent.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
| |
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit fb0700f0fdfc4bec220203d31df87be2b4ccc467.
Switching to AVL tree allows sorting devices by selected parameter
(mount path) but does not implement a real hierarchical layout. That
would require a tree with parent nodes being parent devices / mount
paths.
Cc: Yousong Zhou <yszhou4tech@gmail.com>
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit 32c3126b2f0464106d74317336b6aef1d7d5f82f.
Internally stored list of devices is implemented using struct vlist_tree
and keeps devices sorted by their mount target paths. This DOESN'T mean
that all preceding entires of a given device are its parent devices.
Making such an assumption and mounting all preceding devices results in
unwanted mounts in most cases.
For example having devices like:
/dev/sda1 (mount target: /mnt/foo1)
/dev/sda2 (mount target: /mnt/foo2)
/dev/sdb1 (mount target: /mnt/bar1)
/dev/sdb2 (mount target: /mnt/bar2)
will result in devices vlist_tree having entries sorted like:
/dev/sdb1 (bar1), /dev/sdb2 (bar2), /dev/sda1 (foo1), /dev/sda2 (foo2)
Using autofs and accessing /mnt/foo2 would result in mounting all 4
partitions and spinning unneeded /dev/sdb.
Cc: Yousong Zhou <yszhou4tech@gmail.com>
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
Files like that can remain from using non-autofs mounting and can cause
mounting errors after switching to autofs:
blockd: failed to symlink /mnt/sda1->/tmp/run/blockd/sda1
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
|
| |
Links like that can remain from using autofs and can cause mounting
errors after switching to non-autofs:
block: mounting /dev/sda1 (vfat) as /mnt/sda1 failed (2) - No such file or directory
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
| |
Devices handled with autofs should be seen as available even if
currently unmounted. Mounting is handled on demand and transparently for
users.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
| |
It may help understanding failure reason, e.g.:
blockd: failed to symlink /mnt/sda1->/tmp/run/blockd/sda1 (17) - File exists
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
f2fs max label length is 1024B (512 * uint16_t) which is way above
current 256B used in `struct blkid_struct_probe` which renders labels on
f2fs system unusable:
$ mkfs.f2fs -l drive /dev/sda1
$ block info /dev/sda1
label buffer too small 1024 > 255
So increase the label buffer again in order to make enough space for
f2fs labels.
Fixes: FS#2735
Signed-off-by: Petr Štetiar <ynezz@true.cz>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When retrying extroot mounting after waiting for the underlying device to
appear, the internal device cache was rebuilt without mtd devices, leading
to the following error:
block: extroot: unable to lookup root device /dev/...
The extroot mount procedure needs access to the actual mtd root device to
temporarily mount it for uuid file verification.
Fix this error by rebuilding the cache with mtd devices to allow the
`check_extroot()` procedure to find the internal root device.
Fixes: FS#2701
Fixes: fb0700f ("block: support hierarchical mount/umount")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
|
|
|
|
|
|
|
|
| |
The recent introduction of blkid_new_probe() and blkid_free_probe() in the
dynamically linked libblkid-tiny caused the dlopen'd libblkid.so to call into
the wrong version of blkid_new_probe() within blkid_new_probe_from_filename(),
leading to memory corruption and eventual segmentation faults.
Fixes: b82c5c1 ("libblkid-tiny: add functions for allocating & freeing probe struct")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
commit f0ca7e80d7a171701d0d04a3eae22d97f15d0683 upstream.
* Use only label from the root directory and do not fallback to the label
stored in boot sector. This is how MS-DOS 6.22, MS-DOS 7.10, Windows 98,
Windows XP and also Windows 10 behave. Moreover Windows XP and Windows 10
do not touch label in boot sector anymore, so removing FAT label on those
Windowses leads to having old label still stored in boot sector (which
MS-DOS and Windows fully ignore).
* Label entry "NO NAME" in root directory is treated as label "NO NAME"
instead of empty label. In root directory it has no special meaning.
String "NO NAME" has a special meaning (empty label) only for label
stored in boot sector.
* Label from the boot sector is now stored into LABEL_FATBOOT field. So if
there are applications which depends or needs to read this label, they
have ability.
After this change LABEL always correspondent to the label from the root
directory and LABEL_FATBOOT to the label stored in the boot sector. If some
of those labels is missing or is not present (e.g. "NO LABEL" in boot
sector) then particular field is not set.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
[rmilecki: drop unneeded now downstream hacks for handling spaces]
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
|
|
| |
commit e526f503918cc29d8b1ccf36a5c3a34645d2be6e upstream.
When FAT directory entry has leading byte 0x05 it is interpreted as byte
0xE5. This is how FAT stores file name which starts with byte 0xE5 as
leading byte in 0xE5 in FAT directory entry means that file slot is empty.
Fixes: #533
|
|
|
|
|
|
|
| |
This stub will allow porting more upstream code without commenting out
calls and them unused variables. This will simplify maintenance.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This allows reading multiple chunks of block device data and operating
on them simultaneously. Previous implementation was using a single
buffer (except for reading more data than allocated size) and subsequent
reads were corrupting memory of previously returned buffers.
This fixes e.g. problem with reading NTFS UUID and validating VFAT
signature.
Implementation is based on original libblkid code which handles it
similarly. Buffers are put on probe internal list and freed when
releasing a probe struct.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
|
|
| |
This adds blkid_new_probe() and blkid_free_probe() which have to be used
in place of simple struct memory allocation. They will allow extending
probe struct by any extra initialization code and resources release.
Newly introduced probe.c file is based on original libblkid's code.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
| |
The point of "hotplug" call is to add or remove a single entry to/from
devices list. Using vlist_update() and vlist_flush() was clearing whole
list (and leaving the last entry in case of adding a device).
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
|
| |
vlist_add() expects key to point a persistent memory as it doesn't make
its copy. Passing blob_attr of current message was resulting in
undefined/random behavior including list corruption and possible
crashes.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
| |
Move down the function so that no declaration of find_mount_point() is
not needed
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
|
|
|
|
|
|
|
|
| |
Fixes possible memleak of mp as well
Resolves FS#1523
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
|
|
|
|
| |
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
|