Blame SOURCES/0140-add-default-values-in-fstab_lines.patch

a56a5e
From d52c4a761a5232f9d92cae90259fbb00e3859a9f Mon Sep 17 00:00:00 2001
966cef
From: Dave Young <dyoung@redhat.com>
966cef
Date: Thu, 27 Feb 2014 10:44:23 +0800
966cef
Subject: [PATCH] add default values in fstab_lines
966cef
966cef
It's useful for passing a full fstab line including like fs_passno so fsck
966cef
can take effect.
966cef
966cef
Previously it's assumed that there's no fs_freq and fs_passno in fstab lines
966cef
so original code just append "0 0" at the end of each fstab lines.
966cef
966cef
Improve this issue by assign default value in case they are not passed in.
966cef
Three field are handled here:
966cef
fs_mntops: default to "defaults"
966cef
fs_freq: default to "0"
966cef
fs_passno: default to "2"
966cef
966cef
Signed-off-by: Dave Young <dyoung@redhat.com>
966cef
---
966cef
 dracut.8.asc | 10 +++++++---
966cef
 dracut.sh    |  6 +++++-
966cef
 2 files changed, 12 insertions(+), 4 deletions(-)
966cef
966cef
diff --git a/dracut.8.asc b/dracut.8.asc
966cef
index ba125c0..f97074a 100644
966cef
--- a/dracut.8.asc
966cef
+++ b/dracut.8.asc
966cef
@@ -311,9 +311,13 @@ provide a valid _/etc/fstab_.
966cef
 **--add-fstab** _<filename>_::
966cef
     Add entries of _<filename>_ to the initramfs /etc/fstab.
966cef
 
966cef
-**--mount** "_<device>_ _<mountpoint>_ _<filesystem type>_ _<filesystem options>_"::
966cef
-    Mount _<device>_ on _<mountpoint>_ with _<filesystem type>_ and _
966cef
-    options>_ in the initramfs
966cef
+**--mount** "_<device>_ _<mountpoint>_ _<filesystem type>_ [_<filesystem options>_ [_<dump frequency>_ [_<fsck order>_]]]"::
966cef
+    Mount _<device>_ on _<mountpoint>_ with _<filesystem type>_ in the
966cef
+    initramfs. _<filesystem options>_, _<dump options>_ and _<fsck order>_ can
966cef
+    be specified, see fstab manpage for the details.
966cef
+    The default _<filesystem options>_ is "defaults".
966cef
+    The default _<dump frequency>_ is "0".
966cef
+    the default _<fsck order>_ is "2".
966cef
 
966cef
 **--add-device** _<device>_ ::
966cef
     Bring up _<device>_ in initramfs, _<device>_ should be the device name.
966cef
diff --git a/dracut.sh b/dracut.sh
966cef
index 1c5e688..2d5b7dc 100755
966cef
--- a/dracut.sh
966cef
+++ b/dracut.sh
966cef
@@ -1234,7 +1234,11 @@ if [[ $kernel_only != yes ]]; then
966cef
     [[ $kernel_cmdline ]] && printf "%s\n" "$kernel_cmdline" >> "${initdir}/etc/cmdline.d/01-default.conf"
966cef
 
966cef
     while pop fstab_lines line; do
966cef
-        printf "%s\n" "$line 0 0" >> "${initdir}/etc/fstab"
966cef
+        line=($line)
966cef
+        [ -z "${line[3]}" ] && line[3]="defaults"
966cef
+        [ -z "${line[4]}" ] && line[4]="0"
966cef
+        [ -z "${line[5]}" ] && line[5]="2"
966cef
+        echo "${line[@]}" >> "${initdir}/etc/fstab"
966cef
     done
966cef
 
966cef
     for f in $add_fstab; do