Bug 186713

Summary: problem with S01reboot script when umount devices
Product: [Fedora] Fedora Reporter: VALOIS, Pascal <pascal.valois>
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED RAWHIDE QA Contact: Brock Organ <borgan>
Severity: medium Docs Contact:
Priority: medium    
Version: 5CC: mitr, peter.klotz99, rvokal, vlada
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 8.34-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-05-23 19:22:08 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Use bash arrays for paths from fstab
none
Add with-fstab-escapes
none
Replace the cut&pasted umounting loops by shell functions none

Description VALOIS, Pascal 2006-03-25 16:08:43 UTC
Description of problem:

when umounting during reboot or halt, if a device mount point in /media contains
a space, the umount fails.

for example, i used the part of the script responsible for umounting : 

there is the result : 

> mount | awk '{ print $3 }' | while read line; do
>     mount -n -o ro,remount $line
> done

mount: can't find /media/UDISK in /etc/fstab or /etc/mtab

in fact, my usbkey is named "UDISK 2.0" and so is mounted in "/media/UDISK 2.0"
and umount fails due to the space

Version-Release number of selected component (if applicable):

initscripts-8.31.1-1

How reproducible:

always

Steps to Reproduce:
1. mount a device labeled with a name containing a space
2. init 6 (or init 0)
3. enjoy
  
Actual results:

the device is not cleanly umounted at shutdown

Expected results:

the device MUST BE cleanly umounted at shudown

Additional info:

Comment 1 VALOIS, Pascal 2006-03-25 16:22:43 UTC
umount using the device instead of the mount point would solve the problems.
further more, it doesn't matter the way it's called when you umount prior to
shutdown or reboot.

changing awk {print $3} by awk {print $1} in the S01reboot script do the trick.


Comment 2 Bill Nottingham 2006-03-27 19:53:39 UTC
Yeah, but that will get multiple 'none' entries if any pseudo-fses are left, so
that probably won't work. Does it work for you if you just quote the arg to mount?

Comment 3 VALOIS, Pascal 2006-03-27 23:22:46 UTC
how can you quote when listing mount point with mount ? it's mount that don't
quote, not the script...

so i suggest finding mounted devices like this : 

mount |  awk '{ print $1 }' | grep "^/dev/"

Comment 4 Miloslav Trmač 2006-03-29 00:57:08 UTC
Created attachment 126947 [details]
Use bash arrays for paths from fstab

Parsing (mount) output won't ever be reliable because (mount) doesn't escape
anything and both device and mount point paths can contain arbitrary
characters:

/my/device on /no path on on /my path on type ext3 (rw) [label] type ext3 (rw)

is one of the simpler cases (no embedded newlines).


The attached patch converts initscripts to never parse (mount) output and to
properly decode {fstab,mtab,/proc/mounts} entries.  Handling arbitrary strings
in shell is rather awkward...

Note that this is only a proof of concept and it was very lightly tested.
The real patch should probably also at least unify the cut&pasted unmounting
loops.

Does the idea look reasonable?	If so, I'll try to prepare something
rawhide-worthy.

Comment 5 Bill Nottingham 2006-04-03 21:18:37 UTC
That looks somewhat ugly, and probably rather slow.

Perhaps just wrapping getmntent() would be simpler?

Comment 6 Bill Nottingham 2006-04-03 21:24:11 UTC
*** Bug 187554 has been marked as a duplicate of this bug. ***

Comment 7 Miloslav Trmač 2006-05-08 01:13:53 UTC
Created attachment 128719 [details]
Add with-fstab-escapes

How about this (completely untested)? It allows
    (with-fstab-escapes umount $(awk 'whatever {print $2}'))
which is much simpler than the previous approach, and should be a bit faster
too.

The "with-fstab-escapes" name is too LISPy and too long, I can't think of
anything
better though.

Comment 8 Miloslav Trmač 2006-05-08 02:20:23 UTC
Created attachment 128724 [details]
Replace the cut&pasted umounting loops by shell functions

Additional cleanup: save ~50 lines of copy&pasted shell.

Also adds handling of comments in fstab to same paths where it was missing.

Comment 9 Bill Nottingham 2006-05-08 18:59:16 UTC
I'd just call it 'fstab-escape'. Ideally, there would be a /libexec to stuff it
in , but putting it in /sbin should be ok.

Comment 10 Miloslav Trmač 2006-05-08 19:07:27 UTC
fstab-unescape? It doesn't escape anything...

Comment 11 Bill Nottingham 2006-05-08 19:12:51 UTC
Or decode, or.... really it doesn't matter that much, it's an implementation detail.

Comment 12 Bill Nottingham 2006-05-23 19:22:08 UTC
A fix for this is in 8.34-1.

Comment 13 Peter Klotz 2006-05-25 08:54:40 UTC
Yes, this update resolves the issue (at least for my case).

It should be noted that glib2 must be updated in order to use Rawhide 
initscripts 8.34-1 on Fedora Core 5.


Comment 14 Miloslav Trmač 2006-05-25 15:07:33 UTC
*** Bug 189695 has been marked as a duplicate of this bug. ***