summaryrefslogtreecommitdiff
path: root/src/df.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-02-20 10:37:14 +0000
committerJim Meyering <jim@meyering.net>2003-02-20 10:37:14 +0000
commitfca1c1173cc00b47b5477da645806c3a357c442f (patch)
tree0b0607c503880bae2637d8f077c13486bff57e54 /src/df.c
parent59e474dc56026911301e5e1e243f4d4c0e40c9bb (diff)
downloadcoreutils-fca1c1173cc00b47b5477da645806c3a357c442f.tar.xz
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.
Diffstat (limited to 'src/df.c')
-rw-r--r--src/df.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/df.c b/src/df.c
index 91db548ec..a546ab26f 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