PageRenderTime 26ms CodeModel.GetById 17ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/filesystems/unixfs/ancientfs/ancientfs_2.9bsd.h

http://macfuse.googlecode.com/
C++ Header | 171 lines | 127 code | 20 blank | 24 comment | 5 complexity | 2b968169f22950e82e73bde9596f3212 MD5 | raw file
  1/*
  2 * Ancient UNIX File Systems for MacFUSE
  3 * Amit Singh
  4 * http://osxbook.com
  5 */
  6
  7#ifndef _ANCIENTFS_29BSD_H_
  8#define _ANCIENTFS_29BSD_H_
  9
 10#include "unixfs_internal.h"
 11
 12typedef int16_t  a_short;       /* ancient short */
 13typedef uint16_t a_ushort;      /* ancient unsigned short */
 14typedef int16_t  a_int;         /* ancient int */
 15typedef uint16_t a_uint;        /* ancient unsigned int */
 16typedef int32_t  a_long;        /* ancient long */
 17typedef uint32_t a_ulong;       /* ancient unsigned long */
 18
 19typedef a_uint   a_ino_t;       /* ancient inode type (ancient unsigned int) */
 20typedef a_long   a_off_t;       /* ancient offset type (ancient long) */
 21typedef a_long   a_time_t;      /* ancient time type (ancient long) */
 22typedef a_long   a_daddr_t;     /* ancient disk address type (ancient long) */
 23typedef a_int    a_dev_t;       /* ancient device type (ancient int) */
 24
 25#define UCB_NKB 1
 26
 27#if UCB_NKB == 1
 28#undef  CLSIZE
 29#define CLSIZE   2              /* number of blocks / cluster */
 30#define BSIZE    1024           /* size of secondary block (bytes) */
 31#define NINDIR   (BSIZE/sizeof(a_daddr_t))
 32#define BMASK    01777          /* BSIZE - 1 */
 33#define BSHIFT   10             /* LOG2(BSIZE) */
 34#define NMASK    0377           /* NINDIR - 1 */
 35#define NSHIFT   8              /* LOG2(NINDIR) */
 36#else
 37#define BSIZE    512            /* size of secondary block (bytes) */
 38#define NINDIR   (BSIZE/sizeof(a_daddr_t))
 39#define BMASK    0777           /* BSIZE - 1 */
 40#define BSHIFT   9              /* LOG2(BSIZE) */
 41#define NMASK    0177           /* NINDIR - 1 */
 42#define NSHIFT   7              /* LOG2(NINDIR) */
 43#endif
 44
 45#define ROOTINO  2              /* i number of all roots */
 46#define DIRSIZ   14             /* max characters per directory */
 47#define NICINOD  100            /* number of super block inodes */
 48#define NICFREE  50             /* number of super block free blocks */
 49
 50/*
 51 * Definition of the unix super block.
 52 */
 53struct filsys
 54{
 55    a_ushort  s_isize;          /* size in blocks of i-list */
 56    a_daddr_t s_fsize;          /* size in blocks of entire volume */
 57    a_short   s_nfree;          /* number of addresses in s_free */
 58    a_daddr_t s_free[NICFREE];  /* free block list */
 59    a_short   s_ninode;         /* number of i-nodes in s_inode */
 60    a_ino_t   s_inode[NICINOD]; /* free i-node list */
 61    char      s_flock;          /* lock during free list manipulation */
 62    char      s_ilock;          /* lock during i-list manipulation */
 63    char      s_fmod;           /* super block modified flag */
 64    char      s_ronly;          /* mounted read-only flag */
 65    time_t    s_time;           /* last super block update */
 66
 67    /* remainder not maintained by this version of the system */
 68
 69    a_daddr_t s_tfree;          /* total free blocks*/
 70    a_ino_t   s_tinode;         /* total free inodes */
 71    a_short   s_dinfo[2];       /* interleave stuff */
 72#define s_m   s_dinfo[0]
 73#define s_n   s_dinfo[1]
 74    char      s_fsmnt[12];      /* ordinary file mounted on */
 75    ino_t     s_lasti;          /* start place for circular search */
 76    ino_t     s_nbehind;        /* est # free inodes before s_lasti */
 77} __attribute__((packed));
 78
 79/*
 80 * Inode struct as it appears on a disk block.
 81 */
 82struct dinode
 83{
 84    a_ushort di_mode;     /* mode and type of file */
 85    a_short  di_nlink;    /* number of links to file */
 86    a_short  di_uid;      /* owner's user id */
 87    a_short  di_gid;      /* owner's group id */
 88    a_off_t  di_size;     /* number of bytes in file */
 89    char     di_addr[40]; /* disk block addresses */
 90    a_time_t di_atime;    /* time last accessed */
 91    a_time_t di_mtime;    /* time last modified */
 92    a_time_t di_ctime;    /* time created */
 93} __attribute__((packed));
 94
 95#if UCB_NKB == 1
 96#define INOPB 16 /* 16 inodes per block */
 97/*
 98 * 21 of the address bytes are used;
 99 * 7 addresses of 3 bytes each.
100 */
101#else
102#define INOPB 8 /* 8 inodes per block */
103/*
104 * 39 of the address bytes are used;
105 * 13 addresses of 3 bytes each.
106 */
107#endif
108
109/* inumber to disk address */
110#if UCB_NKB == 1
111#define itod(x) ((a_daddr_t)((((a_uint)(x) + 2 * INOPB - 1) / INOPB)))
112#else
113#define itod(x) (a_daddr_t)((((a_uint)(x) + 15) >> 3))
114#endif
115
116/* inumber to disk offset */
117#if UCB_NKB == 1
118#define itoo(x) ((a_int)(((x) + 2 * INOPB - 1) % INOPB))
119#else
120#define itoo(x) (a_int)(((x) + 15) & 07)
121#endif
122
123#if UCB_NKB == 1
124#define NADDR  7
125#define NINDEX 6
126#else
127#define NADDR 13
128#define NINDEX 15
129#endif
130
131/* flags */
132#define ILOCK   01      /* inode is locked */
133#define IUPD    02      /* inode has been modified */
134#define IACC    04      /* inode access time to be updated */
135#define IMOUNT  010     /* inode is mounted on */
136#define IWANT   020     /* some process waiting on lock */
137#define ITEXT   040     /* inode is pure text prototype */
138#define ICHG    0100    /* inode has been changed */
139#define IPIPE   0200    /* inode is a pipe */
140#ifdef  UCB_QUOTAS
141#define IQUOT   0400    /* directory that has original quota pointer */
142#endif
143
144/* modes */
145#define IFMT    0170000 /* type of file */
146#define IFDIR   0040000 /* directory */
147#define IFCHR   0020000 /* character special */
148#define IFMPC   0030000 /* multiplexed char special */
149#define IFBLK   0060000 /* block special, 0 is regular */
150#define IFMPB   0070000 /* multiplexed block special */
151#define IFREG   0100000 /* regular */
152#define IFLNK   0120000 /* symbolic link */
153#define IFQUOT  0140000 /* quota */
154#define ISUID   04000   /* set user id on execution */
155#define ISGID   02000   /* set group id on execution */
156#define ISVTX   01000   /* save swapped text even after use */
157#define IREAD   0400    /* read, write, execute permissions */
158#define IRWRITE 0200
159#define IEXEC   0100
160
161struct dent {
162    a_ino_t u_ino;          /* inode table pointer */
163    char    u_name[DIRSIZ]; /* component name */
164} __attribute__((packed));
165
166struct fblk {
167    a_short   df_nfree;
168    a_daddr_t df_free[NICFREE];
169} __attribute__((packed));
170
171#endif /* _ANCIENTFS_29BSD_H_ */