PageRenderTime 24ms CodeModel.GetById 14ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/filesystems/unixfs/ancientfs/ancientfs_v4,5,6.h

http://macfuse.googlecode.com/
C++ Header | 98 lines | 68 code | 13 blank | 17 comment | 2 complexity | 6f72fec26f1bf3acac0993f88b7ef8c0 MD5 | raw file
 1/*
 2 * Ancient UNIX File Systems for MacFUSE
 3 * Amit Singh
 4 * http://osxbook.com
 5 */
 6
 7#ifndef _ANCIENTFS_V456_H_
 8#define _ANCIENTFS_V456_H_
 9
10/*
11 * V4 += DIRSIZ 14, size0/size1, groups, 1970 epoch with full seconds
12 * V5 += ISVTX
13 */
14
15#include "unixfs_internal.h"
16#include "ancientfs.h"
17
18typedef int16_t a_ino_t; /* ancient inode type */
19typedef int16_t a_int;   /* ancient int */
20
21#define BSIZE   512
22
23#define ROOTINO 1         /* i number of all roots */
24#define SUPERB  1         /* block number of the super block */
25#define DIRSIZ  14        /* max characters per directory */
26
27/*
28 * Definition of the unix super block.
29 */
30struct filsys
31{
32    a_int   s_isize;      /* size in blocks of the I list */
33    a_int   s_fsize;      /* size in blocks of entire volume */
34    a_int   s_nfree;      /* number of in core free blocks (0 - 100) */
35    a_int   s_free[100];  /* in core free blocks */
36    a_int   s_ninode;     /* number of in core I nodes (0 - 100) */
37    a_ino_t s_inode[100]; /* in core free I nodes */
38    char    s_flock;      /* lock during free list manipulation */
39    char    s_ilock;      /* lock during I list manipulation */
40    char    s_fmod;       /* super block modified flag */
41    char    s_ronly;      /* mounted read-only flag */
42    a_int   s_time[2];    /* current date of last update */
43    a_int   pad[50];
44} __attribute__((packed));
45
46/*
47 * Inode struct as it appears on the disk.
48 */
49struct dinode
50{
51    a_int di_mode;     /* type and permissions */
52    char  di_nlink;    /* directory entries */
53    char  di_uid;      /* owner */
54    char  di_gid;      /* group of owner */
55    char  di_size0;    /* most significant of size */
56    a_int di_size1;    /* least significant of size */
57    a_int di_addr[8];  /* device addresses constituting file */
58    a_int di_atime[2]; /* access time */
59    a_int di_mtime[2]; /* modification time */
60} __attribute__((packed));
61
62/* flags */
63#define ILOCK   01      /* inode is locked */
64#define IUPD    02      /* inode has been modified */
65#define IACC    04      /* inode access time to be updated */
66#define IMOUNT  010     /* inode is mounted on */
67#define IWANT   020     /* some process waiting on lock */
68#define ITEXT   040     /* inode is pure text prototype */
69
70/* modes */
71#define IALLOC  0100000 /* file is used */
72#define IFMT    060000  /* type of file */
73#define IFDIR   040000  /* directory */
74#define IFCHR   020000  /* character special */
75#define IFBLK   060000  /* block special, 0 is regular */
76#define ILARG   010000  /* large addressing algorithm */
77#define ISUID   04000   /* set user id on execution */
78#define ISGID   02000   /* set group id on execution */
79#define ISVTX   01000   /* save swapped text even after use */
80#define IREAD   0400    /* read, write, execute permissions */
81#define IRWRITE 0200
82#define IEXEC   0100
83
84static inline a_int
85ancientfs_v456_mode(mode_t mode)
86{
87    a_int newmode = (a_int)mode & ~(IALLOC | ILARG);
88    if ((newmode & IFMT) == 0) /* ancient regular file */
89        newmode |= S_IFREG;
90    return newmode;
91}
92
93struct dent {
94    a_ino_t u_ino;          /* inode table pointer */
95    char    u_name[DIRSIZ]; /* component name */
96} __attribute__((packed));
97
98#endif /* _ANCIENTFS_V456_H_ */