]> git.ipfire.org Git - thirdparty/util-linux.git/blame - disk-utils/cramfs.h
Imported from util-linux-2.11t tarball.
[thirdparty/util-linux.git] / disk-utils / cramfs.h
CommitLineData
63cccae4
KZ
1#ifndef __CRAMFS_H
2#define __CRAMFS_H
3
4typedef unsigned char u8;
5typedef unsigned short u16;
6typedef unsigned int u32;
7
8#define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
9#define CRAMFS_SIGNATURE "Compressed ROMFS"
10
11/*
12 * Width of various bitfields in struct cramfs_inode.
13 * Primarily used to generate warnings in mkcramfs.
14 */
15#define CRAMFS_MODE_WIDTH 16
16#define CRAMFS_UID_WIDTH 16
17#define CRAMFS_SIZE_WIDTH 24
18#define CRAMFS_GID_WIDTH 8
19#define CRAMFS_NAMELEN_WIDTH 6
20#define CRAMFS_OFFSET_WIDTH 26
21
22
23/*
24 * Reasonably terse representation of the inode data.
25 */
26struct cramfs_inode {
27 u32 mode:16, uid:16;
28 /* SIZE for device files is i_rdev */
29 u32 size:24, gid:8;
30 /* NAMELEN is the length of the file name, divided by 4 and
31 rounded up. (cramfs doesn't support hard links.) */
32 /* OFFSET: For symlinks and non-empty regular files, this
33 contains the offset (divided by 4) of the file data in
34 compressed form (starting with an array of block pointers;
35 see README). For non-empty directories it is the offset
36 (divided by 4) of the inode of the first file in that
37 directory. For anything else, offset is zero. */
38 u32 namelen:6, offset:26;
39};
40
41struct cramfs_info {
42 u32 crc;
43 u32 edition;
44 u32 blocks;
45 u32 files;
46};
47
48/*
49 * Superblock information at the beginning of the FS.
50 */
51struct cramfs_super {
52 u32 magic; /* 0x28cd3d45 - random number */
53 u32 size; /* Not used. mkcramfs currently
54 writes a constant 1<<16 here. */
55 u32 flags; /* 0 */
56 u32 future; /* 0 */
57 u8 signature[16]; /* "Compressed ROMFS" */
58 struct cramfs_info fsid;/* unique filesystem info */
59 u8 name[16]; /* user-defined name */
60 struct cramfs_inode root; /* Root inode data */
61};
62
63#define CRAMFS_FLAG_FSID_VERSION_2 0x00000001 /* fsid version #2 */
64#define CRAMFS_FLAG_SORTED_DIRS 0x00000002 /* sorted dirs */
65#define CRAMFS_FLAG_HOLES 0x00000100 /* support for holes */
66#define CRAMFS_FLAG_WRONG_SIGNATURE 0x00000200 /* reserved */
67#define CRAMFS_FLAG_SHIFTED_ROOT_OFFSET 0x00000400 /* shifted root fs */
68
69/*
70 * Valid values in super.flags. Currently we refuse to mount
71 * if (flags & ~CRAMFS_SUPPORTED_FLAGS). Maybe that should be
72 * changed to test super.future instead.
73 */
74#define CRAMFS_SUPPORTED_FLAGS (0xff)
75
76/* Uncompression interfaces to the underlying zlib */
77int cramfs_uncompress_block(void *dst, int dstlen, void *src, int srclen);
78int cramfs_uncompress_init(void);
79int cramfs_uncompress_exit(void);
80
81#endif