PageRenderTime 46ms CodeModel.GetById 41ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/filesystems/unixfs/ancientfs/ancientfs_tar.h

http://macfuse.googlecode.com/
C++ Header | 85 lines | 65 code | 12 blank | 8 comment | 0 complexity | 170f8c6ef16eaf9eb67e5b36350f9221 MD5 | raw file
 1/*
 2 * Ancient UNIX File Systems for MacFUSE
 3 * Amit Singh
 4 * http://osxbook.com
 5 */
 6
 7#ifndef _ANCIENTFS_TAR_H_
 8#define _ANCIENTFS_TAR_H_
 9
10#include "unixfs_internal.h"
11#include "ancientfs.h"
12
13#define TBLOCK   512
14#define NAMSIZ   100
15
16#define ROOTINO  1
17
18struct filsys
19{
20    uint32_t s_fsize;
21    uint32_t s_files;
22    uint32_t s_directories;
23    uint32_t s_lastino;
24    uint32_t s_dataoffset;
25    struct inode* s_rootip;
26};
27
28#define TMAGIC   "ustar" /* space terminated (pre POSIX) or null terminated */
29#define TMAGLEN  6
30#define TVERSION "00"    /* not null terminated */
31#define TVERSLEN 2
32
33union hblock {
34    char dummy[TBLOCK];
35    struct header {
36        char name[NAMSIZ];     /* name of file */
37        char mode[8];          /* file mode */
38        char uid[8];           /* owner user ID */
39        char gid[8];           /* owner group ID */
40        char size[12];         /* length of file in bytes; no trailing null */
41        char mtime[12];        /* modfiy time of file; no trailing null */
42        char chksum[8];        /* checksum for header */
43        char typeflag;         /* called linkflag in pre-ustar headers */
44        char linkname[NAMSIZ]; /* name of linked file */
45        /* ustar below */
46        char magic[6];         /* USTAR indicator */
47        char version[2];       /* USTAR version; no trailing null */
48        char uname[32];        /* owner user name */
49        char gname[32];        /* owner group name */
50        char devmajor[8];      /* device major number */
51        char devminor[8];      /* device minor number */
52        char prefix[155];      /* prefix for file name */
53   } dbuf;
54};
55
56/* values of typeflag / linkflag */
57#define TARTYPE_REG  '0'       /* USTAR and old tar */
58#define TARTYPE_LNK  '1'       /* USTAR and old tar */
59#define TARTYPE_SYM  '2'       /* USTAR and old tar */
60#define TARTYPE_CHR  '3'       /* USTAR */
61#define TARTYPE_BLK  '4'       /* USTAR */
62#define TARTYPE_DIR  '5'       /* USTAR */
63#define TARTYPE_FIFO '6'       /* USTAR */
64
65struct tar_node_info {
66    struct   inode*         ti_self;
67    struct   tar_node_info* ti_parent;
68    struct   tar_node_info* ti_children;
69    struct   tar_node_info* ti_next_sibling;
70    char*                   ti_name;
71    char*                   ti_linktargetname;
72};
73
74/* modes */
75#define IALLOC  0100000 /* i-node is allocated */
76#define ILARG   010000  /* large file */
77#define IFMT    0170000 /* type of file */
78
79static inline mode_t
80ancientfs_tar_mode(mode_t mode, uint32_t flags)
81{
82    return mode & (uint16_t)~(IALLOC & ILARG);
83}
84
85#endif /* _ANCIENTFS_TAR_H_ */