#include <sys/stat.h>
#include <sys/vfs.h>
#include <sys/ioctl.h>
+#ifdef HAVE_LINUX_FD_H
#include <linux/fd.h>
+#endif
#include <ext2fs/ext2fs.h>
#include <ext2fs/ext2_types.h>
#include <ext2fs/fiemap.h>
print_flag(&fe_flags, FIEMAP_EXTENT_SHARED, flags, "shared,");
/* print any unknown flags as hex values */
for (mask = 1; fe_flags != 0 && mask != 0; mask <<= 1) {
- char hex[6];
+ char hex[sizeof(mask) * 2 + 4]; /* 2 chars/byte + 0x, + NUL */
if ((fe_flags & mask) == 0)
continue;
__u64 buf[2048]; /* __u64 for proper field alignment */
struct fiemap *fiemap = (struct fiemap *)buf;
struct fiemap_extent *fm_ext = &fiemap->fm_extents[0];
- struct fiemap_extent fm_last = {0};
+ struct fiemap_extent fm_last;
int count = (sizeof(buf) - sizeof(*fiemap)) /
sizeof(struct fiemap_extent);
unsigned long long expected = 0;
int rc;
memset(fiemap, 0, sizeof(struct fiemap));
+ memset(&fm_last, 0, sizeof(fm_last));
if (sync_file)
flags |= FIEMAP_FLAG_SYNC;
fm_ext.fe_flags = FIEMAP_EXTENT_MERGED;
}
- if (sync_file)
- fsync(fd);
+ if (sync_file && fsync(fd) != 0)
+ return -errno;
for (i = 0, logical = 0, *num_extents = 0, count = last_block = 0;
i < numblocks;
static void usage(const char *progname)
{
- fprintf(stderr, "Usage: %s [-b{blocksize}] [-BeklsvxX] file ...\n",
+ fprintf(stderr, "Usage: %s [-b{blocksize}] [-BeksvxX] file ...\n",
progname);
exit(1);
}
char *end;
blocksize = strtoul(optarg, &end, 0);
if (end) {
+#if __GNUC_PREREQ (7, 0)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+#endif
switch (end[0]) {
case 'g':
case 'G':
blocksize *= 1024;
- /* no break */
+ /* fall through */
case 'm':
case 'M':
blocksize *= 1024;
- /* no break */
+ /* fall through */
case 'k':
case 'K':
blocksize *= 1024;
default:
break;
}
+#if __GNUC_PREREQ (7, 0)
+#pragma GCC diagnostic pop
+#endif
}
} else { /* Allow -b without argument for compat. Remove
* this eventually so "-b {blocksize}" works */
if (optind == argc)
usage(argv[0]);
- for (cpp = argv + optind; *cpp != '\0'; cpp++) {
+ for (cpp = argv + optind; *cpp != NULL; cpp++) {
int rc2 = frag_report(*cpp);
if (rc2 < 0 && rc == 0)