]> www.infradead.org Git - mtd-utils.git/commitdiff
Switch to using standard types. This is userspace, not kernel.
authorJosh Boyer <jwboyer@gmail.com>
Wed, 17 May 2006 23:21:50 +0000 (18:21 -0500)
committerJosh Boyer <jwboyer@gmail.com>
Wed, 17 May 2006 23:21:50 +0000 (18:21 -0500)
Signed-off-by: Josh Boyer <jwboyer@gmail.com>
include/mtd_swab.h
jffs-dump.c
mkfs.jffs.c
rfddump.c
rfdformat.c

index 05732a9d755c49ec3b811f9920bfe87e92dcde66..a5175dacaf1b74bf1e3755ff8d021482c91e41d7 100644 (file)
@@ -4,26 +4,26 @@
 #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)
index 0a8b7e5371e433c06b8cc4e7af595fe288d4be68..771025ef8428e7f2ac67d46268b0d1a8f78d8660 100644 (file)
@@ -27,7 +27,7 @@
 /* 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.  */
 };
 
 
@@ -80,7 +80,7 @@ int verbose = 0;
 #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);
@@ -89,11 +89,11 @@ void read_data(struct jffs_file *f, const char *path, int offset);
 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)
   {
@@ -178,7 +178,7 @@ jffs_print_raw_inode(struct jffs_raw_inode *raw_inode)
        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:
@@ -193,7 +193,7 @@ static void write_val32(__u32 *adr, __u32 val)
   }
 }
 
-static void write_val16(__u16 *adr, __u16 val)
+static void write_val16(uint16_t *adr, uint16_t val)
 {
   switch(endian) {
   case ENDIAN_HOST:
@@ -208,9 +208,9 @@ static void write_val16(__u16 *adr, __u16 val)
   }
 }
 
-static __u32 read_val32(__u32 *adr)
+static uint32_t read_val32(uint32_t *adr)
 {
-  __u32 val;
+  uint32_t val;
 
   switch(endian) {
   case ENDIAN_HOST:
@@ -226,9 +226,9 @@ static __u32 read_val32(__u32 *adr)
   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:
@@ -249,7 +249,7 @@ main(int argc, char **argv)
 {
        int fs;
        struct stat sb;
-       __u32 wordbuf;
+       uint32_t wordbuf;
        off_t pos = 0;
        off_t end;
        struct jffs_raw_inode ino;
index 7e8de966e6e5827266aabc695146749b035c98b4..de6623ad5944a94a3201944d3a6a9185f6b1807a 100644 (file)
@@ -32,34 +32,34 @@ static int MAX_CHUNK_SIZE = 32768;
 /* 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.  */
 };
 
 
@@ -80,7 +80,7 @@ int verbose = 0;
 #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);
@@ -89,11 +89,11 @@ void read_data(struct jffs_file *f, const char *path, int offset);
 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)
   {
@@ -178,7 +178,7 @@ jffs_print_raw_inode(struct jffs_raw_inode *raw_inode)
        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:
@@ -193,7 +193,7 @@ static void write_val32(__u32 *adr, __u32 val)
   }
 }
 
-static void write_val16(__u16 *adr, __u16 val)
+static void write_val16(uint16_t *adr, uint16_t val)
 {
   switch(endian) {
   case ENDIAN_HOST:
@@ -208,9 +208,9 @@ static void write_val16(__u16 *adr, __u16 val)
   }
 }
 
-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:
@@ -316,7 +316,7 @@ write_file(struct jffs_file *f, FILE *fs, struct stat st)
   {
     if (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode))
     {
-      __u16 tmp;
+      uint16_t tmp;
 
       switch(endian) {
         case ENDIAN_HOST:
index f5884abefb101b061720fdd803d359cfcbb2b94c..d939dbefa224c2b67d01be22f0e32a32dc50ebe6 100644 (file)
--- a/rfddump.c
+++ b/rfddump.c
@@ -45,7 +45,7 @@ struct rfd {
        int header_sectors;
        int data_sectors;
        int header_size;
-       __u16 *header;
+       uint16_t *header;
        int sector_count;
        int *sector_map;
        const char *mtd_filename;
@@ -146,7 +146,7 @@ int build_block_map(struct rfd *rfd, int fd, int block)
 
        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;
@@ -184,7 +184,7 @@ int main(int argc, char *argv[])
        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);
@@ -240,13 +240,13 @@ int main(int argc, char *argv[])
 
        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) {
index ee84a21d0e7a170999c38755592060d3aeb15217..dbe122984b29a753ae0e49eb57060c0ef0b8cca8 100644 (file)
@@ -90,7 +90,7 @@ void process_options(int argc, char *argv[], const char **mtd_filename)
 
 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];