1997-04-26 17:34:30 +04:00
|
|
|
/*
|
|
|
|
* scantest.c - test the speed of the inode scan routine
|
|
|
|
*/
|
|
|
|
|
2011-09-19 01:34:37 +04:00
|
|
|
#include "config.h"
|
1997-04-26 17:34:30 +04:00
|
|
|
#include <string.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <termios.h>
|
|
|
|
#include <time.h>
|
1997-04-26 17:58:21 +04:00
|
|
|
#ifdef HAVE_GETOPT_H
|
1997-04-26 17:34:30 +04:00
|
|
|
#include <getopt.h>
|
1997-04-26 17:58:21 +04:00
|
|
|
#endif
|
1997-04-26 17:34:30 +04:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/ioctl.h>
|
2003-03-14 10:13:48 +03:00
|
|
|
#ifdef HAVE_MALLOC_H
|
1997-04-26 17:34:30 +04:00
|
|
|
#include <malloc.h>
|
2003-03-14 10:13:48 +03:00
|
|
|
#endif
|
1997-04-26 17:34:30 +04:00
|
|
|
#include <sys/resource.h>
|
|
|
|
|
|
|
|
#include "et/com_err.h"
|
|
|
|
#include "../version.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
Many files:
badblocks.c, chattr.c, dumpe2fs.c, e2image.c, findsuper.c, lsattr.c,
mke2fs.c, mklost+found.c, tune2fs.c, util.c: Change location of
ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, resize2fs.h:
resize2fs.h: Change location of ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, debugfs.h:
debugfs.h: Change location of ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, e2fsck.h, scantest.c:
e2fsck.h, scantest.c: Change location of ext2_fs.h to be
ext2fs/ext2_fs.h
ChangeLog, Makefile.in, tst_uuid.c, uuid_time.c:
tst_uuid.c, uuid_time.c: Remove unneeded #include of ext2_fs.h
ChangeLog, Makefile.in, e2p.h:
e2p.h: Change location of ext2_fs.h to be ext2fs/ext2_fs.h
ChangeLog, Makefile.in, test_icount.c, test_rel.c:
test_icount.c, test_rel.c: Change location of ext2_fs.h to be
ext2fs/ext2_fs.h
2001-05-14 15:45:38 +04:00
|
|
|
#include "ext2fs/ext2_fs.h"
|
1997-04-26 17:34:30 +04:00
|
|
|
#include "ext2fs/ext2fs.h"
|
|
|
|
|
|
|
|
|
|
|
|
extern int isatty(int);
|
|
|
|
|
|
|
|
const char * device_name = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This structure is used for keeping track of how much resources have
|
|
|
|
* been used for a particular pass of e2fsck.
|
|
|
|
*/
|
|
|
|
struct resource_track {
|
|
|
|
struct timeval time_start;
|
|
|
|
struct timeval user_start;
|
|
|
|
struct timeval system_start;
|
|
|
|
void *brk_start;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct resource_track global_rtrack;
|
|
|
|
|
|
|
|
void init_resource_track(struct resource_track *track)
|
|
|
|
{
|
|
|
|
struct rusage r;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1997-04-26 17:34:30 +04:00
|
|
|
track->brk_start = sbrk(0);
|
|
|
|
gettimeofday(&track->time_start, 0);
|
|
|
|
getrusage(RUSAGE_SELF, &r);
|
|
|
|
track->user_start = r.ru_utime;
|
|
|
|
track->system_start = r.ru_stime;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ float timeval_subtract(struct timeval *tv1,
|
|
|
|
struct timeval *tv2)
|
|
|
|
{
|
|
|
|
return ((tv1->tv_sec - tv2->tv_sec) +
|
|
|
|
((float) (tv1->tv_usec - tv2->tv_usec)) / 1000000);
|
|
|
|
}
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-03 21:48:10 +04:00
|
|
|
static void print_resource_track(struct resource_track *track)
|
1997-04-26 17:34:30 +04:00
|
|
|
{
|
|
|
|
struct rusage r;
|
|
|
|
struct timeval time_end;
|
|
|
|
|
|
|
|
gettimeofday(&time_end, 0);
|
|
|
|
getrusage(RUSAGE_SELF, &r);
|
|
|
|
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
printf(_("Memory used: %d, elapsed time: %6.3f/%6.3f/%6.3f\n"),
|
1997-04-26 17:34:30 +04:00
|
|
|
(int) (((char *) sbrk(0)) - ((char *) track->brk_start)),
|
|
|
|
timeval_subtract(&time_end, &track->time_start),
|
|
|
|
timeval_subtract(&r.ru_utime, &track->user_start),
|
|
|
|
timeval_subtract(&r.ru_stime, &track->system_start));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main (int argc, char *argv[])
|
|
|
|
{
|
|
|
|
errcode_t retval = 0;
|
|
|
|
int exit_value = 0;
|
|
|
|
int i;
|
|
|
|
ext2_filsys fs;
|
|
|
|
ext2_inode_scan scan;
|
Many files:
dirinfo.c, e2fsck.h, emptydir.c, iscan.c, jfs_user.h, journal.c,
message.c, pass1.c, pass1b.c, pass2.c, pass3.c, pass4.c, pass5.c,
problem.h, scantest.c, super.c, swapfs.c: Change ino_t to ext2_ino_t.
2001-01-11 18:12:14 +03:00
|
|
|
ext2_ino_t ino;
|
1997-04-26 17:34:30 +04:00
|
|
|
struct ext2_inode inode;
|
|
|
|
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
printf(_("size of inode=%d\n"), sizeof(inode));
|
1997-04-26 17:34:30 +04:00
|
|
|
|
|
|
|
device_name = "/dev/hda3";
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1997-04-26 17:34:30 +04:00
|
|
|
init_resource_track(&global_rtrack);
|
|
|
|
|
|
|
|
retval = ext2fs_open(device_name, 0,
|
|
|
|
0, 0, unix_io_manager, &fs);
|
|
|
|
if (retval) {
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
com_err(argv[0], retval, _("while trying to open %s"),
|
1997-04-26 17:34:30 +04:00
|
|
|
device_name);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
retval = ext2fs_open_inode_scan(fs, 0, &scan);
|
|
|
|
if (retval) {
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
com_err(argv[0], retval, _("while opening inode scan"));
|
1997-04-26 17:34:30 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
retval = ext2fs_get_next_inode(scan, &ino, &inode);
|
|
|
|
if (retval) {
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
com_err(argv[0], retval, _("while starting inode scan"));
|
1997-04-26 17:34:30 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
while (ino) {
|
|
|
|
if (!inode.i_links_count)
|
|
|
|
goto next;
|
|
|
|
printf("%lu\n", inode.i_blocks);
|
|
|
|
next:
|
|
|
|
retval = ext2fs_get_next_inode(scan, &ino, &inode);
|
|
|
|
if (retval) {
|
|
|
|
com_err(argv[0], retval,
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 06:11:03 +03:00
|
|
|
_("while doing inode scan"));
|
1997-04-26 17:34:30 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1997-04-26 17:34:30 +04:00
|
|
|
|
2014-07-06 05:06:29 +04:00
|
|
|
ext2fs_close_free(&fs);
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1997-04-26 17:34:30 +04:00
|
|
|
print_resource_track(&global_rtrack);
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1997-04-26 17:34:30 +04:00
|
|
|
return exit_value;
|
|
|
|
}
|