[PATCH] udisks: add nilfs2 label rename

Jiro SEKIBA jir at unicus.jp
Thu Oct 14 21:43:19 PDT 2010


At Thu, 14 Oct 2010 06:17:30 -0700,
Dan Nicholson wrote:
> 
> On Wed, Oct 13, 2010 at 10:56 PM, Jiro SEKIBA <jir at unicus.jp> wrote:
> > Hi,
> >
> > This is a patch to support renaming label of nilfs2 partition.
> > Renaming is done by nilfs2-tune, which is in nilfs2-util > 2.0.20.
> >
> > This patch enables the label test excluded for lacking utility.
> >
> > Signed-off-by: Jiro SEKIBA <jir at unicus.jp>
> > ---
> >  src/daemon.c                              |    2 +-
> >  src/helpers/job-change-filesystem-label.c |    4 ++++
> >  tests/run                                 |    4 ++--
> >  3 files changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/daemon.c b/src/daemon.c
> > index 44be94f..d46c6da 100644
> > --- a/src/daemon.c
> > +++ b/src/daemon.c
> > @@ -395,7 +395,7 @@ static const Filesystem known_file_systems[] =
> >       TRUE, /* can_mount */
> >       TRUE, /* can_create */
> >       80, /* max_label_len */
> > -      FALSE, /* supports_label_rename */
> > +      TRUE, /* supports_label_rename */
> >       FALSE, /* supports_online_label_rename*/
> >       FALSE, /* supports_fsck */
> >       FALSE, /* supports_online_fsck */
> > diff --git a/src/helpers/job-change-filesystem-label.c b/src/helpers/job-change-filesystem-label.c
> > index 5b3e746..bdb28c6 100644
> > --- a/src/helpers/job-change-filesystem-label.c
> > +++ b/src/helpers/job-change-filesystem-label.c
> > @@ -103,6 +103,10 @@ main (int argc,
> >     {
> >       command_line = g_strdup_printf ("ntfslabel %s \"%s\"", device, new_label);
> >     }
> > +  else if (strcmp (fstype, "nilfs2") == 0)
> > +    {
> > +      command_line = g_strdup_printf ("nilfs-tune -L %s \"%s\"", new_label, device);
> > +    }
> 
> Here you're quoting the device path and not the label. So, you could
> do something like:
> 
> nilfs-tune -L My New Label "/dev/sda1"
> 
> That would obviously bomb. I think you'd rather reverse the quoting:
> 
> command_line = g_strdup_printf ("nilfs-tune -L \"%s\" %s", new_label, device);

grr, that's right.  

It also should validate label string with validate_and_escape_label.
I'll send the patch to fix those.

Apart from the bug of nilfs2 specific, I found the problem that
validate_and_escape_label will only escape '"'.
This would be problem when string includes '\'.

For example, string '\"' will be converted to '\\"' by the function.
That string will be surrounded with '"' g_strdup_printf and turn to "\\"".

I'll send the patch for this problem separately.

thanks!

regrads,


> --
> Dan
> _______________________________________________
> devkit-devel mailing list
> devkit-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/devkit-devel


-- 
Jiro SEKIBA <jir at unicus.jp>


More information about the devkit-devel mailing list