OSDN Git Service

ext4_utils: fix build for 64 bit
authorColin Cross <ccross@android.com>
Thu, 23 Jan 2014 21:19:27 +0000 (13:19 -0800)
committerColin Cross <ccross@android.com>
Thu, 30 Jan 2014 03:47:05 +0000 (19:47 -0800)
Correct u64/s64 definitions
Use PRIu64 to print u64

Change-Id: Icaf7998946b0a2faa03495b404af8b94e4e3d047

ext4_utils/ext2simg.c
ext4_utils/ext4_utils.h
ext4_utils/ext4fixup.c
ext4_utils/extent.c
ext4_utils/make_ext4fs.c

index 77c3650..1531f0b 100644 (file)
@@ -22,6 +22,7 @@
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <fcntl.h>
+#include <inttypes.h>
 #include <libgen.h>
 #include <unistd.h>
 
@@ -86,13 +87,13 @@ static int read_ext(int fd)
 
        if (verbose) {
                printf("Found filesystem with parameters:\n");
-               printf("    Size: %llu\n", info.len);
+               printf("    Size: %"PRIu64"\n", info.len);
                printf("    Block size: %d\n", info.block_size);
                printf("    Blocks per group: %d\n", info.blocks_per_group);
                printf("    Inodes per group: %d\n", info.inodes_per_group);
                printf("    Inode size: %d\n", info.inode_size);
                printf("    Label: %s\n", info.label);
-               printf("    Blocks: %llu\n", aux_info.len_blocks);
+               printf("    Blocks: %"PRIu64"\n", aux_info.len_blocks);
                printf("    Block groups: %d\n", aux_info.groups);
                printf("    Reserved block group size: %d\n", info.bg_desc_reserve_blocks);
                printf("    Used %d/%d inodes and %d/%d blocks\n",
index 9b5b7c4..447d416 100644 (file)
@@ -70,8 +70,13 @@ extern int force;
 #define le32_to_cpu(x) (x)
 #define le16_to_cpu(x) (x)
 
+#ifdef __LP64__
+typedef unsigned long u64;
+typedef signed long s64;
+#else
 typedef unsigned long long u64;
 typedef signed long long s64;
+#endif
 typedef unsigned int u32;
 typedef unsigned short int u16;
 typedef unsigned char u8;
index 7cf1f0e..7beeefb 100644 (file)
@@ -25,6 +25,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <fcntl.h>
+#include <inttypes.h>
 #include <unistd.h>
 
 #ifndef USE_MINGW
@@ -235,13 +236,13 @@ static int read_ext(int fd)
 
     if (verbose) {
         printf("Found filesystem with parameters:\n");
-        printf("    Size: %llu\n", info.len);
+        printf("    Size: %"PRIu64"\n", info.len);
         printf("    Block size: %d\n", info.block_size);
         printf("    Blocks per group: %d\n", info.blocks_per_group);
         printf("    Inodes per group: %d\n", info.inodes_per_group);
         printf("    Inode size: %d\n", info.inode_size);
         printf("    Label: %s\n", info.label);
-        printf("    Blocks: %llu\n", aux_info.len_blocks);
+        printf("    Blocks: %"PRIu64"\n", aux_info.len_blocks);
         printf("    Block groups: %d\n", aux_info.groups);
         printf("    Reserved block group size: %d\n", info.bg_desc_reserve_blocks);
         printf("    Used %d/%d inodes and %d/%d blocks\n",
index aeff0f6..abb30ce 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <sparse/sparse.h>
 
+#include <inttypes.h>
 #include <stdlib.h>
 #include <stdio.h>
 
@@ -128,7 +129,7 @@ static struct block_allocation *do_inode_allocate_extents(
 
                if (((int)(info.block_size - sizeof(struct ext4_extent_header) /
                                sizeof(struct ext4_extent))) < allocation_len) {
-                       error("File size %llu is too big to fit in a single extent block\n",
+                       error("File size %"PRIu64" is too big to fit in a single extent block\n",
                                        len);
                        return NULL;
                }
@@ -184,14 +185,14 @@ u8 *inode_allocate_data_extents(struct ext4_inode *inode, u64 len,
 
        alloc = do_inode_allocate_extents(inode, len);
        if (alloc == NULL) {
-               error("failed to allocate extents for %llu bytes", len);
+               error("failed to allocate extents for %"PRIu64" bytes", len);
                return NULL;
        }
 
        if (backing_len) {
                data = extent_create_backing(alloc, backing_len);
                if (!data)
-                       error("failed to create backing for %llu bytes", backing_len);
+                       error("failed to create backing for %"PRIu64" bytes", backing_len);
        }
 
        free_alloc(alloc);
@@ -208,7 +209,7 @@ void inode_allocate_file_extents(struct ext4_inode *inode, u64 len,
 
        alloc = do_inode_allocate_extents(inode, len);
        if (alloc == NULL) {
-               error("failed to allocate extents for %llu bytes", len);
+               error("failed to allocate extents for %"PRIu64" bytes", len);
                return;
        }
 
@@ -224,7 +225,7 @@ void inode_allocate_extents(struct ext4_inode *inode, u64 len)
 
        alloc = do_inode_allocate_extents(inode, len);
        if (alloc == NULL) {
-               error("failed to allocate extents for %llu bytes", len);
+               error("failed to allocate extents for %"PRIu64" bytes", len);
                return;
        }
 
index 2250241..0cb5bae 100644 (file)
@@ -26,6 +26,7 @@
 #include <assert.h>
 #include <dirent.h>
 #include <fcntl.h>
+#include <inttypes.h>
 #include <libgen.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -531,7 +532,7 @@ int make_ext4fs_internal(int fd, const char *_directory,
        info.bg_desc_reserve_blocks = compute_bg_desc_reserve_blocks();
 
        printf("Creating filesystem with parameters:\n");
-       printf("    Size: %llu\n", info.len);
+       printf("    Size: %"PRIu64"\n", info.len);
        printf("    Block size: %d\n", info.block_size);
        printf("    Blocks per group: %d\n", info.blocks_per_group);
        printf("    Inodes per group: %d\n", info.inodes_per_group);
@@ -541,7 +542,7 @@ int make_ext4fs_internal(int fd, const char *_directory,
 
        ext4_create_fs_aux_info();
 
-       printf("    Blocks: %llu\n", aux_info.len_blocks);
+       printf("    Blocks: %"PRIu64"\n", aux_info.len_blocks);
        printf("    Block groups: %d\n", aux_info.groups);
        printf("    Reserved block group size: %d\n", info.bg_desc_reserve_blocks);