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

Andrei Borzenkov arvidjaar at gmail.com
Sat Mar 21 22:29:25 PDT 2015


В 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");
> +}
> +
>  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;
>          }

           }


More information about the systemd-devel mailing list