#include <endian.h>
#define swab16(x) \
- ((__u16)( \
- (((__u16)(x) & (__u16)0x00ffU) << 8) | \
- (((__u16)(x) & (__u16)0xff00U) >> 8) ))
+ ((uint16_t)( \
+ (((uint16_t)(x) & (uint16_t)0x00ffU) << 8) | \
+ (((uint16_t)(x) & (uint16_t)0xff00U) >> 8) ))
#define swab32(x) \
- ((__u32)( \
- (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \
- (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \
- (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \
- (((__u32)(x) & (__u32)0xff000000UL) >> 24) ))
+ ((uint32_t)( \
+ (((uint32_t)(x) & (__u32)0x000000ffUL) << 24) | \
+ (((uint32_t)(x) & (__u32)0x0000ff00UL) << 8) | \
+ (((uint32_t)(x) & (__u32)0x00ff0000UL) >> 8) | \
+ (((uint32_t)(x) & (__u32)0xff000000UL) >> 24) ))
#if __BYTE_ORDER == __BIG_ENDIAN
-#define cpu_to_le16(x) ({ __u16 _x = x; swab16(_x); })
-#define cpu_to_le32(x) ({ __u32 _x = x; swab32(_x); })
+#define cpu_to_le16(x) ({ uint16_t _x = x; swab16(_x); })
+#define cpu_to_le32(x) ({ uint32_t _x = x; swab32(_x); })
#define cpu_to_be16(x) (x)
#define cpu_to_be32(x) (x)
#else
#define cpu_to_le16(x) (x)
#define cpu_to_le32(x) (x)
-#define cpu_to_be16(x) ({ __u16 _x = x; swab16(_x); })
-#define cpu_to_be32(x) ({ __u32 _x = x; swab32(_x); })
+#define cpu_to_be16(x) ({ uint16_t _x = x; swab16(_x); })
+#define cpu_to_be32(x) ({ uint32_t _x = x; swab32(_x); })
#endif
#define le16_to_cpu(x) cpu_to_le16(x)
#define be16_to_cpu(x) cpu_to_be16(x)
/* How many padding bytes should be inserted between two chunks of data
on the flash? */
#define JFFS_GET_PAD_BYTES(size) ((JFFS_ALIGN_SIZE \
- - ((__u32)(size) % JFFS_ALIGN_SIZE)) \
+ - ((uint32_t)(size) % JFFS_ALIGN_SIZE)) \
% JFFS_ALIGN_SIZE)
#define JFFS_EMPTY_BITMASK 0xffffffff
struct jffs_raw_inode
{
- __u32 magic; /* A constant magic number. */
- __u32 ino; /* Inode number. */
- __u32 pino; /* Parent's inode number. */
- __u32 version; /* Version number. */
- __u32 mode; /* file_type, mode */
- __u16 uid;
- __u16 gid;
- __u32 atime;
- __u32 mtime;
- __u32 ctime;
- __u32 offset; /* Where to begin to write. */
- __u32 dsize; /* Size of the file data. */
- __u32 rsize; /* How much are going to be replaced? */
- __u8 nsize; /* Name length. */
- __u8 nlink; /* Number of links. */
- __u8 spare : 6; /* For future use. */
- __u8 rename : 1; /* Is this a special rename? */
- __u8 deleted : 1; /* Has this file been deleted? */
- __u8 accurate; /* The inode is obsolete if accurate == 0. */
- __u32 dchksum; /* Checksum for the data. */
- __u16 nchksum; /* Checksum for the name. */
- __u16 chksum; /* Checksum for the raw_inode. */
+ uint32_t magic; /* A constant magic number. */
+ uint32_t ino; /* Inode number. */
+ uint32_t pino; /* Parent's inode number. */
+ uint32_t version; /* Version number. */
+ uint32_t mode; /* file_type, mode */
+ uint16_t uid;
+ uint16_t gid;
+ uint32_t atime;
+ uint32_t mtime;
+ uint32_t ctime;
+ uint32_t offset; /* Where to begin to write. */
+ uint32_t dsize; /* Size of the file data. */
+ uint32_t rsize; /* How much are going to be replaced? */
+ uint8_t nsize; /* Name length. */
+ uint8_t nlink; /* Number of links. */
+ uint8_t spare : 6; /* For future use. */
+ uint8_t rename : 1; /* Is this a special rename? */
+ uint8_t deleted : 1; /* Has this file been deleted? */
+ uint8_t accurate; /* The inode is obsolete if accurate == 0. */
+ uint32_t dchksum; /* Checksum for the data. */
+ uint16_t nchksum; /* Checksum for the name. */
+ uint16_t chksum; /* Checksum for the raw_inode. */
};
#define ENDIAN_LITTLE 2
int endian = ENDIAN_HOST;
-static __u32 jffs_checksum(void *data, int size);
+static uint32_t jffs_checksum(void *data, int size);
void jffs_print_trace(const char *path, int depth);
int make_root_dir(FILE *fs, int first_ino, const char *root_dir_path,
int depth);
int mkfs(FILE *fs, const char *path, int ino, int parent, int depth);
-static __u32
+static uint32_t
jffs_checksum(void *data, int size)
{
- __u32 sum = 0;
- __u8 *ptr = (__u8 *)data;
+ uint32_t sum = 0;
+ uint8_t *ptr = (uint8_t *)data;
while (size-- > 0)
{
fprintf(stdout, "}\n");
}
-static void write_val32(__u32 *adr, __u32 val)
+static void write_val32(uint32_t *adr, uint32_t val)
{
switch(endian) {
case ENDIAN_HOST:
}
}
-static void write_val16(__u16 *adr, __u16 val)
+static void write_val16(uint16_t *adr, uint16_t val)
{
switch(endian) {
case ENDIAN_HOST:
}
}
-static __u32 read_val32(__u32 *adr)
+static uint32_t read_val32(uint32_t *adr)
{
- __u32 val;
+ uint32_t val;
switch(endian) {
case ENDIAN_HOST:
return val;
}
-static __u16 read_val16(__u16 *adr)
+static uint16_t read_val16(uint16_t *adr)
{
- __u16 val;
+ uint16_t val;
switch(endian) {
case ENDIAN_HOST:
{
int fs;
struct stat sb;
- __u32 wordbuf;
+ uint32_t wordbuf;
off_t pos = 0;
off_t end;
struct jffs_raw_inode ino;
/* How many padding bytes should be inserted between two chunks of data
on the flash? */
#define JFFS_GET_PAD_BYTES(size) ((JFFS_ALIGN_SIZE \
- - ((__u32)(size) % JFFS_ALIGN_SIZE)) \
+ - ((uint32_t)(size) % JFFS_ALIGN_SIZE)) \
% JFFS_ALIGN_SIZE)
struct jffs_raw_inode
{
- __u32 magic; /* A constant magic number. */
- __u32 ino; /* Inode number. */
- __u32 pino; /* Parent's inode number. */
- __u32 version; /* Version number. */
- __u32 mode; /* file_type, mode */
- __u16 uid;
- __u16 gid;
- __u32 atime;
- __u32 mtime;
- __u32 ctime;
- __u32 offset; /* Where to begin to write. */
- __u32 dsize; /* Size of the file data. */
- __u32 rsize; /* How much are going to be replaced? */
- __u8 nsize; /* Name length. */
- __u8 nlink; /* Number of links. */
- __u8 spare : 6; /* For future use. */
- __u8 rename : 1; /* Is this a special rename? */
- __u8 deleted : 1; /* Has this file been deleted? */
- __u8 accurate; /* The inode is obsolete if accurate == 0. */
- __u32 dchksum; /* Checksum for the data. */
- __u16 nchksum; /* Checksum for the name. */
- __u16 chksum; /* Checksum for the raw_inode. */
+ uint32_t magic; /* A constant magic number. */
+ uint32_t ino; /* Inode number. */
+ uint32_t pino; /* Parent's inode number. */
+ uint32_t version; /* Version number. */
+ uint32_t mode; /* file_type, mode */
+ uint16_t uid;
+ uint16_t gid;
+ uint32_t atime;
+ uint32_t mtime;
+ uint32_t ctime;
+ uint32_t offset; /* Where to begin to write. */
+ uint32_t dsize; /* Size of the file data. */
+ uint32_t rsize; /* How much are going to be replaced? */
+ uint8_t nsize; /* Name length. */
+ uint8_t nlink; /* Number of links. */
+ uint8_t spare : 6; /* For future use. */
+ uint8_t rename : 1; /* Is this a special rename? */
+ uint8_t deleted : 1; /* Has this file been deleted? */
+ uint8_t accurate; /* The inode is obsolete if accurate == 0. */
+ uint32_t dchksum; /* Checksum for the data. */
+ uint16_t nchksum; /* Checksum for the name. */
+ uint16_t chksum; /* Checksum for the raw_inode. */
};
#define ENDIAN_LITTLE 2
int endian = ENDIAN_HOST;
-static __u32 jffs_checksum(void *data, int size);
+static uint32_t jffs_checksum(void *data, int size);
void jffs_print_trace(const char *path, int depth);
int make_root_dir(FILE *fs, int first_ino, const char *root_dir_path,
int depth);
int mkfs(FILE *fs, const char *path, int ino, int parent, int depth);
-static __u32
+static uint32_t
jffs_checksum(void *data, int size)
{
- __u32 sum = 0;
- __u8 *ptr = (__u8 *)data;
+ uint32_t sum = 0;
+ uint8_t *ptr = (uint8_t *)data;
while (size-- > 0)
{
fprintf(stderr, "}\n");
}
-static void write_val32(__u32 *adr, __u32 val)
+static void write_val32(uint32_t *adr, uint32_t val)
{
switch(endian) {
case ENDIAN_HOST:
}
}
-static void write_val16(__u16 *adr, __u16 val)
+static void write_val16(uint16_t *adr, uint16_t val)
{
switch(endian) {
case ENDIAN_HOST:
}
}
-static __u32 read_val32(__u32 *adr)
+static uint32_t read_val32(uint32_t *adr)
{
- __u32 val = 0;
+ uint32_t val = 0;
switch(endian) {
case ENDIAN_HOST:
{
if (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode))
{
- __u16 tmp;
+ uint16_t tmp;
switch(endian) {
case ENDIAN_HOST:
int header_sectors;
int data_sectors;
int header_size;
- __u16 *header;
+ uint16_t *header;
int sector_count;
int *sector_map;
const char *mtd_filename;
sectors = 0;
for (i=0; i<rfd->data_sectors; i++) {
- __u16 entry = le16_to_cpu(rfd->header[i + HEADER_MAP_OFFSET]);
+ uint16_t entry = le16_to_cpu(rfd->header[i + HEADER_MAP_OFFSET]);
if (entry == SECTOR_FREE || entry == SECTOR_DELETED)
continue;
struct rfd rfd;
int i, blocks_found;
int out_fd = 0;
- __u8 sector[512];
+ uint8_t sector[512];
int blank, rc, cylinders;
process_options(argc, argv, &rfd);
rfd.header_sectors =
((HEADER_MAP_OFFSET + sectors_per_block) *
- sizeof(__u16) + SECTOR_SIZE - 1) / SECTOR_SIZE;
+ sizeof(uint16_t) + SECTOR_SIZE - 1) / SECTOR_SIZE;
rfd.data_sectors = sectors_per_block - rfd.header_sectors;
cylinders = ((rfd.block_count - 1) * rfd.data_sectors - 1)
/ SECTORS_PER_TRACK;
rfd.sector_count = cylinders * SECTORS_PER_TRACK;
rfd.header_size =
- (HEADER_MAP_OFFSET + rfd.data_sectors) * sizeof(__u16);
+ (HEADER_MAP_OFFSET + rfd.data_sectors) * sizeof(uint16_t);
rfd.header = malloc(rfd.header_size);
if (!rfd.header) {
int main(int argc, char *argv[])
{
- static const __u8 magic[] = { 0x93, 0x91 };
+ static const uint8_t magic[] = { 0x93, 0x91 };
int fd, block_count, i;
struct mtd_info_user mtd_info;
char buf[512];