Bug 75421 - umount fails but it removes entry from /etc/mtab
umount fails but it removes entry from /etc/mtab
Product: Red Hat Linux
Classification: Retired
Component: mount (Show other bugs)
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Elliot Lee
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2002-10-08 07:56 EDT by diego.santacruz
Modified: 2007-04-18 12:47 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2003-01-14 12:10:38 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Fix of problem (save errno across perror() call) (712 bytes, patch)
2002-10-08 08:00 EDT, diego.santacruz
no flags Details | Diff

  None (edit)
Description diego.santacruz 2002-10-08 07:56:37 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 Galeon/1.2.5 (X11; Linux i686; U;) Gecko/20020809

Description of problem:
When using the -f flag and stderr is directed to /dev/null if the umount syscall
fails, umount believes it succeded and removes the entry from /etc/mtab.

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

How reproducible:

Steps to Reproduce:
1. Mount a nfs share at /mnt/test
2. 'cd /mnt/test' so that share is not umountable
3. 'umount -f /mnt/test 2>/dev/null' (stderr must be redirected)

Actual Results:  The share is still mounted (as expected) but there is no entry
in /etc/mtab for it.

Expected Results:  The umount command should fail and not modify the /etc/mtab file

Additional info:

This occurs because errno is not saved across a perror() call. umount2() is
called and fails (because mount point is busy), then perror() fails (because
stderr redirected to /dev/null) and modifies errno, yet errno is consulted as
being the error code of the failed umount2() call.

The stderr redirected to /dev/null occurs in all initscripts since commands are
run through initlog. It bites particularly hard in '/etc/init.d/netfs stop'. So
it's important to fix.

This was already reported back in Dec-2001 for RedHat Linux 7.1, but seems to
have been ignored since then. See bug #57286
Comment 1 diego.santacruz 2002-10-08 08:00:45 EDT
Created attachment 79344 [details]
Fix of problem (save errno across perror() call)
Comment 2 Elliot Lee 2003-01-14 12:10:38 EST
fixed in 2.11y-2

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