linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Emil Lenngren <emil.lenngren@gmail.com>
To: Richard Weinberger <richard.weinberger@gmail.com>
Cc: Richard Weinberger <richard@nod.at>,
	linux-mtd <linux-mtd@lists.infradead.org>,
	Patrick Doyle <wpdster@gmail.com>,
	Artem Bityutskiy <dedekind1@gmail.com>
Subject: Re: [PATCH 1/1] ubi: Allow ubiblock devices nodes to be created by volume name instead of volume ID.
Date: Wed, 28 Aug 2019 15:38:48 +0200	[thread overview]
Message-ID: <CAO1O6sdEw2xjmKQFEA6YXE5vLAtd90ew4t_zynRUvK_ZztDp0w@mail.gmail.com> (raw)
In-Reply-To: <CAFLxGvxoR2kWoEz38QfO2sZDh4=4KXHBm9OrzXAQJWAR8Shmew@mail.gmail.com>

Hi Richard,

Den sön 18 aug. 2019 kl 22:50 skrev Richard Weinberger
<richard.weinberger@gmail.com>:
>
> On Wed, Aug 14, 2019 at 2:34 PM Emil Lenngren <emil.lenngren@gmail.com> wrote:
> > > Isn't this why we have udev, to create fancy by-id/by-path/... naming conventions?
> > >
> > > Thanks,
> > > //richard
> >
> > I actually implemented the same change some time ago, for the exact
> > same reason (swapping two volumes and then reboot). Referring to an
> > ubi volume by name is more convenient than volume numbers, since names
> > can be changed and numbers can't.
> > Is it maybe possible to define both /dev/ubiblock%d_%d and
> > /dev/ubiblock%d_%s at the same time?
> > How would this be done with udev instead to get "fancy by-id"?
>
> Thanks for bringing this topic up again.
> udev allows rules and even helper (scripts) to gain device
> attributes. These can then be used to name/symlink devices as you want.
>
> For example, if you want to have device symlinks by name for UBI
> volumes, you can create a rule like that:
> KERNEL=="ubi?_?", IMPORT{program}="/etc/udev/rules.d/ubi_probe
> $devnode", SYMLINK="ubi%E{MTD_NUM}_%E{VOL_NAME}"
>
> With ubi_probe being:
> #!/bin/sh
> VOL_NAME="$(cat /sys/${DEVPATH}/name)"
> MTD_NUM="$(cat /sys/${DEVPATH}/../mtd_num)"
> echo "VOL_NAME=${VOL_NAME}"
> echo "MTD_NUM=${MTD_NUM}"
>
> I took the chance and reviewed UBI's sysfs interface and found a few
> things which need
> improvement. With these issues addressed you can also work with
> ubiblock by name:
> 1. UBI does not export the UBI device number via sysfs. In 99% of all
> cases mtd_num will be correct,
> but you can select the UBI number upon attach time.
> 2. UBI does not emit a change kevent when an volume is renamed. So
> udev does not see the rename command.
> 3. ubiblock does not set the UBI volume as parent device.
>
> So we can then have a rule like:
> KERNEL=="ubiblock?_?",
> IMPORT{program}="/etc/udev/rules.d/ubiblock_probe $devnode"
> SYMLINK="ubiblock$number_%E{VOL_NAME}"
>
> With ubiblock_probe being:
> #!/bin/sh
> VOL_NAME="$(cat /sys/${DEVPATH}/device/name)"
> echo "VOL_NAME=${VOL_NAME}"
>
> # ls -ltr /dev/ubiblock*
> brw-rw---- 1 root disk 251, 0 18. Aug 22:41 /dev/ubiblock7_0
> lrwxrwxrwx 1 root root     11 18. Aug 22:41 /dev/ubiblock0_test -> ubiblock7_0
> # ubirename /dev/ubi7 test lala
> # ls -ltr /dev/ubiblock*
> brw-rw---- 1 root disk 251, 0 18. Aug 22:42 /dev/ubiblock7_0
> lrwxrwxrwx 1 root root     11 18. Aug 22:42 /dev/ubiblock0_lala -> ubiblock7_0
>
> Does this help? If you need other/more sysfs changes, please tell. :-)
> Attached you can find my WIP patch for these changes. I need to double check
> a few things first before I will send a formal patch.
>
> I think it would even make sense to integrate a more powerful
> ubi_probe (as C program) into systemd-udev
> like we already have for mtd itself.

Will this really work when passing the rootfs to the kernel command
line like "root=/dev/ubiblock0_rootfs"? If the udev rules that set up
the symbolic link /dev/ubiblock0_rootfs are stored in a file on the
rootfs itself, I guess that symlink can't be made available before the
rootfs is mounted...

/Emil

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2019-08-28 13:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-04 15:29 [PATCH 1/1] ubi: Allow ubiblock devices nodes to be created by volume name instead of volume ID Patrick Doyle
2019-04-04 19:37 ` Richard Weinberger
2019-08-14 12:34   ` Emil Lenngren
2019-08-14 18:06     ` Patrick Doyle
2019-08-18 21:03       ` Richard Weinberger
2019-08-18 20:49     ` Richard Weinberger
2019-08-28 13:38       ` Emil Lenngren [this message]
2019-08-28 14:13         ` Richard Weinberger
2019-09-29 13:39           ` Jan Kardell
2019-09-29 13:39           ` Jan Kardell
2019-09-29 17:40             ` Richard Weinberger
2019-12-30 17:31     ` Ezequiel Garcia
2020-01-02 19:06       ` Patrick Doyle
2020-01-08 22:43       ` Richard Weinberger

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=CAO1O6sdEw2xjmKQFEA6YXE5vLAtd90ew4t_zynRUvK_ZztDp0w@mail.gmail.com \
    --to=emil.lenngren@gmail.com \
    --cc=dedekind1@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard.weinberger@gmail.com \
    --cc=richard@nod.at \
    --cc=wpdster@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).