Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 76831 - function halt_get_remaining() in 'halt' script not entirely correct
Summary: function halt_get_remaining() in 'halt' script not entirely correct
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: initscripts
Version: 8.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact: Brock Organ
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-10-27 19:33 UTC by Michal Jaegermann
Modified: 2014-03-17 02:32 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2003-01-14 05:02:54 UTC


Attachments (Terms of Use)

Description Michal Jaegermann 2002-10-27 19:33:39 UTC
Description of Problem:

The problem is that if a 'tmpfs' file system will be mounted following
suggestions from /usr/src/linux-2.4/Documentation/filesystems/tmpfs.txt,
i.e. 'mount -t tmpfs tmpfs /some/where', then the first field shown by
/proc/mounts will be not "none" and this file system will be printed
twice by the first and third invocations of awk.  Here is a corrected
function which, BTW, is calling awk only once:

halt_get_remaining() {
    awk '$2 ~ /^\/$|^\/proc|^\/dev/{next}
    $3 == "tmpfs" {print $2 ; next}
    /(^#|loopfs|autofs|devfs|^none|^\/dev\/root)/ {next}
    {print $2}' /proc/mounts
}

and here is an alternative implemented only in shell

halt_get_remaining() {
    local mpnt fs type rest all
    while read mpnt fs type rest ; do
        case "$fs" in
            /|/proc*|/dev*) continue ;;
        esac
        if [ "$type"  = tmpfs ] ; then
            echo $fs
            continue
        fi
        all="$mpnt $fs $type"
        case "$all" in
            \#*|*loopfs*|*autofs*|*devfs*|*tmpfs*|none*|/dev/root*) continue ;;
        esac
        echo $fs
    done < /proc/mounts
}

Checks for /dev/root and comment lines are likely superflous, but...
Also likely one check for "$all" can be replaced by separate, simpler, checks
for "$mpnt" and "$type" but this changes somewhat semantics of the original.

The other thing is that if procfs happens to be mounted also in some other
place but /proc, which happens, we likely want to print that as well so
this should really be
    $3 == "tmpfs" || $3 == "procfs {print $2 ; next}
and a similar obvious change in a shell version.

Comment 1 Michal Jaegermann 2002-10-27 19:41:30 UTC
Er.. '$3 == "tmpfs" || $3 == "proc" {print $2 ; next}' in the above
(don't type on-line!) but otherwise like it should be.

Comment 2 Bill Nottingham 2003-01-14 05:02:54 UTC
Added in 7.03-1.


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