Patchwork UBIFS: Add /dev/ubiX_Y naming scheme in open_ubi

login
register
mail settings
Submitter Corentin Chary
Date Sept. 24, 2009, 10:47 p.m.
Message ID <1253832477-29064-1-git-send-email-corentincj@iksaif.net>
Download mbox | patch
Permalink /patch/34240/
State New, archived
Headers show

Comments

Corentin Chary - Sept. 24, 2009, 10:47 p.m.
This is needed to use $ mount /dev/ubi0_0 /mnt/nand
You'll also need a recent libblkid with UBI and UBIFS
support.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
 fs/ubifs/super.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
Adrian Hunter - Sept. 25, 2009, 11:37 a.m.
Corentin Chary wrote:
> This is needed to use $ mount /dev/ubi0_0 /mnt/nand
> You'll also need a recent libblkid with UBI and UBIFS
> support.
> 
> Signed-off-by: Corentin Chary <corentincj@iksaif.net>
> ---
>  fs/ubifs/super.c |   12 ++++++++----
>  1 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
> index 7e2b3d4..38320ad 100644
> --- a/fs/ubifs/super.c
> +++ b/fs/ubifs/super.c
> @@ -1843,10 +1843,11 @@ const struct super_operations ubifs_super_operations = {
>   * @mode: UBI volume open mode
>   *
>   * There are several ways to specify UBI volumes when mounting UBIFS:
> - * o ubiX_Y    - UBI device number X, volume Y;
> - * o ubiY      - UBI device number 0, volume Y;
> - * o ubiX:NAME - mount UBI device X, volume with name NAME;
> - * o ubi:NAME  - mount UBI device 0, volume with name NAME.
> + * o /dev/ubiX_Y - UBI device number X, volume Y;
> + * o ubiX_Y      - UBI device number X, volume Y;
> + * o ubiY        - UBI device number 0, volume Y;
> + * o ubiX:NAME   - mount UBI device X, volume with name NAME;
> + * o ubi:NAME    - mount UBI device 0, volume with name NAME.
>   *
>   * Alternative '!' separator may be used instead of ':' (because some shells
>   * like busybox may interpret ':' as an NFS host name separator). This function
> @@ -1858,6 +1859,9 @@ static struct ubi_volume_desc *open_ubi(const char *name, int mode)
>  	int dev, vol;
>  	char *endptr;
>  
> +	if (!strncmp("/dev/", name, 5))
> +		name = name + 5;
> +
>  	if (name[0] != 'u' || name[1] != 'b' || name[2] != 'i')
>  		return ERR_PTR(-EINVAL);

Is this for the kernel?

I do not think UBIFS should interpret the file name.  It should
work off the major and minor numbers from the device node
irrespective of what its path name or file name is.
Corentin Chary - Sept. 25, 2009, 12:27 p.m.
On Fri, Sep 25, 2009 at 1:37 PM, Adrian Hunter <adrian.hunter@nokia.com> wrote:
> Corentin Chary wrote:
>>
>> This is needed to use $ mount /dev/ubi0_0 /mnt/nand
>> You'll also need a recent libblkid with UBI and UBIFS
>> support.
>>
>> Signed-off-by: Corentin Chary <corentincj@iksaif.net>
>> ---
>>  fs/ubifs/super.c |   12 ++++++++----
>>  1 files changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
>> index 7e2b3d4..38320ad 100644
>> --- a/fs/ubifs/super.c
>> +++ b/fs/ubifs/super.c
>> @@ -1843,10 +1843,11 @@ const struct super_operations
>> ubifs_super_operations = {
>>  * @mode: UBI volume open mode
>>  *
>>  * There are several ways to specify UBI volumes when mounting UBIFS:
>> - * o ubiX_Y    - UBI device number X, volume Y;
>> - * o ubiY      - UBI device number 0, volume Y;
>> - * o ubiX:NAME - mount UBI device X, volume with name NAME;
>> - * o ubi:NAME  - mount UBI device 0, volume with name NAME.
>> + * o /dev/ubiX_Y - UBI device number X, volume Y;
>> + * o ubiX_Y      - UBI device number X, volume Y;
>> + * o ubiY        - UBI device number 0, volume Y;
>> + * o ubiX:NAME   - mount UBI device X, volume with name NAME;
>> + * o ubi:NAME    - mount UBI device 0, volume with name NAME.
>>  *
>>  * Alternative '!' separator may be used instead of ':' (because some
>> shells
>>  * like busybox may interpret ':' as an NFS host name separator). This
>> function
>> @@ -1858,6 +1859,9 @@ static struct ubi_volume_desc *open_ubi(const char
>> *name, int mode)
>>        int dev, vol;
>>        char *endptr;
>>  +       if (!strncmp("/dev/", name, 5))
>> +               name = name + 5;
>> +
>>        if (name[0] != 'u' || name[1] != 'b' || name[2] != 'i')
>>                return ERR_PTR(-EINVAL);
>
> Is this for the kernel?
Yes

> I do not think UBIFS should interpret the file name.  It should
> work off the major and minor numbers from the device node
> irrespective of what its path name or file name is.

UBIFS is currently a "nodev" filesystem, it's why I did it that way.

Using name and kern_path we can find the corresponding inode (and
major/minor informations).
But I don't see a way to open the corresponding UBI volume with only
major/minor.
ubi_open_volume use ubi_num and vol_id.
vol_id is minor()-1, but major is not related to ubi_num.

UBI have a "ubi_major2num" internally, is it ok to export this symbol ?

Thanks
Artem Bityutskiy - Sept. 28, 2009, 11:39 a.m.
On Fri, 2009-09-25 at 00:47 +0200, Corentin Chary wrote:
> This is needed to use $ mount /dev/ubi0_0 /mnt/nand
> You'll also need a recent libblkid with UBI and UBIFS
> support.
> 
> Signed-off-by: Corentin Chary <corentincj@iksaif.net>
> ---
>  fs/ubifs/super.c |   12 ++++++++----
>  1 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
> index 7e2b3d4..38320ad 100644
> --- a/fs/ubifs/super.c
> +++ b/fs/ubifs/super.c
> @@ -1843,10 +1843,11 @@ const struct super_operations ubifs_super_operations = {
>   * @mode: UBI volume open mode
>   *
>   * There are several ways to specify UBI volumes when mounting UBIFS:
> - * o ubiX_Y    - UBI device number X, volume Y;
> - * o ubiY      - UBI device number 0, volume Y;
> - * o ubiX:NAME - mount UBI device X, volume with name NAME;
> - * o ubi:NAME  - mount UBI device 0, volume with name NAME.
> + * o /dev/ubiX_Y - UBI device number X, volume Y;
> + * o ubiX_Y      - UBI device number X, volume Y;
> + * o ubiY        - UBI device number 0, volume Y;
> + * o ubiX:NAME   - mount UBI device X, volume with name NAME;
> + * o ubi:NAME    - mount UBI device 0, volume with name NAME.
>   *
>   * Alternative '!' separator may be used instead of ':' (because some shells
>   * like busybox may interpret ':' as an NFS host name separator). This function
> @@ -1858,6 +1859,9 @@ static struct ubi_volume_desc *open_ubi(const char *name, int mode)
>  	int dev, vol;
>  	char *endptr;
>  
> +	if (!strncmp("/dev/", name, 5))
> +		name = name + 5;
> +
>  	if (name[0] != 'u' || name[1] != 'b' || name[2] != 'i')
>  		return ERR_PTR(-EINVAL);

But UBI volume may have arbitrary names. Could we invent something
better?
Corentin Chary - Sept. 28, 2009, 11:53 a.m.
On Mon, Sep 28, 2009 at 1:39 PM, Artem Bityutskiy <dedekind1@gmail.com> wrote:
> On Fri, 2009-09-25 at 00:47 +0200, Corentin Chary wrote:
>> This is needed to use $ mount /dev/ubi0_0 /mnt/nand
>> You'll also need a recent libblkid with UBI and UBIFS
>> support.
>>
>> Signed-off-by: Corentin Chary <corentincj@iksaif.net>
>> ---
>>  fs/ubifs/super.c |   12 ++++++++----
>>  1 files changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
>> index 7e2b3d4..38320ad 100644
>> --- a/fs/ubifs/super.c
>> +++ b/fs/ubifs/super.c
>> @@ -1843,10 +1843,11 @@ const struct super_operations ubifs_super_operations = {
>>   * @mode: UBI volume open mode
>>   *
>>   * There are several ways to specify UBI volumes when mounting UBIFS:
>> - * o ubiX_Y    - UBI device number X, volume Y;
>> - * o ubiY      - UBI device number 0, volume Y;
>> - * o ubiX:NAME - mount UBI device X, volume with name NAME;
>> - * o ubi:NAME  - mount UBI device 0, volume with name NAME.
>> + * o /dev/ubiX_Y - UBI device number X, volume Y;
>> + * o ubiX_Y      - UBI device number X, volume Y;
>> + * o ubiY        - UBI device number 0, volume Y;
>> + * o ubiX:NAME   - mount UBI device X, volume with name NAME;
>> + * o ubi:NAME    - mount UBI device 0, volume with name NAME.
>>   *
>>   * Alternative '!' separator may be used instead of ':' (because some shells
>>   * like busybox may interpret ':' as an NFS host name separator). This function
>> @@ -1858,6 +1859,9 @@ static struct ubi_volume_desc *open_ubi(const char *name, int mode)
>>       int dev, vol;
>>       char *endptr;
>>
>> +     if (!strncmp("/dev/", name, 5))
>> +             name = name + 5;
>> +
>>       if (name[0] != 'u' || name[1] != 'b' || name[2] != 'i')
>>               return ERR_PTR(-EINVAL);
>
> But UBI volume may have arbitrary names. Could we invent something
> better?


Using name and kern_path we can find the corresponding inode (and
major/minor informations).
ubi_open_volume use ubi_num and vol_id.
vol_id is minor()-1, but major is not related to ubi_num.

UBI have a "ubi_major2num" internally, is it ok to export this symbol ?

Then we could do something like
ubi_open_volume(ubi_major2num(major()), minor()-1)
Artem Bityutskiy - Sept. 28, 2009, 12:02 p.m.
On 09/28/2009 02:53 PM, Corentin Chary wrote:
>>> +     if (!strncmp("/dev/", name, 5))
>>> +             name = name + 5;
>>> +
>>>        if (name[0] != 'u' || name[1] != 'b' || name[2] != 'i')
>>>                return ERR_PTR(-EINVAL);
>>
>> But UBI volume may have arbitrary names. Could we invent something
>> better?
>
>
> Using name and kern_path we can find the corresponding inode (and
> major/minor informations).
> ubi_open_volume use ubi_num and vol_id.
> vol_id is minor()-1, but major is not related to ubi_num.
>
> UBI have a "ubi_major2num" internally, is it ok to export this symbol ?
>
> Then we could do something like
> ubi_open_volume(ubi_major2num(major()), minor()-1)

Sounds good.

Patch

diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 7e2b3d4..38320ad 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1843,10 +1843,11 @@  const struct super_operations ubifs_super_operations = {
  * @mode: UBI volume open mode
  *
  * There are several ways to specify UBI volumes when mounting UBIFS:
- * o ubiX_Y    - UBI device number X, volume Y;
- * o ubiY      - UBI device number 0, volume Y;
- * o ubiX:NAME - mount UBI device X, volume with name NAME;
- * o ubi:NAME  - mount UBI device 0, volume with name NAME.
+ * o /dev/ubiX_Y - UBI device number X, volume Y;
+ * o ubiX_Y      - UBI device number X, volume Y;
+ * o ubiY        - UBI device number 0, volume Y;
+ * o ubiX:NAME   - mount UBI device X, volume with name NAME;
+ * o ubi:NAME    - mount UBI device 0, volume with name NAME.
  *
  * Alternative '!' separator may be used instead of ':' (because some shells
  * like busybox may interpret ':' as an NFS host name separator). This function
@@ -1858,6 +1859,9 @@  static struct ubi_volume_desc *open_ubi(const char *name, int mode)
 	int dev, vol;
 	char *endptr;
 
+	if (!strncmp("/dev/", name, 5))
+		name = name + 5;
+
 	if (name[0] != 'u' || name[1] != 'b' || name[2] != 'i')
 		return ERR_PTR(-EINVAL);