home *** CD-ROM | disk | FTP | other *** search
/ The UNIX CD Bookshelf / OREILLY_TUCB_UNIX_CD.iso / upt / examples / SOURCES / DELETE / PART01.Z / PART01 / directories.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-24  |  3.2 KB  |  103 lines

  1. /*
  2.  * $Source: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/directories.h,v $
  3.  * $Author: jik $
  4.  * $Header: /afs/athena.mit.edu/user/j/jik/delete/src/RCS/directories.h,v 1.10 91/02/22 06:33:34 jik Exp $
  5.  * 
  6.  * This file is part of a package including delete, undelete,
  7.  * lsdel, expunge and purge.  The software suite is meant as a
  8.  * replacement for rm which allows for file recovery.
  9.  * 
  10.  * Copyright (c) 1989 by the Massachusetts Institute of Technology.
  11.  * For copying and distribution information, see the file "mit-copyright.h."
  12.  */
  13.  
  14. #include "mit-copyright.h"
  15.  
  16. typedef short Boolean;
  17. #define True            (Boolean) 1
  18. #define False            (Boolean) 0
  19.  
  20.  
  21. #define size_to_k(x)        ((x) / 1024 + (((x) % 1024) ? 1 : 0))
  22.  
  23. #define FOLLOW_LINKS        1
  24. #define DONT_FOLLOW_LINKS    0
  25.  
  26. #define DIR_MATCH        1
  27. #define DIR_NO_MATCH        0
  28.  
  29. typedef struct mystat {
  30.      dev_t st_dev;
  31.      ino_t st_ino;
  32.      unsigned short st_mode;
  33.      off_t st_size;
  34.      time_t st_ctime;
  35. #ifdef notdef
  36.      /*
  37.       * I've tried, unsuccessfully, to figure out exactly what this
  38.       * field means and how I can use it.  Supposedly, it indicates
  39.       * the number of blocks the file actually occupies, i.e. the size
  40.       * of the file minus any holes in it there may be.  The question,
  41.       * however, is this: what's a "block?"
  42.       *
  43.       * At first, I thought that a block is as big as f_bsize returned
  44.       * by a statfs on the file.  But that doesn't prove to be the
  45.       * case, because my home directory in AFS has f_bsize of 8192,
  46.       * st_size of 8192, and st_blocks of 16 (!!), indicating that a
  47.       * block size of 512 bytes is being used.  Where does that size
  48.       * come from, and why isn't it consistent with the f_bsize
  49.       * retrieved from statfs?
  50.       *
  51.       * Until someone can answer these questions for me enough that
  52.       * I'm willing to trust the value in this field, I can't use it.
  53.       * Besides that, it doesn't even exist in the POSIX stat
  54.       * structure, so I'm not even sure it's worth trying to use it.
  55.       *
  56.       * Here's another dilemma: When I do a statfs on my home
  57.       * directory in AFS, it tells me that the f_bsize is 8192.  If
  58.       * that's the case, then when I create a one-character file in my
  59.       * home directory, my quota usage should go up by 8k.  But it
  60.       * doesn't, it goes up by just 1k.  Which means that the f_bsize
  61.       * I'm getting from statfs has nothing to do with the minimum
  62.       * block size of the filesystem.  So what *does* it have to do
  63.       * with?
  64.       */
  65.      long st_blocks;
  66. #endif
  67. } mystat;
  68.  
  69.      
  70. typedef struct filrec {
  71.      char name[MAXNAMLEN];
  72.      struct filrec *previous;
  73.      struct filrec *parent;
  74.      struct filrec *dirs;
  75.      struct filrec *files;
  76.      struct filrec *next;
  77.      Boolean specified;
  78.      Boolean freed;
  79.      struct mystat specs;
  80. } filerec;
  81.  
  82.  
  83.  
  84. int add_directory_to_parent();
  85. int add_file_to_parent();
  86. int add_path_to_tree();
  87. int find_child();
  88. filerec *first_in_directory();
  89. filerec *first_specified_in_directory();
  90. filerec *get_cwd_tree();
  91. filerec *get_root_tree();
  92. filerec *next_directory();
  93. filerec *next_in_directory();
  94. filerec *next_leaf();
  95. filerec *next_specified_directory();
  96. filerec *next_specified_in_directory();
  97. filerec *next_specified_leaf();
  98.  
  99. int get_leaf_path();
  100. int accumulate_names();
  101.  
  102. void free_leaf();
  103.