Bug 186713 - problem with S01reboot script when umount devices
problem with S01reboot script when umount devices
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: initscripts (Show other bugs)
5
All Linux
medium Severity medium
: ---
: ---
Assigned To: Bill Nottingham
Brock Organ
:
: 187554 189695 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-03-25 11:08 EST by VALOIS, Pascal
Modified: 2014-03-16 22:59 EDT (History)
4 users (show)

See Also:
Fixed In Version: 8.34-1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-05-23 15:22:08 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Use bash arrays for paths from fstab (13.10 KB, patch)
2006-03-28 19:57 EST, Miloslav Trmač
no flags Details | Diff
Add with-fstab-escapes (14.55 KB, patch)
2006-05-07 21:13 EDT, Miloslav Trmač
no flags Details | Diff
Replace the cut&pasted umounting loops by shell functions (10.29 KB, patch)
2006-05-07 22:20 EDT, Miloslav Trmač
no flags Details | Diff

  None (edit)
Description VALOIS, Pascal 2006-03-25 11:08:43 EST
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 11:22:43 EST
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 14:53:39 EST
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 18:22:46 EST
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-28 19:57:08 EST
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 17:18:37 EDT
That looks somewhat ugly, and probably rather slow.

Perhaps just wrapping getmntent() would be simpler?
Comment 6 Bill Nottingham 2006-04-03 17:24:11 EDT
*** Bug 187554 has been marked as a duplicate of this bug. ***
Comment 7 Miloslav Trmač 2006-05-07 21:13:53 EDT
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-07 22:20:23 EDT
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 14:59:16 EDT
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 15:07:27 EDT
fstab-unescape? It doesn't escape anything...
Comment 11 Bill Nottingham 2006-05-08 15:12:51 EDT
Or decode, or.... really it doesn't matter that much, it's an implementation detail.
Comment 12 Bill Nottingham 2006-05-23 15:22:08 EDT
A fix for this is in 8.34-1.
Comment 13 Peter Klotz 2006-05-25 04:54:40 EDT
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 11:07:33 EDT
*** Bug 189695 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.