Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 64034 - netmount stop script does not work with spaces in mount point
Summary: netmount stop script does not work with spaces in mount point
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2004-09-14 12:01 UTC by Ojec Borec
Modified: 2004-12-02 02:09 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
netmount (netmount,2.80 KB, text/plain)
2004-12-01 11:36 UTC, SpanKY
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ojec Borec 2004-09-14 12:01:31 UTC
I have following record in /etc/fstab:

ojo:/a\040b /mnt/a\040b nfs rw,nosuid,nodev,v3,rsize=8192,wsize=8192,hard,intr,udp,lock,addr=ojo 0 0

I used \040 for space (see man fstab).

When I try to run script
/etc/init.d/netmount stop
it prints "Failed to unmount filesystems this retry"

So I modified it by adding stop() function this way ( there are 3 new/modified lines started with (*) ):

stop() {
        # umount -art $fstypes doesn't seem to work, so...
        # NB: we have to check if any network filesystems is mounted,
        #     else mount do not exit cleanly

        local sig retry
        local remaining="$(awk '$3 ~ /coda|nfs|ncpfs|smbfs/ { if ($2 != "/") print $2 }' /proc/mounts | sort -r)"

        # just keep things nice and uniform
        if [ -z "${remaining}" ]
        then
                ebegin "Unmounting network filesystems"
                eend 0
        else
                sig=
                retry=3
                while [ -n "${remaining}" -a "${retry}" -gt 0 ]
                do
(*)                     remaining=`echo "${remaining}" | sed 's/\\\040/ /g'`

                        if [ "${retry}" -lt 3 ]
                        then
                                ebegin "Unmounting network filesystems (retry)"
(*)                             umount "${remaining}" &>/dev/null
                                eend $? "Failed to unmount filesystems this retry"
                        else
                                ebegin "Unmounting network filesystems"
(*)                             umount "${remaining}" &>/dev/null
                                eend $? "Failed to unmount filesystems"
                        fi
                        remaining="$(awk '$3 ~ /coda|nfs|ncpfs|smbfs/ { if ($2 != "/") print $2 }' /proc/mounts | sort -r)"
                        [ -z "${remaining}" ] && break
                        /bin/fuser -k -m ${sig} ${remaining} &>/dev/null
                        sleep 5
                        retry=$((${retry} -1))
                        sig=-9
                done
        fi
}

At least it works for me.

Reproducible: Always
Steps to Reproduce:
Comment 1 SpanKY gentoo-dev 2004-09-14 15:56:37 UTC
what if you changed stop to read:
stop() {
    ebegin "Unmounting network filesystems"
    umount -art coda,nfs,ncpfs,smbfs,cifs
    eend $? "Failed to unmount filesystems"
}

there's a comment that says '-art' doesnt work, but that was back around Oct 2001, so i wonder if newer versions of util-linux fix it ...
i know `umount -art nfs` unmounted all my nfs mounts ...
Comment 2 Ojec Borec 2004-09-14 23:43:49 UTC
Yes I saw a comment in that file and '-art' works for me.

# qpkg -I -v util-linux
sys-apps/util-linux-2.12-r4
Comment 3 Aron Griffis (RETIRED) gentoo-dev 2004-09-15 11:11:39 UTC
Ok, this is in rc-scripts cvs now (Spanky's simpler solution)
Comment 4 SpanKY gentoo-dev 2004-10-14 09:10:55 UTC
baselayout-1.11.2+
Comment 5 SpanKY gentoo-dev 2004-11-30 21:09:03 UTC
the extra logic is needed in case the remote filesystems are in use ...
Comment 6 SpanKY gentoo-dev 2004-12-01 11:36:08 UTC
Created attachment 45067 [details]
netmount

the original suggested is not correct ... it may work if there is only 1
filesystem left to unmount, but not if the user has multiple ones and each one
may have spaces

try this netmount and make sure it works for you please :)
Comment 7 SpanKY gentoo-dev 2004-12-01 19:35:38 UTC
added a slightly updated netmount to cvs

watch for it in 1.11.7 !
Comment 8 Ojec Borec 2004-12-02 02:09:27 UTC
2004-12-02 11:08 GMT+2
http://www.gentoo.org/cgi-bin/viewcvs.cgi/sys-apps/baselayout/

I can only see baselayout-1.11.6-r1.ebuild.