PageRenderTime 34ms CodeModel.GetById 15ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

/filesystems/unixfs/ancientfs/ancientfs_itp.h

http://macfuse.googlecode.com/
C++ Header | 97 lines | 75 code | 15 blank | 7 comment | 3 complexity | 8d533d749581362bc89fc0416fa8fdf0 MD5 | raw file
 1/*
 2 * Ancient UNIX File Systems for MacFUSE
 3 * Amit Singh
 4 * http://osxbook.com
 5 */
 6
 7#ifndef _ANCIENTFS_ITP_H_
 8#define _ANCIENTFS_ITP_H_
 9
10#include "unixfs_internal.h"
11#include "ancientfs.h"
12
13#define BSIZE   512
14
15#define ROOTINO  1
16#define DIRSIZ   14
17#define PATHSIZ  48
18
19struct filsys
20{
21    uint32_t s_fsize;
22    uint32_t s_files;
23    uint32_t s_directories;
24    uint32_t s_lastino;
25    struct inode* s_rootip;
26};
27
28struct dinode_itp { /* newer */
29    uint8_t  di_path[PATHSIZ]; /* if di_path[0] == 0, the entry is empty */
30    uint16_t di_mode;       /* type and permissions */
31    uint8_t  di_uid;        /* owner's id */
32    uint8_t  di_gid;        /* group's id */
33    uint8_t  di_unused1;    /* unused */
34    uint8_t  di_size0;      /* size */
35    uint16_t di_size1;      /* size */
36    uint32_t di_mtime;      /* file's modification time */
37    uint16_t di_addr;       /* tape block of the start of the file's contents */
38    uint16_t di_cksum;      /* sum of the 32 words of the directory is 0 */
39} __attribute__((packed));
40
41#define INOPB 8
42
43struct tap_node_info {
44    struct inode* ti_self;
45    uint8_t ti_name[DIRSIZ];
46    struct tap_node_info* ti_parent;
47    struct tap_node_info* ti_children;
48    struct tap_node_info* ti_next_sibling;
49};
50
51/* flags */
52#define ILOCK   01
53#define IUPD    02
54#define IACC    04
55#define IMOUNT  010
56#define IWANT   020
57#define ITEXT   040
58
59/* modes */
60#define IALLOC  0100000 /* file is used */
61#define IFMT    060000  /* type of file */
62#define IFDIR   040000  /* directory */
63#define IFCHR   020000  /* character special */
64#define IFBLK   060000  /* block special, 0 is regular */
65#define ILARG   010000  /* large addressing algorithm */
66#define ISUID   04000   /* set user id on execution */
67#define ISGID   02000   /* set group id on execution */
68#define ISVTX   01000   /* save swapped text even after use */
69#define IREAD   0400    /* read, write, execute permissions */
70#define IRWRITE 0200
71#define IEXEC   0100
72
73#include <sys/stat.h>
74
75static inline mode_t
76ancientfs_itp_mode(mode_t mode, uint32_t flags)
77{
78    mode_t newmode = 0;
79
80    newmode = (int)mode & ~(IALLOC | ILARG);
81    if ((newmode & IFMT) == 0) /* ancient regular file */
82        newmode |= S_IFREG;
83    return newmode;
84}
85
86static inline int
87ancientfs_itp_cksum(uint8_t* de, fs_endian_t e, uint32_t flags)
88{
89    uint16_t* p = (uint16_t*)de;
90    uint16_t cksum = 0;
91    int i = 0;
92    for (i = 0; i < 32; i++, p++)
93        cksum += fs16_to_host(e, *p);
94    return cksum;
95}
96
97#endif /* _ANCIENTFS_ITP_H_ */