Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 213082

Summary: sys-apps/baselayout-1.12.11.1: checkroot doesn't check if there is a comment appended in the fstab line
Product: Gentoo Linux Reporter: Robert <emmi3>
Component: [OLD] baselayoutAssignee: Gentoo's Team for Core System packages <base-system>
Status: RESOLVED DUPLICATE    
Severity: normal CC: roy
Priority: High    
Version: unspecified   
Hardware: x86   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Robert 2008-03-11 22:51:37 UTC
/etc/init.d/checkroot does not check the filesystem if there is a comment at the end of the fstab line for the root-filesystem.

Reproducible: Always

Steps to Reproduce:
1. Append a comment to the entry for the root filesystem e.g:
LABEL=Gentoo  /  ext3  noatime  0  1   # hde6

2. reboot & watch
Actual Results:  
It says:
"Skipping root filesystem check (fstab's passno == 0)"

Expected Results:  
"Checking root filesystem"

The problem is obviously due to the awk-command only checking for EXACTLY 6 fields in the fstab line:
  if [[ -n $(awk '($1 ~ /^(\/|UUID|LABEL)/ && $2 == "/" \
                  && NF == 6 && $6 != 0) { print }' /etc/fstab) ]]
                     ^^^^^^^Here

It should instead check that there are AT LEAST 6 fields:  NF >= 6 

...Or maybe I should not put comments there?
Comment 1 Doug Goldstein (RETIRED) gentoo-dev 2008-03-11 23:48:49 UTC
Interestingly enough what I can appear to find on both Linux and FreeBSD, # is only valid at the start of a line. It's not valid at any point in the middle of a line.

Anyone else's opinion from base-layout on this?

I'd be curious how the script from openrc/baselayout-2 handles this.
Comment 2 Roy Marples 2008-03-12 07:54:22 UTC
OpenRC uses ships with an applet called fstabinfo, just for reasons like this.
The ONLY way to reliably parse /etc/fstab is to use getfsent, getfsfile (or getmntent, getmntfile on some cranky Linux systems)

And yes, according to the format, comments are only valid at the start of the line.
Comment 3 Jakub Moc (RETIRED) gentoo-dev 2008-03-12 15:53:39 UTC

*** This bug has been marked as a duplicate of bug 185063 ***