Whamcloud - gitweb
ext2fs: check if Lustre filesystem is mounted
[tools/e2fsprogs.git] / misc / e2freefrag.c
index b315263..268fac9 100644 (file)
@@ -44,6 +44,10 @@ extern int optind;
 # include "fsmap.h"
 #endif
 
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
+
 static void usage(const char *prog)
 {
        fprintf(stderr, "usage: %s [-c chunksize in kb] [-h] "
@@ -169,7 +173,7 @@ static int scan_online(ext2_filsys fs, struct chunk_info *info)
        int mount_flags;
        int fd;
        int ret;
-       int i;
+       unsigned int i;
 
        /* Try to open the mountpoint for a live query. */
        retval = ext2fs_check_mount_point(fs->device_name, &mount_flags,
@@ -178,7 +182,7 @@ static int scan_online(ext2_filsys fs, struct chunk_info *info)
                com_err(fs->device_name, retval, "while checking mount status");
                return 0;
        }
-       if (!mount_flags & EXT2_MF_MOUNTED)
+       if (!(mount_flags & EXT2_MF_MOUNTED))
                return 0;
        fd = open(mntpoint, O_RDONLY);
        if (fd < 0) {
@@ -255,9 +259,10 @@ static errcode_t dump_chunk_info(ext2_filsys fs, struct chunk_info *info,
        unsigned long start = 0, end;
        int i, retval = 0;
 
-       fprintf(f, "Total blocks: %llu\nFree blocks: %u (%0.1f%%)\n",
-               ext2fs_blocks_count(fs->super), fs->super->s_free_blocks_count,
-               (double)fs->super->s_free_blocks_count * 100 /
+       fprintf(f, "Total blocks: %llu\nFree blocks: %llu (%0.1f%%)\n",
+               ext2fs_blocks_count(fs->super),
+               ext2fs_free_blocks_count(fs->super),
+               (double)ext2fs_free_blocks_count(fs->super) * 100 /
                ext2fs_blocks_count(fs->super));
 
        if (info->chunkbytes) {
@@ -301,7 +306,7 @@ static errcode_t dump_chunk_info(ext2_filsys fs, struct chunk_info *info,
                                info->histogram.fc_chunks[i],
                                info->histogram.fc_blocks[i],
                                (double)info->histogram.fc_blocks[i] * 100 /
-                               fs->super->s_free_blocks_count);
+                               ext2fs_free_blocks_count(fs->super));
                }
                start = end;
                if (start == 1<<10) {