[systemd-devel] [PATCH] fstab-generator: Support root on tmpfs

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Sun Mar 22 18:46:11 PDT 2015


On Sun, Mar 22, 2015 at 08:29:25AM +0300, Andrei Borzenkov wrote:
> В Sun, 22 Mar 2015 00:57:23 +0100
> Tobias Hunger <tobias.hunger at gmail.com> пишет:
> 
> >  src/fstab-generator/fstab-generator.c | 12 +++++++++++-
> >  1 file changed, 11 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
> > index ccc7c6e..6b9719b 100644
> > --- a/src/fstab-generator/fstab-generator.c
> > +++ b/src/fstab-generator/fstab-generator.c
> > @@ -145,6 +145,10 @@ static bool mount_in_initrd(struct mntent *me) {
> >                 streq(me->mnt_dir, "/usr");
> >  }
> >  
> > +static bool type_is_tmpfs(char *type) {
> > +        return !isempty(type) && streq(type, "tmpfs");
> > +}
> > +
This is basically streq_ptr(type, "tmpfs").

> >  static int add_mount(
> >                  const char *what,
> >                  const char *where,
> > @@ -388,13 +392,19 @@ static int add_root_mount(void) {
> >          _cleanup_free_ char *what = NULL;
> >          const char *opts;
> >  
> > +        if (type_is_tmpfs(arg_root_fstype)) {
> > +                /* normalize what to mount to tmpfs */
> > +                if (free_and_strdup(&arg_root_what, "tmpfs") < 0)
> > +                        return log_oom();
> > +        }

> Following code makes sense only for real device, so
> 
>            else {
> 
> > +
> >          if (isempty(arg_root_what)) {
> >                  log_debug("Could not find a root= entry on the kernel command line.");
> >                  return 0;
> >          }
> >  
> >          what = fstab_node_to_udev_node(arg_root_what);
> > -        if (!path_is_absolute(what)) {
> > +        if (!path_is_absolute(what) && !type_is_tmpfs(what)) {
> 
> ... which makes this type_is_tmpfs() redundant
> 
> >                  log_debug("Skipping entry what=%s where=/sysroot type=%s", what, strna(arg_root_fstype));
> >                  return 0;
> >          }

Looks OK. I'm wondering if we should support other device-less fs types
in the same manner. There's ramfs, but it's deprecated, and I don't think there's
anything else we should support, so there's no need to make it more generic.
Can you remake the patch with streq_ptr and the additional else?

Zbyszek


More information about the systemd-devel mailing list