~ubuntu-branches/ubuntu/trusty/util-linux/trusty-proposed

« back to all changes in this revision

Viewing changes to disk-utils/cramfs.h

  • Committer: Package Import Robot
  • Author(s): LaMont Jones
  • Date: 2011-11-03 15:38:23 UTC
  • mto: (4.5.5 sid) (1.6.4)
  • mto: This revision was merged to the branch mainline in revision 85.
  • Revision ID: package-import@ubuntu.com-20111103153823-10sx16jprzxlhkqf
ImportĀ upstreamĀ versionĀ 2.20.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * cramfs_common - cramfs common code
 
3
 *
 
4
 * Copyright (c) 2008 Roy Peled, the.roy.peled  -at-  gmail
 
5
 * Copyright (c) 2004-2006 by Michael Holzt, kju -at- fqdn.org
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 2 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 */
 
18
 
1
19
#ifndef __CRAMFS_H
2
20
#define __CRAMFS_H
3
21
 
4
 
typedef unsigned char u8;
5
 
typedef unsigned short u16;
6
 
typedef unsigned int u32;
 
22
#include <stdint.h>
7
23
 
8
24
#define CRAMFS_MAGIC            0x28cd3d45      /* some random number */
9
25
#define CRAMFS_SIGNATURE        "Compressed ROMFS"
19
35
#define CRAMFS_NAMELEN_WIDTH 6
20
36
#define CRAMFS_OFFSET_WIDTH 26
21
37
 
 
38
#ifndef HOST_IS_BIG_ENDIAN
 
39
#ifdef WORDS_BIGENDIAN
 
40
#define HOST_IS_BIG_ENDIAN 1
 
41
#else
 
42
#define HOST_IS_BIG_ENDIAN 0
 
43
#endif
 
44
#endif
22
45
 
23
46
/*
24
47
 * Reasonably terse representation of the inode data.
25
48
 */
26
49
struct cramfs_inode {
27
 
        u32 mode:16, uid:16;
 
50
        uint32_t mode:16, uid:16;
28
51
        /* 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;
 
52
        uint32_t size:24, gid:8;
 
53
        /*
 
54
         * NAMELEN is the length of the file name, divided by 4 and
 
55
         * rounded up.  (cramfs doesn't support hard links.)
 
56
         *
 
57
         * OFFSET: For symlinks and non-empty regular files, this
 
58
         * contains the offset (divided by 4) of the file data in
 
59
         * compressed form (starting with an array of block pointers;
 
60
         * see README).  For non-empty directories it is the offset
 
61
         * (divided by 4) of the inode of the first file in that
 
62
         * directory.  For anything else, offset is zero.
 
63
         */
 
64
        uint32_t namelen:6, offset:26;
39
65
};
40
66
 
41
67
struct cramfs_info {
42
 
        u32 crc;
43
 
        u32 edition;
44
 
        u32 blocks;
45
 
        u32 files;
 
68
        uint32_t crc;
 
69
        uint32_t edition;
 
70
        uint32_t blocks;
 
71
        uint32_t files;
46
72
};
47
73
 
48
74
/*
49
75
 * Superblock information at the beginning of the FS.
50
76
 */
51
77
struct 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" */
 
78
        uint32_t magic;         /* 0x28cd3d45 - random number */
 
79
        uint32_t size;          /* Not used.  mkcramfs currently
 
80
                                   writes a constant 1<<16 here. */
 
81
        uint32_t flags;         /* 0 */
 
82
        uint32_t future;                /* 0 */
 
83
        uint8_t signature[16];  /* "Compressed ROMFS" */
58
84
        struct cramfs_info fsid;/* unique filesystem info */
59
 
        u8 name[16];            /* user-defined name */
 
85
        uint8_t name[16];               /* user-defined name */
60
86
        struct cramfs_inode root;       /* Root inode data */
61
87
};
62
88
 
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 */
 
89
#define CRAMFS_FLAG_FSID_VERSION_2      0x00000001      /* fsid version #2 */
 
90
#define CRAMFS_FLAG_SORTED_DIRS         0x00000002      /* sorted dirs */
 
91
#define CRAMFS_FLAG_HOLES               0x00000100      /* support for holes */
 
92
#define CRAMFS_FLAG_WRONG_SIGNATURE     0x00000200      /* reserved */
 
93
#define CRAMFS_FLAG_SHIFTED_ROOT_OFFSET 0x00000400      /* shifted root fs */
68
94
 
69
95
/*
70
96
 * Valid values in super.flags.  Currently we refuse to mount
78
104
int cramfs_uncompress_init(void);
79
105
int cramfs_uncompress_exit(void);
80
106
 
 
107
uint32_t u32_toggle_endianness(int big_endian, uint32_t what);
 
108
void super_toggle_endianness(int from_big_endian, struct cramfs_super *super);
 
109
void inode_to_host(int from_big_endian, struct cramfs_inode *inode_in,
 
110
                   struct cramfs_inode *inode_out);
 
111
void inode_from_host(int to_big_endian, struct cramfs_inode *inode_in,
 
112
                     struct cramfs_inode *inode_out);
 
113
 
81
114
#endif