Blame 0161-dracut.sh-Support-mount-with-just-mountpoint-as-para.patch

Harald Hoyer bb31e7
From edbd9ca058bcb19f351aca470581db1a67b706d7 Mon Sep 17 00:00:00 2001
Harald Hoyer bb31e7
From: Fabian <fvogt@suse.com>
Harald Hoyer bb31e7
Date: Fri, 11 Sep 2015 13:35:57 +0200
Harald Hoyer bb31e7
Subject: [PATCH] dracut.sh: Support --mount with just mountpoint as parameter
Harald Hoyer bb31e7
Harald Hoyer bb31e7
Right now the --mount parameter of dracut expects a rather long fstab-like
Harald Hoyer bb31e7
line. This makes it possible to invoke dracut with e.g. --mount /boot.
Harald Hoyer bb31e7
---
Harald Hoyer bb31e7
 dracut.8.asc |  4 ++++
Harald Hoyer bb31e7
 dracut.sh    | 16 +++++++++++++++-
Harald Hoyer bb31e7
 2 files changed, 19 insertions(+), 1 deletion(-)
Harald Hoyer bb31e7
Harald Hoyer bb31e7
diff --git a/dracut.8.asc b/dracut.8.asc
Harald Hoyer bb31e7
index 5f45ed9..d22c1cb 100644
Harald Hoyer bb31e7
--- a/dracut.8.asc
Harald Hoyer bb31e7
+++ b/dracut.8.asc
Harald Hoyer bb31e7
@@ -338,6 +338,10 @@ provide a valid _/etc/fstab_.
Harald Hoyer bb31e7
     The default _<dump frequency>_ is "0".
Harald Hoyer bb31e7
     the default _<fsck order>_ is "2".
Harald Hoyer bb31e7
 
Harald Hoyer bb31e7
+**--mount** "_<mountpoint>_"::
Harald Hoyer bb31e7
+    Like above, but _<device>_, _<filesystem type>_ and _<filesystem options>_
Harald Hoyer bb31e7
+    are determined by looking at the current mounts.
Harald Hoyer bb31e7
+
Harald Hoyer bb31e7
 **--add-device** _<device>_ ::
Harald Hoyer bb31e7
     Bring up _<device>_ in initramfs, _<device>_ should be the device name.
Harald Hoyer bb31e7
     This can be useful in hostonly mode for resume support when your swap is on
Harald Hoyer bb31e7
diff --git a/dracut.sh b/dracut.sh
Harald Hoyer bb31e7
index fb5d400..52a628a 100755
Harald Hoyer bb31e7
--- a/dracut.sh
Harald Hoyer bb31e7
+++ b/dracut.sh
Harald Hoyer bb31e7
@@ -160,6 +160,8 @@ Creates initial ramdisk images for preloading modules
Harald Hoyer bb31e7
   --mount "[DEV] [MP] [FSTYPE] [FSOPTS]"
Harald Hoyer bb31e7
                         Mount device [DEV] on mountpoint [MP] with filesystem
Harald Hoyer bb31e7
                         [FSTYPE] and options [FSOPTS] in the initramfs
Harald Hoyer bb31e7
+  --mount "[MP]"	Same as above, but [DEV], [FSTYPE] and [FSOPTS] are
Harald Hoyer bb31e7
+			determined by looking at the current mounts.
Harald Hoyer bb31e7
   --add-device "[DEV]"  Bring up [DEV] in initramfs
Harald Hoyer bb31e7
   -i, --include [SOURCE] [TARGET]
Harald Hoyer bb31e7
                         Include the files in the SOURCE directory into the
Harald Hoyer bb31e7
@@ -1469,9 +1471,21 @@ if [[ $kernel_only != yes ]]; then
Harald Hoyer bb31e7
 
Harald Hoyer bb31e7
     for line in "${fstab_lines[@]}"; do
Harald Hoyer bb31e7
         line=($line)
Harald Hoyer bb31e7
-        [ -z "${line[3]}" ] && line[3]="defaults"
Harald Hoyer bb31e7
+
Harald Hoyer bb31e7
+        if [ -z "${line[1]}" ]; then
Harald Hoyer bb31e7
+            # Determine device and mount options from current system
Harald Hoyer bb31e7
+            mountpoint -q "${line[0]}" || derror "${line[0]} is not a mount point!"
Harald Hoyer bb31e7
+            line=($(findmnt --raw -n --target "${line[0]}" --output=source,target,fstype,options))
Harald Hoyer bb31e7
+            dinfo "Line for ${line[1]}: ${line[@]}"
Harald Hoyer bb31e7
+        else
Harald Hoyer bb31e7
+            # Use default options
Harald Hoyer bb31e7
+            [ -z "${line[3]}" ] && line[3]="defaults"
Harald Hoyer bb31e7
+        fi
Harald Hoyer bb31e7
+
Harald Hoyer bb31e7
+        # Default options for freq and passno
Harald Hoyer bb31e7
         [ -z "${line[4]}" ] && line[4]="0"
Harald Hoyer bb31e7
         [ -z "${line[5]}" ] && line[5]="2"
Harald Hoyer bb31e7
+
Harald Hoyer bb31e7
         strstr "${line[2]}" "nfs" && line[5]="0"
Harald Hoyer bb31e7
         echo "${line[@]}" >> "${initdir}/etc/fstab"
Harald Hoyer bb31e7
     done