Hello, there is a problem with df when run on an automounted volume: $ df /misc/test; df /misc/test Filesystem 1K-blocks Used Available Use% Mounted on - 0 0 0 - /misc Filesystem 1K-blocks Used Available Use% Mounted on /tmp 15013664 7302844 6935860 52% /misc/test
The /misc/test is an automounted filesystem and as you can see the first run did not trigger the automount. According to Ian Kent (autofs maintainer), an indirect map that uses the browse option won't trigger mounts for system calls such as stat(2), statfs(2) etc. to avoid mount storms when using such things as colour ls. He also suggested to use some other call before stat(2) to make df automount the filesytem. The following patch is a paraphrase of his suggestion rewritten according to Jim Meyering's instructions. --- From 4c064d1b4cc0666bdc5835a72ddf6018f08b4c2c Mon Sep 17 00:00:00 2001 From: Tomas Smetana <[email protected]> Date: Tue, 28 Apr 2009 11:21:49 +0200 Subject: [PATCH] df: use open(2) to trigger automounting --- src/df.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/src/df.c b/src/df.c index 7b8a082..9daa398 100644 --- a/src/df.c +++ b/src/df.c @@ -993,12 +993,16 @@ main (int argc, char **argv) stats = xnmalloc (argc - optind, sizeof *stats); for (i = optind; i < argc; ++i) { - if (stat (argv[i], &stats[i - optind])) + int fd; + if ((fd = open(argv[i], O_RDONLY | O_NOCTTY)) < 0 + || fstat (fd, &stats[i - optind])) { error (0, errno, "%s", quote (argv[i])); exit_status = EXIT_FAILURE; argv[i] = NULL; } + if (0 <= fd) + close(fd); } } -- 1.6.0.6 _______________________________________________ Bug-coreutils mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-coreutils
