project/fstools.git
7 years agocmake: Make blockd link against libjson-c
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>
7 years agolibfstools: add basic documentation of mount functions
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>
7 years agoblockd: add automounting support
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>
7 years agoadd missing includes
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>
7 years agolibfstools: Check return values for fread and system
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>
8 years agofstools: added f2fs to block
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>
8 years agoblock: fall back to external mount helper
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>
8 years agoblock: fix error reporting
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>
8 years agolibblkid-tiny: remove unused name member
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>
8 years agoprobe: stop handling name property
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>
8 years agoblock: remove handling of name property
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>
8 years agolibblkid-tiny: fix SquashFS version detection on different endian systems
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>
8 years agolibblkid-tiny: avoid setting phantom UUIDs
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>
8 years agoprobe: add full libblkid support
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>
8 years agoblock: add probe abstraction layer
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>
8 years agolibfstools: properly label ext4 overlay
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>
8 years agoblock: also probe loop devices
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>
8 years agoblock: include mountpoint in info output
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>
8 years agolibfstools: gather mountpoints from /proc/self/mountinfo
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>
8 years agolibfstools: add rootdisk overlay volume support
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>
8 years agolibfstools: replace hardcoded mentions of jffs2 in a few places
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>
8 years agolibfstools: add ext4 filesystem type
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>
8 years agolibfstools: add f2fs filesystem type and simplify fs type code
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>
8 years agolibfstools: use container_of for volume private data
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>
8 years agolibfstools: call volume_init() before accessing v->blk
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>
8 years agolibfstools: remove obsolete enum
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>
8 years agofix logic bug inside extroot uuid verification code
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>
8 years agolibfstools: "lowerdir" variable name in fopivot
Преподобный Гомер [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".

8 years agofix return code of overlay_mount_fs
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>
8 years agoblock: best-effort in find_mount_point
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>
8 years agoblock: get mountpoints from /proc/self/mountinfo
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>
8 years agoblock: print mountpoint if already mounted
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>
8 years agoblock: also check /proc/self/mountinfo to find mountpoint
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>
8 years agoblock: don't truncate mountpoint path
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>
8 years agoblock: allow block info /dev/ubi?_?
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>
8 years agoblock: avoid ubi{,block} duplicates
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>
8 years agoblock: fix ubi?_? glob pattern
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>
8 years agocmake: Link against libjson-c
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>
8 years agocmake: Find libubox/ulog.h
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>
8 years agoblock.c: Add ability to mount with ACL and XATTR support
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>
8 years agoblock.c: Use <linux/fs.h> instead of defining mount flags ourselves
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>
8 years agoblock.c: Add support for checking vfat filesystems
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>
8 years agoblock.c: Make static string a const char * instead char *
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>
8 years agomount_root: check for preinit sentinel file
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>
8 years agoRevert "mount_root: code failed in failsafe"
John Crispin [Sun, 15 May 2016 14:13:30 +0000 (16:13 +0200)]
Revert "mount_root: code failed in failsafe"

This reverts commit 09f8e0097fe1370700658542e7bda831c31de4bf.

8 years agoRevert "fstools: support for ext4fs overlay"
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>
8 years agomount_root: code failed in failsafe
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>
8 years agosnapshot: md5sum return codes are not properly handled
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>
8 years agoblock: add remount paramter
John Crispin [Wed, 27 Apr 2016 01:30:40 +0000 (03:30 +0200)]
block: add remount paramter

Signed-off-by: John Crispin <john@phrozen.org>
8 years agofstools: support for ext4fs overlay
Ram Chandra Jangir [Fri, 11 Mar 2016 16:31:42 +0000 (22:01 +0530)]
fstools: support for ext4fs overlay

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>
8 years agoblock: respect mount flags for /overlay
Jo-Philipp Wich [Mon, 25 Apr 2016 15:49:38 +0000 (17:49 +0200)]
block: respect mount flags for /overlay

Instead of hardcoding no-flags in the mount syscall, use the user configured
values, this is useful when mounting external overlays with "sync" or "ro"
flags.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
8 years agofstools: check existing filesystem state before writing the new one
Felix Fietkau [Sun, 10 Jan 2016 17:35:36 +0000 (18:35 +0100)]
fstools: check existing filesystem state before writing the new one

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
8 years agofstools: allow to stack another overlay on top of existing one
Roman Yeryomin [Sat, 19 Dec 2015 21:38:02 +0000 (23:38 +0200)]
fstools: allow to stack another overlay on top of existing one

`mount_root ram' will pivot existing root to ram even if it was
overlayfs already. Useful when playing with new configurations
as it allows to preserve existing/stable configuration.

Signed-off-by: Roman Yeryomin <roman@advem.lv>
9 years agofix gcc format security error.
Hauke Mehrtens [Sun, 22 Nov 2015 14:38:01 +0000 (15:38 +0100)]
fix gcc format security error.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
9 years agolibblkid-tiny: Add F2FS support
Martin Blumenstingl [Sat, 31 Oct 2015 15:38:42 +0000 (16:38 +0100)]
libblkid-tiny: Add F2FS support

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
9 years agolibblkid-tiny: Update the code from util-linux's libblkid
Martin Blumenstingl [Sat, 31 Oct 2015 15:38:41 +0000 (16:38 +0100)]
libblkid-tiny: Update the code from util-linux's libblkid

This updates the relevant source files to util-linux changeset
4419ffb9eff5801fdbd385a4a6199b3877f802ad.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
9 years agooverlay: use lstat rather than stat and make sure there are no trailing spaces
John Crispin [Wed, 26 Aug 2015 01:54:46 +0000 (03:54 +0200)]
overlay: use lstat rather than stat and make sure there are no trailing spaces

with this patch even uclibc wont deleted symlinked folders

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agomake jffs2reset not iterate over symlinked folders
John Crispin [Tue, 25 Aug 2015 20:43:18 +0000 (22:43 +0200)]
make jffs2reset not iterate over symlinked folders

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agojffs2reset: add a -r (reboot) option to jffs2reset
John Crispin [Mon, 24 Aug 2015 08:11:47 +0000 (10:11 +0200)]
jffs2reset: add a -r (reboot) option to jffs2reset

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agomount_root: use symlink instead of xattr to store initialization state
Felix Fietkau [Mon, 25 May 2015 21:55:07 +0000 (23:55 +0200)]
mount_root: use symlink instead of xattr to store initialization state

xattr seems to be unreliable with jffs2

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agojffs2reset: use jffs2_mark if rootfs_data isn't mounted
Rafał Miłecki [Sat, 11 Apr 2015 07:56:44 +0000 (09:56 +0200)]
jffs2reset: use jffs2_mark if rootfs_data isn't mounted

Erasing all rootfs_data blocks may cause some problems with partition
identification. It won't contain MAGIC, but will be successfully mounted
with delayed blocks marking. This may be really confusing when user
reboots before JFFS2 finishes its blocks management. During the next
boot rootfs_data will be a valid partition (possibly with data) but
libblkid won't detect it.
Also adjust message in jffs2_mark to make more sense when used together
with jffs2_reset.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
9 years agojffs2reset: avoid code duplication in jffs2_reset and jffs2_mark
Rafał Miłecki [Sat, 11 Apr 2015 07:56:43 +0000 (09:56 +0200)]
jffs2reset: avoid code duplication in jffs2_reset and jffs2_mark

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
9 years agoblock: reject mount sections with relative targets
Jo-Philipp Wich [Sun, 12 Apr 2015 20:18:15 +0000 (22:18 +0200)]
block: reject mount sections with relative targets

Specifying relative target paths leads to undefined results and confuses
users. Explicitely reject relative paths with a warning instead of doing
random stuff.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agomake sure to also scan for leading and ending " when looking for mtd devices
John Crispin [Thu, 9 Apr 2015 20:53:59 +0000 (22:53 +0200)]
make sure to also scan for leading and ending " when looking for mtd devices

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agoproperly handle return codes
John Crispin [Sat, 28 Mar 2015 17:32:22 +0000 (18:32 +0100)]
properly handle return codes

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agomount_root: keep track of overlay initialization state (via xattr)
Felix Fietkau [Sun, 22 Mar 2015 14:59:33 +0000 (15:59 +0100)]
mount_root: keep track of overlay initialization state (via xattr)

Remove all files (except sysupgrade.tgz) if /etc/init.d/done was not called

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agooverlay: call volume_init() before mount
Felix Fietkau [Sun, 22 Mar 2015 13:11:39 +0000 (14:11 +0100)]
overlay: call volume_init() before mount

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agooverlay: create a common function for deleting all overlay data (optionally excluding...
Felix Fietkau [Sun, 22 Mar 2015 13:08:27 +0000 (14:08 +0100)]
overlay: create a common function for deleting all overlay data (optionally excluding sysupgrade.tgz)

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agoswitch to _DEFAULT_SOURCE for modern glibc compat
John Crispin [Thu, 12 Mar 2015 12:57:41 +0000 (13:57 +0100)]
switch to _DEFAULT_SOURCE for modern glibc compat

Signed-off-by: Jeff Waugh <jdub@bethesignal.org>
9 years agomount_root: better log messages for ram overlay cases
Jo-Philipp Wich [Wed, 25 Feb 2015 21:57:57 +0000 (22:57 +0100)]
mount_root: better log messages for ram overlay cases

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agolibfstools: clarify message when switching to internal overlay
Jo-Philipp Wich [Wed, 25 Feb 2015 21:57:34 +0000 (22:57 +0100)]
libfstools: clarify message when switching to internal overlay

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agolibfstools: make mtd_volume_identify() less chatty
Jo-Philipp Wich [Wed, 25 Feb 2015 21:56:51 +0000 (22:56 +0100)]
libfstools: make mtd_volume_identify() less chatty

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agolibfstools: remove dead source file
Jo-Philipp Wich [Wed, 25 Feb 2015 21:42:17 +0000 (22:42 +0100)]
libfstools: remove dead source file

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agolibfstools: convert to ulog() api
Jo-Philipp Wich [Wed, 25 Feb 2015 20:43:54 +0000 (21:43 +0100)]
libfstools: convert to ulog() api

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agoubi: convert to ulog() api
Jo-Philipp Wich [Wed, 25 Feb 2015 20:32:45 +0000 (21:32 +0100)]
ubi: convert to ulog() api

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agosnapshot: convert to ulog() api
Jo-Philipp Wich [Wed, 25 Feb 2015 20:28:12 +0000 (21:28 +0100)]
snapshot: convert to ulog() api

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agojffs2reset: convert to ulog() api
Jo-Philipp Wich [Wed, 25 Feb 2015 20:25:35 +0000 (21:25 +0100)]
jffs2reset: convert to ulog() api

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agomount_root: convert to ulog() api
Jo-Philipp Wich [Wed, 25 Feb 2015 20:16:56 +0000 (21:16 +0100)]
mount_root: convert to ulog() api

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agoblock: convert to ulog() api
Jo-Philipp Wich [Wed, 25 Feb 2015 20:09:25 +0000 (21:09 +0100)]
block: convert to ulog() api

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agoblock: don't declare find_root_dev with UBIFS_EXTROOT
Jo-Philipp Wich [Wed, 25 Feb 2015 18:50:40 +0000 (19:50 +0100)]
block: don't declare find_root_dev with UBIFS_EXTROOT

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agolibfstools: extroot: simplify kmodloader invocation
Jo-Philipp Wich [Wed, 25 Feb 2015 12:44:40 +0000 (13:44 +0100)]
libfstools: extroot: simplify kmodloader invocation

Now that kmodloader supports LD_LIBRARY_PATH and ignores argv[2] we can
remove the extra argument and save one intermediate pointer.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agolibfstools: extroot: rework libdir and block tool discovery
Jo-Philipp Wich [Wed, 18 Feb 2015 18:50:37 +0000 (19:50 +0100)]
libfstools: extroot: rework libdir and block tool discovery

Account for new upper/ directory component in recent overlayfs versions.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agoblock: improve extroot error reporting
Jo-Philipp Wich [Wed, 18 Feb 2015 18:28:59 +0000 (19:28 +0100)]
block: improve extroot error reporting

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agoblock: rework config loading
Jo-Philipp Wich [Wed, 18 Feb 2015 18:28:35 +0000 (19:28 +0100)]
block: rework config loading

Account for the new upper/ directory component in recent overlayfs version.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agoblock: add support for logging to dmesg
Jo-Philipp Wich [Wed, 18 Feb 2015 18:25:36 +0000 (19:25 +0100)]
block: add support for logging to dmesg

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agoblock: support finding root device by mount point
Jo-Philipp Wich [Tue, 17 Feb 2015 19:27:59 +0000 (20:27 +0100)]
block: support finding root device by mount point

When checking extroot, fall back to using stat(/) to determine the root
device node if no rootfs MTD partition can be found, e.g. on systems using
an ext4 root filesystem.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agoblock: extroot: remove unneeded rootfs tests
Jo-Philipp Wich [Tue, 17 Feb 2015 19:19:59 +0000 (20:19 +0100)]
block: extroot: remove unneeded rootfs tests

The code testing for a "rootfs" MTD partition serves no actual purpose and
the test results are not used either. On top of that it prevents working
extroot on non-MTD systems, so drop the code.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agoblock: support builtin fstab config
Jo-Philipp Wich [Tue, 17 Feb 2015 19:13:43 +0000 (20:13 +0100)]
block: support builtin fstab config

Fall back to /etc/config/fstab if the file on the overlay cannot be loaded.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agolibfstools: extroot: support builtin block
Jo-Philipp Wich [Tue, 17 Feb 2015 18:50:00 +0000 (19:50 +0100)]
libfstools: extroot: support builtin block

Fix regression introduced with migration to fs-tools.

The old ubox based exroot did a fall back to /sbin/block if $cfg/sbin/block
did not exist.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agomount_root: try extroot even without mtd volume
Jo-Philipp Wich [Tue, 17 Feb 2015 18:18:27 +0000 (19:18 +0100)]
mount_root: try extroot even without mtd volume

This is a precondition for supporting external overlays on ext4 root fs.
Also rename volume pointer variables for better clarity.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agojffs2reset: fix recursive file/directory removal
Felix Fietkau [Sun, 11 Jan 2015 16:52:46 +0000 (17:52 +0100)]
jffs2reset: fix recursive file/directory removal

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agolibblkid-tiny: add btrfs probe info
Daniel Golle [Mon, 22 Dec 2014 11:34:42 +0000 (12:34 +0100)]
libblkid-tiny: add btrfs probe info

This only adds the magic for btrfs to show btrfs volumes in
block detect.

In order to properly support btrfs with more than one device and avoid
trying to mount the same device group once for each instance we have to
make sure that only one device per group will be mounted (btrfs then
automatically detects all other devices of the group).
For unmounting, the opposite should be applied: umount if called for
any of the devices in a mounted device group, unmount the filesystem.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agolibfstools: ubi: rework reading volumes
Rafał Miłecki [Tue, 23 Dec 2014 21:20:13 +0000 (22:20 +0100)]
libfstools: ubi: rework reading volumes

UBI volume IDs don't have to be contiguous, this may happen if there
were few and the not last one was removed. In such case we may have
e.g. ubi0_0, ubi0_2.
It means we can't simply read value from "volumes_count" and iterate
from 0 to the count - 1.

This patch rewrites ubi_part_match to read whole directory and look
for ubi%d_%d entries in it.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
9 years agolibfstools: ubi: avoid crash in volume finding function
Rafał Miłecki [Tue, 23 Dec 2014 20:33:49 +0000 (21:33 +0100)]
libfstools: ubi: avoid crash in volume finding function

In case /sys/devices/virtual/ubi/ubi?/ubi?_?/name doesn't exist volname
will be NULL and calling strlen for NULL isn't a good idea.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
9 years agolibfstools: fix find_mount to return device path
Rafał Miłecki [Tue, 23 Dec 2014 11:56:52 +0000 (12:56 +0100)]
libfstools: fix find_mount to return device path

So far we were returning mount point which doesn't make sense for a
function that already takes mount point as an argument.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
9 years agoblock: make sure /etc/ exists on the extroot
Rafał Miłecki [Wed, 17 Dec 2014 19:50:07 +0000 (20:50 +0100)]
block: make sure /etc/ exists on the extroot

Otherwise opening .extroot-uuid could fail.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
9 years agoblock: allow mounting UBIFS partition as extroot
Rafał Miłecki [Wed, 17 Dec 2014 19:33:28 +0000 (20:33 +0100)]
block: allow mounting UBIFS partition as extroot

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
9 years agosupport UBI blocks (volumes)
Rafał Miłecki [Wed, 17 Dec 2014 17:47:04 +0000 (18:47 +0100)]
support UBI blocks (volumes)

We already had ubifs idinfo, so only /dev/ubiN_M support was missing.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
9 years agodocument mount_root and block (extroot) a bit
Rafał Miłecki [Wed, 17 Dec 2014 13:22:36 +0000 (14:22 +0100)]
document mount_root and block (extroot) a bit

Also s/fs_data/blkdev_path/ which should make more sense.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
9 years agomake extroot functionality work with ubifs
John Crispin [Sun, 14 Dec 2014 22:00:00 +0000 (23:00 +0100)]
make extroot functionality work with ubifs

http://patchwork.ozlabs.org/patch/420864/

Signed-off-by: Gergely Kiss <mail.gery@gmail.com>