Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#31563 - [initscripts] Shutdown Dismount Fails with Space Char

Attached to Project: Arch Linux
Opened by Dave (DaveCode) - Saturday, 15 September 2012, 21:57 GMT
Last edited by Tom Gundersen (tomegun) - Tuesday, 13 November 2012, 13:20 GMT
Task Type Bug Report
Category System
Status Closed
Assigned To Tom Gundersen (tomegun)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

Arch OS USB flash stick with a spare VFAT partition automounted at boot time. VFAT mount point has a space in its name. Shutdown dismount task fails over the space char and reports failure to user.


Additional info:

Made fresh install of Arch to a USB flash stick from latest installer ISO dated 2012.09.07


Steps to reproduce:

Partition a USB flash stick with ext2 for system, VFAT for the rest of free space. Total of two partitions, standard PC BIOS partition table (cfdisk).

Install Arch Linux from ISO to flash stick. No GUIs or fanciness, just terminal stuff. Use ext2 on the 1st (Arch system) partition. Make a VFAT filesystem on the 2nd partition.

mkdir a folder like "/Flash\ Stick/" on the stick's 1st ext2 system partition as mount point for 2nd VFAT partition. In fstab, use 'auto' for automount of the 2nd partition, and the usual \040 for the mount point's space char.

Now restart. "/Flash\ Stick" works fine at this point.

Now shutdown. Watch the scrolling notices carefully.

You'll catch the faiure from umount. It reports something like, no such folder "/Flash" cut at the space char.
This task depends upon

Closed by  Tom Gundersen (tomegun)
Tuesday, 13 November 2012, 13:20 GMT
Reason for closing:  Fixed
Additional comments about closing:  in git
Comment by Dave (DaveCode) - Saturday, 15 September 2012, 22:01 GMT
Oops the partition table is

1. VFAT
2. ext2

Reason for VFAT first is to read stick on Mac/Win systems which prefer/need it first. Don't know that it matters for the bug but duly noted. Thanks all.
Comment by Dave Reisner (falconindy) - Saturday, 15 September 2012, 22:12 GMT
I agree that this is broken, but I can't see why it would be broken in the way you describe. It has nothing at all to do with fstype, and everything to do with not unescaping targets in the umount_all function from /etc/rc.d/functions.
Comment by Alex Rampp (BitSchupser) - Saturday, 22 September 2012, 20:54 GMT
Take a look at line 649 of /etc/rc.d/functions. The output of findmnt will be piped into a while read loop. The problem is, that read uses the space as field delimiter for the three variables it reads. I would suggest putting the target variable to the end of the argument list because read stores all fields that it didn't consume yet in the last variable (would be our whole mount point including spaces). To make this clearer take a look at this diff:

*** 645,652 ****
umount_all() {
# $1: restrict to fstype

! findmnt -mrunRo TARGET,FSTYPE,OPTIONS / | {
! while read -r target fstype options; do
# match only targeted fstypes
if [[ $1 && $1 != "$fstype" ]]; then
continue
--- 645,652 ----
umount_all() {
# $1: restrict to fstype

! findmnt -mrunRo FSTYPE,OPTIONS,TARGET / | {
! while read -r fstype options target; do
# match only targeted fstypes
if [[ $1 && $1 != "$fstype" ]]; then
continue

I have not tested it but I think it should fix it.
Comment by Dave Reisner (falconindy) - Saturday, 22 September 2012, 21:04 GMT
No, it won't work. The -r flag to findmnt means that a mountpoint such as "foo bar" will be displayed as "foo\x20bar". THIS is why it fails. Reordering the columns won't do anything to solve this.
Comment by Lukas Jirkovsky (6xx) - Sunday, 21 October 2012, 13:37 GMT
What about the following change (not tested)

--- functions.orig 2012-10-21 15:36:27.729225154 +0200
+++ functions 2012-10-21 15:37:53.169255242 +0200
@@ -645,6 +645,8 @@ umount_all() {

findmnt -mrunRo TARGET,FSTYPE,OPTIONS / | {
while read -r target fstype options; do
+ # interpret the ascii chars, such as \x20 (space)
+ target=`echo -e $target`
# match only targeted fstypes
if [[ $1 && $1 != "$fstype" ]]; then
continue
Comment by Dave Reisner (falconindy) - Sunday, 21 October 2012, 14:01 GMT
Problem is that if you ever encounter foo\bar, you'll expand that to fooar, as \b will be interpreted as a backspace. There's a few options as I see it, in my order of preference:

1) Implement recursive umount in libmount and/or umount (i.e. we could just do umount -R -t tmpfs /; umount -R /).
2) Add an unmangle function[0] which only respects octal and hex escapes.
3) Reorder the output columns to the findmnt call, ditch the '-r' flag, and hope that options never contains a space (they can).

[0] https://github.com/falconindy/arch-install-scripts/blob/master/common#L69
Comment by Lukas Jirkovsky (6xx) - Sunday, 21 October 2012, 16:39 GMT
falconindy: this shouldn't happen, because '\' in foo\bar is replaced by \x5c
Comment by Dave Reisner (falconindy) - Sunday, 21 October 2012, 16:53 GMT
Ah, so it does. Well, my #1 preference still holds.
Comment by Tom Gundersen (tomegun) - Sunday, 04 November 2012, 16:19 GMT
If anyone wants this fixed, post a patch to the projects ml. I'm not going to be working on this.

Loading...