#ifndef __CRAMFS_H
#define __CRAMFS_H
-typedef unsigned char u8;
-typedef unsigned short u16;
-typedef unsigned int u32;
+#include <stdint.h>
#define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
#define CRAMFS_SIGNATURE "Compressed ROMFS"
* Reasonably terse representation of the inode data.
*/
struct cramfs_inode {
- u32 mode:16, uid:16;
+ uint32_t mode:16, uid:16;
/* SIZE for device files is i_rdev */
- u32 size:24, gid:8;
+ uint32_t size:24, gid:8;
/* NAMELEN is the length of the file name, divided by 4 and
rounded up. (cramfs doesn't support hard links.) */
/* OFFSET: For symlinks and non-empty regular files, this
see README). For non-empty directories it is the offset
(divided by 4) of the inode of the first file in that
directory. For anything else, offset is zero. */
- u32 namelen:6, offset:26;
+ uint32_t namelen:6, offset:26;
};
struct cramfs_info {
- u32 crc;
- u32 edition;
- u32 blocks;
- u32 files;
+ uint32_t crc;
+ uint32_t edition;
+ uint32_t blocks;
+ uint32_t files;
};
/*
* Superblock information at the beginning of the FS.
*/
struct cramfs_super {
- u32 magic; /* 0x28cd3d45 - random number */
- u32 size; /* Not used. mkcramfs currently
+ uint32_t magic; /* 0x28cd3d45 - random number */
+ uint32_t size; /* Not used. mkcramfs currently
writes a constant 1<<16 here. */
- u32 flags; /* 0 */
- u32 future; /* 0 */
- u8 signature[16]; /* "Compressed ROMFS" */
+ uint32_t flags; /* 0 */
+ uint32_t future; /* 0 */
+ uint8_t signature[16]; /* "Compressed ROMFS" */
struct cramfs_info fsid;/* unique filesystem info */
- u8 name[16]; /* user-defined name */
+ uint8_t name[16]; /* user-defined name */
struct cramfs_inode root; /* Root inode data */
};
int cramfs_uncompress_init(void);
int cramfs_uncompress_exit(void);
-u32 u32_toggle_endianness(int big_endian, u32 what);
+uint32_t u32_toggle_endianness(int big_endian, uint32_t what);
void super_toggle_endianness(int from_big_endian, struct cramfs_super *super);
void inode_to_host(int from_big_endian, struct cramfs_inode *inode_in, struct cramfs_inode *inode_out);
void inode_from_host(int to_big_endian, struct cramfs_inode *inode_in, struct cramfs_inode *inode_out);
#include <stdio.h>
#include <stdarg.h>
+#include <stdint.h>
#include <unistd.h>
#include <dirent.h>
#include <stdlib.h>
exit(status);
}
-int get_superblock_endianness(u32 magic)
+int get_superblock_endianness(uint32_t magic)
{
if (magic == CRAMFS_MAGIC) {
cramfs_is_big_endian = HOST_IS_BIG_ENDIAN;
static void test_crc(int start)
{
void *buf;
- u32 crc;
+ uint32_t crc;
if (!(super.flags & CRAMFS_FLAG_FSID_VERSION_2)) {
#ifdef INCLUDE_FS_TESTS
do {
unsigned long out = page_size;
- unsigned long next = u32_toggle_endianness(cramfs_is_big_endian, *(u32 *) romfs_read(offset));
+ unsigned long next = u32_toggle_endianness(cramfs_is_big_endian, *(uint32_t *) romfs_read(offset));
if (next > end_data) {
end_data = next;
{
unsigned long offset = i->offset << 2;
unsigned long curr = offset + 4;
- unsigned long next = u32_toggle_endianness(cramfs_is_big_endian, *(u32 *) romfs_read(offset));
+ unsigned long next = u32_toggle_endianness(cramfs_is_big_endian, *(uint32_t *) romfs_read(offset));
unsigned long size;
if (offset == 0) {
exit(MKFS_ERROR);
}
- *(u32 *) (base + offset) = u32_toggle_endianness(cramfs_is_big_endian, curr);
+ *(uint32_t *) (base + offset) = u32_toggle_endianness(cramfs_is_big_endian, curr);
offset += 4;
} while (size);
loff_t fslen_ub = sizeof(struct cramfs_super);
unsigned int fslen_max;
char const *dirname, *outfile;
- u32 crc = crc32(0L, Z_NULL, 0);
+ uint32_t crc = crc32(0L, Z_NULL, 0);
int c;
cramfs_is_big_endian = HOST_IS_BIG_ENDIAN; /* default is to use host order */