From fca1c1173cc00b47b5477da645806c3a357c442f Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 20 Feb 2003 10:37:14 +0000 Subject: [PATCH] Now, df always displays the device file name corresponding to the 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 | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/df.c b/src/df.c index 91db548ec5..a546ab26f4 100644 --- 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 -- 2.47.3