Whamcloud - gitweb
git://git.whamcloud.com
/
tools
/
e2fsprogs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add more intelligent handling of the mke2fs.conf installation process
[tools/e2fsprogs.git]
/
misc
/
filefrag.c
diff --git
a/misc/filefrag.c
b/misc/filefrag.c
index
5d144ff
..
27675b1
100644
(file)
--- a/
misc/filefrag.c
+++ b/
misc/filefrag.c
@@
-44,9
+44,16
@@
int verbose = 0;
#define FIBMAP _IO(0x00,1) /* bmap access */
#define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
#define FIBMAP _IO(0x00,1) /* bmap access */
#define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
-#define EXT
3
_EXTENTS_FL 0x00080000 /* Inode uses extents */
+#define EXT
4
_EXTENTS_FL 0x00080000 /* Inode uses extents */
#define EXT3_IOC_GETFLAGS _IOR('f', 1, long)
#define EXT3_IOC_GETFLAGS _IOR('f', 1, long)
+static unsigned int div_ceil(unsigned int a, unsigned int b)
+{
+ if (!a)
+ return 0;
+ return ((a - 1) / b) + 1;
+}
+
static unsigned long get_bmap(int fd, unsigned long block)
{
int ret;
static unsigned long get_bmap(int fd, unsigned long block)
{
int ret;
@@
-75,8
+82,8
@@
static void frag_report(const char *filename)
struct stat fileinfo;
#endif
int bs;
struct stat fileinfo;
#endif
int bs;
- long
i,
fd;
- unsigned long block, last_block = 0, numblocks;
+ long fd;
+ unsigned long block, last_block = 0, numblocks
, i
;
long bpib; /* Blocks per indirect block */
long cylgroups;
int discont = 0, expected;
long bpib; /* Blocks per indirect block */
long cylgroups;
int discont = 0, expected;
@@
-103,9
+110,10
@@
static void frag_report(const char *filename)
(fsinfo.f_type == 0xef53))
is_ext2++;
if (verbose) {
(fsinfo.f_type == 0xef53))
is_ext2++;
if (verbose) {
- printf("Filesystem type is: %x\n", fsinfo.f_type);
+ printf("Filesystem type is: %lx\n",
+ (unsigned long) fsinfo.f_type);
}
}
- cylgroups =
(fsinfo.f_blocks + fsinfo.f_bsize*8-1) / fsinfo.f_bsize*8
;
+ cylgroups =
div_ceil(fsinfo.f_blocks, fsinfo.f_bsize*8)
;
if (verbose) {
printf("Filesystem cylinder groups is approximately %ld\n",
cylgroups);
if (verbose) {
printf("Filesystem cylinder groups is approximately %ld\n",
cylgroups);
@@
-126,7
+134,7
@@
static void frag_report(const char *filename)
}
if (ioctl(fd, EXT3_IOC_GETFLAGS, &flags) < 0)
flags = 0;
}
if (ioctl(fd, EXT3_IOC_GETFLAGS, &flags) < 0)
flags = 0;
- if (flags & EXT
3
_EXTENTS_FL) {
+ if (flags & EXT
4
_EXTENTS_FL) {
printf("File is stored in extents format\n");
is_ext2 = 0;
}
printf("File is stored in extents format\n");
is_ext2 = 0;
}