public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* Adding -N volume name to ubi utils
@ 2008-11-24 17:07 Richard Titmuss
  2008-11-25  8:53 ` Adrian Hunter
  2008-12-02  8:56 ` Artem Bityutskiy
  0 siblings, 2 replies; 3+ messages in thread
From: Richard Titmuss @ 2008-11-24 17:07 UTC (permalink / raw)
  To: linux-mtd

Hi,

I am trying to modify the ubi tools in mtd_utils to allow the ubi volume 
name to be specified on the command line, the relevant commands are 
ubinfo, ubirmvol and ubiupdatevol. The idea is that you could use any of 
the following command arguments to specify a ubi volume:

   ubirmvol /dev/ubi0 -N rootfs    # ubi device node and volume name
   ubirmvol /dev/ubi0 -n 1    # ubi device node and volume id
   ubirmvol /dev/ubi0_1    # ubi volume node

Other than consistency the main feature this adds is support for using 
-N to specify the volume by name to all the commands.

The problem is these commands need different information to work:
- ubinfo loads information from the /sys file system, it's easy to 
support for all the above command arguments.
- ubirmvol needs a ubi device node and a volume id, how can this work if 
a volume node is specified?
- ubiupdatevol needs a ubi volume node, how can this work if a device 
node is specified?

So my questions is how can the appropriate device node be generated by 
these commands if it is not specified on the command line. It would be 
possible to use something like:
  sprintf(node, "/dev/ubi%d_%d", args.devn, args.vol_id);

However I don't think that hard coding the /dev path is an acceptable 
solution, and assume that's why the -d (device number) argument was 
deprecated. Does anyone have any suggestions on a better solution?

Thanks,
Richard

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Adding -N volume name to ubi utils
  2008-11-24 17:07 Adding -N volume name to ubi utils Richard Titmuss
@ 2008-11-25  8:53 ` Adrian Hunter
  2008-12-02  8:56 ` Artem Bityutskiy
  1 sibling, 0 replies; 3+ messages in thread
From: Adrian Hunter @ 2008-11-25  8:53 UTC (permalink / raw)
  To: ext Richard Titmuss; +Cc: linux-mtd

Richard Titmuss wrote:
> I am trying to modify the ubi tools in mtd_utils to allow the ubi volume 
> name to be specified on the command line, the relevant commands are 
> ubinfo, ubirmvol and ubiupdatevol. The idea is that you could use any of 
> the following command arguments to specify a ubi volume:
> 
>    ubirmvol /dev/ubi0 -N rootfs    # ubi device node and volume name
>    ubirmvol /dev/ubi0 -n 1    # ubi device node and volume id
>    ubirmvol /dev/ubi0_1    # ubi volume node
> 
> Other than consistency the main feature this adds is support for using 
> -N to specify the volume by name to all the commands.
> 
> The problem is these commands need different information to work:
> - ubinfo loads information from the /sys file system, it's easy to 
> support for all the above command arguments.
> - ubirmvol needs a ubi device node and a volume id, how can this work if 
> a volume node is specified?
> - ubiupdatevol needs a ubi volume node, how can this work if a device 
> node is specified?
> 
> So my questions is how can the appropriate device node be generated by 
> these commands if it is not specified on the command line. It would be 
> possible to use something like:
>   sprintf(node, "/dev/ubi%d_%d", args.devn, args.vol_id);
> 
> However I don't think that hard coding the /dev path is an acceptable 
> solution, and assume that's why the -d (device number) argument was 
> deprecated. Does anyone have any suggestions on a better solution?

In principle, you should use udev rules to create device nodes that
are easy to work with e.g.

/dev/ubi/rootfs/vol
/dev/ubi/rootfs/dev

so then you can make a script say ubirmvolbyname

#!/bin/sh
ubirmvol /dev/ubi/$1/dev -N $1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Adding -N volume name to ubi utils
  2008-11-24 17:07 Adding -N volume name to ubi utils Richard Titmuss
  2008-11-25  8:53 ` Adrian Hunter
@ 2008-12-02  8:56 ` Artem Bityutskiy
  1 sibling, 0 replies; 3+ messages in thread
From: Artem Bityutskiy @ 2008-12-02  8:56 UTC (permalink / raw)
  To: Richard Titmuss; +Cc: linux-mtd

Hi,

On Mon, 2008-11-24 at 17:07 +0000, Richard Titmuss wrote:
> I am trying to modify the ubi tools in mtd_utils to allow the ubi volume 
> name to be specified on the command line, the relevant commands are 
> ubinfo, ubirmvol and ubiupdatevol. The idea is that you could use any of 
> the following command arguments to specify a ubi volume:
> 
>    ubirmvol /dev/ubi0 -N rootfs    # ubi device node and volume name
>    ubirmvol /dev/ubi0 -n 1    # ubi device node and volume id

Looks OK.

>    ubirmvol /dev/ubi0_1    # ubi volume node

Probably also fine.

> Other than consistency the main feature this adds is support for using 
> -N to specify the volume by name to all the commands.

Right.

> The problem is these commands need different information to work:
> - ubinfo loads information from the /sys file system, it's easy to 
> support for all the above command arguments.

Yes.

> - ubirmvol needs a ubi device node and a volume id, how can this work if 
> a volume node is specified?

sysfs contains all the information. Character device gives you
major:minor. UBI _devices_ always have minor=0. So you can distinguish
between UBI volume/device chdev nodes. And you may look into all

/sys/class/ubi/ubiX/ubiX_Y/dev

and find the volume. Then you have all the information.

> - ubiupdatevol needs a ubi volume node, how can this work if a device 
> node is specified?

Similarly. Add corresponding scanning functions to libubi
(mtd-utils/ubi-utils/new-utils/src/libubi.c).

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-12-02  8:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-24 17:07 Adding -N volume name to ubi utils Richard Titmuss
2008-11-25  8:53 ` Adrian Hunter
2008-12-02  8:56 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox