"Fossies" - the Fresh Open Source Software Archive

Member "jfsutils-1.1.15/include/jfs_types.h" (22 Nov 2005, 4474 Bytes) of archive /linux/misc/jfsutils-1.1.15.tar.gz:


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 "jfs_types.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  *   Copyright (c) International Business Machines Corp., 2000-2002
    3  *
    4  *   This program is free software;  you can redistribute it and/or modify
    5  *   it under the terms of the GNU General Public License as published by
    6  *   the Free Software Foundation; either version 2 of the License, or
    7  *   (at your option) any later version.
    8  *
    9  *   This program is distributed in the hope that it will be useful,
   10  *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
   11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
   12  *   the GNU General Public License for more details.
   13  *
   14  *   You should have received a copy of the GNU General Public License
   15  *   along with this program;  if not, write to the Free Software
   16  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   17  */
   18 #ifndef _H_JFS_TYPES
   19 #define _H_JFS_TYPES
   20 
   21 #include <sys/types.h> /* Neccessary for *BSD systems */
   22 /*
   23  *  jfs_types.h:
   24  *
   25  * basic type/utility  definitions
   26  *
   27  * note: this header file must be the 1st include file
   28  * of JFS include list in all JFS .c file.
   29  */
   30 
   31 #ifdef HAVE_STDINT_H
   32 # include <stdint.h>
   33 #else
   34 # include <sys/types.h>
   35 typedef u_int8_t uint8_t;
   36 typedef u_int16_t uint16_t;
   37 typedef u_int32_t uint32_t;
   38 typedef u_int64_t uint64_t;
   39 #endif
   40 
   41 #ifdef HAVE_STDBOOL_H
   42 # include <stdbool.h>
   43 #else
   44 typedef enum {
   45     false = 0,
   46     true = 1
   47 } bool;
   48 #endif /* HAVE_STDBOOL_H */
   49 
   50 
   51 /*
   52  * Unicase character.  Part of the ondisk format.
   53  */
   54 typedef uint16_t UniChar;
   55 
   56 
   57 /*
   58  * Almost identical to Linux's timespec, but not quite
   59  */
   60 struct timestruc_t {
   61     uint32_t  tv_sec;
   62     uint32_t  tv_nsec;
   63 };
   64 
   65 /*
   66  *  handy
   67  */
   68 #undef MIN
   69 #define MIN(a,b) (((a)<(b))?(a):(b))
   70 #undef MAX
   71 #define MAX(a,b) (((a)>(b))?(a):(b))
   72 #undef ROUNDUP
   73 #define ROUNDUP(x, y)   ( ((x) + ((y) - 1)) & ~((y) - 1) )
   74 
   75 #define LEFTMOSTONE 0x80000000
   76 #define HIGHORDER   0x80000000u /* high order bit on            */
   77 #define ONES        0xffffffffu /* all bit on                   */
   78 
   79 /*
   80  *  physical xd (pxd)
   81  */
   82 typedef struct {
   83     unsigned  len:24;
   84     unsigned  addr1:8;
   85     uint32_t  addr2;
   86 } pxd_t;
   87 
   88 /* xd_t field construction */
   89 
   90 #define PXDlength(pxd, length32)    ((pxd)->len = __cpu_to_le24(length32))
   91 #define PXDaddress(pxd, address64)\
   92 {\
   93     (pxd)->addr1 = ((int64_t)address64) >> 32;\
   94     (pxd)->addr2 = __cpu_to_le32((address64) & 0xffffffff);\
   95 }
   96 
   97 /* xd_t field extraction */
   98 #define lengthPXD(pxd)  __le24_to_cpu((pxd)->len)
   99 #define addressPXD(pxd)\
  100     ( ((int64_t)((pxd)->addr1)) << 32 | __le32_to_cpu((pxd)->addr2))
  101 
  102 /* pxd list */
  103 struct pxdlist {
  104     int16_t  maxnpxd;
  105     int16_t  npxd;
  106     pxd_t    pxd[8];
  107 };
  108 
  109 
  110 /*
  111  *  data extent descriptor (dxd)
  112  */
  113 typedef struct {
  114     unsigned  flag:8;   /* 1: flags */
  115     unsigned  rsrvd:24; /* 3: */
  116     uint32_t  size;     /* 4: size in byte */
  117     unsigned  len:24;   /* 3: length in unit of fsblksize */
  118     unsigned  addr1:8;  /* 1: address in unit of fsblksize */
  119     uint32_t  addr2;    /* 4: address in unit of fsblksize */
  120 } dxd_t;            /* - 16 - */
  121 
  122 /* dxd_t flags */
  123 #define DXD_INDEX   0x80    /* B+-tree index */
  124 #define DXD_INLINE  0x40    /* in-line data extent */
  125 #define DXD_EXTENT  0x20    /* out-of-line single extent */
  126 #define DXD_FILE    0x10    /* out-of-line file (inode) */
  127 #define DXD_CORRUPT 0x08    /* Inconsistency detected */
  128 
  129 /* dxd_t field construction
  130  *  Conveniently, the PXD macros work for DXD
  131  */
  132 #define DXDlength   PXDlength
  133 #define DXDaddress  PXDaddress
  134 #define lengthDXD   lengthPXD
  135 #define addressDXD  addressPXD
  136 
  137 /*
  138  *      directory entry argument
  139  */
  140 struct component_name {
  141     int namlen;
  142     UniChar *name;
  143 };
  144 
  145 
  146 /*
  147  *  DASD limit information - stored in directory inode
  148  */
  149 struct dasd {
  150     uint8_t   thresh;       /* Alert Threshold (in percent) */
  151     uint8_t   delta;        /* Alert Threshold delta (in percent)   */
  152     uint8_t   rsrvd1;
  153     uint8_t   limit_hi;     /* DASD limit (in logical blocks)       */
  154     uint32_t  limit_lo;     /* DASD limit (in logical blocks)       */
  155     uint8_t   rsrvd2[3];
  156     uint8_t   used_hi;      /* DASD usage (in logical blocks)       */
  157     uint32_t  used_lo;      /* DASD usage (in logical blocks)       */
  158 };
  159 
  160 #define DASDLIMIT(dasdp) \
  161     (((uint64_t)((dasdp)->limit_hi) << 32) + __le32_to_cpu((dasdp)->limit_lo))
  162 #define setDASDLIMIT(dasdp, limit)\
  163 {\
  164     (dasdp)->limit_hi = ((uint64_t)limit) >> 32;\
  165     (dasdp)->limit_lo = __cpu_to_le32(limit);\
  166 }
  167 #define DASDUSED(dasdp) \
  168     (((uint64_t)((dasdp)->used_hi) << 32) + __le32_to_cpu((dasdp)->used_lo))
  169 #define setDASDUSED(dasdp, used)\
  170 {\
  171     (dasdp)->used_hi = ((uint64_t)used) >> 32;\
  172     (dasdp)->used_lo = __cpu_to_le32(used);\
  173 }
  174 
  175 #endif              /* !_H_JFS_TYPES */