]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
cramfs: use stdint.h instead of u{8,16,32}
authorSami Kerola <kerolasa@iki.fi>
Wed, 20 Jul 2011 20:00:02 +0000 (22:00 +0200)
committerSami Kerola <kerolasa@iki.fi>
Wed, 20 Jul 2011 20:49:48 +0000 (22:49 +0200)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
disk-utils/cramfs.h
disk-utils/cramfs_common.c
disk-utils/fsck.cramfs.c
disk-utils/mkfs.cramfs.c

index ba4ba7fbc014ff65fe431bac9a80034a851c6357..0ce2cec7683436f5769fa199aa9c5aa48f618d7e 100644 (file)
@@ -19,9 +19,7 @@
 #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"
@@ -49,9 +47,9 @@ typedef unsigned int u32;
  * 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
@@ -60,28 +58,28 @@ struct cramfs_inode {
           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 */
 };
 
@@ -103,7 +101,7 @@ int cramfs_uncompress_block(void *dst, int dstlen, void *src, int srclen);
 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);
index c76dbd1cfca331f5affb9763fffb532b97df377f..f4a257dd0a05653145546dff6c68be03e4deecdd 100644 (file)
@@ -20,7 +20,7 @@
 #include "cramfs.h"
 #include "../include/bitops.h"
 
-u32 u32_toggle_endianness(int big_endian, u32 what)
+uint32_t u32_toggle_endianness(int big_endian, uint32_t what)
 {
        return big_endian == HOST_IS_BIG_ENDIAN ? what : swab32(what);
 }
index 3d0c3e5f137b3ba1ce6c2c12385155dbc374a664..d615a953adc80f64a17ac17d1cc8a33000cd8e52 100644 (file)
@@ -38,6 +38,7 @@
 
 #include <stdio.h>
 #include <stdarg.h>
+#include <stdint.h>
 #include <unistd.h>
 #include <dirent.h>
 #include <stdlib.h>
@@ -139,7 +140,7 @@ static void die(int status, int syserr, const char *fmt, ...)
        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;
@@ -236,7 +237,7 @@ static void test_super(int *start, size_t *length) {
 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
@@ -402,7 +403,7 @@ static void do_uncompress(char *path, int fd, unsigned long offset, unsigned lon
 
        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;
@@ -563,7 +564,7 @@ static void do_symlink(char *path, struct cramfs_inode *i)
 {
        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) {
index 6767ba3c3e22206ac5998bbad09ad4baf84475ca..0bfd1370c4f182a804bf77621961d631bc12c2a9 100644 (file)
@@ -634,7 +634,7 @@ do_compress(char *base, unsigned int offset, unsigned char const *name,
                        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);
 
@@ -736,7 +736,7 @@ int main(int argc, char **argv)
        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 */