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

Tobias Hunger tobias.hunger at gmail.com
Mon Mar 23 01:21:44 PDT 2015


Hi Zbyszek,

I had been thinking about adding more device-less fs types, too, and
came to the same conclusion:-)

I'll rework the patch with the new else, use streq_ptr and alse rename
type_is_tmpfs to fstype_is_tmpfs. I think that is cleaner. I'll send
it as soon as I get round to it.

Thanks for the review!

Best Regards,
Tobias

On Mon, Mar 23, 2015 at 2:46 AM, Zbigniew Jędrzejewski-Szmek
<zbyszek at in.waw.pl> wrote:
> 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