Skip to contentSkip to conversation

95rootfs-block: fix missing root when label contains slash

PATCH Superseded Andrey Borzenkov 2 participants 4 messages Nov 5, 2010 – Nov 10, 2010 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 95rootfs-block: fix missing root when label contains slash

It is not clearly documented, but apparently fsck
(or, probably, getmntent) is using backslash as
escape character.

Label containing slash is converted to \x2f but '\' is eaten by fsck later. Escape '\' before writing into fstab.

---
 modules.d/95rootfs-block/mount-root.sh |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
modules.d/95rootfs-block/mount-root.sh +3 -1
index ff64209..493b54b 100755
@@ -106,7 +106,9 @@ if [ -n "$root" -a -z "${root%%block:*}" ]; then
             done
     fi
 
-    echo ${root#block:} "$NEWROOT" "$rootfs" ${rflags},${rootopts} 1 1 > /etc/fstab
+    # backslashes are treated as escape character in fstab
+    esc_root=$(echo ${root#block:} | sed ',\\,\\\\,g')
+    echo "$esc_root" "$NEWROOT" "$rootfs" ${rflags},${rootopts} 1 1 > /etc/fstab
 
     if [ -z "$fastboot" -a "$READONLY" != "yes" ]; then
         info "Checking filesystems"
Signature · 1 line
tg: (921f4b5..) upstream/rootdev (depends on: master)

A message that is not in the archive (sent off-list or not yet received): 1288963916-3609-1-git-send-email-arvidjaar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH v2 1/1 95rootfs-block: fix missing root when label contains slash

It is not clearly documented, but apparently fsck
(or, probably, getmntent) is using backslash as
escape character.

Label containing slash is converted to \x2f but '\' is eaten by fsck later. Escape '\' before writing into fstab.

v2:
- fix sed expression
- use printf instead of echo because echo eats '\' as well

---
 modules.d/95rootfs-block/mount-root.sh |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
modules.d/95rootfs-block/mount-root.sh +3 -1
index ff64209..9065bed 100755
@@ -106,7 +106,9 @@ if [ -n "$root" -a -z "${root%%block:*}" ]; then
             done
     fi
 
-    echo ${root#block:} "$NEWROOT" "$rootfs" ${rflags},${rootopts} 1 1 > /etc/fstab
+    # backslashes are treated as escape character in fstab
+    esc_root=$(echo ${root#block:} | sed 's,\\,\\\\,g')
+    printf "%s $NEWROOT $rootfs ${rflags},${rootopts} 1 1\n" "$esc_root" > /etc/fstab
 
     if [ -z "$fastboot" -a "$READONLY" != "yes" ]; then
         info "Checking filesystems"
Signature · 1 line
tg: (1c29003..) upstream/rootdev (depends on: master)

A message that is not in the archive (sent off-list or not yet received): 1289080013-3525-1-git-send-email-arvidjaar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#4 lore raw
Quoted 23 lines · Andrey Borzenkov

It is not clearly documented, but apparently fsck
(or, probably, getmntent) is using backslash as
escape character.

Label containing slash is converted to \x2f but '\' is eaten by fsck later. Escape '\' before writing into fstab.

v2:
- fix sed expression
- use printf instead of echo because echo eats '\' as well

---
  modules.d/95rootfs-block/mount-root.sh |    4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)
modules.d/95rootfs-block/mount-root.sh +0 -0
index ff64209..9065bed 100755

modules.d/95rootfs-block/mount-root.sh if [ -n "$root" -a -z "${root%%block:*}" ]; then · line 114

Quoted 10 lines
modules.d/95rootfs-block/mount-root.sh +3 -1
@@ -106,7 +106,9 @@ if [ -n "$root" -a -z "${root%%block:*}" ]; then
              done
      fi
 
-    echo ${root#block:} "$NEWROOT" "$rootfs" ${rflags},${rootopts} 1 1>  /etc/fstab
+    # backslashes are treated as escape character in fstab
+    esc_root=$(echo ${root#block:} | sed 's,\\,\\\\,g')
+    printf "%s $NEWROOT $rootfs ${rflags},${rootopts} 1 1\n" "$esc_root">  /etc/fstab
 
      if [ -z "$fastboot" -a "$READONLY" != "yes" ]; then
          info "Checking filesystems"

maybe we should just turn \x2f back into / ??

#5 lore raw
In reply to a message not in the archive
Quoted 23 lines · Andrey Borzenkov

It is not clearly documented, but apparently fsck
(or, probably, getmntent) is using backslash as
escape character.

Label containing slash is converted to \x2f but '\' is eaten by fsck later. Escape '\' before writing into fstab.

v2:
- fix sed expression
- use printf instead of echo because echo eats '\' as well

---
  modules.d/95rootfs-block/mount-root.sh |    4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)
modules.d/95rootfs-block/mount-root.sh +0 -0
index ff64209..9065bed 100755

modules.d/95rootfs-block/mount-root.sh if [ -n "$root" -a -z "${root%%block:*}" ]; then · line 114

Quoted 10 lines
modules.d/95rootfs-block/mount-root.sh +3 -1
@@ -106,7 +106,9 @@ if [ -n "$root" -a -z "${root%%block:*}" ]; then
              done
      fi
 
-    echo ${root#block:} "$NEWROOT" "$rootfs" ${rflags},${rootopts} 1 1>  /etc/fstab
+    # backslashes are treated as escape character in fstab
+    esc_root=$(echo ${root#block:} | sed 's,\\,\\\\,g')
+    printf "%s $NEWROOT $rootfs ${rflags},${rootopts} 1 1\n" "$esc_root">  /etc/fstab
 
      if [ -z "$fastboot" -a "$READONLY" != "yes" ]; then
          info "Checking filesystems"

pushed