summaryrefslogtreecommitdiff
path: root/src/df.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-01-11 09:39:40 +0000
committerJim Meyering <jim@meyering.net>2003-01-11 09:39:40 +0000
commit35d5499fca61926e0cc308def317d1b4acdea902 (patch)
treed402f4397ad6d00c6463fe0438a30858bd1362fc /src/df.c
parent8a5ad5c78c99c6f006a853d125584940b5d5bd1a (diff)
downloadcoreutils-35d5499fca61926e0cc308def317d1b4acdea902.tar.gz
Include "canonicalize.h".
Use canonicalize_file_name unconditionally.
Diffstat (limited to 'src/df.c')
-rw-r--r--src/df.c76
1 files changed, 4 insertions, 72 deletions
diff --git a/src/df.c b/src/df.c
index e498e8a3f..91580787c 100644
--- a/src/df.c
+++ b/src/df.c
@@ -30,6 +30,7 @@
#include <assert.h>
#include "system.h"
+#include "canonicalize.h"
#include "dirname.h"
#include "error.h"
#include "fsusage.h"
@@ -530,7 +531,6 @@ show_point (const char *point, const struct stat *statp)
struct stat disk_stats;
struct mount_entry *me;
struct mount_entry *matching_dummy = NULL;
- char *needs_freeing = NULL;
/* If POINT is an absolute path name, see if we can find the
mount point without performing any extra stat calls at all. */
@@ -551,78 +551,14 @@ show_point (const char *point, const struct stat *statp)
goto show_matching_dummy;
}
- /* Ideally, the following mess of #if'd code would be in a separate
- file, and there'd be a single function call here. FIXME, someday. */
-
-#if HAVE_REALPATH || HAVE_RESOLVEPATH || HAVE_CANONICALIZE_FILE_NAME
/* Calculate the real absolute path for POINT, and use that to find
the mount point. This avoids statting unavailable mount points,
which can hang df. */
{
- char const *abspoint = point;
- char *resolved;
- ssize_t resolved_len;
+ char *resolved = canonicalize_file_name (point);
+ ssize_t resolved_len = resolved ? strlen (resolved) : -1;
struct mount_entry *best_match = NULL;
-# if HAVE_CANONICALIZE_FILE_NAME
- resolved = canonicalize_file_name (abspoint);
- resolved_len = resolved ? strlen (resolved) : -1;
-# else
-# if HAVE_RESOLVEPATH
- /* All known hosts with resolvepath (e.g. Solaris 7) don't turn
- relative names into absolute ones, so prepend the working
- directory if the path is not absolute. */
-
- if (*point != '/')
- {
- static char const *wd;
-
- if (! wd)
- {
- struct stat pwd_stats;
- struct stat dot_stats;
-
- /* Use PWD if it is correct; this is usually cheaper than
- xgetcwd. */
- wd = getenv ("PWD");
- if (! (wd
- && stat (wd, &pwd_stats) == 0
- && stat (".", &dot_stats) == 0
- && SAME_INODE (pwd_stats, dot_stats)))
- wd = xgetcwd ();
- }
-
- if (wd)
- {
- needs_freeing = path_concat (wd, point, NULL);
- if (needs_freeing)
- abspoint = needs_freeing;
- }
- }
-# endif
-
-# if HAVE_RESOLVEPATH
- {
- size_t resolved_size = strlen (abspoint);
- while (1)
- {
- resolved_size = 2 * resolved_size + 1;
- resolved = xmalloc (resolved_size);
- resolved_len = resolvepath (abspoint, resolved, resolved_size);
- if (resolved_len < resolved_size)
- break;
- free (resolved);
- }
- }
-# else
- /* Use realpath only as a last resort.
- It provides a very poor interface. */
- resolved = xmalloc (PATH_MAX + 1);
- resolved = (char *) realpath (abspoint, resolved);
- resolved_len = resolved ? strlen (resolved) : -1;
-# endif
-# endif
-
if (1 <= resolved_len && resolved[0] == '/')
{
size_t best_match_len = 0;
@@ -653,7 +589,6 @@ show_point (const char *point, const struct stat *statp)
goto show_me;
}
}
-#endif
for (me = mount_list; me; me = me->me_next)
{
@@ -705,16 +640,13 @@ show_point (const char *point, const struct stat *statp)
error (0, errno, "%s", quote (point));
}
- goto free_then_return;
+ return;
show_matching_dummy:
me = matching_dummy;
show_me:
show_dev (me->me_devname, me->me_mountdir, me->me_type, me->me_dummy,
me->me_remote);
- free_then_return:
- if (needs_freeing)
- free (needs_freeing);
}
/* Determine what kind of node PATH is and show the disk usage