Allow specifying reserved blocks percentage
[project/make_ext4fs.git] / ext4_utils.c
index ad0491f..2f1dbb2 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>
@@ -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)
@@ -541,4 +533,3 @@ int read_ext(int fd, int verbose)
 
        return 0;
 }
-