From e295f4f388d9ab0e0bdafd97c1ac9fc8f38edc5e Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 4 Feb 2003 11:48:27 +0000 Subject: [PATCH] `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. --- src/df.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/df.c b/src/df.c index 83a74fe82f..5a767f3da8 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) { -- 2.47.3