"Fossies" - the Fresh Open Source Software Archive

Member "quotactl-1.00/quotause/quotaio_v2.h" (9 Oct 2005, 4758 Bytes) of package /linux/privat/old/quotactl-1.00.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "quotaio_v2.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  *
    3  *  Header file for disk format of new quotafile format
    4  *
    5  */
    6 
    7 #ifndef _QUOTAIO_V2_H
    8 #define _QUOTAIO_V2_H
    9 
   10 #include <sys/types.h>
   11 #include "quota.h"
   12 
   13 #define V2_DQINFOOFF    sizeof(struct v2_disk_dqheader)
   14     /* Offset of info header in file */
   15 #define V2_DQBLKSIZE_BITS   10u
   16 #define V2_DQBLKSIZE    (1u << V2_DQBLKSIZE_BITS)
   17     /* Size of block with quota structures */
   18 #define V2_DQTREEOFF    1   /* Offset of tree in file in blocks */
   19 #define V2_DQTREEDEPTH  4   /* Depth of quota tree */
   20 #define V2_DQSTRINBLK    \
   21   ((V2_DQBLKSIZE - sizeof(struct v2_disk_dqdbheader)) / \
   22   sizeof(struct v2_disk_dqblk))
   23      /* Number of entries in one blocks */
   24 #define V2_GETIDINDEX(id, depth) \
   25   (((id) >> ((V2_DQTREEDEPTH-(depth)-1)*8)) & 0xff)
   26 #define INIT_V2_VERSIONS { 0, 0}
   27 
   28 #define BYTES_PER_WORD (sizeof(unsigned int)/sizeof(unsigned char))
   29 
   30 typedef union {
   31     unsigned char bytes[V2_DQBLKSIZE];
   32     unsigned int  words[V2_DQBLKSIZE/BYTES_PER_WORD];
   33 } dqbuf;
   34 
   35 struct v2_disk_dqheader {
   36     u_int32_t dqh_magic;    /* Magic number identifying file */
   37     u_int32_t dqh_version;  /* File version */
   38 } __attribute__ ((packed));
   39 
   40 /* Flags for version specific files */
   41 #define V2_DQF_MASK  0x0000 /* Mask for all valid ondisk flags */
   42 
   43 /* Header with type and version specific information */
   44 struct v2_disk_dqinfo {
   45     u_int32_t dqi_bgrace;
   46         /* Time before block soft limit becomes hard limit */
   47     u_int32_t dqi_igrace;
   48         /* Time before inode soft limit becomes hard limit */
   49     u_int32_t dqi_flags;    /* Flags for quotafile (DQF_*) */
   50     u_int32_t dqi_blocks;   /* Number of blocks in file */
   51     u_int32_t dqi_free_blk; /* Number of first free block in the list */
   52     u_int32_t dqi_free_entry;
   53         /* Number of block with at least one free entry */
   54 } __attribute__ ((packed));
   55 
   56 /* Structure of header of block with quota structures. It is padded to
   57    16 bytes so there will be space for exactly 18 quota-entries in a
   58    block
   59 */
   60 struct v2_disk_dqdbheader {
   61     u_int32_t dqdh_next_free;   /* Number of next block with free entry */
   62     u_int32_t dqdh_prev_free;   /* Number of previous block with free entry */
   63     u_int16_t dqdh_entries; /* Number of valid entries in block */
   64     u_int16_t dqdh_pad1;
   65     u_int32_t dqdh_pad2;
   66 } __attribute__ ((packed));
   67 
   68 /* Structure of quota for one user on disk */
   69 struct v2_disk_dqblk {
   70     /* An empty frame for one of these in a quota file is distinguishable
   71        by the fact that it is all zeroes.  A real structure would not be
   72        all zero, because zero for a limit means "no limit," and you
   73        you represent absences of any limit with absence of an entry.
   74     */
   75     u_int32_t dqb_id;   /* id this quota applies to */
   76     u_int32_t dqb_ihardlimit;   /* absolute limit on allocated inodes */
   77     u_int32_t dqb_isoftlimit;   /* preferred inode limit */
   78     u_int32_t dqb_curinodes;    /* current # allocated inodes */
   79     u_int32_t dqb_bhardlimit;
   80         /* absolute limit on disk space (in QUOTABLOCK_SIZE) */
   81     u_int32_t dqb_bsoftlimit;
   82         /* preferred limit on disk space (in QUOTABLOCK_SIZE) */
   83     u_int64_t dqb_curspace; /* current space occupied (in bytes) */
   84     u_int64_t dqb_btime;    /* time limit for excessive disk use */
   85     u_int64_t dqb_itime;    /* time limit for excessive inode use */
   86 } __attribute__ ((packed));
   87 
   88 static inline struct v2_disk_dqblk *
   89 V2_GETENTRIES(dqbuf * const bufP) {
   90 /*----------------------------------------------------------------------------
   91    Given a buffer containing the contents of a quota file block,
   92    assuming it is a quota block, return the address of the place where
   93    the actual entries start in that buffer.
   94 -----------------------------------------------------------------------------*/
   95     return (struct v2_disk_dqblk *)(&bufP->bytes[0] + 
   96                                     sizeof(struct v2_disk_dqdbheader));
   97 }
   98 
   99 
  100 /* Structure of quota for communication with kernel */
  101 struct v2_kern_dqblk {
  102     unsigned int dqb_ihardlimit;
  103     unsigned int dqb_isoftlimit;
  104     unsigned int dqb_curinodes;
  105     unsigned int dqb_bhardlimit;
  106     unsigned int dqb_bsoftlimit;
  107     qsize_t dqb_curspace;
  108     time_t dqb_btime;
  109     time_t dqb_itime;
  110 };
  111 
  112 /* Structure of quotafile info for communication with kernel */
  113 struct v2_kern_dqinfo {
  114     unsigned int dqi_bgrace;
  115     unsigned int dqi_igrace;
  116     unsigned int dqi_flags;
  117     unsigned int dqi_blocks;
  118     unsigned int dqi_free_blk;
  119     unsigned int dqi_free_entry;
  120 };
  121 
  122 /* Structure with gathered statistics from kernel */
  123 struct v2_dqstats {
  124     u_int32_t lookups;
  125     u_int32_t drops;
  126     u_int32_t reads;
  127     u_int32_t writes;
  128     u_int32_t cache_hits;
  129     u_int32_t allocated_dquots;
  130     u_int32_t free_dquots;
  131     u_int32_t syncs;
  132     u_int32_t version;
  133 };
  134 
  135 #endif