]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Now, df always displays the device file name corresponding to the
authorJim Meyering <jim@meyering.net>
Thu, 20 Feb 2003 10:37:14 +0000 (10:37 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 20 Feb 2003 10:37:14 +0000 (10:37 +0000)
listed mount point under `Filesystem'.  Before, for an unmounted
block- or character-special file argument, it would display the
command-line argument instead.

(show_disk): Return a value indicating whether
there was a match.  Don't try to find a mount point here.
(show_entry): If show_disk doesn't find a match, call show_point.

src/df.c

index 91db548ec5ee5ae647578e8f033d4d8cb0690d01..a546ab26f41c50a40536e74455c420b20e0bd7d8 100644 (file)
--- a/src/df.c
+++ b/src/df.c
@@ -506,35 +506,23 @@ done:
   return mp;
 }
 
-/* Identify the directory, if any, that device
-   DISK is mounted on, and show its disk usage.
+/* If DISK corresponds to a mount point, show its usage
+   and return nonzero.  Otherwise, return zero.
    STATP must be the result of `stat (DISK, STATP)'.  */
-
-static void
+static int
 show_disk (const char *disk, const struct stat *statp)
 {
   struct mount_entry *me;
-  char *mount_point;
 
   for (me = mount_list; me; me = me->me_next)
     if (STREQ (disk, me->me_devname))
       {
        show_dev (me->me_devname, me->me_mountdir, me->me_type,
                  me->me_dummy, me->me_remote);
-       return;
+       return 1;
       }
 
-  mount_point = find_mount_point (disk, statp);
-  if (!mount_point)
-    {
-      error (0, errno, "%s", quote (disk));
-      exit_status = EXIT_FAILURE;
-    }
-
-  /* No filesystem is mounted on DISK. */
-  show_dev (disk, mount_point, NULL, 0, 0);
-  if (mount_point)
-    free (mount_point);
+  return 0;
 }
 
 /* Figure out which device file or directory POINT is mounted on
@@ -670,10 +658,11 @@ show_point (const char *point, const struct stat *statp)
 static void
 show_entry (const char *path, const struct stat *statp)
 {
-  if (S_ISBLK (statp->st_mode) || S_ISCHR (statp->st_mode))
-    show_disk (path, statp);
-  else
-    show_point (path, statp);
+  if ((S_ISBLK (statp->st_mode) || S_ISCHR (statp->st_mode))
+      && show_disk (path, statp))
+    return;
+
+  show_point (path, statp);
 }
 
 /* Show all mounted filesystems, except perhaps those that are of