+2005-03-18 Theodore Ts'o <tytso@mit.edu>
+
+ * filefrag.c (frag_report): Automatically detect files that are
+ stored using the new experimental file fragments format,
+ and use the non-ext2 algorithm for determing the number of
+ extents. Avoid reporting a false discontinuity if there
+ is a non-allocated block (or extent) at the beginning of
+ the file.
+
2006-02-05 Theodore Ts'o <tytso@mit.edu>
* Release of E2fsprogs 1.36
#define FIBMAP _IO(0x00,1) /* bmap access */
#define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
+#define EXT3_EXTENTS_FL 0x00080000 /* Inode uses extents */
+#define EXT3_IOC_GETFLAGS _IOR('f', 1, long)
+
static unsigned long get_bmap(int fd, unsigned long block)
{
int ret;
long cylgroups;
int discont = 0, expected;
int is_ext2 = 0;
+ unsigned int flags;
if (statfs(filename, &fsinfo) < 0) {
perror("statfs");
close(fd);
return;
}
+ if (ioctl(fd, EXT3_IOC_GETFLAGS, &flags) < 0) {
+ perror("EXT3_IOC_GETFLAGS");
+ close(fd);
+ return;
+ }
+ if (flags & EXT3_EXTENTS_FL) {
+ printf("File is stored in extents format\n");
+ is_ext2 = 0;
+ }
if (verbose)
printf("Blocksize of file %s is %ld\n", filename, bs);
bpib = bs / 4;
last_block++;
}
block = get_bmap(fd, i);
- if (i && block && (block != last_block +1) ) {
+ if (block == 0)
+ continue;
+ if (last_block && (block != last_block +1) ) {
if (verbose)
printf("Discontinuity: Block %ld is at %ld (was %ld)\n",
i, block, last_block);
discont++;
}
- if (block)
- last_block = block;
+ last_block = block;
}
if (discont==0)
printf("%s: 1 extent found", filename);