diff options
author | Tomas Smetana <t.smetana@gmail.com> | 2009-04-28 11:21:49 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-04-28 14:32:17 +0200 |
commit | dbd17157d7e693b8de9737f802db0e235ff5a3e6 (patch) | |
tree | c820a31396b6091e8e4ffbe22267cae29070c7a5 /src/df.c | |
parent | cb9fd937437cf4f9347925f6b9c82f4e92bae6e5 (diff) | |
download | coreutils-dbd17157d7e693b8de9737f802db0e235ff5a3e6.tar.gz coreutils-dbd17157d7e693b8de9737f802db0e235ff5a3e6.tar.bz2 coreutils-dbd17157d7e693b8de9737f802db0e235ff5a3e6.zip |
df: use open(2), not stat, to trigger automounting
* 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
Diffstat (limited to 'src/df.c')
-rw-r--r-- | src/df.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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); } } |