summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-02-04 11:48:27 +0000
committerJim Meyering <jim@meyering.net>2003-02-04 11:48:27 +0000
commite295f4f388d9ab0e0bdafd97c1ac9fc8f38edc5e (patch)
tree4cde1e9f04780fd50a5c3fd6405740898219b4cb
parent144418cd9db07666edb4b11f21a620a75acce625 (diff)
downloadcoreutils-e295f4f388d9ab0e0bdafd97c1ac9fc8f38edc5e.tar.xz
`df /dev/block-or-char-device-file--not-mounted' now reports
the name of the file system on which the file resides, usually `/'. Before, it would leave the `Mounted on' field blank. (show_disk): Add parameter: STATP. If we don't find a matching device name, then resort to calling find_mount_point.
-rw-r--r--src/df.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/df.c b/src/df.c
index 83a74fe82..5a767f3da 100644
--- a/src/df.c
+++ b/src/df.c
@@ -504,12 +504,14 @@ done:
}
/* Identify the directory, if any, that device
- DISK is mounted on, and show its disk usage. */
+ DISK is mounted on, and show its disk usage.
+ STATP must be the result of `stat (DISK, STATP)'. */
static void
-show_disk (const char *disk)
+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))
@@ -518,13 +520,23 @@ show_disk (const char *disk)
me->me_dummy, me->me_remote);
return;
}
+
+ 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, (char *) NULL, (char *) NULL, 0, 0);
+ show_dev (disk, mount_point, NULL, 0, 0);
+ if (mount_point)
+ free (mount_point);
}
/* Figure out which device file or directory POINT is mounted on
and show its disk usage.
- STATP is the results of `stat' on POINT. */
+ STATP must be the result of `stat (POINT, STATP)'. */
static void
show_point (const char *point, const struct stat *statp)
{