🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Mike Rendell Fri, 11 Dec 1992 11:30
fileutils-3.4: diffs to add -l (--local) option to df
#1153
Author: Mike Rendell
Date: Fri, 11 Dec 1992 11:30
168 lines
5710 bytes
The following diffs add a -l (--local) flag to df to tell it to only list
local disks.  A disk is `local' if its device is a block or character
special device.  This is useful when you don't want to see (or hang on) lots
of NFS filesystems.


*** src/df.c.orig	Fri Jul 17 01:08:40 1992
--- src/df.c	Fri Dec 11 15:10:04 1992
***************
*** 15,27 ****
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  
! /* Usage: df [-aikP] [-t fstype] [--all] [--inodes] [--type fstype]
!    [--kilobytes] [--portability] [path...]
  
     Options:
     -a, --all		List all filesystems, even zero-size ones.
     -i, --inodes		List inode usage information instead of block usage.
     -k, --kilobytes	Print sizes in 1K blocks instead of 512-byte blocks.
     -P, --portability	Use the POSIX output format (one line per filesystem).
     -t, --type fstype	Limit the listing to filesystems of type `fstype'.
  			Multiple -t options can be given.
--- 15,29 ----
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  
! /* Usage: df [-aiklP] [-t fstype] [--all] [--inodes] [--type fstype]
!    [--kilobytes] [--local] [--portability] [path...]
  
     Options:
     -a, --all		List all filesystems, even zero-size ones.
     -i, --inodes		List inode usage information instead of block usage.
     -k, --kilobytes	Print sizes in 1K blocks instead of 512-byte blocks.
+    -l, --local		Limit the listing to local filesystems, ie, ones whose
+ 			disk is a block or character special device.
     -P, --portability	Use the POSIX output format (one line per filesystem).
     -t, --type fstype	Limit the listing to filesystems of type `fstype'.
  			Multiple -t options can be given.
***************
*** 60,65 ****
--- 62,70 ----
  /* If nonzero, use 1K blocks instead of 512-byte blocks. */
  int kilobyte_blocks;
  
+ /* If nonzero, report only on local disks.  */
+ int show_local_only;
+ 
  /* If nonzero, use the POSIX output format.  */
  int posix_format;
  
***************
*** 98,103 ****
--- 103,109 ----
    {"all", 0, &show_all_fs, 1},
    {"inodes", 0, &inode_format, 1},
    {"kilobytes", 0, &kilobyte_blocks, 1},
+   {"local", 0, &show_local_only, 1},
    {"portability", 0, &posix_format, 1},
    {"type", 1, 0, 't'},
    {NULL, 0, NULL, 0}
***************
*** 119,125 ****
    posix_format = 0;
    exit_status = 0;
  
!   while ((i = getopt_long (argc, argv, "aikPt:v", long_options, (int *) 0))
  	 != EOF)
      {
        switch (i)
--- 125,131 ----
    posix_format = 0;
    exit_status = 0;
  
!   while ((i = getopt_long (argc, argv, "aiklPt:v", long_options, (int *) 0))
  	 != EOF)
      {
        switch (i)
***************
*** 135,140 ****
--- 141,149 ----
  	case 'k':
  	  kilobyte_blocks = 1;
  	  break;
+ 	case 'l':
+ 	  show_local_only = 1;
+ 	  break;
  	case 'P':
  	  posix_format = 1;
  	  break;
***************
*** 293,298 ****
--- 302,319 ----
    long inodes_percent_used;
    char *stat_file;
  
+   /* A filesystem is considered local if DISK is a block/char special device.
+      This means /proc and /fd filesystems, as well as NFS filesystems,
+      are not considered local.  */
+   if (show_local_only)
+     {
+       struct stat statb;
+ 
+       if (stat (disk, &statb) != 0
+ 	  || !(S_ISBLK(statb.st_mode) || S_ISCHR(statb.st_mode)))
+ 	return;
+     }
+ 
    if (!fs_to_list (fstype))
      return;
  
***************
*** 391,398 ****
  usage ()
  {
    fprintf (stderr, "\
! Usage: %s [-aikPv] [-t fstype] [--all] [--inodes] [--type fstype]\n\
!        [--kilobytes] [--portability] [path...]\n",
  	   program_name);
    exit (1);
  }
--- 412,419 ----
  usage ()
  {
    fprintf (stderr, "\
! Usage: %s [-aiklPv] [-t fstype] [--all] [--inodes] [--type fstype]\n\
!        [--kilobytes] [--local] [--portability] [path...]\n",
  	   program_name);
    exit (1);
  }


*** man/df.1.orig	Fri Jul 17 01:13:12 1992
--- man/df.1	Mon Nov 30 13:49:34 1992
***************
*** 3,9 ****
  df \- summarize free disk space
  .SH SYNOPSIS
  .B df
! [\-aikPv] [\-t fstype] [\-\-all] [\-\-inodes] [\-\-type fstype]
  [\-\-kilobytes] [\-\-portability] [path...]
  .SH DESCRIPTION
  This manual page
--- 3,9 ----
  df \- summarize free disk space
  .SH SYNOPSIS
  .B df
! [\-aiklPv] [\-t fstype] [\-\-all] [\-\-inodes] [\-\-type fstype]
  [\-\-kilobytes] [\-\-local] [\-\-portability] [path...]
  .SH DESCRIPTION
  This manual page
***************
*** 45,50 ****
--- 45,55 ----
  .I "\-k, \-\-kilobytes"
  Print sizes in 1K blocks instead of 512-byte blocks.  This overrides
  the environment variable POSIXLY_CORRECT.
+ .TP
+ .I "\-l, \-\-local"
+ Limit the listing to `local' filesystems, where a `local' filesystem
+ is one that is mounted from block or character device.  This is a
+ simple way of not listing filesystems mounted over NFS.
  .TP
  .I "\-P, \-\-portability"
  Use the POSIX output format.  This is like the default format except

--
Michael Rendell - Dept. of Comp. Sci., Memorial University of Newfoundland
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads