]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(show_dev): Omit local devices if show_all_fs is negative.
authorJim Meyering <jim@meyering.net>
Sat, 25 Jul 1998 14:36:07 +0000 (14:36 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 25 Jul 1998 14:36:07 +0000 (14:36 +0000)
(show_all_fs): If negative, omit non-local filesystems.
All uses of (all_fs != 0) changed to (all_fs > 0).
(long_options, usage, main): Add -l or --local option.
(main): When asking for df of an explicit file name, get all
the mount points, so that we're more likely to find it when
we look it up.

src/df.c

index 3b49c7708030209389a7988b7dfe7ce405e63717..60d554a60ed845cc13022787aa08d102c1247a69 100644 (file)
--- a/src/df.c
+++ b/src/df.c
@@ -47,8 +47,8 @@ char *program_name;
 /* If nonzero, show inode information. */
 static int inode_format;
 
-/* If nonzero, show even filesystems with zero size or
-   uninteresting types. */
+/* If positive, show all entries; if zero, omit size-zero entries and
+   automounter dummies; if negative, also omit non-local filesystems.  */
 static int show_all_fs;
 
 /* If nonzero, output data for each filesystem corresponding to a
@@ -117,6 +117,7 @@ static struct option const long_options[] =
   {"human-readable", no_argument, 0, 'h'},
   {"si", no_argument, 0, 'H'},
   {"kilobytes", no_argument, 0, 'k'},
+  {"local", no_argument, &show_all_fs, -1},
   {"megabytes", no_argument, 0, 'm'},
   {"portability", no_argument, &posix_format, 1},
   {"print-type", no_argument, &print_type, 1},
@@ -213,15 +214,18 @@ show_dev (const char *disk, const char *mount_point, const char *fstype)
   struct fs_usage fsu;
   const char *stat_file;
 
-  if (!selected_fstype (fstype) || excluded_fstype (fstype))
-    return;
-
   /* If MOUNT_POINT is NULL, then the filesystem is not mounted, and this
      program reports on the filesystem that the special file is on.
      It would be better to report on the unmounted filesystem,
      but statfs doesn't do that on most systems.  */
   stat_file = mount_point ? mount_point : disk;
 
+  if (show_all_fs < 0 && fstype && REMOTE_FS_TYPE (fstype))
+    return;
+
+  if (!selected_fstype (fstype) || excluded_fstype (fstype))
+    return;
+
   if (get_fs_usage (stat_file, disk, &fsu))
     {
       error (0, errno, "%s", stat_file);
@@ -229,7 +233,7 @@ show_dev (const char *disk, const char *mount_point, const char *fstype)
       return;
     }
 
-  if (fsu.fsu_blocks == 0 && !show_all_fs && !show_listed_fs)
+  if (fsu.fsu_blocks == 0 && show_all_fs <= 0 && !show_listed_fs)
     return;
 
   if (! disk)
@@ -548,6 +552,7 @@ or all filesystems by default.\n\
   -H, --si              likewise, but use powers of 1000 not 1024\n\
   -i, --inodes          list inode information instead of block usage\n\
   -k, --kilobytes       like --block-size=1024\n\
+  -l, --local           limit listing to local filesystems\n\
   -m, --megabytes       like --block-size=1048576\n\
       --no-sync         do not invoke sync before getting usage info (default)\n\
   -P, --portability     use the POSIX output format\n\
@@ -588,7 +593,7 @@ main (int argc, char **argv)
   posix_format = 0;
   exit_status = 0;
 
-  while ((c = getopt_long (argc, argv, "aiF:hHkmPTt:vx:", long_options, NULL))
+  while ((c = getopt_long (argc, argv, "aiF:hHklmPTt:vx:", long_options, NULL))
         != -1)
     {
       switch (c)
@@ -610,6 +615,9 @@ main (int argc, char **argv)
        case 'k':
          output_block_size = 1024;
          break;
+       case 'l':
+         show_all_fs = -1;
+         break;
        case 'm':
          output_block_size = 1024 * 1024;
          break;
@@ -708,7 +716,7 @@ main (int argc, char **argv)
     read_filesystem_list ((fs_select_list != NULL
                           || fs_exclude_list != NULL
                           || print_type),
-                         show_all_fs);
+                         optind == argc ? show_all_fs : 1);
 
   if (mount_list == NULL)
     error (1, errno, _("cannot read table of mounted filesystems"));