PageRenderTime 49ms CodeModel.GetById 36ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/filesystems/unixfs/ancientfs/ancientfs_v7.h

http://macfuse.googlecode.com/
C++ Header | 138 lines | 98 code | 19 blank | 21 comment | 0 complexity | 44cc561a0be04f21b1c7f4391ddef17c MD5 | raw file
  1/*
  2 * Ancient UNIX File Systems for MacFUSE
  3 * Amit Singh
  4 * http://osxbook.com
  5 */
  6
  7#ifndef _ANCIENTFS_V7_H_
  8#define _ANCIENTFS_V7_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_ulong  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#if V10_4K
 26#define BSIZE  4096            /* size of secondary block (bytes) */
 27#define BMASK  07777           /* BSIZE - 1 */
 28#define NINDIR (BSIZE/sizeof(a_daddr_t))
 29#define NMASK  01777           /* NINDIR - 1 */
 30#define NSHIFT 10              /* LOG2(NINDIR) */
 31#else
 32#define BSIZE  512             /* size of secondary block (bytes) */
 33#define BMASK  0777            /* BSIZE - 1 */
 34#define NINDIR (BSIZE/sizeof(a_daddr_t))
 35#define NMASK  0177            /* NINDIR - 1 */
 36#define NSHIFT 7               /* LOG2(NINDIR) */
 37#endif
 38
 39#define ROOTINO 2              /* i number of all roots */
 40#define SUPERB  ((a_daddr_t)1) /* block number of the super block */
 41#define DIRSIZ  14             /* max characters per directory */
 42#define NICINOD 100            /* number of super block inodes */
 43#define NICFREE 50             /* number of super block free blocks */
 44
 45/*
 46 * Definition of the unix super block.
 47 */
 48struct filsys
 49{
 50    a_ushort  s_isize;          /* size in blocks of i-list */
 51    a_daddr_t s_fsize;          /* size in blocks of entire volume */
 52    a_short   s_nfree;          /* number of addresses in s_free */
 53    a_daddr_t s_free[NICFREE];  /* free block list */
 54    a_short   s_ninode;         /* number of i-nodes in s_inode */
 55    a_ino_t   s_inode[NICINOD]; /* free i-node list */
 56    char      s_flock;          /* lock during free list manipulation */
 57    char      s_ilock;          /* lock during i-list manipulation */
 58    char      s_fmod;           /* super block modified flag */
 59    char      s_ronly;          /* mounted read-only flag */
 60    time_t    s_time;           /* last super block update */
 61
 62    /* remainder not maintained by this version of the system */
 63
 64    a_daddr_t s_tfree;          /* total free blocks*/
 65    a_ino_t   s_tinode;         /* total free inodes */
 66    a_short   s_m;              /* interleave factor */
 67    a_short   s_n;              /* " " */
 68    char      s_fname[6];       /* file system name */
 69    char      s_fpack[6];       /* file system pack name */
 70} __attribute__((packed));
 71
 72/*
 73 * Inode struct as it appears on a disk block.
 74 */
 75struct dinode
 76{
 77    a_ushort di_mode;     /* mode and type of file */
 78    a_short  di_nlink;    /* number of links to file */
 79    a_short  di_uid;      /* owner's user id */
 80    a_short  di_gid;      /* owner's group id */
 81    a_off_t  di_size;     /* number of bytes in file */
 82    char     di_addr[40]; /* disk block addresses */
 83    a_time_t di_atime;    /* time last accessed */
 84    a_time_t di_mtime;    /* time last modified */
 85    a_time_t di_ctime;    /* time created */
 86} __attribute__((packed));
 87
 88#define INOPB 8 /* 8 inodes per block */
 89/*
 90 * the 40 address bytes:
 91 *      39 used; 13 addresses
 92 *      of 3 bytes each.
 93 */
 94
 95/* inumber to disk address */
 96#define itod(x) (a_daddr_t)((((a_uint)(x) + 15) >> 3))
 97
 98/* inumber to disk offset */
 99#define itoo(x) (a_int)(((x) + 15) & 07)
100
101#define NADDR  13
102#define NINDEX 15
103
104/* flags */
105#define ILOCK   01      /* inode is locked */
106#define IUPD    02      /* inode has been modified */
107#define IACC    04      /* inode access time to be updated */
108#define IMOUNT  010     /* inode is mounted on */
109#define IWANT   020     /* some process waiting on lock */
110#define ITEXT   040     /* inode is pure text prototype */
111#define ICHG    0100    /* inode has been changed */
112
113/* modes */
114#define IFMT    0170000 /* type of file */
115#define IFDIR   0040000 /* directory */
116#define IFCHR   0020000 /* character special */
117#define IFBLK   0060000 /* block special, 0 is regular */
118#define IFREG   0100000 /* regular */
119#define IFMPC   0030000 /* multiplexed char special */
120#define IFMPB   0070000 /* multiplexed block special */
121#define ISUID   04000   /* set user id on execution */
122#define ISGID   02000   /* set group id on execution */
123#define ISVTX   01000   /* save swapped text even after use */
124#define IREAD   0400    /* read, write, execute permissions */
125#define IRWRITE 0200
126#define IEXEC   0100
127
128struct dent {
129    a_ino_t u_ino;          /* inode table pointer */
130    char    u_name[DIRSIZ]; /* component name */
131} __attribute__((packed));
132
133struct fblk {
134    a_int     df_nfree;
135    a_daddr_t df_free[NICFREE];
136} __attribute__((packed));
137
138#endif /* _ANCIENTFS_V7_H_ */