[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] remove "dev=" mount option special processing for df

From: Paul A. Clarke
Subject: [PATCH] remove "dev=" mount option special processing for df
Date: Tue, 18 Oct 2005 09:14:26 -0500

I have a question about some rather obscure code related to the "df"
command.  In lib/mountlist.c, there is this code:

        devopt = strstr (mnt->mnt_opts, "dev=");
        if (devopt)
          me->me_dev = strtoul (devopt + 4, NULL, 16);
          me->me_dev = (dev_t) -1;      /* Magic; means not known yet. */

This code appears to date pretty far back, even pre 1992.  The question
is why is the df command parsing the mount options looking for "dev=",
and in a not-so-rigorous way at that?

I dug through google searches, and, as the man pages suggest, there is a
hint related to old SunOS code.
http://www.manpages.info/sunos/mnttab.4.html says:
>      The mnttab file system provides the previously  undocumented
>      dev=xxx  option  in  the option string for each mounted file
>      system. This is provided for legacy applications that  might
>      have been using the dev=information option.
>      Using dev=option in applications  is  strongly  discouraged. [...]

I can find no such references in any Linux documentation, and no "dev="
options magically appear in /etc/mtab or /proc/mounts.  Indeed, the
above referenced code from mountlist.c will accidentally trip over the
"logdev=" and "rtdev=" options for XFS, as well as the "dev=" option
used by IBM's GPFS.  There may be other filesystems which support
options like ".*dev=.*".

Now, when does any of this code come into play?  It is in a fairly
obscure case:
- a filesystem which happens to have the string "dev=" in its mount options
- the current working directory is in this filesystem
- the current working directory is unlinked
- df is performed on the current working directory

$ cd /devequalfs; mkdir dummy; cd dummy; df .; rmdir ../dummy; df .
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/devequalfs        7880200   1641512   5838388  22% /devequalfs
Filesystem           1K-blocks      Used Available Use% Mounted on
-                      7880200   1641512   5838388  22% /devequalfs

My suggestion is to remove the special processing code for "dev=", at
least for systems which don't uniformly support a "dev=" option.  Of
the systems for which the comments imply this code is used (4.3BSD, SunOS,
HP-UX, Dynix, Irix) and the one that I know does (Linux), I'm only
familiar with (and have easy access to) Linux.  (For those that do
support it, if any, I'd recommend making the processing more rigorous,
as searching for ".*dev=.*" will have false positives.)

Attached is a trivial and minimal patch which removes the code which
does the "dev=" special processing, although only for Linux.

I welcome your comments.
Paul Clarke, IBM

Attachment: coreutils-5.2.1-nodevequal.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]