git-svn: trunk@4910
aCaB authored on 2009/03/08 03:16:20... | ... |
@@ -64,7 +64,7 @@ short recursion = 0, printinfected = 0, bell = 0; |
64 | 64 |
int main(int argc, char **argv) |
65 | 65 |
{ |
66 | 66 |
int ds, dms, ret; |
67 |
- double mb; |
|
67 |
+ double mb, rmb; |
|
68 | 68 |
struct timeval t1, t2; |
69 | 69 |
#ifndef C_WINDOWS |
70 | 70 |
struct timezone tz; |
... | ... |
@@ -195,6 +195,8 @@ int main(int argc, char **argv) |
195 | 195 |
} |
196 | 196 |
mb = info.blocks * (CL_COUNT_PRECISION / 1024) / 1024.0; |
197 | 197 |
logg("Data scanned: %2.2lf MB\n", mb); |
198 |
+ rmb = info.rblocks * (CL_COUNT_PRECISION / 1024) / 1024.0; |
|
199 |
+ logg("Data read: %2.2lf MB (ratio %.2f:1)\n", rmb, info.rblocks ? (double)info.blocks/(double)info.rblocks : 0); |
|
198 | 200 |
logg("Time: %u.%3.3u sec (%u m %u s)\n", ds, dms/1000, ds/60, ds%60); |
199 | 201 |
} |
200 | 202 |
|
... | ... |
@@ -26,7 +26,8 @@ struct s_info { |
26 | 26 |
unsigned int dirs; /* number of scanned directories */ |
27 | 27 |
unsigned int files; /* number of scanned files */ |
28 | 28 |
unsigned int ifiles; /* number of infected files */ |
29 |
- unsigned long int blocks; /* number of read 16kb blocks */ |
|
29 |
+ unsigned long int blocks; /* number of *scanned* 16kb blocks */ |
|
30 |
+ unsigned long int rblocks; /* number of *read* 16kb blocks */ |
|
30 | 31 |
}; |
31 | 32 |
|
32 | 33 |
extern struct s_info info; |
... | ... |
@@ -79,7 +79,7 @@ dev_t procdev; |
79 | 79 |
|
80 | 80 |
static int scanfile(const char *filename, struct cl_engine *engine, const struct optstruct *opts, unsigned int options) |
81 | 81 |
{ |
82 |
- int ret = 0, fd, included, printclean = 1; |
|
82 |
+ int ret = 0, fd, included, printclean = 1, fsize; |
|
83 | 83 |
const struct optstruct *opt; |
84 | 84 |
const char *virname; |
85 | 85 |
#ifdef C_LINUX |
... | ... |
@@ -122,12 +122,13 @@ static int scanfile(const char *filename, struct cl_engine *engine, const struct |
122 | 122 |
} |
123 | 123 |
} |
124 | 124 |
|
125 |
- if(fileinfo(filename, 1) == 0) { |
|
125 |
+ fsize = fileinfo(filename, 1); |
|
126 |
+ if(fsize == 0) { |
|
126 | 127 |
if(!printinfected) |
127 | 128 |
logg("~%s: Empty file\n", filename); |
128 | 129 |
return 0; |
129 | 130 |
} |
130 |
- |
|
131 |
+ info.rblocks += fsize / CL_COUNT_PRECISION; |
|
131 | 132 |
#ifndef C_WINDOWS |
132 | 133 |
if(geteuid()) |
133 | 134 |
if(checkaccess(filename, NULL, R_OK) != 1) { |
... | ... |
@@ -258,6 +259,7 @@ static int scandirs(const char *dirname, struct cl_engine *engine, const struct |
258 | 258 |
static int scanstdin(const struct cl_engine *engine, const struct optstruct *opts, int options) |
259 | 259 |
{ |
260 | 260 |
int ret; |
261 |
+ unsigned int fsize = 0; |
|
261 | 262 |
const char *virname, *tmpdir; |
262 | 263 |
char *file, buff[FILEBUFF]; |
263 | 264 |
size_t bread; |
... | ... |
@@ -290,17 +292,19 @@ static int scanstdin(const struct cl_engine *engine, const struct optstruct *opt |
290 | 290 |
return 63; |
291 | 291 |
} |
292 | 292 |
|
293 |
- while((bread = fread(buff, 1, FILEBUFF, stdin))) |
|
293 |
+ while((bread = fread(buff, 1, FILEBUFF, stdin))) { |
|
294 |
+ fsize += bread; |
|
294 | 295 |
if(fwrite(buff, 1, bread, fs) < bread) { |
295 | 296 |
logg("!Can't write to %s\n", file); |
296 | 297 |
free(file); |
297 | 298 |
return 58; |
298 | 299 |
} |
299 |
- |
|
300 |
+ } |
|
300 | 301 |
fclose(fs); |
301 | 302 |
|
302 | 303 |
logg("*Checking %s\n", file); |
303 | 304 |
info.files++; |
305 |
+ info.rblocks += fsize / CL_COUNT_PRECISION; |
|
304 | 306 |
|
305 | 307 |
if((ret = cl_scanfile(file, &virname, &info.blocks, engine, options)) == CL_VIRUS) { |
306 | 308 |
logg("stdin: %s FOUND\n", virname); |