diff options
Diffstat (limited to 'include/linux/cramfs_fs.h')
-rw-r--r-- | include/linux/cramfs_fs.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/include/linux/cramfs_fs.h b/include/linux/cramfs_fs.h new file mode 100644 index 000000000000..a8948f34b776 --- /dev/null +++ b/include/linux/cramfs_fs.h | |||
@@ -0,0 +1,98 @@ | |||
1 | #ifndef __CRAMFS_H | ||
2 | #define __CRAMFS_H | ||
3 | |||
4 | #ifndef __KERNEL__ | ||
5 | |||
6 | typedef unsigned char u8; | ||
7 | typedef unsigned short u16; | ||
8 | typedef unsigned int u32; | ||
9 | |||
10 | #endif | ||
11 | |||
12 | #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */ | ||
13 | #define CRAMFS_SIGNATURE "Compressed ROMFS" | ||
14 | |||
15 | /* | ||
16 | * Width of various bitfields in struct cramfs_inode. | ||
17 | * Primarily used to generate warnings in mkcramfs. | ||
18 | */ | ||
19 | #define CRAMFS_MODE_WIDTH 16 | ||
20 | #define CRAMFS_UID_WIDTH 16 | ||
21 | #define CRAMFS_SIZE_WIDTH 24 | ||
22 | #define CRAMFS_GID_WIDTH 8 | ||
23 | #define CRAMFS_NAMELEN_WIDTH 6 | ||
24 | #define CRAMFS_OFFSET_WIDTH 26 | ||
25 | |||
26 | /* | ||
27 | * Since inode.namelen is a unsigned 6-bit number, the maximum cramfs | ||
28 | * path length is 63 << 2 = 252. | ||
29 | */ | ||
30 | #define CRAMFS_MAXPATHLEN (((1 << CRAMFS_NAMELEN_WIDTH) - 1) << 2) | ||
31 | |||
32 | /* | ||
33 | * Reasonably terse representation of the inode data. | ||
34 | */ | ||
35 | struct cramfs_inode { | ||
36 | u32 mode:CRAMFS_MODE_WIDTH, uid:CRAMFS_UID_WIDTH; | ||
37 | /* SIZE for device files is i_rdev */ | ||
38 | u32 size:CRAMFS_SIZE_WIDTH, gid:CRAMFS_GID_WIDTH; | ||
39 | /* NAMELEN is the length of the file name, divided by 4 and | ||
40 | rounded up. (cramfs doesn't support hard links.) */ | ||
41 | /* OFFSET: For symlinks and non-empty regular files, this | ||
42 | contains the offset (divided by 4) of the file data in | ||
43 | compressed form (starting with an array of block pointers; | ||
44 | see README). For non-empty directories it is the offset | ||
45 | (divided by 4) of the inode of the first file in that | ||
46 | directory. For anything else, offset is zero. */ | ||
47 | u32 namelen:CRAMFS_NAMELEN_WIDTH, offset:CRAMFS_OFFSET_WIDTH; | ||
48 | }; | ||
49 | |||
50 | struct cramfs_info { | ||
51 | u32 crc; | ||
52 | u32 edition; | ||
53 | u32 blocks; | ||
54 | u32 files; | ||
55 | }; | ||
56 | |||
57 | /* | ||
58 | * Superblock information at the beginning of the FS. | ||
59 | */ | ||
60 | struct cramfs_super { | ||
61 | u32 magic; /* 0x28cd3d45 - random number */ | ||
62 | u32 size; /* length in bytes */ | ||
63 | u32 flags; /* feature flags */ | ||
64 | u32 future; /* reserved for future use */ | ||
65 | u8 signature[16]; /* "Compressed ROMFS" */ | ||
66 | struct cramfs_info fsid; /* unique filesystem info */ | ||
67 | u8 name[16]; /* user-defined name */ | ||
68 | struct cramfs_inode root; /* root inode data */ | ||
69 | }; | ||
70 | |||
71 | /* | ||
72 | * Feature flags | ||
73 | * | ||
74 | * 0x00000000 - 0x000000ff: features that work for all past kernels | ||
75 | * 0x00000100 - 0xffffffff: features that don't work for past kernels | ||
76 | */ | ||
77 | #define CRAMFS_FLAG_FSID_VERSION_2 0x00000001 /* fsid version #2 */ | ||
78 | #define CRAMFS_FLAG_SORTED_DIRS 0x00000002 /* sorted dirs */ | ||
79 | #define CRAMFS_FLAG_HOLES 0x00000100 /* support for holes */ | ||
80 | #define CRAMFS_FLAG_WRONG_SIGNATURE 0x00000200 /* reserved */ | ||
81 | #define CRAMFS_FLAG_SHIFTED_ROOT_OFFSET 0x00000400 /* shifted root fs */ | ||
82 | |||
83 | /* | ||
84 | * Valid values in super.flags. Currently we refuse to mount | ||
85 | * if (flags & ~CRAMFS_SUPPORTED_FLAGS). Maybe that should be | ||
86 | * changed to test super.future instead. | ||
87 | */ | ||
88 | #define CRAMFS_SUPPORTED_FLAGS ( 0x000000ff \ | ||
89 | | CRAMFS_FLAG_HOLES \ | ||
90 | | CRAMFS_FLAG_WRONG_SIGNATURE \ | ||
91 | | CRAMFS_FLAG_SHIFTED_ROOT_OFFSET ) | ||
92 | |||
93 | /* Uncompression interfaces to the underlying zlib */ | ||
94 | int cramfs_uncompress_block(void *dst, int dstlen, void *src, int srclen); | ||
95 | int cramfs_uncompress_init(void); | ||
96 | int cramfs_uncompress_exit(void); | ||
97 | |||
98 | #endif | ||