Yousong Zhou [Fri, 25 Oct 2019 10:51:49 +0000 (10:51 +0000)]
block: use fsck.fat instead of dosfsck
Dosfsck is only available when --enable-compat-symlinks was given when
configuring dosfstools. These symlinks are not enabled in OpenWrt
dosfstools package
Suggested by Reiner Otto in FS#2408
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Yousong Zhou [Fri, 25 Oct 2019 10:48:47 +0000 (10:48 +0000)]
libblkid-tiny: ntfs: fix use-after-free
The memory pointed to by ns can be reallocated when checking mft records
Fixes FS#2129
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Hauke Mehrtens [Mon, 2 Sep 2019 19:26:18 +0000 (21:26 +0200)]
mkdev: Avoid out of bounds read
readlink() truncates and does not null terminate the string when more
bytes would be written than available. Just increase the char array by
one and assume that there is a problem when all bytes are needed.
Coverity: #
1330087, #
1329991
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Ansuel Smith [Sun, 16 Jun 2019 17:00:50 +0000 (19:00 +0200)]
libblkid-tiny: use blkid_probe_set_utf8label for label set
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Ansuel Smith [Sun, 16 Jun 2019 17:00:49 +0000 (19:00 +0200)]
libblkid-tiny: adds blkid_probe_set_utf8label support
Currently set_utf8label support is missing. Adds a stripped down version of encode.c file from original libblkid and adds the function to libblkid-tiny.c.
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Jo-Philipp Wich [Wed, 28 Aug 2019 10:19:29 +0000 (12:19 +0200)]
probe: fallback to libblkid.so.1 when libblkid.so does not exist
OpenWrt commit
0e70f69a35 ("treewide: revise library packaging") removed
the unversioned library symlink from the libblkid package, breaking
dynamic loading of the library at runtime.
Add a fallback to "libblkid.so.1" to allow using the dynamic library
for filesystem probing again.
Fixes: FS#2274
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Ansuel Smith [Sun, 16 Jun 2019 17:00:48 +0000 (19:00 +0200)]
libblkid-tiny: increment label size to 256
Btrfs max label lenght is 255. Increment the blkid_struct_probe struct to respect this new max value.
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Ansuel Smith [Sun, 16 Jun 2019 17:00:47 +0000 (19:00 +0200)]
libblkid-tiny: fix wrong btrfs label length
Btrfs label length is 256 included the termination char ( '\0' ) as the real max length is 255 (less than 256 from the wiki).
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Jo-Philipp Wich [Wed, 27 Mar 2019 07:59:02 +0000 (08:59 +0100)]
block: prevent mount point confusion
Do not perform substring matches when identifying mount points to
avoid returning wrong entries, e.g. "/dev/mmcblk0p10" when
"/dev/mmcblk0p1" was requested.
Fixes: FS#2196
Ref: https://bugs.openwrt.org/index.php?do=details&task_id=2196
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Jo-Philipp Wich [Wed, 27 Mar 2019 07:55:07 +0000 (08:55 +0100)]
libfstools: avoid false positives when matching devices and volumes
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>
Petr Štetiar [Tue, 26 Mar 2019 22:50:47 +0000 (23:50 +0100)]
libfstools: Fix overflow of F2FS_MINSIZE constant
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>
Petr Štetiar [Tue, 26 Mar 2019 15:34:29 +0000 (16:34 +0100)]
libfstools: Print error in case of loop blkdev failure
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>
Rafał Miłecki [Wed, 12 Dec 2018 14:24:35 +0000 (15:24 +0100)]
block(d): improve hotplug.d "mount" events for the autofs
So far - when using autofs - "add" and "remove" action events were
triggered on every (un)mount. It wasn't very helpful when using autofs
due to its nature.
The point of blockd & autofs is to have block devices mounted on an
access request. Its users should not care / know if it's currently
mounted or not. Mounting should be handled transparently.
To make that work it requires informing listeners whenever device:
1) Becomes *ready* for mounting (by triggering "add" action)
2) Becomes *unavailable* (by triggering "remove" action)
The current mounting state is something that autofs & blockd should
handle internally and should not notify listeners about.
This is implemented by:
1) block generating events for non-autofs cases only (when (un)mounting)
2) blockd informing block when autofs resource becomes (un)available
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Rafał Miłecki [Wed, 12 Dec 2018 14:24:34 +0000 (15:24 +0100)]
blockd: unmount device explicitly when it disappears
To keep autofs behavior consistent blockd should request both: mounting
and unmounting when needed. It's important as autofs-related actions may
require slightly different handling.
Without this patch:
1) autofs mounts were handled using TYPE_AUTOFS
2) autofs unmounts were handled using TYPE_HOTPLUG
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Rafał Miłecki [Mon, 10 Dec 2018 06:48:50 +0000 (07:48 +0100)]
block: remove target directory after unmounting
This removes dangling directory fixing two issues:
1) Non autofs case
Leaving directory in /mnt/ and switching to autofs would result in
blockd failing to symlink().
2) autofs case
Leaving directory in /var/run/blockd/ could result in apps trying to
access it causing errors like:
blockd: kernel is requesting a mount -> sda1
blockd: failed to run block. add/sda1
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Rafał Miłecki [Sun, 9 Dec 2018 16:52:10 +0000 (17:52 +0100)]
block: cleanup handling "start" action of the "autofs" command
When blockd starts it uses "start" action for getting current state of
block devices. The way main_autofs() was implemented was a bit hacky
though:
1) It was calling mount_device() with TYPE_HOTPLUG
First of all that made code harder to understand. Faking TYPE_HOTPLUG
for a TYPE_AUTOFS made following mount_device() logic more complex.
Secondly the only reason for that seems to be to trigger "swap" and
extroot checks in the mount_device(). Other than that it was only
about calling blockd_notify() anyway.
2) It wasn't consistent
Consider a "swap" or extroot without an "autofs" set (a pretty
expected case).
a) During original TYPE_HOTPLUG event mount_device() would detect
both cases early and return without calling blockd_notify().
b) With previous main_autofs() implementation blockd_notify() was
called for both cases.
With this change main_autofs() doesn't fake TYPE_HOTPLUG and it follows
mount_device() logic which should result in an expected & consistent
state of devices in blockd.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Rafał Miłecki [Sun, 9 Dec 2018 15:11:59 +0000 (16:11 +0100)]
block: make blockd_notify() return an int instead of void
It allows improving block by handling blockd_notify() errors.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Rafał Miłecki [Sun, 9 Dec 2018 14:52:32 +0000 (15:52 +0100)]
block: generate hotplug.d mount events
With this change block generates 2 "mount" hotplug.d subsystem events:
1) "add" when block device gets mounted
2) "remove" when block device gets unmounted
This allows e.g. controlling USB storage dependant software using
hotplug.d listeners.
A very similar solution was implemented in mountd which was replaced by
blockd.
Right now this is implemented using a call to the /sbin/hotplug-call.
A possible improvement is to rewrite above shell script into a C lib
function. For now let's just assume that script exists.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Rafał Miłecki [Sun, 9 Dec 2018 13:22:17 +0000 (14:22 +0100)]
block: validate amount of arguments for the "autofs" command
Using argv[3] without checking argc value could result in undefined
behavior. It could result in a crash or accessing a NULL that separates
argv from envp on UNIX.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: John Crispin <john@phrozen.org>
Rafał Miłecki [Fri, 7 Dec 2018 13:13:10 +0000 (14:13 +0100)]
blockd: don't reparse blob msg in the vlist callbacks
ubus message is parsed in the block_hotplug() which fills all the struct
device fields. Once that is done there is no need to parse original
message again - it's enough to get required data from the struct.
This also fixes handling messages with "autofs" set to 0. They were
incorrectly interpreted due to the missing blobmsg_get_u32().
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: John Crispin <john@phrozen.org>
Rafał Miłecki [Thu, 6 Dec 2018 08:13:39 +0000 (09:13 +0100)]
blockd: don't unmount device when removing it from the list
Device gets removed from the list (vlist_delete()) when block calls
"hotplug" method of blockd using ubus. Right after that block unmounts
that device on its own.
blockd shouldn't care about unmounting on its own for following reasons:
1) To avoid code/behavior duplication with block
2) To keep behavior consistent with mounting (blockd doesn't mount)
3) To allow implementing more features in block (e.g. hotplug.d events)
To make unmounting the most reliable the plan is to have:
1) block receiving hotplug.d "block" subsystem events "remove"
2) blockd stopping reporting device (so we avoid new users & let
existing ones realize mount can't be used anymore)
3) block notifying (through hotplug.d "mount" subsystem) all users about
device being unmounted - that should stop all apps accessing it
4) block unmount device
That should allow storage users stop accessing mount point & let block
unmount device cleanly.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: John Crispin <john@phrozen.org>
Rafał Miłecki [Fri, 30 Nov 2018 17:26:12 +0000 (18:26 +0100)]
block: don't duplicate unmounting code in the mount_action()
Use umount_device() helper instead.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Rafał Miłecki [Fri, 30 Nov 2018 17:26:11 +0000 (18:26 +0100)]
block: make umount_device() function more generic
Make it accept device path instead of struct probe_info. This way it can
be reused by code fired when device is already gone.
To keep existing functionality two checks have been moved to the
main_umount().
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Rafał Miłecki [Fri, 30 Nov 2018 13:09:23 +0000 (14:09 +0100)]
block: don't duplicate mounting code in the mount_device()
Once target directory gets specified mounting code is identical for
devices having and not having UCI config entry. Share it.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Michael Heimpold <mhei@heimpold.de>
Rafał Miłecki [Fri, 30 Nov 2018 13:09:22 +0000 (14:09 +0100)]
block: simplify code picking mount target directory
Using a set of 3 conditional block each setting "target" variable makes
code easier to follow.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Michael Heimpold <mhei@heimpold.de>
Rafał Miłecki [Fri, 30 Nov 2018 13:09:21 +0000 (14:09 +0100)]
block: move blockd_notify() call out of the conditional blocks
That function is called no matter if "m" variable is null or not. This
saves a one duplicated line & allows merging two conditional blocks
starting with if (m). It doesn't change code execution order.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Michael Heimpold <mhei@heimpold.de>
Rafał Miłecki [Fri, 30 Nov 2018 13:09:20 +0000 (14:09 +0100)]
block: fix formatting & indent in the mount_device()
There was some misformatted code that seemed like switch block having an
else block. This improves code readability.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Michael Heimpold <mhei@heimpold.de>
Michael Heimpold [Sat, 24 Nov 2018 09:22:44 +0000 (10:22 +0100)]
fstools: use EXIT_FAILURE when indicating error on exit
According to man page, using the EXIT_* macros is more portable than using
plain integer values.
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
Michael Heimpold [Sat, 24 Nov 2018 09:22:53 +0000 (10:22 +0100)]
fstools: guard usage of WEXITSTATUS
According to man page, using WEXITSTATUS should be guarded by a check
of WIFEXITED, so add this check.
While at, also print an error message in case fsck was terminated
by a signal.
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
Ansuel Smith [Fri, 28 Sep 2018 23:01:02 +0000 (01:01 +0200)]
fstools: add ntfs support
This adds ntfs support to block-mount
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Pierre Lebleu [Wed, 23 May 2018 08:55:58 +0000 (10:55 +0200)]
fstools: allow the mounting with full access time accounting
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>
Pierre Lebleu [Wed, 23 May 2018 08:55:57 +0000 (10:55 +0200)]
fstools: allow to compress the filesystem
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>
Rafał Miłecki [Mon, 16 Apr 2018 14:11:47 +0000 (16:11 +0200)]
libfstools: move mount points when switching to JFFS2
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>
Rafał Miłecki [Mon, 16 Apr 2018 12:30:12 +0000 (14:30 +0200)]
libfstools: add "const" to char pointer arguments in mount_move()
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>
Rafał Miłecki [Fri, 13 Apr 2018 11:26:14 +0000 (13:26 +0200)]
libfstools: fix foreachdir() to pass dir with a trailing slash
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>
John Crispin [Sun, 11 Feb 2018 13:24:59 +0000 (14:24 +0100)]
strip trailing spaces from vfat labels
Signed-off-by: John Crispin <john@phrozen.org>
John Crispin [Mon, 22 Jan 2018 06:22:40 +0000 (07:22 +0100)]
fix vfat volume label
the libblkid copies len+1 bytes causing a buffer overrun.
Signed-off-by: John Crispin <john@phrozen.org>
Daniel Golle [Fri, 2 Feb 2018 00:32:21 +0000 (01:32 +0100)]
block: support /dev/nvme* nodes
Add glob for NVM Express SSD device nodes to support systems with
such PCIe SSDs.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Roman Yeryomin [Sun, 7 Jan 2018 18:04:02 +0000 (20:04 +0200)]
overlay: fix compilation with glibc
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>
Rafał Miłecki [Fri, 5 Jan 2018 14:24:30 +0000 (15:24 +0100)]
libfstools: optimize building directory string for glob
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>
Rafał Miłecki [Thu, 4 Jan 2018 13:58:18 +0000 (14:58 +0100)]
libfstools: support file paths longer than 255 chars
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>
Roman Yeryomin [Fri, 15 Dec 2017 14:10:30 +0000 (16:10 +0200)]
overlay: fix race condition when switching to jffs2
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>
Rafał Miłecki [Mon, 25 Dec 2017 19:52:11 +0000 (20:52 +0100)]
libblkid-tiny: add support for NTFS superblock
Its copied from the util-linux project and its libblkid. Call to the
blkid_probe_set_utf8label was commented out due to libblkid-tiny not
supporting it yet.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: John Crispin <john@phrozen.org>
Rosen Penev [Sun, 10 Dec 2017 04:54:41 +0000 (20:54 -0800)]
fstools: Replace strerror(errno) with %m format.
Saves 1472 bytes under glibc. No other difference.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Rafał Miłecki [Mon, 7 Aug 2017 09:20:09 +0000 (11:20 +0200)]
libblkid-tiny: add support for UBI superblock
Detecting UBI superblock may be useful for tools wanting to simplify or
automate attaching UBI. Please note it's not directly related to the
ubifs support which is just a filesystem working on top of UBI volume.
This patch adds simple code reading UBI version and unique number and
setting it in the blkid_probe.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Robert Young [Mon, 31 Jul 2017 16:49:59 +0000 (18:49 +0200)]
fstools: add btrfs support
Signed-off-by: Robert Young <yayooo@gmail.com>
W. Michael Petullo [Wed, 12 Jul 2017 11:02:18 +0000 (07:02 -0400)]
block: support /dev/xvd* nodes
Xen provides paravirtualized block devices which most often appear as
/dev/xvd*. This patch adds this pattern to those known to the block
utilitiy. These devices require a kernel compiled with the xen-blkfront
driver.
Signed-off-by: W. Michael Petullo <mike@flyn.org>
Daniel Golle [Fri, 30 Jun 2017 15:20:22 +0000 (17:20 +0200)]
libfstools: fix matching device name
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>
Felix Fietkau [Tue, 9 May 2017 10:37:42 +0000 (12:37 +0200)]
fstools: use -Wno-format-truncation instead of -Wno-error=format-truncation
Fixes build error with older gcc
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Pieter Smith [Wed, 29 Mar 2017 16:21:56 +0000 (18:21 +0200)]
libfstools: fix multiple volume_identify usages with the same volume
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>
Felix Fietkau [Thu, 4 May 2017 14:13:34 +0000 (16:13 +0200)]
build: disable the format-truncation warning error to fix gcc 7 build errors
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Daniel Golle [Thu, 20 Apr 2017 17:50:41 +0000 (19:50 +0200)]
libfstools: silence mkfs.{ext4,f2fs}
Reduce noise during firstboot when creating overlay fs on block
rootdisk devices.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Florian Fainelli [Tue, 28 Mar 2017 00:10:57 +0000 (17:10 -0700)]
cmake: Make blockd link against libjson-c
Similar to commit
35aa20c51995 ("cmake: Link against libjson-c"), blockd
uses libblob_msg which needs libjson-c.
Fixes: 98bbb5a068d6 ("blockd: add automounting support")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Rafał Miłecki [Mon, 27 Mar 2017 11:17:40 +0000 (13:17 +0200)]
libfstools: add basic documentation of mount functions
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: John Crispin <john@phrozen.org>
John Crispin [Tue, 21 Feb 2017 11:52:15 +0000 (12:52 +0100)]
blockd: add automounting support
Signed-off-by: John Crispin <john@phrozen.org>
Felix Fietkau [Sat, 11 Feb 2017 15:01:50 +0000 (16:01 +0100)]
add missing includes
On glibc 2.25, sys/sysmacros.h needs to be included for makedev, major
and minor.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Florian Fainelli [Sun, 4 Dec 2016 23:13:49 +0000 (15:13 -0800)]
libfstools: Check return values for fread and system
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>
Alberto Bursi [Thu, 27 Oct 2016 20:59:27 +0000 (20:59 +0000)]
fstools: added f2fs to block
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>
Jo-Philipp Wich [Fri, 21 Oct 2016 14:53:57 +0000 (16:53 +0200)]
block: fall back to external mount helper
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>
Jo-Philipp Wich [Fri, 21 Oct 2016 13:46:25 +0000 (15:46 +0200)]
block: fix error reporting
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>
Jo-Philipp Wich [Mon, 17 Oct 2016 11:12:31 +0000 (13:12 +0200)]
libblkid-tiny: remove unused name member
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>
Jo-Philipp Wich [Mon, 17 Oct 2016 11:10:07 +0000 (13:10 +0200)]
probe: stop handling name property
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>
Jo-Philipp Wich [Mon, 17 Oct 2016 11:06:57 +0000 (13:06 +0200)]
block: remove handling of name property
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>
Jo-Philipp Wich [Mon, 17 Oct 2016 09:40:14 +0000 (11:40 +0200)]
libblkid-tiny: fix SquashFS version detection on different endian systems
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Jo-Philipp Wich [Mon, 17 Oct 2016 09:28:31 +0000 (11:28 +0200)]
libblkid-tiny: avoid setting phantom UUIDs
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>
Jo-Philipp Wich [Sun, 16 Oct 2016 22:05:15 +0000 (00:05 +0200)]
probe: add full libblkid support
Attempt to dlopen() libblkid.so at runtime and use it for proping
filesystems if available.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Jo-Philipp Wich [Sun, 16 Oct 2016 20:45:59 +0000 (22:45 +0200)]
block: add probe abstraction layer
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>
Daniel Golle [Fri, 23 Sep 2016 03:10:42 +0000 (05:10 +0200)]
libfstools: properly label ext4 overlay
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Daniel Golle [Fri, 23 Sep 2016 03:10:05 +0000 (05:10 +0200)]
block: also probe loop devices
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Daniel Golle [Sun, 24 Jul 2016 18:44:38 +0000 (20:44 +0200)]
block: include mountpoint in info output
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Daniel Golle [Sun, 11 Sep 2016 14:52:52 +0000 (16:52 +0200)]
libfstools: gather mountpoints from /proc/self/mountinfo
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>
Felix Fietkau [Tue, 6 Sep 2016 14:37:13 +0000 (16:37 +0200)]
libfstools: add rootdisk overlay volume support
Uses either ext4 or f2fs, depending on the overlay volume size
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Thu, 8 Sep 2016 11:03:26 +0000 (13:03 +0200)]
libfstools: replace hardcoded mentions of jffs2 in a few places
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Thu, 8 Sep 2016 10:09:34 +0000 (12:09 +0200)]
libfstools: add ext4 filesystem type
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Thu, 8 Sep 2016 10:02:08 +0000 (12:02 +0200)]
libfstools: add f2fs filesystem type and simplify fs type code
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Tue, 6 Sep 2016 14:14:35 +0000 (16:14 +0200)]
libfstools: use container_of for volume private data
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Wed, 7 Sep 2016 15:30:09 +0000 (17:30 +0200)]
libfstools: call volume_init() before accessing v->blk
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Tue, 6 Sep 2016 11:52:33 +0000 (13:52 +0200)]
libfstools: remove obsolete enum
Signed-off-by: Felix Fietkau <nbd@nbd.name>
John Crispin [Wed, 31 Aug 2016 16:16:31 +0000 (18:16 +0200)]
fix logic bug inside extroot uuid verification code
Signed-off-by: John Crispin <john@phrozen.org>
Преподобный Гомер [Wed, 17 Aug 2016 11:51:31 +0000 (14:51 +0300)]
libfstools: "lowerdir" variable name in fopivot
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".
John Crispin [Tue, 16 Aug 2016 10:06:33 +0000 (12:06 +0200)]
fix return code of overlay_mount_fs
Signed-off-by: John Crispin <john@phrozen.org>
Daniel Golle [Sun, 24 Jul 2016 15:54:31 +0000 (17:54 +0200)]
block: best-effort in find_mount_point
Don't immediatly fail if block device cannot be stat'ed.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Daniel Golle [Sun, 24 Jul 2016 13:16:16 +0000 (15:16 +0200)]
block: get mountpoints from /proc/self/mountinfo
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>
Daniel Golle [Thu, 21 Jul 2016 02:04:34 +0000 (04:04 +0200)]
block: print mountpoint if already mounted
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Daniel Golle [Thu, 21 Jul 2016 01:55:48 +0000 (03:55 +0200)]
block: also check /proc/self/mountinfo to find mountpoint
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>
Daniel Golle [Thu, 21 Jul 2016 01:19:22 +0000 (03:19 +0200)]
block: don't truncate mountpoint path
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Daniel Golle [Wed, 20 Jul 2016 23:57:50 +0000 (01:57 +0200)]
block: allow block info /dev/ubi?_?
Allow querying /dev/ubi?_? devices though they are not block devices.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Daniel Golle [Wed, 20 Jul 2016 22:58:08 +0000 (00:58 +0200)]
block: avoid ubi{,block} duplicates
Skip ubi?_? device if ubiblock?_? is present.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Daniel Golle [Wed, 20 Jul 2016 23:20:10 +0000 (01:20 +0200)]
block: fix ubi?_? glob pattern
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>
Florian Fainelli [Fri, 1 Jul 2016 23:06:42 +0000 (16:06 -0700)]
cmake: Link against libjson-c
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>
Florian Fainelli [Fri, 1 Jul 2016 23:06:41 +0000 (16:06 -0700)]
cmake: Find libubox/ulog.h
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>
Daniel Dickinson [Sun, 22 May 2016 09:30:38 +0000 (05:30 -0400)]
block.c: Add ability to mount with ACL and XATTR support
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>
Daniel Dickinson [Sun, 22 May 2016 09:30:37 +0000 (05:30 -0400)]
block.c: Use <linux/fs.h> instead of defining mount flags ourselves
Let's use the cannonical source of mount flags instead of
defining the flags ourselves.
Signed-off-by: Daniel Dickinson <lede@daniel.thecshore.com>
Daniel Dickinson [Sun, 22 May 2016 09:22:48 +0000 (05:22 -0400)]
block.c: Add support for checking vfat filesystems
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>
Daniel Dickinson [Sun, 22 May 2016 09:22:47 +0000 (05:22 -0400)]
block.c: Make static string a const char * instead char *
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>
John Crispin [Sun, 15 May 2016 14:20:20 +0000 (16:20 +0200)]
mount_root: check for preinit sentinel file
Signed-off-by: John Crispin <john@phrozen.org>
John Crispin [Sun, 15 May 2016 14:13:30 +0000 (16:13 +0200)]
Revert "mount_root: code failed in failsafe"
This reverts commit
09f8e0097fe1370700658542e7bda831c31de4bf.
John Crispin [Wed, 11 May 2016 16:07:36 +0000 (18:07 +0200)]
Revert "fstools: support for ext4fs overlay"
This reverts commit
bf4f08af9b8fe991216023a906182744eb1e4645.
this patch was breaking devices that have a normal ext4 rootfs
Signed-off-by: John Crispin <john@phrozen.org>
John Crispin [Tue, 10 May 2016 13:39:37 +0000 (15:39 +0200)]
mount_root: code failed in failsafe
the code checks if we are in PREINIT before mounting root.
change this to check if root is actually mounted.
this is a regression caused by ssh login during failsafe.
Signed-off-by: John Crispin <john@phrozen.org>
John Crispin [Wed, 27 Apr 2016 05:34:04 +0000 (07:34 +0200)]
snapshot: md5sum return codes are not properly handled
Signed-off-by: John Crispin <john@phrozen.org>