make_ext4fs: Remove off64_t in favor of standard off_t
[project/make_ext4fs.git] / ext4_utils.c
index ad0491f..1a886d7 100644 (file)
 #include <stddef.h>
 #include <string.h>
 
-#ifdef USE_MINGW
-#include <winsock2.h>
-#else
 #include <arpa/inet.h>
 #include <sys/ioctl.h>
-#endif
 
 #if defined(__linux__)
 #include <linux/fs.h>
@@ -98,9 +94,9 @@ int ext4_bg_has_super_block(int bg)
 /* Function to read the primary superblock */
 void read_sb(int fd, struct ext4_super_block *sb)
 {
-       off64_t ret;
+       off_t ret;
 
-       ret = lseek64(fd, 1024, SEEK_SET);
+       ret = lseek(fd, 1024, SEEK_SET);
        if (ret < 0)
                critical_error_errno("failed to seek to superblock");
 
@@ -114,9 +110,9 @@ void read_sb(int fd, struct ext4_super_block *sb)
 /* Function to write a primary or backup superblock at a given offset */
 void write_sb(int fd, unsigned long long offset, struct ext4_super_block *sb)
 {
-       off64_t ret;
+       off_t ret;
 
-       ret = lseek64(fd, offset, SEEK_SET);
+       ret = lseek(fd, offset, SEEK_SET);
        if (ret < 0)
                critical_error_errno("failed to seek to superblock");
 
@@ -195,7 +191,7 @@ void ext4_fill_in_sb()
 
        sb->s_inodes_count = info.inodes_per_group * aux_info.groups;
        sb->s_blocks_count_lo = aux_info.len_blocks;
-       sb->s_r_blocks_count_lo = 0;
+       sb->s_r_blocks_count_lo = (aux_info.len_blocks / 100) * info.reserve_pcnt;
        sb->s_free_blocks_count_lo = 0;
        sb->s_free_inodes_count = 0;
        sb->s_first_data_block = aux_info.first_data_block;
@@ -443,16 +439,12 @@ u64 get_block_device_size(int fd)
 
 int is_block_device_fd(int fd)
 {
-#ifdef USE_MINGW
-       return 0;
-#else
        struct stat st;
        int ret = fstat(fd, &st);
        if (ret < 0)
                return 0;
 
        return S_ISBLK(st.st_mode);
-#endif
 }
 
 u64 get_file_size(int fd)
@@ -500,18 +492,18 @@ u64 parse_num(const char *arg)
 
 int read_ext(int fd, int verbose)
 {
-       off64_t ret;
+       off_t ret;
        struct ext4_super_block sb;
 
        read_sb(fd, &sb);
 
        ext4_parse_sb_info(&sb);
 
-       ret = lseek64(fd, info.len, SEEK_SET);
+       ret = lseek(fd, info.len, SEEK_SET);
        if (ret < 0)
                critical_error_errno("failed to seek to end of input image");
 
-       ret = lseek64(fd, info.block_size * (aux_info.first_data_block + 1), SEEK_SET);
+       ret = lseek(fd, info.block_size * (aux_info.first_data_block + 1), SEEK_SET);
        if (ret < 0)
                critical_error_errno("failed to seek to block group descriptors");
 
@@ -541,4 +533,3 @@ int read_ext(int fd, int verbose)
 
        return 0;
 }
-