oweals/fstools.git
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>
9 years agolibfstools: drop removed functions from the header file
Rafał Miłecki [Sun, 14 Dec 2014 17:58:17 +0000 (18:58 +0100)]
libfstools: drop removed functions from the header file

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
9 years agolibfstools: accept volume as argument in most calls
Rafał Miłecki [Sun, 14 Dec 2014 17:58:16 +0000 (18:58 +0100)]
libfstools: accept volume as argument in most calls

This optimizes code: drops unneeded calls to the volume_find and checks.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
9 years agomount: fix sysupgrade handling for mainline overlayfs
Felix Fietkau [Mon, 1 Dec 2014 21:04:49 +0000 (22:04 +0100)]
mount: fix sysupgrade handling for mainline overlayfs

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agomake the block tool ignore case when comparing uuid strings
John Crispin [Mon, 1 Dec 2014 18:30:38 +0000 (19:30 +0100)]
make the block tool ignore case when comparing uuid strings

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agoHandle overlayfs' new name in 3.18
Imre Kaloz [Mon, 24 Nov 2014 15:49:02 +0000 (16:49 +0100)]
Handle overlayfs' new name in 3.18

overlayfs has been renamed in Linus' tree - try both names in mount.c

Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
10 years agolibfstools/mount: Support latest overlayfs versions
Maxime Ripard [Thu, 9 Oct 2014 13:07:35 +0000 (15:07 +0200)]
libfstools/mount: Support latest overlayfs versions

The latest overlayfs revisions (v23 and above) require an additional directory
to be given in the options.

Since we need to support both pre-v23 and post-v23 versions, take a lazy
approach and try to first mount without a workdir, and if it fails, try with
it.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
10 years agoadd support for /dev/cd* virtual io
John Crispin [Fri, 3 Oct 2014 15:46:26 +0000 (17:46 +0200)]
add support for /dev/cd* virtual io

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agolibfstools: fix matching fstype
Daniel Golle [Sat, 21 Jun 2014 23:34:28 +0000 (01:34 +0200)]
libfstools: fix matching fstype

the previous commit accidentally also matched against the trailing
null byte of a constant string but should not.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
10 years agofix jffs2reset on ubifs overlay
Daniel Golle [Sat, 21 Jun 2014 20:07:26 +0000 (22:07 +0200)]
fix jffs2reset on ubifs overlay

change find_mount_point parameter to match either all or only
jffs2 and ubifs, which are typically used on embedded mtd devices.
For now, find_mount_point was used without the fstype parameter
except for a single occurance in jffs2reset. There it is desireable
to apply the same logic as previously hard-coded to jffs2 also in the
case of a ubifs overlay, so firstboot aka. factory-reset works as
expected.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
10 years agolibfstools: be more consistent with other existing code
Daniel Golle [Thu, 22 May 2014 12:32:17 +0000 (14:32 +0200)]
libfstools: be more consistent with other existing code

just cosmetics

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
10 years agosnapshot: add explicit cast to fix warning on x86_64 and switch to unsigned
Felix Fietkau [Mon, 2 Jun 2014 09:38:18 +0000 (11:38 +0200)]
snapshot: add explicit cast to fix warning on x86_64 and switch to unsigned

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agosnapshot: use cross-platform macros for fprintf on 64-bit values to fix build for...
Felix Fietkau [Sat, 31 May 2014 12:44:27 +0000 (14:44 +0200)]
snapshot: use cross-platform macros for fprintf on 64-bit values to fix build for 64 bit targets

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolibfstools/ubi: some more clean-up
Daniel Golle [Wed, 21 May 2014 14:41:26 +0000 (16:41 +0200)]
libfstools/ubi: some more clean-up

10 years agoubi: fix false positive in volume_find
Daniel Golle [Wed, 21 May 2014 02:42:29 +0000 (04:42 +0200)]
ubi: fix false positive in volume_find

An off-by-one made the string compare check only the string
length and not the terminating \0 which lead to rootfs being
found as rootfs_data.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
10 years agocosmetic: fix indentation
Luka Perkov [Wed, 21 May 2014 00:12:04 +0000 (02:12 +0200)]
cosmetic: fix indentation

Signed-off-by: Luka Perkov <luka@openwrt.org>
10 years agolibubi-utils: export static library
Daniel Golle [Tue, 20 May 2014 00:43:51 +0000 (02:43 +0200)]
libubi-utils: export static library

uboot-envtools will use parts of libubi-utils in the near future
to allow native r/w support of ubi-volume backed environments.

Install libubi-utils.a as well as the headers needed so uboot-envtools
can link libubi-utils.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
10 years agoskip ubi volume detection if ubifs is not present (fall back to mtd in that case)
Felix Fietkau [Mon, 19 May 2014 21:02:56 +0000 (23:02 +0200)]
skip ubi volume detection if ubifs is not present (fall back to mtd in that case)

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoadd ubi detach support, fix handling for kernel/rootfs ubi partitions
Felix Fietkau [Mon, 19 May 2014 20:30:43 +0000 (22:30 +0200)]
add ubi detach support, fix handling for kernel/rootfs ubi partitions

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agomatch full mtd partition names
Felix Fietkau [Mon, 19 May 2014 20:25:30 +0000 (22:25 +0200)]
match full mtd partition names

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agoubi: remove voltype left-over variable
daniel [Tue, 13 May 2014 04:41:46 +0000 (06:41 +0200)]
ubi: remove voltype left-over variable

10 years agosupport for ubifs overlay
daniel [Mon, 12 May 2014 19:19:11 +0000 (21:19 +0200)]
support for ubifs overlay

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
10 years agocosmetics
daniel [Mon, 7 Apr 2014 17:16:01 +0000 (19:16 +0200)]
cosmetics

fix and copy&paste mistake in an error message
images to flash to volumes are of type ubifs rather than ubi

10 years agoblock: detect /dev/ubiblock*
daniel [Mon, 12 May 2014 19:48:13 +0000 (21:48 +0200)]
block: detect /dev/ubiblock*

10 years agoset LD_LIBRARY_PATH when invoking block extroot from temporary overlay
Jo-Philipp Wich [Thu, 17 Apr 2014 17:56:31 +0000 (19:56 +0200)]
set LD_LIBRARY_PATH when invoking block extroot from temporary overlay

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
10 years agosplit snapshot tool properly
John Crispin [Mon, 7 Apr 2014 10:50:48 +0000 (11:50 +0100)]
split snapshot tool properly

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agojffs2mark did not check the return code properly
John Crispin [Mon, 7 Apr 2014 10:53:59 +0000 (11:53 +0100)]
jffs2mark did not check the return code properly

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agosplit fs-state back into seperate tools
John Crispin [Sun, 6 Apr 2014 02:16:05 +0000 (03:16 +0100)]
split fs-state back into seperate tools

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agoadd ubi flashing tool
John Crispin [Thu, 3 Apr 2014 17:14:51 +0000 (18:14 +0100)]
add ubi flashing tool

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agomove files around
John Crispin [Thu, 3 Apr 2014 17:38:18 +0000 (18:38 +0100)]
move files around

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agoadd gitignore
John Crispin [Thu, 3 Apr 2014 14:56:30 +0000 (15:56 +0100)]
add gitignore

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agovarious updates
John Crispin [Sun, 23 Mar 2014 10:25:25 +0000 (10:25 +0000)]
various updates

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agoinitial import of fs-tools package
John Crispin [Tue, 18 Feb 2014 00:55:53 +0000 (00:55 +0000)]
initial import of fs-tools package

Signed-off-by: John Crispin <blogic@openwrt.org>