PageRenderTime 31ms CodeModel.GetById 17ms app.highlight 9ms RepoModel.GetById 2ms app.codeStats 0ms

/filesystems/unixfs/ancientfs/ancientfs_cpio_newc.h

http://macfuse.googlecode.com/
C++ Header | 72 lines | 54 code | 10 blank | 8 comment | 0 complexity | 52e68cf44b790cba828b9d2fe78c9b64 MD5 | raw file
 1/*
 2 * Ancient UNIX File Systems for MacFUSE
 3 * Amit Singh
 4 * http://osxbook.com
 5 */
 6
 7#ifndef _ANCIENTFS_CPIO_NEWC_H_
 8#define _ANCIENTFS_CPIO_NEWC_H_
 9
10#include "unixfs_internal.h"
11#include "ancientfs.h"
12
13#define ROOTINO  1
14
15struct filsys
16{
17    uint32_t s_fsize;
18    uint32_t s_files;
19    uint32_t s_directories;
20    uint32_t s_lastino;
21    uint32_t s_dataoffset;
22    uint32_t s_needsswap;
23    struct inode* s_rootip;
24};
25
26#define CPIO_NEWC_BLOCK       512
27#define CPIO_NEWC_MAGIC       "070701"
28#define CPIO_NEWCRC_MAGIC     "070702"
29#define CPIO_NEWC_MAGLEN      6
30#define CPIO_NEWC_TRAILER     "TRAILER!!!"
31#define CPIO_NEWC_TRAILER_LEN (sizeof(CPIO_NEWC_TRAILER)/sizeof(unsigned char))
32
33struct cpio_newc_header {
34    char c_magic[6];
35    char c_ino[8];
36    char c_mode[8];
37    char c_uid[8];
38    char c_gid[8];
39    char c_nlink[8];
40    char c_mtime[8];
41    char c_filesize[8];
42    char c_devmajor[8];
43    char c_devminor[8];
44    char c_rdevmajor[8];
45    char c_rdevminor[8];
46    char c_namesize[8];
47    char c_check[8];
48/*  char c_name[c_namesize rounded to 4 bytes]; */
49/*  char c_data[c_filesize rounded to 4 bytes]; */
50} __attribute__((packed));
51
52struct cpio_newc_node_info {
53    struct inode*               ci_self;
54    struct cpio_newc_node_info* ci_parent;
55    struct cpio_newc_node_info* ci_children;
56    struct cpio_newc_node_info* ci_next_sibling;
57    char*                       ci_name;
58    char*                       ci_linktargetname;
59};
60
61/* modes */
62#define IALLOC  0100000 /* i-node is allocated */
63#define ILARG   010000  /* large file */
64#define IFMT    0170000 /* type of file */
65
66static inline mode_t
67ancientfs_cpio_newc_mode(mode_t mode, uint32_t flags)
68{
69    return mode & (uint16_t)~(IALLOC & ILARG);
70}
71
72#endif /* _ANCIENTFS_CPIO_NEWC_H_ */