[BACK]Return to du.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / du

Diff for /src/usr.bin/du/du.c between version 1.2 and 1.3

version 1.2, 1996/06/26 05:32:38 version 1.3, 1996/10/18 18:16:07
Line 1 
Line 1 
 /*      $OpenBSD$       */  /*      $OpenBSD$       */
 /*      $NetBSD: du.c,v 1.10 1995/09/28 06:19:56 perry Exp $    */  /*      $NetBSD: du.c,v 1.11 1996/10/18 07:20:35 thorpej Exp $  */
   
 /*  /*
  * Copyright (c) 1989, 1993, 1994   * Copyright (c) 1989, 1993, 1994
Line 73 
Line 73 
 {  {
         FTS *fts;          FTS *fts;
         FTSENT *p;          FTSENT *p;
         long blocksize;          long blocksize, totalblocks;
         int ftsoptions, listdirs, listfiles;          int ftsoptions, listdirs, listfiles;
         int Hflag, Lflag, Pflag, aflag, ch, kflag, notused, rval, sflag;          int Hflag, Lflag, Pflag, aflag, ch, cflag, kflag, notused, rval, sflag;
         char **save;          char **save;
   
         save = argv;          save = argv;
         Hflag = Lflag = Pflag = aflag = kflag = sflag = 0;          Hflag = Lflag = Pflag = aflag = cflag = kflag = sflag = 0;
           totalblocks = 0;
         ftsoptions = FTS_PHYSICAL;          ftsoptions = FTS_PHYSICAL;
         while ((ch = getopt(argc, argv, "HLPaksx")) != EOF)          while ((ch = getopt(argc, argv, "HLPacksx")) != EOF)
                 switch (ch) {                  switch (ch) {
                 case 'H':                  case 'H':
                         Hflag = 1;                          Hflag = 1;
Line 98 
Line 99 
                 case 'a':                  case 'a':
                         aflag = 1;                          aflag = 1;
                         break;                          break;
                   case 'c':
                           cflag = 1;
                           break;
                 case 'k':                  case 'k':
                         blocksize = 1024;                          blocksize = 1024;
                         kflag = 1;                          kflag = 1;
Line 156 
Line 160 
         blocksize /= 512;          blocksize /= 512;
   
         if ((fts = fts_open(argv, ftsoptions, NULL)) == NULL)          if ((fts = fts_open(argv, ftsoptions, NULL)) == NULL)
                 err(1, NULL);                  err(1, "fts_open");
   
         for (rval = 0; (p = fts_read(fts)) != NULL;)          for (rval = 0; (p = fts_read(fts)) != NULL;)
                 switch (p->fts_info) {                  switch (p->fts_info) {
Line 165 
Line 169 
                 case FTS_DP:                  case FTS_DP:
                         p->fts_parent->fts_number +=                          p->fts_parent->fts_number +=
                             p->fts_number += p->fts_statp->st_blocks;                              p->fts_number += p->fts_statp->st_blocks;
                           if (cflag)
                                   totalblocks += p->fts_statp->st_blocks;
                         /*                          /*
                          * If listing each directory, or not listing files                           * If listing each directory, or not listing files
                          * or directories and this is post-order of the                           * or directories and this is post-order of the
                          * root of a traversal, display the total.                           * root of a traversal, display the total.
                          */                           */
                         if (listdirs || !listfiles && !p->fts_level)                          if (listdirs || (!listfiles && !p->fts_level))
                                 (void)printf("%ld\t%s\n",                                  (void)printf("%ld\t%s\n",
                                     howmany(p->fts_number, blocksize),                                      howmany(p->fts_number, blocksize),
                                     p->fts_path);                                      p->fts_path);
Line 195 
Line 201 
                                     howmany(p->fts_statp->st_blocks, blocksize),                                      howmany(p->fts_statp->st_blocks, blocksize),
                                     p->fts_path);                                      p->fts_path);
                         p->fts_parent->fts_number += p->fts_statp->st_blocks;                          p->fts_parent->fts_number += p->fts_statp->st_blocks;
                           if (cflag)
                                   totalblocks += p->fts_statp->st_blocks;
                 }                  }
         if (errno)          if (errno)
                 err(1, "fts_read");                  err(1, "fts_read");
           if (cflag)
                   (void)printf("%ld\ttotal\n",
                       howmany(totalblocks, blocksize));
         exit(0);          exit(0);
 }  }
   
Line 225 
Line 236 
   
         if (nfiles == maxfiles && (files = realloc((char *)files,          if (nfiles == maxfiles && (files = realloc((char *)files,
             (u_int)(sizeof(ID) * (maxfiles += 128)))) == NULL)              (u_int)(sizeof(ID) * (maxfiles += 128)))) == NULL)
                 err(1, "");                  err(1, "can't allocate memory");
         files[nfiles].inode = ino;          files[nfiles].inode = ino;
         files[nfiles].dev = dev;          files[nfiles].dev = dev;
         ++nfiles;          ++nfiles;
Line 237 
Line 248 
 {  {
   
         (void)fprintf(stderr,          (void)fprintf(stderr,
                 "usage: du [-H | -L | -P] [-a | -s] [-kx] [file ...]\n");                  "usage: du [-H | -L | -P] [-a | -s] [-ckx] [file ...]\n");
         exit(1);          exit(1);
 }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3