mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Michael Olbrich <mol@pengutronix.de>
To: ptxdist@pengutronix.de
Cc: u.kleine-koenig@pengutronix.de
Subject: Re: [ptxdist] [APPLIED] mtd-utils: Add support for ubifs mount helper
Date: Mon, 25 Jan 2021 08:20:43 +0100	[thread overview]
Message-ID: <E1l3wB1-007rNa-IZ@dude03.red.stw.pengutronix.de> (raw)
In-Reply-To: <20210119144626.7368-3-u.kleine-koenig@pengutronix.de>

Thanks, applied as 9b9185a7696ea48f86035e4c2f95229151b2811b.

Michael

[sent from post-receive hook]

On Mon, 25 Jan 2021 08:20:43 +0100, Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
> This helper simplifies mounting ubifs filesystems via /etc/fstab. This
> helper already exists upstream, is not released yet, though.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Message-Id: <20210119144626.7368-3-u.kleine-koenig@pengutronix.de>
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> 
> diff --git a/patches/mtd-utils-2.1.2/0002-Add-an-ubifs-mount-helper.patch b/patches/mtd-utils-2.1.2/0002-Add-an-ubifs-mount-helper.patch
> new file mode 100644
> index 000000000000..f45b660ee2d1
> --- /dev/null
> +++ b/patches/mtd-utils-2.1.2/0002-Add-an-ubifs-mount-helper.patch
> @@ -0,0 +1,142 @@
> +From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>
> +Date: Tue, 6 Oct 2020 11:19:13 +0200
> +Subject: [PATCH] Add an ubifs mount helper
> +MIME-Version: 1.0
> +Content-Type: text/plain; charset=UTF-8
> +Content-Transfer-Encoding: 8bit
> +
> +This abstracts away attaching of the right ubi and then selecting the right
> +ubi device and volume to mount.
> +
> +As described in the comment at the top this allows to mount ubifs volumes
> +directly from /etc/fstab without having to use hardcoded numbers (which
> +depend on mount order and so are unreliable) and extra magic to care for
> +attaching.
> +
> +Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> +Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
> +Origin: upstream, commit:efeba0875ed181e7c1c7915742a3868799604d0c
> +---
> + ubifs-utils/Makemodule.am |   2 +
> + ubifs-utils/mount.ubifs   | 101 ++++++++++++++++++++++++++++++++++++++++++++++
> + 2 files changed, 103 insertions(+)
> + create mode 100755 ubifs-utils/mount.ubifs
> +
> +diff --git a/ubifs-utils/Makemodule.am b/ubifs-utils/Makemodule.am
> +index 59109ccd613c..5c5d99f7572b 100644
> +--- a/ubifs-utils/Makemodule.am
> ++++ b/ubifs-utils/Makemodule.am
> +@@ -47,4 +47,6 @@ UBIFS_EXTRA = \
> + 
> + EXTRA_DIST += $(UBIFS_HEADER) $(UBIFS_EXTRA)
> + 
> ++dist_sbin_SCRIPTS = ubifs-utils/mount.ubifs
> ++
> + sbin_PROGRAMS += $(UBIFS_BINS)
> +diff --git a/ubifs-utils/mount.ubifs b/ubifs-utils/mount.ubifs
> +new file mode 100755
> +index 000000000000..b94ddc5649f4
> +--- /dev/null
> ++++ b/ubifs-utils/mount.ubifs
> +@@ -0,0 +1,101 @@
> ++#!/bin/sh
> ++
> ++# This script should be installed as /sbin/mount.ubifs. The benefit is that an
> ++# fstab entry like:
> ++#
> ++# 	mtd=mtddev:home     /home        ubifs   defaults 0 0
> ++#
> ++# results in the ubi contained in the mtd named "mtddev" to be attached (if not
> ++# already done) and then the volume named "home" being mounted to /home.
> ++
> ++# This is called by mount with the following options:
> ++# /sbin/mount.ubifs spec dir [-sfnv] [-N namespace] [-o options] [-t type.subtype]
> ++
> ++spec="$1"
> ++shift
> ++
> ++mtdname2num() {
> ++	local name
> ++
> ++	name="$1"
> ++
> ++	for d in $(find /sys/class/mtd/ -regex '.*/mtd[0-9]*'); do
> ++		case "$d" in
> ++			*ro)
> ++				continue
> ++				;;
> ++		esac
> ++
> ++		if test "$name" = "$(cat "$d/name")"; then
> ++			local dev mtdnum
> ++
> ++			dev="$(basename "$d")"
> ++			mtdnum="${dev#mtd}"
> ++			echo "$mtdnum"
> ++			return
> ++		fi
> ++	done
> ++
> ++	return 1
> ++}
> ++
> ++mtdnum2ubi() {
> ++	local mtdnum
> ++
> ++	mtdnum="$1"
> ++
> ++	for d in $(find /sys/class/ubi/ -regex '.*/ubi[0-9]*'); do
> ++		case "$d" in
> ++			*_[0-9]*)
> ++				continue
> ++				;;
> ++		esac
> ++
> ++		if test "$mtdnum" = "$(cat "$d/mtd_num")"; then
> ++			local ubi
> ++
> ++			ubi="$(basename "$d")"
> ++			echo "$ubi"
> ++			return;
> ++		fi
> ++	done
> ++
> ++	return 1
> ++}
> ++
> ++mtdnum2ubi_autoattach() {
> ++	local mtdnum ubi
> ++
> ++	mtdnum="$1"
> ++
> ++	ubi="$(mtdnum2ubi "$mtdnum")" && { echo "$ubi"; return; }
> ++
> ++	# ubiattach might fail with "mtdX is already attached to ubiY" if there
> ++	# is more than one mount to do in the same mtd partition. So ignore errors.
> ++	ubiattach -m "$mtdnum" >&2 || true
> ++
> ++	mtdnum2ubi "$mtdnum"
> ++}
> ++
> ++case "$spec" in
> ++	mtd=*:*)
> ++		spec="${spec#mtd=}"
> ++		mtd="${spec%:*}"
> ++		rspec="${spec#*:}"
> ++
> ++		mtdnum="$(mtdname2num "$mtd")" || {
> ++			echo "Failed to find mtdnum for mtd \"$mtd\""
> ++			exit 1
> ++		}
> ++
> ++		ubi="$(mtdnum2ubi_autoattach "$mtdnum")" || {
> ++			echo "Failed to find ubi for mtd \"$mtd\""
> ++			exit 1
> ++		}
> ++
> ++		spec="$ubi:$rspec"
> ++
> ++		;;
> ++esac
> ++
> ++/bin/mount -i -t ubifs "$spec" "$@"
> diff --git a/patches/mtd-utils-2.1.2/series b/patches/mtd-utils-2.1.2/series
> index 92dc1b94f4ca..7a5eec8b0eeb 100644
> --- a/patches/mtd-utils-2.1.2/series
> +++ b/patches/mtd-utils-2.1.2/series
> @@ -1,4 +1,5 @@
>  # generated by git-ptx-patches
>  #tag:base --start-number 1
>  0001-nandmarkbad-new-util-to-mark-blocks-as-bad.patch
> -# 407ded52b82ffa3ff91d50cf6b2388e0  - git-ptx-patches magic
> +0002-Add-an-ubifs-mount-helper.patch
> +# 096af547b18d202f08576089a0cee058  - git-ptx-patches magic
> diff --git a/rules/mtd-utils.in b/rules/mtd-utils.in
> index 29a8b413c0c5..4a51a8ff7408 100644
> --- a/rules/mtd-utils.in
> +++ b/rules/mtd-utils.in
> @@ -293,6 +293,12 @@ config MTD_UTILS_UBIFORMAT
>  	help
>  	  Format an MTD device
>  
> +config MTD_UTILS_UBIFS_MOUNTHELPER
> +	bool
> +	prompt "mount.ubifs"
> +	help
> +	  Simplifies attaching an ubi and mounting an ubifs via /etc/fstab.
> +
>  config MTD_UTILS_UBIHEALTHD
>  	bool
>  	prompt "ubihealthd"
> diff --git a/rules/mtd-utils.make b/rules/mtd-utils.make
> index 0506bb776b8f..c608d0aef8db 100644
> --- a/rules/mtd-utils.make
> +++ b/rules/mtd-utils.make
> @@ -186,6 +186,10 @@ ifdef PTXCONF_MTD_UTILS_UBICRC32
>  	@$(call install_copy, mtd-utils, 0, 0, 0755, -, \
>  		/usr/sbin/ubicrc32)
>  endif
> +ifdef PTXCONF_MTD_UTILS_UBIFS_MOUNTHELPER
> +	@$(call install_copy, mtd-utils, 0, 0, 0755, -, \
> +		/usr/sbin/mount.ubifs)
> +endif
>  ifdef PTXCONF_MTD_UTILS_UBIHEALTHD
>  	@$(call install_copy, mtd-utils, 0, 0, 0755, -, \
>  		/usr/sbin/ubihealthd)

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

  reply	other threads:[~2021-01-25  7:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-19 14:46 [ptxdist] [PATCH 1/3] mtd-utils: spring cleanup Uwe Kleine-König
2021-01-19 14:46 ` [ptxdist] [PATCH 2/3] mtd-utils: version bump 2.1.1 -> 2.1.2 Uwe Kleine-König
2021-01-25  7:20   ` [ptxdist] [APPLIED] " Michael Olbrich
2021-01-19 14:46 ` [ptxdist] [PATCH 3/3] mtd-utils: Add support for ubifs mount helper Uwe Kleine-König
2021-01-25  7:20   ` Michael Olbrich [this message]
2021-02-01 16:10 ` [ptxdist] [PATCH 1/3] mtd-utils: spring cleanup Uwe Kleine-König
2021-02-02 13:52   ` Michael Olbrich
2021-02-03  7:11 ` [ptxdist] [APPLIED] " Michael Olbrich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1l3wB1-007rNa-IZ@dude03.red.stw.pengutronix.de \
    --to=mol@pengutronix.de \
    --cc=ptxdist@pengutronix.de \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox