]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
df: use open(2), not stat, to trigger automounting
authorTomas Smetana <t.smetana@gmail.com>
Tue, 28 Apr 2009 09:21:49 +0000 (11:21 +0200)
committerJim Meyering <meyering@redhat.com>
Tue, 28 Apr 2009 12:32:17 +0000 (14:32 +0200)
* src/df.c (main): When iterating over command-line arguments,
attempting to ensure each backing file system is mounted, use
open, not stat.  stat is no longer sufficient to trigger
automounting, in some cases.  Based on a suggestion from Ian Kent.
More details in http://bugzilla.redhat.com/497830

THANKS
src/df.c

diff --git a/THANKS b/THANKS
index 876a6b6652bbbc53ea6975e955bfc29252707215..cf801c57acba76dc1d921aa6d9c82dfd37a9a008 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -235,6 +235,7 @@ Hugh Daniel                         hugh@xanadu.com
 Ian Bruce                           ian.bruce@myrealbox.com
 Iain Calder                         ic56@rogers.com
 Ian Jackson                         ijackson@chiark.greenend.org.uk
+Ian Kent                            ikent@redhat.com
 Ian Lance Taylor                    ian@cygnus.com
 Ian Turner                          vectro@pipeline.com
 Iida Yosiaki                        iida@gnu.org
index 7b8a0824e115354d9ee7502a78c7ea0a5e6e1fea..a3eb98a6115ed322e1bb80b797817594bc540684 100644 (file)
--- a/src/df.c
+++ b/src/df.c
@@ -1,5 +1,5 @@
 /* df - summarize free disk space
-   Copyright (C) 91, 1995-2008 Free Software Foundation, Inc.
+   Copyright (C) 91, 1995-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -993,12 +993,15 @@ 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 = open (argv[i], O_RDONLY | O_NOCTTY);
+         if (fd < 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);
        }
     }