diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-10-19 20:52:57 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-10-19 20:52:57 +0000 |
commit | e674eb78e4cbd52d4b044d8e67d1620b32244e8f (patch) | |
tree | 8751bdd6f866ef10ad0131961256a62bc50772c6 | |
parent | e494fdd2c73f7f2979f7e02d65e46a50bd86a59f (diff) | |
download | busybox-w32-e674eb78e4cbd52d4b044d8e67d1620b32244e8f.tar.gz busybox-w32-e674eb78e4cbd52d4b044d8e67d1620b32244e8f.tar.bz2 busybox-w32-e674eb78e4cbd52d4b044d8e67d1620b32244e8f.zip |
Made em work.
-rw-r--r-- | fsck_minix.c | 302 | ||||
-rw-r--r-- | internal.h | 25 | ||||
-rw-r--r-- | mkfs_minix.c | 129 | ||||
-rw-r--r-- | util-linux/fsck_minix.c | 302 | ||||
-rw-r--r-- | util-linux/mkfs_minix.c | 129 | ||||
-rw-r--r-- | utility.c | 2 |
6 files changed, 439 insertions, 450 deletions
diff --git a/fsck_minix.c b/fsck_minix.c index e4b14d705..125274734 100644 --- a/fsck_minix.c +++ b/fsck_minix.c | |||
@@ -85,6 +85,7 @@ | |||
85 | * enforced (but it's not much fun on a character device :-). | 85 | * enforced (but it's not much fun on a character device :-). |
86 | */ | 86 | */ |
87 | 87 | ||
88 | #include "internal.h" | ||
88 | #include <stdio.h> | 89 | #include <stdio.h> |
89 | #include <errno.h> | 90 | #include <errno.h> |
90 | #include <unistd.h> | 91 | #include <unistd.h> |
@@ -98,8 +99,6 @@ | |||
98 | 99 | ||
99 | #include <linux/fs.h> | 100 | #include <linux/fs.h> |
100 | #include <linux/minix_fs.h> | 101 | #include <linux/minix_fs.h> |
101 | #include "../version.h" | ||
102 | #include "nls.h" | ||
103 | 102 | ||
104 | #ifdef MINIX2_SUPER_MAGIC2 | 103 | #ifdef MINIX2_SUPER_MAGIC2 |
105 | #define HAVE_MINIX2 1 | 104 | #define HAVE_MINIX2 1 |
@@ -171,10 +170,8 @@ static char *zone_map; | |||
171 | static unsigned char * inode_count = NULL; | 170 | static unsigned char * inode_count = NULL; |
172 | static unsigned char * zone_count = NULL; | 171 | static unsigned char * zone_count = NULL; |
173 | 172 | ||
174 | void recursive_check(unsigned int ino); | 173 | static void recursive_check(unsigned int ino); |
175 | void recursive_check2(unsigned int ino); | 174 | static void recursive_check2(unsigned int ino); |
176 | |||
177 | #include "bitops.h" | ||
178 | 175 | ||
179 | #define inode_in_use(x) (bit(inode_map,(x))) | 176 | #define inode_in_use(x) (bit(inode_map,(x))) |
180 | #define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1)) | 177 | #define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1)) |
@@ -185,22 +182,22 @@ void recursive_check2(unsigned int ino); | |||
185 | #define mark_zone(x) (setbit(zone_map,(x)-FIRSTZONE+1),changed=1) | 182 | #define mark_zone(x) (setbit(zone_map,(x)-FIRSTZONE+1),changed=1) |
186 | #define unmark_zone(x) (clrbit(zone_map,(x)-FIRSTZONE+1),changed=1) | 183 | #define unmark_zone(x) (clrbit(zone_map,(x)-FIRSTZONE+1),changed=1) |
187 | 184 | ||
188 | void leave(int) __attribute__ ((noreturn)); | 185 | static void leave(int) __attribute__ ((noreturn)); |
189 | void leave(int status) | 186 | static void leave(int status) |
190 | { | 187 | { |
191 | if (termios_set) | 188 | if (termios_set) |
192 | tcsetattr(0, TCSANOW, &termios); | 189 | tcsetattr(0, TCSANOW, &termios); |
193 | exit(status); | 190 | exit(status); |
194 | } | 191 | } |
195 | 192 | ||
196 | void usage(void) { | 193 | static void show_usage(void) { |
197 | fprintf(stderr, | 194 | fprintf(stderr, |
198 | _("Usage: %s [-larvsmf] /dev/name\n"), | 195 | "Usage: %s [-larvsmf] /dev/name\n", |
199 | program_name); | 196 | program_name); |
200 | leave(16); | 197 | leave(16); |
201 | } | 198 | } |
202 | 199 | ||
203 | void die(const char *str) { | 200 | static void die(const char *str) { |
204 | fprintf(stderr, "%s: %s\n", program_name, str); | 201 | fprintf(stderr, "%s: %s\n", program_name, str); |
205 | leave(8); | 202 | leave(8); |
206 | } | 203 | } |
@@ -209,7 +206,7 @@ void die(const char *str) { | |||
209 | * This simply goes through the file-name data and prints out the | 206 | * This simply goes through the file-name data and prints out the |
210 | * current file. | 207 | * current file. |
211 | */ | 208 | */ |
212 | void print_current_name(void) | 209 | static void print_current_name(void) |
213 | { | 210 | { |
214 | int i=0; | 211 | int i=0; |
215 | 212 | ||
@@ -219,7 +216,7 @@ void print_current_name(void) | |||
219 | printf ("/"); | 216 | printf ("/"); |
220 | } | 217 | } |
221 | 218 | ||
222 | int ask(const char * string, int def) | 219 | static int ask(const char * string, int def) |
223 | { | 220 | { |
224 | int c; | 221 | int c; |
225 | 222 | ||
@@ -293,13 +290,13 @@ static void check_mount(void) | |||
293 | else | 290 | else |
294 | close(fd); | 291 | close(fd); |
295 | 292 | ||
296 | printf (_("%s is mounted. "), device_name); | 293 | printf ("%s is mounted. ", device_name); |
297 | if (isatty(0) && isatty(1)) | 294 | if (isatty(0) && isatty(1)) |
298 | cont = ask(_("Do you really want to continue"), 0); | 295 | cont = ask("Do you really want to continue", 0); |
299 | else | 296 | else |
300 | cont = 0; | 297 | cont = 0; |
301 | if (!cont) { | 298 | if (!cont) { |
302 | printf (_("check aborted.\n")); | 299 | printf ("check aborted.\n"); |
303 | exit (0); | 300 | exit (0); |
304 | } | 301 | } |
305 | return; | 302 | return; |
@@ -311,19 +308,19 @@ static void check_mount(void) | |||
311 | * if an error was corrected, and returns the zone (0 for no zone | 308 | * if an error was corrected, and returns the zone (0 for no zone |
312 | * or a bad zone-number). | 309 | * or a bad zone-number). |
313 | */ | 310 | */ |
314 | int check_zone_nr(unsigned short * nr, int * corrected) | 311 | static int check_zone_nr(unsigned short * nr, int * corrected) |
315 | { | 312 | { |
316 | if (!*nr) | 313 | if (!*nr) |
317 | return 0; | 314 | return 0; |
318 | if (*nr < FIRSTZONE) | 315 | if (*nr < FIRSTZONE) |
319 | printf(_("Zone nr < FIRSTZONE in file `")); | 316 | printf("Zone nr < FIRSTZONE in file `"); |
320 | else if (*nr >= ZONES) | 317 | else if (*nr >= ZONES) |
321 | printf(_("Zone nr >= ZONES in file `")); | 318 | printf("Zone nr >= ZONES in file `"); |
322 | else | 319 | else |
323 | return *nr; | 320 | return *nr; |
324 | print_current_name(); | 321 | print_current_name(); |
325 | printf("'."); | 322 | printf("'."); |
326 | if (ask(_("Remove block"),1)) { | 323 | if (ask("Remove block",1)) { |
327 | *nr = 0; | 324 | *nr = 0; |
328 | *corrected = 1; | 325 | *corrected = 1; |
329 | } | 326 | } |
@@ -331,19 +328,19 @@ int check_zone_nr(unsigned short * nr, int * corrected) | |||
331 | } | 328 | } |
332 | 329 | ||
333 | #ifdef HAVE_MINIX2 | 330 | #ifdef HAVE_MINIX2 |
334 | int check_zone_nr2 (unsigned int *nr, int *corrected) | 331 | static int check_zone_nr2 (unsigned int *nr, int *corrected) |
335 | { | 332 | { |
336 | if (!*nr) | 333 | if (!*nr) |
337 | return 0; | 334 | return 0; |
338 | if (*nr < FIRSTZONE) | 335 | if (*nr < FIRSTZONE) |
339 | printf (_("Zone nr < FIRSTZONE in file `")); | 336 | printf ("Zone nr < FIRSTZONE in file `"); |
340 | else if (*nr >= ZONES) | 337 | else if (*nr >= ZONES) |
341 | printf (_("Zone nr >= ZONES in file `")); | 338 | printf ("Zone nr >= ZONES in file `"); |
342 | else | 339 | else |
343 | return *nr; | 340 | return *nr; |
344 | print_current_name (); | 341 | print_current_name (); |
345 | printf ("'."); | 342 | printf ("'."); |
346 | if (ask (_("Remove block"), 1)) { | 343 | if (ask ("Remove block", 1)) { |
347 | *nr = 0; | 344 | *nr = 0; |
348 | *corrected = 1; | 345 | *corrected = 1; |
349 | } | 346 | } |
@@ -354,20 +351,20 @@ int check_zone_nr2 (unsigned int *nr, int *corrected) | |||
354 | /* | 351 | /* |
355 | * read-block reads block nr into the buffer at addr. | 352 | * read-block reads block nr into the buffer at addr. |
356 | */ | 353 | */ |
357 | void read_block(unsigned int nr, char * addr) | 354 | static void read_block(unsigned int nr, char * addr) |
358 | { | 355 | { |
359 | if (!nr) { | 356 | if (!nr) { |
360 | memset(addr,0,BLOCK_SIZE); | 357 | memset(addr,0,BLOCK_SIZE); |
361 | return; | 358 | return; |
362 | } | 359 | } |
363 | if (BLOCK_SIZE*nr != lseek(IN, BLOCK_SIZE*nr, SEEK_SET)) { | 360 | if (BLOCK_SIZE*nr != lseek(IN, BLOCK_SIZE*nr, SEEK_SET)) { |
364 | printf(_("Read error: unable to seek to block in file '")); | 361 | printf("Read error: unable to seek to block in file '"); |
365 | print_current_name(); | 362 | print_current_name(); |
366 | printf("'\n"); | 363 | printf("'\n"); |
367 | memset(addr,0,BLOCK_SIZE); | 364 | memset(addr,0,BLOCK_SIZE); |
368 | errors_uncorrected = 1; | 365 | errors_uncorrected = 1; |
369 | } else if (BLOCK_SIZE != read(IN, addr, BLOCK_SIZE)) { | 366 | } else if (BLOCK_SIZE != read(IN, addr, BLOCK_SIZE)) { |
370 | printf(_("Read error: bad block in file '")); | 367 | printf("Read error: bad block in file '"); |
371 | print_current_name(); | 368 | print_current_name(); |
372 | printf("'\n"); | 369 | printf("'\n"); |
373 | memset(addr,0,BLOCK_SIZE); | 370 | memset(addr,0,BLOCK_SIZE); |
@@ -378,20 +375,20 @@ void read_block(unsigned int nr, char * addr) | |||
378 | /* | 375 | /* |
379 | * write_block writes block nr to disk. | 376 | * write_block writes block nr to disk. |
380 | */ | 377 | */ |
381 | void write_block(unsigned int nr, char * addr) | 378 | static void write_block(unsigned int nr, char * addr) |
382 | { | 379 | { |
383 | if (!nr) | 380 | if (!nr) |
384 | return; | 381 | return; |
385 | if (nr < FIRSTZONE || nr >= ZONES) { | 382 | if (nr < FIRSTZONE || nr >= ZONES) { |
386 | printf(_("Internal error: trying to write bad block\n" | 383 | printf("Internal error: trying to write bad block\n" |
387 | "Write request ignored\n")); | 384 | "Write request ignored\n"); |
388 | errors_uncorrected = 1; | 385 | errors_uncorrected = 1; |
389 | return; | 386 | return; |
390 | } | 387 | } |
391 | if (BLOCK_SIZE*nr != lseek(IN, BLOCK_SIZE*nr, SEEK_SET)) | 388 | if (BLOCK_SIZE*nr != lseek(IN, BLOCK_SIZE*nr, SEEK_SET)) |
392 | die(_("seek failed in write_block")); | 389 | die("seek failed in write_block"); |
393 | if (BLOCK_SIZE != write(IN, addr, BLOCK_SIZE)) { | 390 | if (BLOCK_SIZE != write(IN, addr, BLOCK_SIZE)) { |
394 | printf(_("Write error: bad block in file '")); | 391 | printf("Write error: bad block in file '"); |
395 | print_current_name(); | 392 | print_current_name(); |
396 | printf("'\n"); | 393 | printf("'\n"); |
397 | errors_uncorrected = 1; | 394 | errors_uncorrected = 1; |
@@ -403,7 +400,7 @@ void write_block(unsigned int nr, char * addr) | |||
403 | * It sets 'changed' if the inode has needed changing, and re-writes | 400 | * It sets 'changed' if the inode has needed changing, and re-writes |
404 | * any indirect blocks with errors. | 401 | * any indirect blocks with errors. |
405 | */ | 402 | */ |
406 | int map_block(struct minix_inode * inode, unsigned int blknr) | 403 | static int map_block(struct minix_inode * inode, unsigned int blknr) |
407 | { | 404 | { |
408 | unsigned short ind[BLOCK_SIZE>>1]; | 405 | unsigned short ind[BLOCK_SIZE>>1]; |
409 | unsigned short dind[BLOCK_SIZE>>1]; | 406 | unsigned short dind[BLOCK_SIZE>>1]; |
@@ -438,7 +435,7 @@ int map_block(struct minix_inode * inode, unsigned int blknr) | |||
438 | } | 435 | } |
439 | 436 | ||
440 | #ifdef HAVE_MINIX2 | 437 | #ifdef HAVE_MINIX2 |
441 | int map_block2 (struct minix2_inode *inode, unsigned int blknr) | 438 | static int map_block2 (struct minix2_inode *inode, unsigned int blknr) |
442 | { | 439 | { |
443 | unsigned int ind[BLOCK_SIZE >> 2]; | 440 | unsigned int ind[BLOCK_SIZE >> 2]; |
444 | unsigned int dind[BLOCK_SIZE >> 2]; | 441 | unsigned int dind[BLOCK_SIZE >> 2]; |
@@ -496,7 +493,7 @@ int map_block2 (struct minix2_inode *inode, unsigned int blknr) | |||
496 | } | 493 | } |
497 | #endif | 494 | #endif |
498 | 495 | ||
499 | void write_super_block(void) | 496 | static void write_super_block(void) |
500 | { | 497 | { |
501 | /* | 498 | /* |
502 | * Set the state of the filesystem based on whether or not there | 499 | * Set the state of the filesystem based on whether or not there |
@@ -510,26 +507,26 @@ void write_super_block(void) | |||
510 | Super.s_state &= ~MINIX_ERROR_FS; | 507 | Super.s_state &= ~MINIX_ERROR_FS; |
511 | 508 | ||
512 | if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET)) | 509 | if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET)) |
513 | die(_("seek failed in write_super_block")); | 510 | die("seek failed in write_super_block"); |
514 | if (BLOCK_SIZE != write(IN, super_block_buffer, BLOCK_SIZE)) | 511 | if (BLOCK_SIZE != write(IN, super_block_buffer, BLOCK_SIZE)) |
515 | die(_("unable to write super-block")); | 512 | die("unable to write super-block"); |
516 | 513 | ||
517 | return; | 514 | return; |
518 | } | 515 | } |
519 | 516 | ||
520 | void write_tables(void) | 517 | static void write_tables(void) |
521 | { | 518 | { |
522 | write_super_block(); | 519 | write_super_block(); |
523 | 520 | ||
524 | if (IMAPS*BLOCK_SIZE != write(IN,inode_map,IMAPS*BLOCK_SIZE)) | 521 | if (IMAPS*BLOCK_SIZE != write(IN,inode_map,IMAPS*BLOCK_SIZE)) |
525 | die(_("Unable to write inode map")); | 522 | die("Unable to write inode map"); |
526 | if (ZMAPS*BLOCK_SIZE != write(IN,zone_map,ZMAPS*BLOCK_SIZE)) | 523 | if (ZMAPS*BLOCK_SIZE != write(IN,zone_map,ZMAPS*BLOCK_SIZE)) |
527 | die(_("Unable to write zone map")); | 524 | die("Unable to write zone map"); |
528 | if (INODE_BUFFER_SIZE != write(IN,inode_buffer,INODE_BUFFER_SIZE)) | 525 | if (INODE_BUFFER_SIZE != write(IN,inode_buffer,INODE_BUFFER_SIZE)) |
529 | die(_("Unable to write inodes")); | 526 | die("Unable to write inodes"); |
530 | } | 527 | } |
531 | 528 | ||
532 | void get_dirsize (void) | 529 | static void get_dirsize (void) |
533 | { | 530 | { |
534 | int block; | 531 | int block; |
535 | char blk[BLOCK_SIZE]; | 532 | char blk[BLOCK_SIZE]; |
@@ -552,12 +549,12 @@ void get_dirsize (void) | |||
552 | /* use defaults */ | 549 | /* use defaults */ |
553 | } | 550 | } |
554 | 551 | ||
555 | void read_superblock(void) | 552 | static void read_superblock(void) |
556 | { | 553 | { |
557 | if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET)) | 554 | if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET)) |
558 | die(_("seek failed")); | 555 | die("seek failed"); |
559 | if (BLOCK_SIZE != read(IN, super_block_buffer, BLOCK_SIZE)) | 556 | if (BLOCK_SIZE != read(IN, super_block_buffer, BLOCK_SIZE)) |
560 | die(_("unable to read super block")); | 557 | die("unable to read super block"); |
561 | if (MAGIC == MINIX_SUPER_MAGIC) { | 558 | if (MAGIC == MINIX_SUPER_MAGIC) { |
562 | namelen = 14; | 559 | namelen = 14; |
563 | dirsize = 16; | 560 | dirsize = 16; |
@@ -577,20 +574,20 @@ void read_superblock(void) | |||
577 | version2 = 1; | 574 | version2 = 1; |
578 | #endif | 575 | #endif |
579 | } else | 576 | } else |
580 | die(_("bad magic number in super-block")); | 577 | die("bad magic number in super-block"); |
581 | if (ZONESIZE != 0 || BLOCK_SIZE != 1024) | 578 | if (ZONESIZE != 0 || BLOCK_SIZE != 1024) |
582 | die(_("Only 1k blocks/zones supported")); | 579 | die("Only 1k blocks/zones supported"); |
583 | if (IMAPS * BLOCK_SIZE * 8 < INODES + 1) | 580 | if (IMAPS * BLOCK_SIZE * 8 < INODES + 1) |
584 | die(_("bad s_imap_blocks field in super-block")); | 581 | die("bad s_imap_blocks field in super-block"); |
585 | if (ZMAPS * BLOCK_SIZE * 8 < ZONES - FIRSTZONE + 1) | 582 | if (ZMAPS * BLOCK_SIZE * 8 < ZONES - FIRSTZONE + 1) |
586 | die(_("bad s_zmap_blocks field in super-block")); | 583 | die("bad s_zmap_blocks field in super-block"); |
587 | } | 584 | } |
588 | 585 | ||
589 | void read_tables(void) | 586 | static void read_tables(void) |
590 | { | 587 | { |
591 | inode_map = malloc(IMAPS * BLOCK_SIZE); | 588 | inode_map = malloc(IMAPS * BLOCK_SIZE); |
592 | if (!inode_map) | 589 | if (!inode_map) |
593 | die(_("Unable to allocate buffer for inode map")); | 590 | die("Unable to allocate buffer for inode map"); |
594 | zone_map = malloc(ZMAPS * BLOCK_SIZE); | 591 | zone_map = malloc(ZMAPS * BLOCK_SIZE); |
595 | if (!inode_map) | 592 | if (!inode_map) |
596 | die("Unable to allocate buffer for zone map"); | 593 | die("Unable to allocate buffer for zone map"); |
@@ -598,32 +595,32 @@ void read_tables(void) | |||
598 | memset(zone_map,0,sizeof(zone_map)); | 595 | memset(zone_map,0,sizeof(zone_map)); |
599 | inode_buffer = malloc(INODE_BUFFER_SIZE); | 596 | inode_buffer = malloc(INODE_BUFFER_SIZE); |
600 | if (!inode_buffer) | 597 | if (!inode_buffer) |
601 | die(_("Unable to allocate buffer for inodes")); | 598 | die("Unable to allocate buffer for inodes"); |
602 | inode_count = malloc(INODES + 1); | 599 | inode_count = malloc(INODES + 1); |
603 | if (!inode_count) | 600 | if (!inode_count) |
604 | die(_("Unable to allocate buffer for inode count")); | 601 | die("Unable to allocate buffer for inode count"); |
605 | zone_count = malloc(ZONES); | 602 | zone_count = malloc(ZONES); |
606 | if (!zone_count) | 603 | if (!zone_count) |
607 | die(_("Unable to allocate buffer for zone count")); | 604 | die("Unable to allocate buffer for zone count"); |
608 | if (IMAPS*BLOCK_SIZE != read(IN,inode_map,IMAPS*BLOCK_SIZE)) | 605 | if (IMAPS*BLOCK_SIZE != read(IN,inode_map,IMAPS*BLOCK_SIZE)) |
609 | die(_("Unable to read inode map")); | 606 | die("Unable to read inode map"); |
610 | if (ZMAPS*BLOCK_SIZE != read(IN,zone_map,ZMAPS*BLOCK_SIZE)) | 607 | if (ZMAPS*BLOCK_SIZE != read(IN,zone_map,ZMAPS*BLOCK_SIZE)) |
611 | die(_("Unable to read zone map")); | 608 | die("Unable to read zone map"); |
612 | if (INODE_BUFFER_SIZE != read(IN,inode_buffer,INODE_BUFFER_SIZE)) | 609 | if (INODE_BUFFER_SIZE != read(IN,inode_buffer,INODE_BUFFER_SIZE)) |
613 | die(_("Unable to read inodes")); | 610 | die("Unable to read inodes"); |
614 | if (NORM_FIRSTZONE != FIRSTZONE) { | 611 | if (NORM_FIRSTZONE != FIRSTZONE) { |
615 | printf(_("Warning: Firstzone != Norm_firstzone\n")); | 612 | printf("Warning: Firstzone != Norm_firstzone\n"); |
616 | errors_uncorrected = 1; | 613 | errors_uncorrected = 1; |
617 | } | 614 | } |
618 | get_dirsize (); | 615 | get_dirsize (); |
619 | if (show) { | 616 | if (show) { |
620 | printf(_("%ld inodes\n"),INODES); | 617 | printf("%ld inodes\n",INODES); |
621 | printf(_("%ld blocks\n"),ZONES); | 618 | printf("%ld blocks\n",ZONES); |
622 | printf(_("Firstdatazone=%ld (%ld)\n"),FIRSTZONE,NORM_FIRSTZONE); | 619 | printf("Firstdatazone=%ld (%ld)\n",FIRSTZONE,NORM_FIRSTZONE); |
623 | printf(_("Zonesize=%d\n"),BLOCK_SIZE<<ZONESIZE); | 620 | printf("Zonesize=%d\n",BLOCK_SIZE<<ZONESIZE); |
624 | printf(_("Maxsize=%ld\n"),MAXSIZE); | 621 | printf("Maxsize=%ld\n",MAXSIZE); |
625 | printf(_("Filesystem state=%d\n"), Super.s_state); | 622 | printf("Filesystem state=%d\n", Super.s_state); |
626 | printf(_("namelen=%d\n\n"),namelen); | 623 | printf("namelen=%d\n\n",namelen); |
627 | } | 624 | } |
628 | } | 625 | } |
629 | 626 | ||
@@ -637,12 +634,12 @@ struct minix_inode * get_inode(unsigned int nr) | |||
637 | inode = Inode + nr; | 634 | inode = Inode + nr; |
638 | if (!inode_count[nr]) { | 635 | if (!inode_count[nr]) { |
639 | if (!inode_in_use(nr)) { | 636 | if (!inode_in_use(nr)) { |
640 | printf(_("Inode %d marked not used, but used for file '"), | 637 | printf("Inode %d marked not used, but used for file '", |
641 | nr); | 638 | nr); |
642 | print_current_name(); | 639 | print_current_name(); |
643 | printf("'\n"); | 640 | printf("'\n"); |
644 | if (repair) { | 641 | if (repair) { |
645 | if (ask(_("Mark in use"),1)) | 642 | if (ask("Mark in use",1)) |
646 | mark_inode(nr); | 643 | mark_inode(nr); |
647 | } else { | 644 | } else { |
648 | errors_uncorrected = 1; | 645 | errors_uncorrected = 1; |
@@ -664,13 +661,13 @@ struct minix_inode * get_inode(unsigned int nr) | |||
664 | ; | 661 | ; |
665 | else { | 662 | else { |
666 | print_current_name(); | 663 | print_current_name(); |
667 | printf(_(" has mode %05o\n"),inode->i_mode); | 664 | printf(" has mode %05o\n",inode->i_mode); |
668 | } | 665 | } |
669 | 666 | ||
670 | } else | 667 | } else |
671 | links++; | 668 | links++; |
672 | if (!++inode_count[nr]) { | 669 | if (!++inode_count[nr]) { |
673 | printf(_("Warning: inode count too big.\n")); | 670 | printf("Warning: inode count too big.\n"); |
674 | inode_count[nr]--; | 671 | inode_count[nr]--; |
675 | errors_uncorrected = 1; | 672 | errors_uncorrected = 1; |
676 | } | 673 | } |
@@ -689,11 +686,11 @@ get_inode2 (unsigned int nr) | |||
689 | inode = Inode2 + nr; | 686 | inode = Inode2 + nr; |
690 | if (!inode_count[nr]) { | 687 | if (!inode_count[nr]) { |
691 | if (!inode_in_use (nr)) { | 688 | if (!inode_in_use (nr)) { |
692 | printf (_("Inode %d marked not used, but used for file '"), nr); | 689 | printf ("Inode %d marked not used, but used for file '", nr); |
693 | print_current_name (); | 690 | print_current_name (); |
694 | printf ("'\n"); | 691 | printf ("'\n"); |
695 | if (repair) { | 692 | if (repair) { |
696 | if (ask (_("Mark in use"), 1)) | 693 | if (ask ("Mark in use", 1)) |
697 | mark_inode (nr); | 694 | mark_inode (nr); |
698 | else | 695 | else |
699 | errors_uncorrected = 1; | 696 | errors_uncorrected = 1; |
@@ -713,12 +710,12 @@ get_inode2 (unsigned int nr) | |||
713 | else if (S_ISFIFO (inode->i_mode)); | 710 | else if (S_ISFIFO (inode->i_mode)); |
714 | else { | 711 | else { |
715 | print_current_name (); | 712 | print_current_name (); |
716 | printf (_(" has mode %05o\n"), inode->i_mode); | 713 | printf (" has mode %05o\n", inode->i_mode); |
717 | } | 714 | } |
718 | } else | 715 | } else |
719 | links++; | 716 | links++; |
720 | if (!++inode_count[nr]) { | 717 | if (!++inode_count[nr]) { |
721 | printf (_("Warning: inode count too big.\n")); | 718 | printf ("Warning: inode count too big.\n"); |
722 | inode_count[nr]--; | 719 | inode_count[nr]--; |
723 | errors_uncorrected = 1; | 720 | errors_uncorrected = 1; |
724 | } | 721 | } |
@@ -726,16 +723,16 @@ get_inode2 (unsigned int nr) | |||
726 | } | 723 | } |
727 | #endif | 724 | #endif |
728 | 725 | ||
729 | void check_root(void) | 726 | static void check_root(void) |
730 | { | 727 | { |
731 | struct minix_inode * inode = Inode + ROOT_INO; | 728 | struct minix_inode * inode = Inode + ROOT_INO; |
732 | 729 | ||
733 | if (!inode || !S_ISDIR(inode->i_mode)) | 730 | if (!inode || !S_ISDIR(inode->i_mode)) |
734 | die(_("root inode isn't a directory")); | 731 | die("root inode isn't a directory"); |
735 | } | 732 | } |
736 | 733 | ||
737 | #ifdef HAVE_MINIX2 | 734 | #ifdef HAVE_MINIX2 |
738 | void check_root2 (void) | 735 | static void check_root2 (void) |
739 | { | 736 | { |
740 | struct minix2_inode *inode = Inode2 + ROOT_INO; | 737 | struct minix2_inode *inode = Inode2 + ROOT_INO; |
741 | 738 | ||
@@ -754,10 +751,10 @@ static int add_zone(unsigned short * znr, int * corrected) | |||
754 | if (!block) | 751 | if (!block) |
755 | return 0; | 752 | return 0; |
756 | if (zone_count[block]) { | 753 | if (zone_count[block]) { |
757 | printf(_("Block has been used before. Now in file `")); | 754 | printf("Block has been used before. Now in file `"); |
758 | print_current_name(); | 755 | print_current_name(); |
759 | printf("'."); | 756 | printf("'."); |
760 | if (ask(_("Clear"),1)) { | 757 | if (ask("Clear",1)) { |
761 | *znr = 0; | 758 | *znr = 0; |
762 | block = 0; | 759 | block = 0; |
763 | *corrected = 1; | 760 | *corrected = 1; |
@@ -766,10 +763,10 @@ static int add_zone(unsigned short * znr, int * corrected) | |||
766 | if (!block) | 763 | if (!block) |
767 | return 0; | 764 | return 0; |
768 | if (!zone_in_use(block)) { | 765 | if (!zone_in_use(block)) { |
769 | printf(_("Block %d in file `"),block); | 766 | printf("Block %d in file `",block); |
770 | print_current_name(); | 767 | print_current_name(); |
771 | printf(_("' is marked not in use.")); | 768 | printf("' is marked not in use."); |
772 | if (ask(_("Correct"),1)) | 769 | if (ask("Correct",1)) |
773 | mark_zone(block); | 770 | mark_zone(block); |
774 | } | 771 | } |
775 | if (!++zone_count[block]) | 772 | if (!++zone_count[block]) |
@@ -788,10 +785,10 @@ static int add_zone2 (unsigned int *znr, int *corrected) | |||
788 | if (!block) | 785 | if (!block) |
789 | return 0; | 786 | return 0; |
790 | if (zone_count[block]) { | 787 | if (zone_count[block]) { |
791 | printf (_("Block has been used before. Now in file `")); | 788 | printf ("Block has been used before. Now in file `"); |
792 | print_current_name (); | 789 | print_current_name (); |
793 | printf ("'."); | 790 | printf ("'."); |
794 | if (ask (_("Clear"), 1)) { | 791 | if (ask ("Clear", 1)) { |
795 | *znr = 0; | 792 | *znr = 0; |
796 | block = 0; | 793 | block = 0; |
797 | *corrected = 1; | 794 | *corrected = 1; |
@@ -800,10 +797,10 @@ static int add_zone2 (unsigned int *znr, int *corrected) | |||
800 | if (!block) | 797 | if (!block) |
801 | return 0; | 798 | return 0; |
802 | if (!zone_in_use (block)) { | 799 | if (!zone_in_use (block)) { |
803 | printf (_("Block %d in file `"), block); | 800 | printf ("Block %d in file `", block); |
804 | print_current_name (); | 801 | print_current_name (); |
805 | printf (_("' is marked not in use.")); | 802 | printf ("' is marked not in use."); |
806 | if (ask (_("Correct"), 1)) | 803 | if (ask ("Correct", 1)) |
807 | mark_zone (block); | 804 | mark_zone (block); |
808 | } | 805 | } |
809 | if (!++zone_count[block]) | 806 | if (!++zone_count[block]) |
@@ -899,7 +896,7 @@ add_zone_tind2 (unsigned int *znr, int *corrected) | |||
899 | } | 896 | } |
900 | #endif | 897 | #endif |
901 | 898 | ||
902 | void check_zones(unsigned int i) | 899 | static void check_zones(unsigned int i) |
903 | { | 900 | { |
904 | struct minix_inode * inode; | 901 | struct minix_inode * inode; |
905 | 902 | ||
@@ -918,7 +915,7 @@ void check_zones(unsigned int i) | |||
918 | } | 915 | } |
919 | 916 | ||
920 | #ifdef HAVE_MINIX2 | 917 | #ifdef HAVE_MINIX2 |
921 | void | 918 | static void |
922 | check_zones2 (unsigned int i) | 919 | check_zones2 (unsigned int i) |
923 | { | 920 | { |
924 | struct minix2_inode *inode; | 921 | struct minix2_inode *inode; |
@@ -939,7 +936,7 @@ check_zones2 (unsigned int i) | |||
939 | } | 936 | } |
940 | #endif | 937 | #endif |
941 | 938 | ||
942 | void check_file(struct minix_inode * dir, unsigned int offset) | 939 | static void check_file(struct minix_inode * dir, unsigned int offset) |
943 | { | 940 | { |
944 | static char blk[BLOCK_SIZE]; | 941 | static char blk[BLOCK_SIZE]; |
945 | struct minix_inode * inode; | 942 | struct minix_inode * inode; |
@@ -953,9 +950,9 @@ void check_file(struct minix_inode * dir, unsigned int offset) | |||
953 | ino = * (unsigned short *) (name-2); | 950 | ino = * (unsigned short *) (name-2); |
954 | if (ino > INODES) { | 951 | if (ino > INODES) { |
955 | print_current_name(); | 952 | print_current_name(); |
956 | printf(_(" contains a bad inode number for file '")); | 953 | printf(" contains a bad inode number for file '"); |
957 | printf("%.*s'.",namelen,name); | 954 | printf("%.*s'.",namelen,name); |
958 | if (ask(_(" Remove"),1)) { | 955 | if (ask(" Remove",1)) { |
959 | *(unsigned short *)(name-2) = 0; | 956 | *(unsigned short *)(name-2) = 0; |
960 | write_block(block, blk); | 957 | write_block(block, blk); |
961 | } | 958 | } |
@@ -969,14 +966,14 @@ void check_file(struct minix_inode * dir, unsigned int offset) | |||
969 | if (!offset) { | 966 | if (!offset) { |
970 | if (!inode || strcmp(".",name)) { | 967 | if (!inode || strcmp(".",name)) { |
971 | print_current_name(); | 968 | print_current_name(); |
972 | printf(_(": bad directory: '.' isn't first\n")); | 969 | printf(": bad directory: '.' isn't first\n"); |
973 | errors_uncorrected = 1; | 970 | errors_uncorrected = 1; |
974 | } else return; | 971 | } else return; |
975 | } | 972 | } |
976 | if (offset == dirsize) { | 973 | if (offset == dirsize) { |
977 | if (!inode || strcmp("..",name)) { | 974 | if (!inode || strcmp("..",name)) { |
978 | print_current_name(); | 975 | print_current_name(); |
979 | printf(_(": bad directory: '..' isn't second\n")); | 976 | printf(": bad directory: '..' isn't second\n"); |
980 | errors_uncorrected = 1; | 977 | errors_uncorrected = 1; |
981 | } else return; | 978 | } else return; |
982 | } | 979 | } |
@@ -1002,7 +999,7 @@ void check_file(struct minix_inode * dir, unsigned int offset) | |||
1002 | } | 999 | } |
1003 | 1000 | ||
1004 | #ifdef HAVE_MINIX2 | 1001 | #ifdef HAVE_MINIX2 |
1005 | void | 1002 | static void |
1006 | check_file2 (struct minix2_inode *dir, unsigned int offset) | 1003 | check_file2 (struct minix2_inode *dir, unsigned int offset) |
1007 | { | 1004 | { |
1008 | static char blk[BLOCK_SIZE]; | 1005 | static char blk[BLOCK_SIZE]; |
@@ -1017,9 +1014,9 @@ check_file2 (struct minix2_inode *dir, unsigned int offset) | |||
1017 | ino = *(unsigned short *) (name - 2); | 1014 | ino = *(unsigned short *) (name - 2); |
1018 | if (ino > INODES) { | 1015 | if (ino > INODES) { |
1019 | print_current_name (); | 1016 | print_current_name (); |
1020 | printf (_(" contains a bad inode number for file '")); | 1017 | printf (" contains a bad inode number for file '"); |
1021 | printf ("%.*s'.", namelen, name); | 1018 | printf ("%.*s'.", namelen, name); |
1022 | if (ask (_(" Remove"), 1)) { | 1019 | if (ask (" Remove", 1)) { |
1023 | *(unsigned short *) (name - 2) = 0; | 1020 | *(unsigned short *) (name - 2) = 0; |
1024 | write_block (block, blk); | 1021 | write_block (block, blk); |
1025 | } | 1022 | } |
@@ -1033,7 +1030,7 @@ check_file2 (struct minix2_inode *dir, unsigned int offset) | |||
1033 | if (!offset) { | 1030 | if (!offset) { |
1034 | if (!inode || strcmp (".", name)) { | 1031 | if (!inode || strcmp (".", name)) { |
1035 | print_current_name (); | 1032 | print_current_name (); |
1036 | printf (_(": bad directory: '.' isn't first\n")); | 1033 | printf (": bad directory: '.' isn't first\n"); |
1037 | errors_uncorrected = 1; | 1034 | errors_uncorrected = 1; |
1038 | } else | 1035 | } else |
1039 | return; | 1036 | return; |
@@ -1041,7 +1038,7 @@ check_file2 (struct minix2_inode *dir, unsigned int offset) | |||
1041 | if (offset == dirsize) { | 1038 | if (offset == dirsize) { |
1042 | if (!inode || strcmp ("..", name)) { | 1039 | if (!inode || strcmp ("..", name)) { |
1043 | print_current_name (); | 1040 | print_current_name (); |
1044 | printf (_(": bad directory: '..' isn't second\n")); | 1041 | printf (": bad directory: '..' isn't second\n"); |
1045 | errors_uncorrected = 1; | 1042 | errors_uncorrected = 1; |
1046 | } else | 1043 | } else |
1047 | return; | 1044 | return; |
@@ -1066,17 +1063,17 @@ check_file2 (struct minix2_inode *dir, unsigned int offset) | |||
1066 | } | 1063 | } |
1067 | #endif | 1064 | #endif |
1068 | 1065 | ||
1069 | void recursive_check(unsigned int ino) | 1066 | static void recursive_check(unsigned int ino) |
1070 | { | 1067 | { |
1071 | struct minix_inode * dir; | 1068 | struct minix_inode * dir; |
1072 | unsigned int offset; | 1069 | unsigned int offset; |
1073 | 1070 | ||
1074 | dir = Inode + ino; | 1071 | dir = Inode + ino; |
1075 | if (!S_ISDIR(dir->i_mode)) | 1072 | if (!S_ISDIR(dir->i_mode)) |
1076 | die(_("internal error")); | 1073 | die("internal error"); |
1077 | if (dir->i_size < 2 * dirsize) { | 1074 | if (dir->i_size < 2 * dirsize) { |
1078 | print_current_name(); | 1075 | print_current_name(); |
1079 | printf(_(": bad directory: size<32")); | 1076 | printf(": bad directory: size<32"); |
1080 | errors_uncorrected = 1; | 1077 | errors_uncorrected = 1; |
1081 | } | 1078 | } |
1082 | for (offset = 0 ; offset < dir->i_size ; offset += dirsize) | 1079 | for (offset = 0 ; offset < dir->i_size ; offset += dirsize) |
@@ -1084,7 +1081,7 @@ void recursive_check(unsigned int ino) | |||
1084 | } | 1081 | } |
1085 | 1082 | ||
1086 | #ifdef HAVE_MINIX2 | 1083 | #ifdef HAVE_MINIX2 |
1087 | void | 1084 | static void |
1088 | recursive_check2 (unsigned int ino) | 1085 | recursive_check2 (unsigned int ino) |
1089 | { | 1086 | { |
1090 | struct minix2_inode *dir; | 1087 | struct minix2_inode *dir; |
@@ -1095,7 +1092,7 @@ recursive_check2 (unsigned int ino) | |||
1095 | die ("internal error"); | 1092 | die ("internal error"); |
1096 | if (dir->i_size < 2 * dirsize) { | 1093 | if (dir->i_size < 2 * dirsize) { |
1097 | print_current_name (); | 1094 | print_current_name (); |
1098 | printf (_(": bad directory: size < 32")); | 1095 | printf (": bad directory: size < 32"); |
1099 | errors_uncorrected = 1; | 1096 | errors_uncorrected = 1; |
1100 | } | 1097 | } |
1101 | for (offset = 0; offset < dir->i_size; offset += dirsize) | 1098 | for (offset = 0; offset < dir->i_size; offset += dirsize) |
@@ -1103,23 +1100,23 @@ recursive_check2 (unsigned int ino) | |||
1103 | } | 1100 | } |
1104 | #endif | 1101 | #endif |
1105 | 1102 | ||
1106 | int bad_zone(int i) | 1103 | static int bad_zone(int i) |
1107 | { | 1104 | { |
1108 | char buffer[1024]; | 1105 | char buffer[1024]; |
1109 | 1106 | ||
1110 | if (BLOCK_SIZE*i != lseek(IN, BLOCK_SIZE*i, SEEK_SET)) | 1107 | if (BLOCK_SIZE*i != lseek(IN, BLOCK_SIZE*i, SEEK_SET)) |
1111 | die(_("seek failed in bad_zone")); | 1108 | die("seek failed in bad_zone"); |
1112 | return (BLOCK_SIZE != read(IN, buffer, BLOCK_SIZE)); | 1109 | return (BLOCK_SIZE != read(IN, buffer, BLOCK_SIZE)); |
1113 | } | 1110 | } |
1114 | 1111 | ||
1115 | void check_counts(void) | 1112 | static void check_counts(void) |
1116 | { | 1113 | { |
1117 | int i; | 1114 | int i; |
1118 | 1115 | ||
1119 | for (i=1 ; i <= INODES ; i++) { | 1116 | for (i=1 ; i <= INODES ; i++) { |
1120 | if (!inode_in_use(i) && Inode[i].i_mode && warn_mode) { | 1117 | if (!inode_in_use(i) && Inode[i].i_mode && warn_mode) { |
1121 | printf(_("Inode %d mode not cleared."),i); | 1118 | printf("Inode %d mode not cleared.",i); |
1122 | if (ask(_("Clear"),1)) { | 1119 | if (ask("Clear",1)) { |
1123 | Inode[i].i_mode = 0; | 1120 | Inode[i].i_mode = 0; |
1124 | changed = 1; | 1121 | changed = 1; |
1125 | } | 1122 | } |
@@ -1127,21 +1124,20 @@ void check_counts(void) | |||
1127 | if (!inode_count[i]) { | 1124 | if (!inode_count[i]) { |
1128 | if (!inode_in_use(i)) | 1125 | if (!inode_in_use(i)) |
1129 | continue; | 1126 | continue; |
1130 | printf(_("Inode %d not used, marked used in the bitmap."),i); | 1127 | printf("Inode %d not used, marked used in the bitmap.",i); |
1131 | if (ask(_("Clear"),1)) | 1128 | if (ask("Clear",1)) |
1132 | unmark_inode(i); | 1129 | unmark_inode(i); |
1133 | continue; | 1130 | continue; |
1134 | } | 1131 | } |
1135 | if (!inode_in_use(i)) { | 1132 | if (!inode_in_use(i)) { |
1136 | printf(_("Inode %d used, marked unused in the bitmap."), | 1133 | printf("Inode %d used, marked unused in the bitmap.", i); |
1137 | i); | ||
1138 | if (ask("Set",1)) | 1134 | if (ask("Set",1)) |
1139 | mark_inode(i); | 1135 | mark_inode(i); |
1140 | } | 1136 | } |
1141 | if (Inode[i].i_nlinks != inode_count[i]) { | 1137 | if (Inode[i].i_nlinks != inode_count[i]) { |
1142 | printf(_("Inode %d (mode = %07o), i_nlinks=%d, counted=%d."), | 1138 | printf("Inode %d (mode = %07o), i_nlinks=%d, counted=%d.", |
1143 | i,Inode[i].i_mode,Inode[i].i_nlinks,inode_count[i]); | 1139 | i,Inode[i].i_mode,Inode[i].i_nlinks,inode_count[i]); |
1144 | if (ask(_("Set i_nlinks to count"),1)) { | 1140 | if (ask("Set i_nlinks to count",1)) { |
1145 | Inode[i].i_nlinks=inode_count[i]; | 1141 | Inode[i].i_nlinks=inode_count[i]; |
1146 | changed=1; | 1142 | changed=1; |
1147 | } | 1143 | } |
@@ -1153,26 +1149,26 @@ void check_counts(void) | |||
1153 | if (!zone_count[i]) { | 1149 | if (!zone_count[i]) { |
1154 | if (bad_zone(i)) | 1150 | if (bad_zone(i)) |
1155 | continue; | 1151 | continue; |
1156 | printf(_("Zone %d: marked in use, no file uses it."),i); | 1152 | printf("Zone %d: marked in use, no file uses it.",i); |
1157 | if (ask(_("Unmark"),1)) | 1153 | if (ask("Unmark",1)) |
1158 | unmark_zone(i); | 1154 | unmark_zone(i); |
1159 | continue; | 1155 | continue; |
1160 | } | 1156 | } |
1161 | printf(_("Zone %d: %sin use, counted=%d\n"), | 1157 | printf("Zone %d: %sin use, counted=%d\n", |
1162 | i,zone_in_use(i)?"":_("not "),zone_count[i]); | 1158 | i,zone_in_use(i)?"":"not ",zone_count[i]); |
1163 | } | 1159 | } |
1164 | } | 1160 | } |
1165 | 1161 | ||
1166 | #ifdef HAVE_MINIX2 | 1162 | #ifdef HAVE_MINIX2 |
1167 | void | 1163 | static void |
1168 | check_counts2 (void) | 1164 | check_counts2 (void) |
1169 | { | 1165 | { |
1170 | int i; | 1166 | int i; |
1171 | 1167 | ||
1172 | for (i = 1; i <= INODES; i++) { | 1168 | for (i = 1; i <= INODES; i++) { |
1173 | if (!inode_in_use (i) && Inode2[i].i_mode && warn_mode) { | 1169 | if (!inode_in_use (i) && Inode2[i].i_mode && warn_mode) { |
1174 | printf (_("Inode %d mode not cleared."), i); | 1170 | printf ("Inode %d mode not cleared.", i); |
1175 | if (ask (_("Clear"), 1)) { | 1171 | if (ask ("Clear", 1)) { |
1176 | Inode2[i].i_mode = 0; | 1172 | Inode2[i].i_mode = 0; |
1177 | changed = 1; | 1173 | changed = 1; |
1178 | } | 1174 | } |
@@ -1180,20 +1176,20 @@ check_counts2 (void) | |||
1180 | if (!inode_count[i]) { | 1176 | if (!inode_count[i]) { |
1181 | if (!inode_in_use (i)) | 1177 | if (!inode_in_use (i)) |
1182 | continue; | 1178 | continue; |
1183 | printf (_("Inode %d not used, marked used in the bitmap."), i); | 1179 | printf ("Inode %d not used, marked used in the bitmap.", i); |
1184 | if (ask (_("Clear"), 1)) | 1180 | if (ask ("Clear", 1)) |
1185 | unmark_inode (i); | 1181 | unmark_inode (i); |
1186 | continue; | 1182 | continue; |
1187 | } | 1183 | } |
1188 | if (!inode_in_use (i)) { | 1184 | if (!inode_in_use (i)) { |
1189 | printf (_("Inode %d used, marked unused in the bitmap."), i); | 1185 | printf ("Inode %d used, marked unused in the bitmap.", i); |
1190 | if (ask (_("Set"), 1)) | 1186 | if (ask ("Set", 1)) |
1191 | mark_inode (i); | 1187 | mark_inode (i); |
1192 | } | 1188 | } |
1193 | if (Inode2[i].i_nlinks != inode_count[i]) { | 1189 | if (Inode2[i].i_nlinks != inode_count[i]) { |
1194 | printf (_("Inode %d (mode = %07o), i_nlinks=%d, counted=%d."), | 1190 | printf ("Inode %d (mode = %07o), i_nlinks=%d, counted=%d.", |
1195 | i, Inode2[i].i_mode, Inode2[i].i_nlinks, inode_count[i]); | 1191 | i, Inode2[i].i_mode, Inode2[i].i_nlinks, inode_count[i]); |
1196 | if (ask (_("Set i_nlinks to count"), 1)) { | 1192 | if (ask ("Set i_nlinks to count", 1)) { |
1197 | Inode2[i].i_nlinks = inode_count[i]; | 1193 | Inode2[i].i_nlinks = inode_count[i]; |
1198 | changed = 1; | 1194 | changed = 1; |
1199 | } | 1195 | } |
@@ -1205,18 +1201,18 @@ check_counts2 (void) | |||
1205 | if (!zone_count[i]) { | 1201 | if (!zone_count[i]) { |
1206 | if (bad_zone (i)) | 1202 | if (bad_zone (i)) |
1207 | continue; | 1203 | continue; |
1208 | printf (_("Zone %d: marked in use, no file uses it."), i); | 1204 | printf ("Zone %d: marked in use, no file uses it.", i); |
1209 | if (ask (_("Unmark"), 1)) | 1205 | if (ask ("Unmark", 1)) |
1210 | unmark_zone (i); | 1206 | unmark_zone (i); |
1211 | continue; | 1207 | continue; |
1212 | } | 1208 | } |
1213 | printf (_("Zone %d: %sin use, counted=%d\n"), | 1209 | printf ("Zone %d: %sin use, counted=%d\n", |
1214 | i, zone_in_use (i) ? "" : _("not "), zone_count[i]); | 1210 | i, zone_in_use (i) ? "" : "not ", zone_count[i]); |
1215 | } | 1211 | } |
1216 | } | 1212 | } |
1217 | #endif | 1213 | #endif |
1218 | 1214 | ||
1219 | void check(void) | 1215 | static void check(void) |
1220 | { | 1216 | { |
1221 | memset(inode_count,0,(INODES + 1) * sizeof(*inode_count)); | 1217 | memset(inode_count,0,(INODES + 1) * sizeof(*inode_count)); |
1222 | memset(zone_count,0,ZONES*sizeof(*zone_count)); | 1218 | memset(zone_count,0,ZONES*sizeof(*zone_count)); |
@@ -1226,7 +1222,7 @@ void check(void) | |||
1226 | } | 1222 | } |
1227 | 1223 | ||
1228 | #ifdef HAVE_MINIX2 | 1224 | #ifdef HAVE_MINIX2 |
1229 | void | 1225 | static void |
1230 | check2 (void) | 1226 | check2 (void) |
1231 | { | 1227 | { |
1232 | memset (inode_count, 0, (INODES + 1) * sizeof (*inode_count)); | 1228 | memset (inode_count, 0, (INODES + 1) * sizeof (*inode_count)); |
@@ -1244,24 +1240,19 @@ fsck_minix_main(int argc, char ** argv) | |||
1244 | int count; | 1240 | int count; |
1245 | int retcode = 0; | 1241 | int retcode = 0; |
1246 | 1242 | ||
1247 | setlocale(LC_ALL, ""); | ||
1248 | bindtextdomain(PACKAGE, LOCALEDIR); | ||
1249 | textdomain(PACKAGE); | ||
1250 | |||
1251 | |||
1252 | if (argc && *argv) | 1243 | if (argc && *argv) |
1253 | program_name = *argv; | 1244 | program_name = *argv; |
1254 | if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE) | 1245 | if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE) |
1255 | die(_("bad inode size")); | 1246 | die("bad inode size"); |
1256 | #ifdef HAVE_MINIX2 | 1247 | #ifdef HAVE_MINIX2 |
1257 | if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) | 1248 | if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) |
1258 | die(_("bad v2 inode size")); | 1249 | die("bad v2 inode size"); |
1259 | #endif | 1250 | #endif |
1260 | while (argc-- > 1) { | 1251 | while (argc-- > 1) { |
1261 | argv++; | 1252 | argv++; |
1262 | if (argv[0][0] != '-') { | 1253 | if (argv[0][0] != '-') { |
1263 | if (device_name) | 1254 | if (device_name) |
1264 | usage(); | 1255 | show_usage(); |
1265 | else | 1256 | else |
1266 | device_name = argv[0]; | 1257 | device_name = argv[0]; |
1267 | } else while (*++argv[0]) | 1258 | } else while (*++argv[0]) |
@@ -1273,19 +1264,19 @@ fsck_minix_main(int argc, char ** argv) | |||
1273 | case 's': show=1; break; | 1264 | case 's': show=1; break; |
1274 | case 'm': warn_mode=1; break; | 1265 | case 'm': warn_mode=1; break; |
1275 | case 'f': force=1; break; | 1266 | case 'f': force=1; break; |
1276 | default: usage(); | 1267 | default: show_usage(); |
1277 | } | 1268 | } |
1278 | } | 1269 | } |
1279 | if (!device_name) | 1270 | if (!device_name) |
1280 | usage(); | 1271 | show_usage(); |
1281 | check_mount(); /* trying to check a mounted filesystem? */ | 1272 | check_mount(); /* trying to check a mounted filesystem? */ |
1282 | if (repair && !automatic) { | 1273 | if (repair && !automatic) { |
1283 | if (!isatty(0) || !isatty(1)) | 1274 | if (!isatty(0) || !isatty(1)) |
1284 | die(_("need terminal for interactive repairs")); | 1275 | die("need terminal for interactive repairs"); |
1285 | } | 1276 | } |
1286 | IN = open(device_name,repair?O_RDWR:O_RDONLY); | 1277 | IN = open(device_name,repair?O_RDWR:O_RDONLY); |
1287 | if (IN < 0) | 1278 | if (IN < 0) |
1288 | die(_("unable to open '%s'")); | 1279 | die("unable to open '%s'"); |
1289 | for (count=0 ; count<3 ; count++) | 1280 | for (count=0 ; count<3 ; count++) |
1290 | sync(); | 1281 | sync(); |
1291 | read_superblock(); | 1282 | read_superblock(); |
@@ -1296,19 +1287,18 @@ fsck_minix_main(int argc, char ** argv) | |||
1296 | * flags and whether or not the -f switch was specified on the | 1287 | * flags and whether or not the -f switch was specified on the |
1297 | * command line. | 1288 | * command line. |
1298 | */ | 1289 | */ |
1299 | printf("%s, %s / %s\n", program_name, program_version, | 1290 | printf("%s, %s\n", program_name, program_version); |
1300 | util_linux_version); | ||
1301 | if ( !(Super.s_state & MINIX_ERROR_FS) && | 1291 | if ( !(Super.s_state & MINIX_ERROR_FS) && |
1302 | (Super.s_state & MINIX_VALID_FS) && | 1292 | (Super.s_state & MINIX_VALID_FS) && |
1303 | !force ) { | 1293 | !force ) { |
1304 | if (repair) | 1294 | if (repair) |
1305 | printf(_("%s is clean, no check.\n"), device_name); | 1295 | printf("%s is clean, no check.\n", device_name); |
1306 | return retcode; | 1296 | return retcode; |
1307 | } | 1297 | } |
1308 | else if (force) | 1298 | else if (force) |
1309 | printf(_("Forcing filesystem check on %s.\n"), device_name); | 1299 | printf("Forcing filesystem check on %s.\n", device_name); |
1310 | else if (repair) | 1300 | else if (repair) |
1311 | printf(_("Filesystem on %s is dirty, needs checking.\n"),\ | 1301 | printf("Filesystem on %s is dirty, needs checking.\n",\ |
1312 | device_name); | 1302 | device_name); |
1313 | 1303 | ||
1314 | read_tables(); | 1304 | read_tables(); |
@@ -1337,29 +1327,29 @@ fsck_minix_main(int argc, char ** argv) | |||
1337 | for (i=1,free=0 ; i <= INODES ; i++) | 1327 | for (i=1,free=0 ; i <= INODES ; i++) |
1338 | if (!inode_in_use(i)) | 1328 | if (!inode_in_use(i)) |
1339 | free++; | 1329 | free++; |
1340 | printf(_("\n%6ld inodes used (%ld%%)\n"),(INODES-free), | 1330 | printf("\n%6ld inodes used (%ld%%)\n",(INODES-free), |
1341 | 100*(INODES-free)/INODES); | 1331 | 100*(INODES-free)/INODES); |
1342 | for (i=FIRSTZONE,free=0 ; i < ZONES ; i++) | 1332 | for (i=FIRSTZONE,free=0 ; i < ZONES ; i++) |
1343 | if (!zone_in_use(i)) | 1333 | if (!zone_in_use(i)) |
1344 | free++; | 1334 | free++; |
1345 | printf(_("%6ld zones used (%ld%%)\n"),(ZONES-free), | 1335 | printf("%6ld zones used (%ld%%)\n",(ZONES-free), |
1346 | 100*(ZONES-free)/ZONES); | 1336 | 100*(ZONES-free)/ZONES); |
1347 | printf(_("\n%6d regular files\n" | 1337 | printf("\n%6d regular files\n" |
1348 | "%6d directories\n" | 1338 | "%6d directories\n" |
1349 | "%6d character device files\n" | 1339 | "%6d character device files\n" |
1350 | "%6d block device files\n" | 1340 | "%6d block device files\n" |
1351 | "%6d links\n" | 1341 | "%6d links\n" |
1352 | "%6d symbolic links\n" | 1342 | "%6d symbolic links\n" |
1353 | "------\n" | 1343 | "------\n" |
1354 | "%6d files\n"), | 1344 | "%6d files\n", |
1355 | regular,directory,chardev,blockdev, | 1345 | regular,directory,chardev,blockdev, |
1356 | links-2*directory+1,symlinks,total-2*directory+1); | 1346 | links-2*directory+1,symlinks,total-2*directory+1); |
1357 | } | 1347 | } |
1358 | if (changed) { | 1348 | if (changed) { |
1359 | write_tables(); | 1349 | write_tables(); |
1360 | printf(_( "----------------------------\n" | 1350 | printf( "----------------------------\n" |
1361 | "FILE SYSTEM HAS BEEN CHANGED\n" | 1351 | "FILE SYSTEM HAS BEEN CHANGED\n" |
1362 | "----------------------------\n")); | 1352 | "----------------------------\n"); |
1363 | for (count=0 ; count<3 ; count++) | 1353 | for (count=0 ; count<3 ; count++) |
1364 | sync(); | 1354 | sync(); |
1365 | } | 1355 | } |
diff --git a/internal.h b/internal.h index ae0148b2e..dcddea05a 100644 --- a/internal.h +++ b/internal.h | |||
@@ -138,5 +138,30 @@ extern int parse_mode( const char* s, mode_t* theMode); | |||
138 | extern volatile void usage(const char *usage); | 138 | extern volatile void usage(const char *usage); |
139 | 139 | ||
140 | 140 | ||
141 | |||
142 | #if defined (BB_FSCK_MINIX) || defined (BB_MKFS_MINIX) | ||
143 | |||
144 | static inline int bit(char * addr,unsigned int nr) | ||
145 | { | ||
146 | return (addr[nr >> 3] & (1<<(nr & 7))) != 0; | ||
147 | } | ||
148 | |||
149 | static inline int setbit(char * addr,unsigned int nr) | ||
150 | { | ||
151 | int __res = bit(addr, nr); | ||
152 | addr[nr >> 3] |= (1<<(nr & 7)); | ||
153 | return __res != 0; \ | ||
154 | } | ||
155 | |||
156 | static inline int clrbit(char * addr,unsigned int nr) | ||
157 | { | ||
158 | int __res = bit(addr, nr); | ||
159 | addr[nr >> 3] &= ~(1<<(nr & 7)); | ||
160 | return __res != 0; | ||
161 | } | ||
162 | |||
163 | #endif | ||
164 | |||
165 | |||
141 | #endif | 166 | #endif |
142 | 167 | ||
diff --git a/mkfs_minix.c b/mkfs_minix.c index 7c8af7e1d..926a023b4 100644 --- a/mkfs_minix.c +++ b/mkfs_minix.c | |||
@@ -58,6 +58,7 @@ | |||
58 | * enforced (but it's not much fun on a character device :-). | 58 | * enforced (but it's not much fun on a character device :-). |
59 | */ | 59 | */ |
60 | 60 | ||
61 | #include "internal.h" | ||
61 | #include <stdio.h> | 62 | #include <stdio.h> |
62 | #include <time.h> | 63 | #include <time.h> |
63 | #include <unistd.h> | 64 | #include <unistd.h> |
@@ -75,9 +76,6 @@ | |||
75 | #include <linux/fs.h> | 76 | #include <linux/fs.h> |
76 | #include <linux/minix_fs.h> | 77 | #include <linux/minix_fs.h> |
77 | 78 | ||
78 | #include "nls.h" | ||
79 | #include "../version.h" | ||
80 | |||
81 | #ifdef MINIX2_SUPER_MAGIC2 | 79 | #ifdef MINIX2_SUPER_MAGIC2 |
82 | #define HAVE_MINIX2 1 | 80 | #define HAVE_MINIX2 1 |
83 | #endif | 81 | #endif |
@@ -152,8 +150,6 @@ static unsigned short good_blocks_table[MAX_GOOD_BLOCKS]; | |||
152 | static int used_good_blocks = 0; | 150 | static int used_good_blocks = 0; |
153 | static unsigned long req_nr_inodes = 0; | 151 | static unsigned long req_nr_inodes = 0; |
154 | 152 | ||
155 | #include "bitops.h" | ||
156 | |||
157 | #define inode_in_use(x) (bit(inode_map,(x))) | 153 | #define inode_in_use(x) (bit(inode_map,(x))) |
158 | #define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1)) | 154 | #define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1)) |
159 | 155 | ||
@@ -168,22 +164,16 @@ static unsigned long req_nr_inodes = 0; | |||
168 | * to compile this under minix, volatile gives a warning, as | 164 | * to compile this under minix, volatile gives a warning, as |
169 | * exit() isn't defined as volatile under minix. | 165 | * exit() isn't defined as volatile under minix. |
170 | */ | 166 | */ |
171 | volatile void fatal_error(const char * fmt_string,int status) | 167 | static volatile void die(char *str) { |
172 | { | ||
173 | fprintf(stderr,fmt_string,program_name,device_name); | ||
174 | exit(status); | ||
175 | } | ||
176 | |||
177 | volatile void die(char *str) { | ||
178 | fprintf(stderr, "%s: %s\n", program_name, str); | 168 | fprintf(stderr, "%s: %s\n", program_name, str); |
179 | exit(8); | 169 | exit(8); |
180 | } | 170 | } |
181 | 171 | ||
182 | volatile void usage() | 172 | static volatile void show_usage() |
183 | { | 173 | { |
184 | fprintf(stderr, "%s (%s)\n", program_name, util_linux_version); | 174 | fprintf(stderr, "%s\n", program_name); |
185 | fprintf(stderr, | 175 | fprintf(stderr, |
186 | _("Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n"), | 176 | "Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n", |
187 | program_name); | 177 | program_name); |
188 | exit(16); | 178 | exit(16); |
189 | } | 179 | } |
@@ -207,7 +197,7 @@ static void check_mount(void) | |||
207 | if (!mnt) | 197 | if (!mnt) |
208 | return; | 198 | return; |
209 | 199 | ||
210 | die(_("%s is mounted; will not make a filesystem here!")); | 200 | die("%s is mounted; will not make a filesystem here!"); |
211 | } | 201 | } |
212 | 202 | ||
213 | static long valid_offset (int fd, int offset) | 203 | static long valid_offset (int fd, int offset) |
@@ -261,43 +251,43 @@ static int get_size(const char *file) | |||
261 | return size; | 251 | return size; |
262 | } | 252 | } |
263 | 253 | ||
264 | void write_tables(void) | 254 | static void write_tables(void) |
265 | { | 255 | { |
266 | /* Mark the super block valid. */ | 256 | /* Mark the super block valid. */ |
267 | Super.s_state |= MINIX_VALID_FS; | 257 | Super.s_state |= MINIX_VALID_FS; |
268 | Super.s_state &= ~MINIX_ERROR_FS; | 258 | Super.s_state &= ~MINIX_ERROR_FS; |
269 | 259 | ||
270 | if (lseek(DEV, 0, SEEK_SET)) | 260 | if (lseek(DEV, 0, SEEK_SET)) |
271 | die(_("seek to boot block failed in write_tables")); | 261 | die("seek to boot block failed in write_tables"); |
272 | if (512 != write(DEV, boot_block_buffer, 512)) | 262 | if (512 != write(DEV, boot_block_buffer, 512)) |
273 | die(_("unable to clear boot sector")); | 263 | die("unable to clear boot sector"); |
274 | if (BLOCK_SIZE != lseek(DEV, BLOCK_SIZE, SEEK_SET)) | 264 | if (BLOCK_SIZE != lseek(DEV, BLOCK_SIZE, SEEK_SET)) |
275 | die(_("seek failed in write_tables")); | 265 | die("seek failed in write_tables"); |
276 | if (BLOCK_SIZE != write(DEV, super_block_buffer, BLOCK_SIZE)) | 266 | if (BLOCK_SIZE != write(DEV, super_block_buffer, BLOCK_SIZE)) |
277 | die(_("unable to write super-block")); | 267 | die("unable to write super-block"); |
278 | if (IMAPS*BLOCK_SIZE != write(DEV,inode_map,IMAPS*BLOCK_SIZE)) | 268 | if (IMAPS*BLOCK_SIZE != write(DEV,inode_map,IMAPS*BLOCK_SIZE)) |
279 | die(_("unable to write inode map")); | 269 | die("unable to write inode map"); |
280 | if (ZMAPS*BLOCK_SIZE != write(DEV,zone_map,ZMAPS*BLOCK_SIZE)) | 270 | if (ZMAPS*BLOCK_SIZE != write(DEV,zone_map,ZMAPS*BLOCK_SIZE)) |
281 | die(_("unable to write zone map")); | 271 | die("unable to write zone map"); |
282 | if (INODE_BUFFER_SIZE != write(DEV,inode_buffer,INODE_BUFFER_SIZE)) | 272 | if (INODE_BUFFER_SIZE != write(DEV,inode_buffer,INODE_BUFFER_SIZE)) |
283 | die(_("unable to write inodes")); | 273 | die("unable to write inodes"); |
284 | 274 | ||
285 | } | 275 | } |
286 | 276 | ||
287 | void write_block(int blk, char * buffer) | 277 | static void write_block(int blk, char * buffer) |
288 | { | 278 | { |
289 | if (blk*BLOCK_SIZE != lseek(DEV, blk*BLOCK_SIZE, SEEK_SET)) | 279 | if (blk*BLOCK_SIZE != lseek(DEV, blk*BLOCK_SIZE, SEEK_SET)) |
290 | die(_("seek failed in write_block")); | 280 | die("seek failed in write_block"); |
291 | if (BLOCK_SIZE != write(DEV, buffer, BLOCK_SIZE)) | 281 | if (BLOCK_SIZE != write(DEV, buffer, BLOCK_SIZE)) |
292 | die(_("write failed in write_block")); | 282 | die("write failed in write_block"); |
293 | } | 283 | } |
294 | 284 | ||
295 | int get_free_block(void) | 285 | static int get_free_block(void) |
296 | { | 286 | { |
297 | int blk; | 287 | int blk; |
298 | 288 | ||
299 | if (used_good_blocks+1 >= MAX_GOOD_BLOCKS) | 289 | if (used_good_blocks+1 >= MAX_GOOD_BLOCKS) |
300 | die(_("too many bad blocks")); | 290 | die("too many bad blocks"); |
301 | if (used_good_blocks) | 291 | if (used_good_blocks) |
302 | blk = good_blocks_table[used_good_blocks-1]+1; | 292 | blk = good_blocks_table[used_good_blocks-1]+1; |
303 | else | 293 | else |
@@ -305,13 +295,13 @@ int get_free_block(void) | |||
305 | while (blk < ZONES && zone_in_use(blk)) | 295 | while (blk < ZONES && zone_in_use(blk)) |
306 | blk++; | 296 | blk++; |
307 | if (blk >= ZONES) | 297 | if (blk >= ZONES) |
308 | die(_("not enough good blocks")); | 298 | die("not enough good blocks"); |
309 | good_blocks_table[used_good_blocks] = blk; | 299 | good_blocks_table[used_good_blocks] = blk; |
310 | used_good_blocks++; | 300 | used_good_blocks++; |
311 | return blk; | 301 | return blk; |
312 | } | 302 | } |
313 | 303 | ||
314 | void mark_good_blocks(void) | 304 | static void mark_good_blocks(void) |
315 | { | 305 | { |
316 | int blk; | 306 | int blk; |
317 | 307 | ||
@@ -329,7 +319,7 @@ inline int next(int zone) | |||
329 | return 0; | 319 | return 0; |
330 | } | 320 | } |
331 | 321 | ||
332 | void make_bad_inode(void) | 322 | static void make_bad_inode(void) |
333 | { | 323 | { |
334 | struct minix_inode * inode = &Inode[MINIX_BAD_INO]; | 324 | struct minix_inode * inode = &Inode[MINIX_BAD_INO]; |
335 | int i,j,zone; | 325 | int i,j,zone; |
@@ -371,7 +361,7 @@ void make_bad_inode(void) | |||
371 | goto end_bad; | 361 | goto end_bad; |
372 | } | 362 | } |
373 | } | 363 | } |
374 | die(_("too many bad blocks")); | 364 | die("too many bad blocks"); |
375 | end_bad: | 365 | end_bad: |
376 | if (ind) | 366 | if (ind) |
377 | write_block(ind, (char *) ind_block); | 367 | write_block(ind, (char *) ind_block); |
@@ -380,7 +370,7 @@ end_bad: | |||
380 | } | 370 | } |
381 | 371 | ||
382 | #ifdef HAVE_MINIX2 | 372 | #ifdef HAVE_MINIX2 |
383 | void | 373 | static void |
384 | make_bad_inode2 (void) | 374 | make_bad_inode2 (void) |
385 | { | 375 | { |
386 | struct minix2_inode *inode = &Inode2[MINIX_BAD_INO]; | 376 | struct minix2_inode *inode = &Inode2[MINIX_BAD_INO]; |
@@ -422,7 +412,7 @@ make_bad_inode2 (void) | |||
422 | } | 412 | } |
423 | } | 413 | } |
424 | /* Could make triple indirect block here */ | 414 | /* Could make triple indirect block here */ |
425 | die (_("too many bad blocks")); | 415 | die ("too many bad blocks"); |
426 | end_bad: | 416 | end_bad: |
427 | if (ind) | 417 | if (ind) |
428 | write_block (ind, (char *) ind_block); | 418 | write_block (ind, (char *) ind_block); |
@@ -431,7 +421,7 @@ make_bad_inode2 (void) | |||
431 | } | 421 | } |
432 | #endif | 422 | #endif |
433 | 423 | ||
434 | void make_root_inode(void) | 424 | static void make_root_inode(void) |
435 | { | 425 | { |
436 | struct minix_inode * inode = &Inode[MINIX_ROOT_INO]; | 426 | struct minix_inode * inode = &Inode[MINIX_ROOT_INO]; |
437 | 427 | ||
@@ -454,7 +444,7 @@ void make_root_inode(void) | |||
454 | } | 444 | } |
455 | 445 | ||
456 | #ifdef HAVE_MINIX2 | 446 | #ifdef HAVE_MINIX2 |
457 | void | 447 | static void |
458 | make_root_inode2 (void) | 448 | make_root_inode2 (void) |
459 | { | 449 | { |
460 | struct minix2_inode *inode = &Inode2[MINIX_ROOT_INO]; | 450 | struct minix2_inode *inode = &Inode2[MINIX_ROOT_INO]; |
@@ -478,7 +468,7 @@ make_root_inode2 (void) | |||
478 | } | 468 | } |
479 | #endif | 469 | #endif |
480 | 470 | ||
481 | void setup_tables(void) | 471 | static void setup_tables(void) |
482 | { | 472 | { |
483 | int i; | 473 | int i; |
484 | unsigned long inodes; | 474 | unsigned long inodes; |
@@ -526,7 +516,7 @@ void setup_tables(void) | |||
526 | inode_map = malloc(IMAPS * BLOCK_SIZE); | 516 | inode_map = malloc(IMAPS * BLOCK_SIZE); |
527 | zone_map = malloc(ZMAPS * BLOCK_SIZE); | 517 | zone_map = malloc(ZMAPS * BLOCK_SIZE); |
528 | if (!inode_map || !zone_map) | 518 | if (!inode_map || !zone_map) |
529 | die(_("unable to allocate buffers for maps")); | 519 | die("unable to allocate buffers for maps"); |
530 | memset(inode_map,0xff,IMAPS * BLOCK_SIZE); | 520 | memset(inode_map,0xff,IMAPS * BLOCK_SIZE); |
531 | memset(zone_map,0xff,ZMAPS * BLOCK_SIZE); | 521 | memset(zone_map,0xff,ZMAPS * BLOCK_SIZE); |
532 | for (i = FIRSTZONE ; i<ZONES ; i++) | 522 | for (i = FIRSTZONE ; i<ZONES ; i++) |
@@ -535,13 +525,13 @@ void setup_tables(void) | |||
535 | unmark_inode(i); | 525 | unmark_inode(i); |
536 | inode_buffer = malloc(INODE_BUFFER_SIZE); | 526 | inode_buffer = malloc(INODE_BUFFER_SIZE); |
537 | if (!inode_buffer) | 527 | if (!inode_buffer) |
538 | die(_("unable to allocate buffer for inodes")); | 528 | die("unable to allocate buffer for inodes"); |
539 | memset(inode_buffer,0,INODE_BUFFER_SIZE); | 529 | memset(inode_buffer,0,INODE_BUFFER_SIZE); |
540 | printf(_("%ld inodes\n"),INODES); | 530 | printf("%ld inodes\n",INODES); |
541 | printf(_("%ld blocks\n"),ZONES); | 531 | printf("%ld blocks\n",ZONES); |
542 | printf(_("Firstdatazone=%ld (%ld)\n"),FIRSTZONE,NORM_FIRSTZONE); | 532 | printf("Firstdatazone=%ld (%ld)\n",FIRSTZONE,NORM_FIRSTZONE); |
543 | printf(_("Zonesize=%d\n"),BLOCK_SIZE<<ZONESIZE); | 533 | printf("Zonesize=%d\n",BLOCK_SIZE<<ZONESIZE); |
544 | printf(_("Maxsize=%ld\n\n"),MAXSIZE); | 534 | printf("Maxsize=%ld\n\n",MAXSIZE); |
545 | } | 535 | } |
546 | 536 | ||
547 | /* | 537 | /* |
@@ -555,7 +545,7 @@ long do_check(char * buffer, int try, unsigned int current_block) | |||
555 | /* Seek to the correct loc. */ | 545 | /* Seek to the correct loc. */ |
556 | if (lseek(DEV, current_block * BLOCK_SIZE, SEEK_SET) != | 546 | if (lseek(DEV, current_block * BLOCK_SIZE, SEEK_SET) != |
557 | current_block * BLOCK_SIZE ) { | 547 | current_block * BLOCK_SIZE ) { |
558 | die(_("seek failed during testing of blocks")); | 548 | die("seek failed during testing of blocks"); |
559 | } | 549 | } |
560 | 550 | ||
561 | 551 | ||
@@ -563,7 +553,7 @@ long do_check(char * buffer, int try, unsigned int current_block) | |||
563 | got = read(DEV, buffer, try * BLOCK_SIZE); | 553 | got = read(DEV, buffer, try * BLOCK_SIZE); |
564 | if (got < 0) got = 0; | 554 | if (got < 0) got = 0; |
565 | if (got & (BLOCK_SIZE - 1 )) { | 555 | if (got & (BLOCK_SIZE - 1 )) { |
566 | printf(_("Weird values in do_check: probably bugs\n")); | 556 | printf("Weird values in do_check: probably bugs\n"); |
567 | } | 557 | } |
568 | got /= BLOCK_SIZE; | 558 | got /= BLOCK_SIZE; |
569 | return got; | 559 | return got; |
@@ -571,7 +561,7 @@ long do_check(char * buffer, int try, unsigned int current_block) | |||
571 | 561 | ||
572 | static unsigned int currently_testing = 0; | 562 | static unsigned int currently_testing = 0; |
573 | 563 | ||
574 | void alarm_intr(int alnum) | 564 | static void alarm_intr(int alnum) |
575 | { | 565 | { |
576 | if (currently_testing >= ZONES) | 566 | if (currently_testing >= ZONES) |
577 | return; | 567 | return; |
@@ -583,7 +573,7 @@ void alarm_intr(int alnum) | |||
583 | fflush(stdout); | 573 | fflush(stdout); |
584 | } | 574 | } |
585 | 575 | ||
586 | void check_blocks(void) | 576 | static void check_blocks(void) |
587 | { | 577 | { |
588 | int try,got; | 578 | int try,got; |
589 | static char buffer[BLOCK_SIZE * TEST_BUFFER_BLOCKS]; | 579 | static char buffer[BLOCK_SIZE * TEST_BUFFER_BLOCKS]; |
@@ -594,7 +584,7 @@ void check_blocks(void) | |||
594 | while (currently_testing < ZONES) { | 584 | while (currently_testing < ZONES) { |
595 | if (lseek(DEV,currently_testing*BLOCK_SIZE,SEEK_SET) != | 585 | if (lseek(DEV,currently_testing*BLOCK_SIZE,SEEK_SET) != |
596 | currently_testing*BLOCK_SIZE) | 586 | currently_testing*BLOCK_SIZE) |
597 | die(_("seek failed in check_blocks")); | 587 | die("seek failed in check_blocks"); |
598 | try = TEST_BUFFER_BLOCKS; | 588 | try = TEST_BUFFER_BLOCKS; |
599 | if (currently_testing + try > ZONES) | 589 | if (currently_testing + try > ZONES) |
600 | try = ZONES-currently_testing; | 590 | try = ZONES-currently_testing; |
@@ -603,18 +593,18 @@ void check_blocks(void) | |||
603 | if (got == try) | 593 | if (got == try) |
604 | continue; | 594 | continue; |
605 | if (currently_testing < FIRSTZONE) | 595 | if (currently_testing < FIRSTZONE) |
606 | die(_("bad blocks before data-area: cannot make fs")); | 596 | die("bad blocks before data-area: cannot make fs"); |
607 | mark_zone(currently_testing); | 597 | mark_zone(currently_testing); |
608 | badblocks++; | 598 | badblocks++; |
609 | currently_testing++; | 599 | currently_testing++; |
610 | } | 600 | } |
611 | if (badblocks > 1) | 601 | if (badblocks > 1) |
612 | printf(_("%d bad blocks\n"), badblocks); | 602 | printf("%d bad blocks\n", badblocks); |
613 | else if (badblocks == 1) | 603 | else if (badblocks == 1) |
614 | printf(_("one bad block\n")); | 604 | printf("one bad block\n"); |
615 | } | 605 | } |
616 | 606 | ||
617 | void get_list_blocks(filename) | 607 | static void get_list_blocks(filename) |
618 | char *filename; | 608 | char *filename; |
619 | 609 | ||
620 | { | 610 | { |
@@ -623,7 +613,7 @@ char *filename; | |||
623 | 613 | ||
624 | listfile=fopen(filename,"r"); | 614 | listfile=fopen(filename,"r"); |
625 | if(listfile == (FILE *)NULL) { | 615 | if(listfile == (FILE *)NULL) { |
626 | die(_("can't open file of bad blocks")); | 616 | die("can't open file of bad blocks"); |
627 | } | 617 | } |
628 | while(!feof(listfile)) { | 618 | while(!feof(listfile)) { |
629 | fscanf(listfile,"%ld\n", &blockno); | 619 | fscanf(listfile,"%ld\n", &blockno); |
@@ -631,9 +621,9 @@ char *filename; | |||
631 | badblocks++; | 621 | badblocks++; |
632 | } | 622 | } |
633 | if(badblocks > 1) | 623 | if(badblocks > 1) |
634 | printf(_("%d bad blocks\n"), badblocks); | 624 | printf("%d bad blocks\n", badblocks); |
635 | else if (badblocks == 1) | 625 | else if (badblocks == 1) |
636 | printf(_("one bad block\n")); | 626 | printf("one bad block\n"); |
637 | } | 627 | } |
638 | 628 | ||
639 | extern int | 629 | extern int |
@@ -647,10 +637,10 @@ mkfs_minix_main(int argc, char ** argv) | |||
647 | if (argc && *argv) | 637 | if (argc && *argv) |
648 | program_name = *argv; | 638 | program_name = *argv; |
649 | if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE) | 639 | if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE) |
650 | die(_("bad inode size")); | 640 | die("bad inode size"); |
651 | #ifdef HAVE_MINIX2 | 641 | #ifdef HAVE_MINIX2 |
652 | if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) | 642 | if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) |
653 | die(_("bad inode size")); | 643 | die("bad inode size"); |
654 | #endif | 644 | #endif |
655 | opterr = 0; | 645 | opterr = 0; |
656 | while ((i = getopt(argc, argv, "ci:l:n:v")) != EOF) | 646 | while ((i = getopt(argc, argv, "ci:l:n:v")) != EOF) |
@@ -665,13 +655,13 @@ mkfs_minix_main(int argc, char ** argv) | |||
665 | case 'n': | 655 | case 'n': |
666 | i = strtoul(optarg,&tmp,0); | 656 | i = strtoul(optarg,&tmp,0); |
667 | if (*tmp) | 657 | if (*tmp) |
668 | usage(); | 658 | show_usage(); |
669 | if (i == 14) | 659 | if (i == 14) |
670 | magic = MINIX_SUPER_MAGIC; | 660 | magic = MINIX_SUPER_MAGIC; |
671 | else if (i == 30) | 661 | else if (i == 30) |
672 | magic = MINIX_SUPER_MAGIC2; | 662 | magic = MINIX_SUPER_MAGIC2; |
673 | else | 663 | else |
674 | usage(); | 664 | show_usage(); |
675 | namelen = i; | 665 | namelen = i; |
676 | dirsize = i+2; | 666 | dirsize = i+2; |
677 | break; | 667 | break; |
@@ -679,11 +669,12 @@ mkfs_minix_main(int argc, char ** argv) | |||
679 | #ifdef HAVE_MINIX2 | 669 | #ifdef HAVE_MINIX2 |
680 | version2 = 1; | 670 | version2 = 1; |
681 | #else | 671 | #else |
682 | fatal_error(_("%s: not compiled with minix v2 support\n"),-1); | 672 | fprintf(stderr,"%s: not compiled with minix v2 support\n",program_name,device_name); |
673 | exit(-1); | ||
683 | #endif | 674 | #endif |
684 | break; | 675 | break; |
685 | default: | 676 | default: |
686 | usage(); | 677 | show_usage(); |
687 | } | 678 | } |
688 | argc -= optind; | 679 | argc -= optind; |
689 | argv += optind; | 680 | argv += optind; |
@@ -695,15 +686,15 @@ mkfs_minix_main(int argc, char ** argv) | |||
695 | if (argc > 0) { | 686 | if (argc > 0) { |
696 | BLOCKS = strtol(argv[0],&tmp,0); | 687 | BLOCKS = strtol(argv[0],&tmp,0); |
697 | if (*tmp) { | 688 | if (*tmp) { |
698 | printf(_("strtol error: number of blocks not specified")); | 689 | printf("strtol error: number of blocks not specified"); |
699 | usage(); | 690 | show_usage(); |
700 | } | 691 | } |
701 | } | 692 | } |
702 | 693 | ||
703 | if (device_name && !BLOCKS) | 694 | if (device_name && !BLOCKS) |
704 | BLOCKS = get_size (device_name) / 1024; | 695 | BLOCKS = get_size (device_name) / 1024; |
705 | if (!device_name || BLOCKS<10) { | 696 | if (!device_name || BLOCKS<10) { |
706 | usage(); | 697 | show_usage(); |
707 | } | 698 | } |
708 | #ifdef HAVE_MINIX2 | 699 | #ifdef HAVE_MINIX2 |
709 | if (version2) { | 700 | if (version2) { |
@@ -727,13 +718,13 @@ mkfs_minix_main(int argc, char ** argv) | |||
727 | strcpy(tmp+2,".badblocks"); | 718 | strcpy(tmp+2,".badblocks"); |
728 | DEV = open(device_name,O_RDWR ); | 719 | DEV = open(device_name,O_RDWR ); |
729 | if (DEV<0) | 720 | if (DEV<0) |
730 | die(_("unable to open %s")); | 721 | die("unable to open %s"); |
731 | if (fstat(DEV,&statbuf)<0) | 722 | if (fstat(DEV,&statbuf)<0) |
732 | die(_("unable to stat %s")); | 723 | die("unable to stat %s"); |
733 | if (!S_ISBLK(statbuf.st_mode)) | 724 | if (!S_ISBLK(statbuf.st_mode)) |
734 | check=0; | 725 | check=0; |
735 | else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340) | 726 | else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340) |
736 | die(_("will not try to make filesystem on '%s'")); | 727 | die("will not try to make filesystem on '%s'"); |
737 | setup_tables(); | 728 | setup_tables(); |
738 | if (check) | 729 | if (check) |
739 | check_blocks(); | 730 | check_blocks(); |
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c index e4b14d705..125274734 100644 --- a/util-linux/fsck_minix.c +++ b/util-linux/fsck_minix.c | |||
@@ -85,6 +85,7 @@ | |||
85 | * enforced (but it's not much fun on a character device :-). | 85 | * enforced (but it's not much fun on a character device :-). |
86 | */ | 86 | */ |
87 | 87 | ||
88 | #include "internal.h" | ||
88 | #include <stdio.h> | 89 | #include <stdio.h> |
89 | #include <errno.h> | 90 | #include <errno.h> |
90 | #include <unistd.h> | 91 | #include <unistd.h> |
@@ -98,8 +99,6 @@ | |||
98 | 99 | ||
99 | #include <linux/fs.h> | 100 | #include <linux/fs.h> |
100 | #include <linux/minix_fs.h> | 101 | #include <linux/minix_fs.h> |
101 | #include "../version.h" | ||
102 | #include "nls.h" | ||
103 | 102 | ||
104 | #ifdef MINIX2_SUPER_MAGIC2 | 103 | #ifdef MINIX2_SUPER_MAGIC2 |
105 | #define HAVE_MINIX2 1 | 104 | #define HAVE_MINIX2 1 |
@@ -171,10 +170,8 @@ static char *zone_map; | |||
171 | static unsigned char * inode_count = NULL; | 170 | static unsigned char * inode_count = NULL; |
172 | static unsigned char * zone_count = NULL; | 171 | static unsigned char * zone_count = NULL; |
173 | 172 | ||
174 | void recursive_check(unsigned int ino); | 173 | static void recursive_check(unsigned int ino); |
175 | void recursive_check2(unsigned int ino); | 174 | static void recursive_check2(unsigned int ino); |
176 | |||
177 | #include "bitops.h" | ||
178 | 175 | ||
179 | #define inode_in_use(x) (bit(inode_map,(x))) | 176 | #define inode_in_use(x) (bit(inode_map,(x))) |
180 | #define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1)) | 177 | #define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1)) |
@@ -185,22 +182,22 @@ void recursive_check2(unsigned int ino); | |||
185 | #define mark_zone(x) (setbit(zone_map,(x)-FIRSTZONE+1),changed=1) | 182 | #define mark_zone(x) (setbit(zone_map,(x)-FIRSTZONE+1),changed=1) |
186 | #define unmark_zone(x) (clrbit(zone_map,(x)-FIRSTZONE+1),changed=1) | 183 | #define unmark_zone(x) (clrbit(zone_map,(x)-FIRSTZONE+1),changed=1) |
187 | 184 | ||
188 | void leave(int) __attribute__ ((noreturn)); | 185 | static void leave(int) __attribute__ ((noreturn)); |
189 | void leave(int status) | 186 | static void leave(int status) |
190 | { | 187 | { |
191 | if (termios_set) | 188 | if (termios_set) |
192 | tcsetattr(0, TCSANOW, &termios); | 189 | tcsetattr(0, TCSANOW, &termios); |
193 | exit(status); | 190 | exit(status); |
194 | } | 191 | } |
195 | 192 | ||
196 | void usage(void) { | 193 | static void show_usage(void) { |
197 | fprintf(stderr, | 194 | fprintf(stderr, |
198 | _("Usage: %s [-larvsmf] /dev/name\n"), | 195 | "Usage: %s [-larvsmf] /dev/name\n", |
199 | program_name); | 196 | program_name); |
200 | leave(16); | 197 | leave(16); |
201 | } | 198 | } |
202 | 199 | ||
203 | void die(const char *str) { | 200 | static void die(const char *str) { |
204 | fprintf(stderr, "%s: %s\n", program_name, str); | 201 | fprintf(stderr, "%s: %s\n", program_name, str); |
205 | leave(8); | 202 | leave(8); |
206 | } | 203 | } |
@@ -209,7 +206,7 @@ void die(const char *str) { | |||
209 | * This simply goes through the file-name data and prints out the | 206 | * This simply goes through the file-name data and prints out the |
210 | * current file. | 207 | * current file. |
211 | */ | 208 | */ |
212 | void print_current_name(void) | 209 | static void print_current_name(void) |
213 | { | 210 | { |
214 | int i=0; | 211 | int i=0; |
215 | 212 | ||
@@ -219,7 +216,7 @@ void print_current_name(void) | |||
219 | printf ("/"); | 216 | printf ("/"); |
220 | } | 217 | } |
221 | 218 | ||
222 | int ask(const char * string, int def) | 219 | static int ask(const char * string, int def) |
223 | { | 220 | { |
224 | int c; | 221 | int c; |
225 | 222 | ||
@@ -293,13 +290,13 @@ static void check_mount(void) | |||
293 | else | 290 | else |
294 | close(fd); | 291 | close(fd); |
295 | 292 | ||
296 | printf (_("%s is mounted. "), device_name); | 293 | printf ("%s is mounted. ", device_name); |
297 | if (isatty(0) && isatty(1)) | 294 | if (isatty(0) && isatty(1)) |
298 | cont = ask(_("Do you really want to continue"), 0); | 295 | cont = ask("Do you really want to continue", 0); |
299 | else | 296 | else |
300 | cont = 0; | 297 | cont = 0; |
301 | if (!cont) { | 298 | if (!cont) { |
302 | printf (_("check aborted.\n")); | 299 | printf ("check aborted.\n"); |
303 | exit (0); | 300 | exit (0); |
304 | } | 301 | } |
305 | return; | 302 | return; |
@@ -311,19 +308,19 @@ static void check_mount(void) | |||
311 | * if an error was corrected, and returns the zone (0 for no zone | 308 | * if an error was corrected, and returns the zone (0 for no zone |
312 | * or a bad zone-number). | 309 | * or a bad zone-number). |
313 | */ | 310 | */ |
314 | int check_zone_nr(unsigned short * nr, int * corrected) | 311 | static int check_zone_nr(unsigned short * nr, int * corrected) |
315 | { | 312 | { |
316 | if (!*nr) | 313 | if (!*nr) |
317 | return 0; | 314 | return 0; |
318 | if (*nr < FIRSTZONE) | 315 | if (*nr < FIRSTZONE) |
319 | printf(_("Zone nr < FIRSTZONE in file `")); | 316 | printf("Zone nr < FIRSTZONE in file `"); |
320 | else if (*nr >= ZONES) | 317 | else if (*nr >= ZONES) |
321 | printf(_("Zone nr >= ZONES in file `")); | 318 | printf("Zone nr >= ZONES in file `"); |
322 | else | 319 | else |
323 | return *nr; | 320 | return *nr; |
324 | print_current_name(); | 321 | print_current_name(); |
325 | printf("'."); | 322 | printf("'."); |
326 | if (ask(_("Remove block"),1)) { | 323 | if (ask("Remove block",1)) { |
327 | *nr = 0; | 324 | *nr = 0; |
328 | *corrected = 1; | 325 | *corrected = 1; |
329 | } | 326 | } |
@@ -331,19 +328,19 @@ int check_zone_nr(unsigned short * nr, int * corrected) | |||
331 | } | 328 | } |
332 | 329 | ||
333 | #ifdef HAVE_MINIX2 | 330 | #ifdef HAVE_MINIX2 |
334 | int check_zone_nr2 (unsigned int *nr, int *corrected) | 331 | static int check_zone_nr2 (unsigned int *nr, int *corrected) |
335 | { | 332 | { |
336 | if (!*nr) | 333 | if (!*nr) |
337 | return 0; | 334 | return 0; |
338 | if (*nr < FIRSTZONE) | 335 | if (*nr < FIRSTZONE) |
339 | printf (_("Zone nr < FIRSTZONE in file `")); | 336 | printf ("Zone nr < FIRSTZONE in file `"); |
340 | else if (*nr >= ZONES) | 337 | else if (*nr >= ZONES) |
341 | printf (_("Zone nr >= ZONES in file `")); | 338 | printf ("Zone nr >= ZONES in file `"); |
342 | else | 339 | else |
343 | return *nr; | 340 | return *nr; |
344 | print_current_name (); | 341 | print_current_name (); |
345 | printf ("'."); | 342 | printf ("'."); |
346 | if (ask (_("Remove block"), 1)) { | 343 | if (ask ("Remove block", 1)) { |
347 | *nr = 0; | 344 | *nr = 0; |
348 | *corrected = 1; | 345 | *corrected = 1; |
349 | } | 346 | } |
@@ -354,20 +351,20 @@ int check_zone_nr2 (unsigned int *nr, int *corrected) | |||
354 | /* | 351 | /* |
355 | * read-block reads block nr into the buffer at addr. | 352 | * read-block reads block nr into the buffer at addr. |
356 | */ | 353 | */ |
357 | void read_block(unsigned int nr, char * addr) | 354 | static void read_block(unsigned int nr, char * addr) |
358 | { | 355 | { |
359 | if (!nr) { | 356 | if (!nr) { |
360 | memset(addr,0,BLOCK_SIZE); | 357 | memset(addr,0,BLOCK_SIZE); |
361 | return; | 358 | return; |
362 | } | 359 | } |
363 | if (BLOCK_SIZE*nr != lseek(IN, BLOCK_SIZE*nr, SEEK_SET)) { | 360 | if (BLOCK_SIZE*nr != lseek(IN, BLOCK_SIZE*nr, SEEK_SET)) { |
364 | printf(_("Read error: unable to seek to block in file '")); | 361 | printf("Read error: unable to seek to block in file '"); |
365 | print_current_name(); | 362 | print_current_name(); |
366 | printf("'\n"); | 363 | printf("'\n"); |
367 | memset(addr,0,BLOCK_SIZE); | 364 | memset(addr,0,BLOCK_SIZE); |
368 | errors_uncorrected = 1; | 365 | errors_uncorrected = 1; |
369 | } else if (BLOCK_SIZE != read(IN, addr, BLOCK_SIZE)) { | 366 | } else if (BLOCK_SIZE != read(IN, addr, BLOCK_SIZE)) { |
370 | printf(_("Read error: bad block in file '")); | 367 | printf("Read error: bad block in file '"); |
371 | print_current_name(); | 368 | print_current_name(); |
372 | printf("'\n"); | 369 | printf("'\n"); |
373 | memset(addr,0,BLOCK_SIZE); | 370 | memset(addr,0,BLOCK_SIZE); |
@@ -378,20 +375,20 @@ void read_block(unsigned int nr, char * addr) | |||
378 | /* | 375 | /* |
379 | * write_block writes block nr to disk. | 376 | * write_block writes block nr to disk. |
380 | */ | 377 | */ |
381 | void write_block(unsigned int nr, char * addr) | 378 | static void write_block(unsigned int nr, char * addr) |
382 | { | 379 | { |
383 | if (!nr) | 380 | if (!nr) |
384 | return; | 381 | return; |
385 | if (nr < FIRSTZONE || nr >= ZONES) { | 382 | if (nr < FIRSTZONE || nr >= ZONES) { |
386 | printf(_("Internal error: trying to write bad block\n" | 383 | printf("Internal error: trying to write bad block\n" |
387 | "Write request ignored\n")); | 384 | "Write request ignored\n"); |
388 | errors_uncorrected = 1; | 385 | errors_uncorrected = 1; |
389 | return; | 386 | return; |
390 | } | 387 | } |
391 | if (BLOCK_SIZE*nr != lseek(IN, BLOCK_SIZE*nr, SEEK_SET)) | 388 | if (BLOCK_SIZE*nr != lseek(IN, BLOCK_SIZE*nr, SEEK_SET)) |
392 | die(_("seek failed in write_block")); | 389 | die("seek failed in write_block"); |
393 | if (BLOCK_SIZE != write(IN, addr, BLOCK_SIZE)) { | 390 | if (BLOCK_SIZE != write(IN, addr, BLOCK_SIZE)) { |
394 | printf(_("Write error: bad block in file '")); | 391 | printf("Write error: bad block in file '"); |
395 | print_current_name(); | 392 | print_current_name(); |
396 | printf("'\n"); | 393 | printf("'\n"); |
397 | errors_uncorrected = 1; | 394 | errors_uncorrected = 1; |
@@ -403,7 +400,7 @@ void write_block(unsigned int nr, char * addr) | |||
403 | * It sets 'changed' if the inode has needed changing, and re-writes | 400 | * It sets 'changed' if the inode has needed changing, and re-writes |
404 | * any indirect blocks with errors. | 401 | * any indirect blocks with errors. |
405 | */ | 402 | */ |
406 | int map_block(struct minix_inode * inode, unsigned int blknr) | 403 | static int map_block(struct minix_inode * inode, unsigned int blknr) |
407 | { | 404 | { |
408 | unsigned short ind[BLOCK_SIZE>>1]; | 405 | unsigned short ind[BLOCK_SIZE>>1]; |
409 | unsigned short dind[BLOCK_SIZE>>1]; | 406 | unsigned short dind[BLOCK_SIZE>>1]; |
@@ -438,7 +435,7 @@ int map_block(struct minix_inode * inode, unsigned int blknr) | |||
438 | } | 435 | } |
439 | 436 | ||
440 | #ifdef HAVE_MINIX2 | 437 | #ifdef HAVE_MINIX2 |
441 | int map_block2 (struct minix2_inode *inode, unsigned int blknr) | 438 | static int map_block2 (struct minix2_inode *inode, unsigned int blknr) |
442 | { | 439 | { |
443 | unsigned int ind[BLOCK_SIZE >> 2]; | 440 | unsigned int ind[BLOCK_SIZE >> 2]; |
444 | unsigned int dind[BLOCK_SIZE >> 2]; | 441 | unsigned int dind[BLOCK_SIZE >> 2]; |
@@ -496,7 +493,7 @@ int map_block2 (struct minix2_inode *inode, unsigned int blknr) | |||
496 | } | 493 | } |
497 | #endif | 494 | #endif |
498 | 495 | ||
499 | void write_super_block(void) | 496 | static void write_super_block(void) |
500 | { | 497 | { |
501 | /* | 498 | /* |
502 | * Set the state of the filesystem based on whether or not there | 499 | * Set the state of the filesystem based on whether or not there |
@@ -510,26 +507,26 @@ void write_super_block(void) | |||
510 | Super.s_state &= ~MINIX_ERROR_FS; | 507 | Super.s_state &= ~MINIX_ERROR_FS; |
511 | 508 | ||
512 | if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET)) | 509 | if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET)) |
513 | die(_("seek failed in write_super_block")); | 510 | die("seek failed in write_super_block"); |
514 | if (BLOCK_SIZE != write(IN, super_block_buffer, BLOCK_SIZE)) | 511 | if (BLOCK_SIZE != write(IN, super_block_buffer, BLOCK_SIZE)) |
515 | die(_("unable to write super-block")); | 512 | die("unable to write super-block"); |
516 | 513 | ||
517 | return; | 514 | return; |
518 | } | 515 | } |
519 | 516 | ||
520 | void write_tables(void) | 517 | static void write_tables(void) |
521 | { | 518 | { |
522 | write_super_block(); | 519 | write_super_block(); |
523 | 520 | ||
524 | if (IMAPS*BLOCK_SIZE != write(IN,inode_map,IMAPS*BLOCK_SIZE)) | 521 | if (IMAPS*BLOCK_SIZE != write(IN,inode_map,IMAPS*BLOCK_SIZE)) |
525 | die(_("Unable to write inode map")); | 522 | die("Unable to write inode map"); |
526 | if (ZMAPS*BLOCK_SIZE != write(IN,zone_map,ZMAPS*BLOCK_SIZE)) | 523 | if (ZMAPS*BLOCK_SIZE != write(IN,zone_map,ZMAPS*BLOCK_SIZE)) |
527 | die(_("Unable to write zone map")); | 524 | die("Unable to write zone map"); |
528 | if (INODE_BUFFER_SIZE != write(IN,inode_buffer,INODE_BUFFER_SIZE)) | 525 | if (INODE_BUFFER_SIZE != write(IN,inode_buffer,INODE_BUFFER_SIZE)) |
529 | die(_("Unable to write inodes")); | 526 | die("Unable to write inodes"); |
530 | } | 527 | } |
531 | 528 | ||
532 | void get_dirsize (void) | 529 | static void get_dirsize (void) |
533 | { | 530 | { |
534 | int block; | 531 | int block; |
535 | char blk[BLOCK_SIZE]; | 532 | char blk[BLOCK_SIZE]; |
@@ -552,12 +549,12 @@ void get_dirsize (void) | |||
552 | /* use defaults */ | 549 | /* use defaults */ |
553 | } | 550 | } |
554 | 551 | ||
555 | void read_superblock(void) | 552 | static void read_superblock(void) |
556 | { | 553 | { |
557 | if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET)) | 554 | if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET)) |
558 | die(_("seek failed")); | 555 | die("seek failed"); |
559 | if (BLOCK_SIZE != read(IN, super_block_buffer, BLOCK_SIZE)) | 556 | if (BLOCK_SIZE != read(IN, super_block_buffer, BLOCK_SIZE)) |
560 | die(_("unable to read super block")); | 557 | die("unable to read super block"); |
561 | if (MAGIC == MINIX_SUPER_MAGIC) { | 558 | if (MAGIC == MINIX_SUPER_MAGIC) { |
562 | namelen = 14; | 559 | namelen = 14; |
563 | dirsize = 16; | 560 | dirsize = 16; |
@@ -577,20 +574,20 @@ void read_superblock(void) | |||
577 | version2 = 1; | 574 | version2 = 1; |
578 | #endif | 575 | #endif |
579 | } else | 576 | } else |
580 | die(_("bad magic number in super-block")); | 577 | die("bad magic number in super-block"); |
581 | if (ZONESIZE != 0 || BLOCK_SIZE != 1024) | 578 | if (ZONESIZE != 0 || BLOCK_SIZE != 1024) |
582 | die(_("Only 1k blocks/zones supported")); | 579 | die("Only 1k blocks/zones supported"); |
583 | if (IMAPS * BLOCK_SIZE * 8 < INODES + 1) | 580 | if (IMAPS * BLOCK_SIZE * 8 < INODES + 1) |
584 | die(_("bad s_imap_blocks field in super-block")); | 581 | die("bad s_imap_blocks field in super-block"); |
585 | if (ZMAPS * BLOCK_SIZE * 8 < ZONES - FIRSTZONE + 1) | 582 | if (ZMAPS * BLOCK_SIZE * 8 < ZONES - FIRSTZONE + 1) |
586 | die(_("bad s_zmap_blocks field in super-block")); | 583 | die("bad s_zmap_blocks field in super-block"); |
587 | } | 584 | } |
588 | 585 | ||
589 | void read_tables(void) | 586 | static void read_tables(void) |
590 | { | 587 | { |
591 | inode_map = malloc(IMAPS * BLOCK_SIZE); | 588 | inode_map = malloc(IMAPS * BLOCK_SIZE); |
592 | if (!inode_map) | 589 | if (!inode_map) |
593 | die(_("Unable to allocate buffer for inode map")); | 590 | die("Unable to allocate buffer for inode map"); |
594 | zone_map = malloc(ZMAPS * BLOCK_SIZE); | 591 | zone_map = malloc(ZMAPS * BLOCK_SIZE); |
595 | if (!inode_map) | 592 | if (!inode_map) |
596 | die("Unable to allocate buffer for zone map"); | 593 | die("Unable to allocate buffer for zone map"); |
@@ -598,32 +595,32 @@ void read_tables(void) | |||
598 | memset(zone_map,0,sizeof(zone_map)); | 595 | memset(zone_map,0,sizeof(zone_map)); |
599 | inode_buffer = malloc(INODE_BUFFER_SIZE); | 596 | inode_buffer = malloc(INODE_BUFFER_SIZE); |
600 | if (!inode_buffer) | 597 | if (!inode_buffer) |
601 | die(_("Unable to allocate buffer for inodes")); | 598 | die("Unable to allocate buffer for inodes"); |
602 | inode_count = malloc(INODES + 1); | 599 | inode_count = malloc(INODES + 1); |
603 | if (!inode_count) | 600 | if (!inode_count) |
604 | die(_("Unable to allocate buffer for inode count")); | 601 | die("Unable to allocate buffer for inode count"); |
605 | zone_count = malloc(ZONES); | 602 | zone_count = malloc(ZONES); |
606 | if (!zone_count) | 603 | if (!zone_count) |
607 | die(_("Unable to allocate buffer for zone count")); | 604 | die("Unable to allocate buffer for zone count"); |
608 | if (IMAPS*BLOCK_SIZE != read(IN,inode_map,IMAPS*BLOCK_SIZE)) | 605 | if (IMAPS*BLOCK_SIZE != read(IN,inode_map,IMAPS*BLOCK_SIZE)) |
609 | die(_("Unable to read inode map")); | 606 | die("Unable to read inode map"); |
610 | if (ZMAPS*BLOCK_SIZE != read(IN,zone_map,ZMAPS*BLOCK_SIZE)) | 607 | if (ZMAPS*BLOCK_SIZE != read(IN,zone_map,ZMAPS*BLOCK_SIZE)) |
611 | die(_("Unable to read zone map")); | 608 | die("Unable to read zone map"); |
612 | if (INODE_BUFFER_SIZE != read(IN,inode_buffer,INODE_BUFFER_SIZE)) | 609 | if (INODE_BUFFER_SIZE != read(IN,inode_buffer,INODE_BUFFER_SIZE)) |
613 | die(_("Unable to read inodes")); | 610 | die("Unable to read inodes"); |
614 | if (NORM_FIRSTZONE != FIRSTZONE) { | 611 | if (NORM_FIRSTZONE != FIRSTZONE) { |
615 | printf(_("Warning: Firstzone != Norm_firstzone\n")); | 612 | printf("Warning: Firstzone != Norm_firstzone\n"); |
616 | errors_uncorrected = 1; | 613 | errors_uncorrected = 1; |
617 | } | 614 | } |
618 | get_dirsize (); | 615 | get_dirsize (); |
619 | if (show) { | 616 | if (show) { |
620 | printf(_("%ld inodes\n"),INODES); | 617 | printf("%ld inodes\n",INODES); |
621 | printf(_("%ld blocks\n"),ZONES); | 618 | printf("%ld blocks\n",ZONES); |
622 | printf(_("Firstdatazone=%ld (%ld)\n"),FIRSTZONE,NORM_FIRSTZONE); | 619 | printf("Firstdatazone=%ld (%ld)\n",FIRSTZONE,NORM_FIRSTZONE); |
623 | printf(_("Zonesize=%d\n"),BLOCK_SIZE<<ZONESIZE); | 620 | printf("Zonesize=%d\n",BLOCK_SIZE<<ZONESIZE); |
624 | printf(_("Maxsize=%ld\n"),MAXSIZE); | 621 | printf("Maxsize=%ld\n",MAXSIZE); |
625 | printf(_("Filesystem state=%d\n"), Super.s_state); | 622 | printf("Filesystem state=%d\n", Super.s_state); |
626 | printf(_("namelen=%d\n\n"),namelen); | 623 | printf("namelen=%d\n\n",namelen); |
627 | } | 624 | } |
628 | } | 625 | } |
629 | 626 | ||
@@ -637,12 +634,12 @@ struct minix_inode * get_inode(unsigned int nr) | |||
637 | inode = Inode + nr; | 634 | inode = Inode + nr; |
638 | if (!inode_count[nr]) { | 635 | if (!inode_count[nr]) { |
639 | if (!inode_in_use(nr)) { | 636 | if (!inode_in_use(nr)) { |
640 | printf(_("Inode %d marked not used, but used for file '"), | 637 | printf("Inode %d marked not used, but used for file '", |
641 | nr); | 638 | nr); |
642 | print_current_name(); | 639 | print_current_name(); |
643 | printf("'\n"); | 640 | printf("'\n"); |
644 | if (repair) { | 641 | if (repair) { |
645 | if (ask(_("Mark in use"),1)) | 642 | if (ask("Mark in use",1)) |
646 | mark_inode(nr); | 643 | mark_inode(nr); |
647 | } else { | 644 | } else { |
648 | errors_uncorrected = 1; | 645 | errors_uncorrected = 1; |
@@ -664,13 +661,13 @@ struct minix_inode * get_inode(unsigned int nr) | |||
664 | ; | 661 | ; |
665 | else { | 662 | else { |
666 | print_current_name(); | 663 | print_current_name(); |
667 | printf(_(" has mode %05o\n"),inode->i_mode); | 664 | printf(" has mode %05o\n",inode->i_mode); |
668 | } | 665 | } |
669 | 666 | ||
670 | } else | 667 | } else |
671 | links++; | 668 | links++; |
672 | if (!++inode_count[nr]) { | 669 | if (!++inode_count[nr]) { |
673 | printf(_("Warning: inode count too big.\n")); | 670 | printf("Warning: inode count too big.\n"); |
674 | inode_count[nr]--; | 671 | inode_count[nr]--; |
675 | errors_uncorrected = 1; | 672 | errors_uncorrected = 1; |
676 | } | 673 | } |
@@ -689,11 +686,11 @@ get_inode2 (unsigned int nr) | |||
689 | inode = Inode2 + nr; | 686 | inode = Inode2 + nr; |
690 | if (!inode_count[nr]) { | 687 | if (!inode_count[nr]) { |
691 | if (!inode_in_use (nr)) { | 688 | if (!inode_in_use (nr)) { |
692 | printf (_("Inode %d marked not used, but used for file '"), nr); | 689 | printf ("Inode %d marked not used, but used for file '", nr); |
693 | print_current_name (); | 690 | print_current_name (); |
694 | printf ("'\n"); | 691 | printf ("'\n"); |
695 | if (repair) { | 692 | if (repair) { |
696 | if (ask (_("Mark in use"), 1)) | 693 | if (ask ("Mark in use", 1)) |
697 | mark_inode (nr); | 694 | mark_inode (nr); |
698 | else | 695 | else |
699 | errors_uncorrected = 1; | 696 | errors_uncorrected = 1; |
@@ -713,12 +710,12 @@ get_inode2 (unsigned int nr) | |||
713 | else if (S_ISFIFO (inode->i_mode)); | 710 | else if (S_ISFIFO (inode->i_mode)); |
714 | else { | 711 | else { |
715 | print_current_name (); | 712 | print_current_name (); |
716 | printf (_(" has mode %05o\n"), inode->i_mode); | 713 | printf (" has mode %05o\n", inode->i_mode); |
717 | } | 714 | } |
718 | } else | 715 | } else |
719 | links++; | 716 | links++; |
720 | if (!++inode_count[nr]) { | 717 | if (!++inode_count[nr]) { |
721 | printf (_("Warning: inode count too big.\n")); | 718 | printf ("Warning: inode count too big.\n"); |
722 | inode_count[nr]--; | 719 | inode_count[nr]--; |
723 | errors_uncorrected = 1; | 720 | errors_uncorrected = 1; |
724 | } | 721 | } |
@@ -726,16 +723,16 @@ get_inode2 (unsigned int nr) | |||
726 | } | 723 | } |
727 | #endif | 724 | #endif |
728 | 725 | ||
729 | void check_root(void) | 726 | static void check_root(void) |
730 | { | 727 | { |
731 | struct minix_inode * inode = Inode + ROOT_INO; | 728 | struct minix_inode * inode = Inode + ROOT_INO; |
732 | 729 | ||
733 | if (!inode || !S_ISDIR(inode->i_mode)) | 730 | if (!inode || !S_ISDIR(inode->i_mode)) |
734 | die(_("root inode isn't a directory")); | 731 | die("root inode isn't a directory"); |
735 | } | 732 | } |
736 | 733 | ||
737 | #ifdef HAVE_MINIX2 | 734 | #ifdef HAVE_MINIX2 |
738 | void check_root2 (void) | 735 | static void check_root2 (void) |
739 | { | 736 | { |
740 | struct minix2_inode *inode = Inode2 + ROOT_INO; | 737 | struct minix2_inode *inode = Inode2 + ROOT_INO; |
741 | 738 | ||
@@ -754,10 +751,10 @@ static int add_zone(unsigned short * znr, int * corrected) | |||
754 | if (!block) | 751 | if (!block) |
755 | return 0; | 752 | return 0; |
756 | if (zone_count[block]) { | 753 | if (zone_count[block]) { |
757 | printf(_("Block has been used before. Now in file `")); | 754 | printf("Block has been used before. Now in file `"); |
758 | print_current_name(); | 755 | print_current_name(); |
759 | printf("'."); | 756 | printf("'."); |
760 | if (ask(_("Clear"),1)) { | 757 | if (ask("Clear",1)) { |
761 | *znr = 0; | 758 | *znr = 0; |
762 | block = 0; | 759 | block = 0; |
763 | *corrected = 1; | 760 | *corrected = 1; |
@@ -766,10 +763,10 @@ static int add_zone(unsigned short * znr, int * corrected) | |||
766 | if (!block) | 763 | if (!block) |
767 | return 0; | 764 | return 0; |
768 | if (!zone_in_use(block)) { | 765 | if (!zone_in_use(block)) { |
769 | printf(_("Block %d in file `"),block); | 766 | printf("Block %d in file `",block); |
770 | print_current_name(); | 767 | print_current_name(); |
771 | printf(_("' is marked not in use.")); | 768 | printf("' is marked not in use."); |
772 | if (ask(_("Correct"),1)) | 769 | if (ask("Correct",1)) |
773 | mark_zone(block); | 770 | mark_zone(block); |
774 | } | 771 | } |
775 | if (!++zone_count[block]) | 772 | if (!++zone_count[block]) |
@@ -788,10 +785,10 @@ static int add_zone2 (unsigned int *znr, int *corrected) | |||
788 | if (!block) | 785 | if (!block) |
789 | return 0; | 786 | return 0; |
790 | if (zone_count[block]) { | 787 | if (zone_count[block]) { |
791 | printf (_("Block has been used before. Now in file `")); | 788 | printf ("Block has been used before. Now in file `"); |
792 | print_current_name (); | 789 | print_current_name (); |
793 | printf ("'."); | 790 | printf ("'."); |
794 | if (ask (_("Clear"), 1)) { | 791 | if (ask ("Clear", 1)) { |
795 | *znr = 0; | 792 | *znr = 0; |
796 | block = 0; | 793 | block = 0; |
797 | *corrected = 1; | 794 | *corrected = 1; |
@@ -800,10 +797,10 @@ static int add_zone2 (unsigned int *znr, int *corrected) | |||
800 | if (!block) | 797 | if (!block) |
801 | return 0; | 798 | return 0; |
802 | if (!zone_in_use (block)) { | 799 | if (!zone_in_use (block)) { |
803 | printf (_("Block %d in file `"), block); | 800 | printf ("Block %d in file `", block); |
804 | print_current_name (); | 801 | print_current_name (); |
805 | printf (_("' is marked not in use.")); | 802 | printf ("' is marked not in use."); |
806 | if (ask (_("Correct"), 1)) | 803 | if (ask ("Correct", 1)) |
807 | mark_zone (block); | 804 | mark_zone (block); |
808 | } | 805 | } |
809 | if (!++zone_count[block]) | 806 | if (!++zone_count[block]) |
@@ -899,7 +896,7 @@ add_zone_tind2 (unsigned int *znr, int *corrected) | |||
899 | } | 896 | } |
900 | #endif | 897 | #endif |
901 | 898 | ||
902 | void check_zones(unsigned int i) | 899 | static void check_zones(unsigned int i) |
903 | { | 900 | { |
904 | struct minix_inode * inode; | 901 | struct minix_inode * inode; |
905 | 902 | ||
@@ -918,7 +915,7 @@ void check_zones(unsigned int i) | |||
918 | } | 915 | } |
919 | 916 | ||
920 | #ifdef HAVE_MINIX2 | 917 | #ifdef HAVE_MINIX2 |
921 | void | 918 | static void |
922 | check_zones2 (unsigned int i) | 919 | check_zones2 (unsigned int i) |
923 | { | 920 | { |
924 | struct minix2_inode *inode; | 921 | struct minix2_inode *inode; |
@@ -939,7 +936,7 @@ check_zones2 (unsigned int i) | |||
939 | } | 936 | } |
940 | #endif | 937 | #endif |
941 | 938 | ||
942 | void check_file(struct minix_inode * dir, unsigned int offset) | 939 | static void check_file(struct minix_inode * dir, unsigned int offset) |
943 | { | 940 | { |
944 | static char blk[BLOCK_SIZE]; | 941 | static char blk[BLOCK_SIZE]; |
945 | struct minix_inode * inode; | 942 | struct minix_inode * inode; |
@@ -953,9 +950,9 @@ void check_file(struct minix_inode * dir, unsigned int offset) | |||
953 | ino = * (unsigned short *) (name-2); | 950 | ino = * (unsigned short *) (name-2); |
954 | if (ino > INODES) { | 951 | if (ino > INODES) { |
955 | print_current_name(); | 952 | print_current_name(); |
956 | printf(_(" contains a bad inode number for file '")); | 953 | printf(" contains a bad inode number for file '"); |
957 | printf("%.*s'.",namelen,name); | 954 | printf("%.*s'.",namelen,name); |
958 | if (ask(_(" Remove"),1)) { | 955 | if (ask(" Remove",1)) { |
959 | *(unsigned short *)(name-2) = 0; | 956 | *(unsigned short *)(name-2) = 0; |
960 | write_block(block, blk); | 957 | write_block(block, blk); |
961 | } | 958 | } |
@@ -969,14 +966,14 @@ void check_file(struct minix_inode * dir, unsigned int offset) | |||
969 | if (!offset) { | 966 | if (!offset) { |
970 | if (!inode || strcmp(".",name)) { | 967 | if (!inode || strcmp(".",name)) { |
971 | print_current_name(); | 968 | print_current_name(); |
972 | printf(_(": bad directory: '.' isn't first\n")); | 969 | printf(": bad directory: '.' isn't first\n"); |
973 | errors_uncorrected = 1; | 970 | errors_uncorrected = 1; |
974 | } else return; | 971 | } else return; |
975 | } | 972 | } |
976 | if (offset == dirsize) { | 973 | if (offset == dirsize) { |
977 | if (!inode || strcmp("..",name)) { | 974 | if (!inode || strcmp("..",name)) { |
978 | print_current_name(); | 975 | print_current_name(); |
979 | printf(_(": bad directory: '..' isn't second\n")); | 976 | printf(": bad directory: '..' isn't second\n"); |
980 | errors_uncorrected = 1; | 977 | errors_uncorrected = 1; |
981 | } else return; | 978 | } else return; |
982 | } | 979 | } |
@@ -1002,7 +999,7 @@ void check_file(struct minix_inode * dir, unsigned int offset) | |||
1002 | } | 999 | } |
1003 | 1000 | ||
1004 | #ifdef HAVE_MINIX2 | 1001 | #ifdef HAVE_MINIX2 |
1005 | void | 1002 | static void |
1006 | check_file2 (struct minix2_inode *dir, unsigned int offset) | 1003 | check_file2 (struct minix2_inode *dir, unsigned int offset) |
1007 | { | 1004 | { |
1008 | static char blk[BLOCK_SIZE]; | 1005 | static char blk[BLOCK_SIZE]; |
@@ -1017,9 +1014,9 @@ check_file2 (struct minix2_inode *dir, unsigned int offset) | |||
1017 | ino = *(unsigned short *) (name - 2); | 1014 | ino = *(unsigned short *) (name - 2); |
1018 | if (ino > INODES) { | 1015 | if (ino > INODES) { |
1019 | print_current_name (); | 1016 | print_current_name (); |
1020 | printf (_(" contains a bad inode number for file '")); | 1017 | printf (" contains a bad inode number for file '"); |
1021 | printf ("%.*s'.", namelen, name); | 1018 | printf ("%.*s'.", namelen, name); |
1022 | if (ask (_(" Remove"), 1)) { | 1019 | if (ask (" Remove", 1)) { |
1023 | *(unsigned short *) (name - 2) = 0; | 1020 | *(unsigned short *) (name - 2) = 0; |
1024 | write_block (block, blk); | 1021 | write_block (block, blk); |
1025 | } | 1022 | } |
@@ -1033,7 +1030,7 @@ check_file2 (struct minix2_inode *dir, unsigned int offset) | |||
1033 | if (!offset) { | 1030 | if (!offset) { |
1034 | if (!inode || strcmp (".", name)) { | 1031 | if (!inode || strcmp (".", name)) { |
1035 | print_current_name (); | 1032 | print_current_name (); |
1036 | printf (_(": bad directory: '.' isn't first\n")); | 1033 | printf (": bad directory: '.' isn't first\n"); |
1037 | errors_uncorrected = 1; | 1034 | errors_uncorrected = 1; |
1038 | } else | 1035 | } else |
1039 | return; | 1036 | return; |
@@ -1041,7 +1038,7 @@ check_file2 (struct minix2_inode *dir, unsigned int offset) | |||
1041 | if (offset == dirsize) { | 1038 | if (offset == dirsize) { |
1042 | if (!inode || strcmp ("..", name)) { | 1039 | if (!inode || strcmp ("..", name)) { |
1043 | print_current_name (); | 1040 | print_current_name (); |
1044 | printf (_(": bad directory: '..' isn't second\n")); | 1041 | printf (": bad directory: '..' isn't second\n"); |
1045 | errors_uncorrected = 1; | 1042 | errors_uncorrected = 1; |
1046 | } else | 1043 | } else |
1047 | return; | 1044 | return; |
@@ -1066,17 +1063,17 @@ check_file2 (struct minix2_inode *dir, unsigned int offset) | |||
1066 | } | 1063 | } |
1067 | #endif | 1064 | #endif |
1068 | 1065 | ||
1069 | void recursive_check(unsigned int ino) | 1066 | static void recursive_check(unsigned int ino) |
1070 | { | 1067 | { |
1071 | struct minix_inode * dir; | 1068 | struct minix_inode * dir; |
1072 | unsigned int offset; | 1069 | unsigned int offset; |
1073 | 1070 | ||
1074 | dir = Inode + ino; | 1071 | dir = Inode + ino; |
1075 | if (!S_ISDIR(dir->i_mode)) | 1072 | if (!S_ISDIR(dir->i_mode)) |
1076 | die(_("internal error")); | 1073 | die("internal error"); |
1077 | if (dir->i_size < 2 * dirsize) { | 1074 | if (dir->i_size < 2 * dirsize) { |
1078 | print_current_name(); | 1075 | print_current_name(); |
1079 | printf(_(": bad directory: size<32")); | 1076 | printf(": bad directory: size<32"); |
1080 | errors_uncorrected = 1; | 1077 | errors_uncorrected = 1; |
1081 | } | 1078 | } |
1082 | for (offset = 0 ; offset < dir->i_size ; offset += dirsize) | 1079 | for (offset = 0 ; offset < dir->i_size ; offset += dirsize) |
@@ -1084,7 +1081,7 @@ void recursive_check(unsigned int ino) | |||
1084 | } | 1081 | } |
1085 | 1082 | ||
1086 | #ifdef HAVE_MINIX2 | 1083 | #ifdef HAVE_MINIX2 |
1087 | void | 1084 | static void |
1088 | recursive_check2 (unsigned int ino) | 1085 | recursive_check2 (unsigned int ino) |
1089 | { | 1086 | { |
1090 | struct minix2_inode *dir; | 1087 | struct minix2_inode *dir; |
@@ -1095,7 +1092,7 @@ recursive_check2 (unsigned int ino) | |||
1095 | die ("internal error"); | 1092 | die ("internal error"); |
1096 | if (dir->i_size < 2 * dirsize) { | 1093 | if (dir->i_size < 2 * dirsize) { |
1097 | print_current_name (); | 1094 | print_current_name (); |
1098 | printf (_(": bad directory: size < 32")); | 1095 | printf (": bad directory: size < 32"); |
1099 | errors_uncorrected = 1; | 1096 | errors_uncorrected = 1; |
1100 | } | 1097 | } |
1101 | for (offset = 0; offset < dir->i_size; offset += dirsize) | 1098 | for (offset = 0; offset < dir->i_size; offset += dirsize) |
@@ -1103,23 +1100,23 @@ recursive_check2 (unsigned int ino) | |||
1103 | } | 1100 | } |
1104 | #endif | 1101 | #endif |
1105 | 1102 | ||
1106 | int bad_zone(int i) | 1103 | static int bad_zone(int i) |
1107 | { | 1104 | { |
1108 | char buffer[1024]; | 1105 | char buffer[1024]; |
1109 | 1106 | ||
1110 | if (BLOCK_SIZE*i != lseek(IN, BLOCK_SIZE*i, SEEK_SET)) | 1107 | if (BLOCK_SIZE*i != lseek(IN, BLOCK_SIZE*i, SEEK_SET)) |
1111 | die(_("seek failed in bad_zone")); | 1108 | die("seek failed in bad_zone"); |
1112 | return (BLOCK_SIZE != read(IN, buffer, BLOCK_SIZE)); | 1109 | return (BLOCK_SIZE != read(IN, buffer, BLOCK_SIZE)); |
1113 | } | 1110 | } |
1114 | 1111 | ||
1115 | void check_counts(void) | 1112 | static void check_counts(void) |
1116 | { | 1113 | { |
1117 | int i; | 1114 | int i; |
1118 | 1115 | ||
1119 | for (i=1 ; i <= INODES ; i++) { | 1116 | for (i=1 ; i <= INODES ; i++) { |
1120 | if (!inode_in_use(i) && Inode[i].i_mode && warn_mode) { | 1117 | if (!inode_in_use(i) && Inode[i].i_mode && warn_mode) { |
1121 | printf(_("Inode %d mode not cleared."),i); | 1118 | printf("Inode %d mode not cleared.",i); |
1122 | if (ask(_("Clear"),1)) { | 1119 | if (ask("Clear",1)) { |
1123 | Inode[i].i_mode = 0; | 1120 | Inode[i].i_mode = 0; |
1124 | changed = 1; | 1121 | changed = 1; |
1125 | } | 1122 | } |
@@ -1127,21 +1124,20 @@ void check_counts(void) | |||
1127 | if (!inode_count[i]) { | 1124 | if (!inode_count[i]) { |
1128 | if (!inode_in_use(i)) | 1125 | if (!inode_in_use(i)) |
1129 | continue; | 1126 | continue; |
1130 | printf(_("Inode %d not used, marked used in the bitmap."),i); | 1127 | printf("Inode %d not used, marked used in the bitmap.",i); |
1131 | if (ask(_("Clear"),1)) | 1128 | if (ask("Clear",1)) |
1132 | unmark_inode(i); | 1129 | unmark_inode(i); |
1133 | continue; | 1130 | continue; |
1134 | } | 1131 | } |
1135 | if (!inode_in_use(i)) { | 1132 | if (!inode_in_use(i)) { |
1136 | printf(_("Inode %d used, marked unused in the bitmap."), | 1133 | printf("Inode %d used, marked unused in the bitmap.", i); |
1137 | i); | ||
1138 | if (ask("Set",1)) | 1134 | if (ask("Set",1)) |
1139 | mark_inode(i); | 1135 | mark_inode(i); |
1140 | } | 1136 | } |
1141 | if (Inode[i].i_nlinks != inode_count[i]) { | 1137 | if (Inode[i].i_nlinks != inode_count[i]) { |
1142 | printf(_("Inode %d (mode = %07o), i_nlinks=%d, counted=%d."), | 1138 | printf("Inode %d (mode = %07o), i_nlinks=%d, counted=%d.", |
1143 | i,Inode[i].i_mode,Inode[i].i_nlinks,inode_count[i]); | 1139 | i,Inode[i].i_mode,Inode[i].i_nlinks,inode_count[i]); |
1144 | if (ask(_("Set i_nlinks to count"),1)) { | 1140 | if (ask("Set i_nlinks to count",1)) { |
1145 | Inode[i].i_nlinks=inode_count[i]; | 1141 | Inode[i].i_nlinks=inode_count[i]; |
1146 | changed=1; | 1142 | changed=1; |
1147 | } | 1143 | } |
@@ -1153,26 +1149,26 @@ void check_counts(void) | |||
1153 | if (!zone_count[i]) { | 1149 | if (!zone_count[i]) { |
1154 | if (bad_zone(i)) | 1150 | if (bad_zone(i)) |
1155 | continue; | 1151 | continue; |
1156 | printf(_("Zone %d: marked in use, no file uses it."),i); | 1152 | printf("Zone %d: marked in use, no file uses it.",i); |
1157 | if (ask(_("Unmark"),1)) | 1153 | if (ask("Unmark",1)) |
1158 | unmark_zone(i); | 1154 | unmark_zone(i); |
1159 | continue; | 1155 | continue; |
1160 | } | 1156 | } |
1161 | printf(_("Zone %d: %sin use, counted=%d\n"), | 1157 | printf("Zone %d: %sin use, counted=%d\n", |
1162 | i,zone_in_use(i)?"":_("not "),zone_count[i]); | 1158 | i,zone_in_use(i)?"":"not ",zone_count[i]); |
1163 | } | 1159 | } |
1164 | } | 1160 | } |
1165 | 1161 | ||
1166 | #ifdef HAVE_MINIX2 | 1162 | #ifdef HAVE_MINIX2 |
1167 | void | 1163 | static void |
1168 | check_counts2 (void) | 1164 | check_counts2 (void) |
1169 | { | 1165 | { |
1170 | int i; | 1166 | int i; |
1171 | 1167 | ||
1172 | for (i = 1; i <= INODES; i++) { | 1168 | for (i = 1; i <= INODES; i++) { |
1173 | if (!inode_in_use (i) && Inode2[i].i_mode && warn_mode) { | 1169 | if (!inode_in_use (i) && Inode2[i].i_mode && warn_mode) { |
1174 | printf (_("Inode %d mode not cleared."), i); | 1170 | printf ("Inode %d mode not cleared.", i); |
1175 | if (ask (_("Clear"), 1)) { | 1171 | if (ask ("Clear", 1)) { |
1176 | Inode2[i].i_mode = 0; | 1172 | Inode2[i].i_mode = 0; |
1177 | changed = 1; | 1173 | changed = 1; |
1178 | } | 1174 | } |
@@ -1180,20 +1176,20 @@ check_counts2 (void) | |||
1180 | if (!inode_count[i]) { | 1176 | if (!inode_count[i]) { |
1181 | if (!inode_in_use (i)) | 1177 | if (!inode_in_use (i)) |
1182 | continue; | 1178 | continue; |
1183 | printf (_("Inode %d not used, marked used in the bitmap."), i); | 1179 | printf ("Inode %d not used, marked used in the bitmap.", i); |
1184 | if (ask (_("Clear"), 1)) | 1180 | if (ask ("Clear", 1)) |
1185 | unmark_inode (i); | 1181 | unmark_inode (i); |
1186 | continue; | 1182 | continue; |
1187 | } | 1183 | } |
1188 | if (!inode_in_use (i)) { | 1184 | if (!inode_in_use (i)) { |
1189 | printf (_("Inode %d used, marked unused in the bitmap."), i); | 1185 | printf ("Inode %d used, marked unused in the bitmap.", i); |
1190 | if (ask (_("Set"), 1)) | 1186 | if (ask ("Set", 1)) |
1191 | mark_inode (i); | 1187 | mark_inode (i); |
1192 | } | 1188 | } |
1193 | if (Inode2[i].i_nlinks != inode_count[i]) { | 1189 | if (Inode2[i].i_nlinks != inode_count[i]) { |
1194 | printf (_("Inode %d (mode = %07o), i_nlinks=%d, counted=%d."), | 1190 | printf ("Inode %d (mode = %07o), i_nlinks=%d, counted=%d.", |
1195 | i, Inode2[i].i_mode, Inode2[i].i_nlinks, inode_count[i]); | 1191 | i, Inode2[i].i_mode, Inode2[i].i_nlinks, inode_count[i]); |
1196 | if (ask (_("Set i_nlinks to count"), 1)) { | 1192 | if (ask ("Set i_nlinks to count", 1)) { |
1197 | Inode2[i].i_nlinks = inode_count[i]; | 1193 | Inode2[i].i_nlinks = inode_count[i]; |
1198 | changed = 1; | 1194 | changed = 1; |
1199 | } | 1195 | } |
@@ -1205,18 +1201,18 @@ check_counts2 (void) | |||
1205 | if (!zone_count[i]) { | 1201 | if (!zone_count[i]) { |
1206 | if (bad_zone (i)) | 1202 | if (bad_zone (i)) |
1207 | continue; | 1203 | continue; |
1208 | printf (_("Zone %d: marked in use, no file uses it."), i); | 1204 | printf ("Zone %d: marked in use, no file uses it.", i); |
1209 | if (ask (_("Unmark"), 1)) | 1205 | if (ask ("Unmark", 1)) |
1210 | unmark_zone (i); | 1206 | unmark_zone (i); |
1211 | continue; | 1207 | continue; |
1212 | } | 1208 | } |
1213 | printf (_("Zone %d: %sin use, counted=%d\n"), | 1209 | printf ("Zone %d: %sin use, counted=%d\n", |
1214 | i, zone_in_use (i) ? "" : _("not "), zone_count[i]); | 1210 | i, zone_in_use (i) ? "" : "not ", zone_count[i]); |
1215 | } | 1211 | } |
1216 | } | 1212 | } |
1217 | #endif | 1213 | #endif |
1218 | 1214 | ||
1219 | void check(void) | 1215 | static void check(void) |
1220 | { | 1216 | { |
1221 | memset(inode_count,0,(INODES + 1) * sizeof(*inode_count)); | 1217 | memset(inode_count,0,(INODES + 1) * sizeof(*inode_count)); |
1222 | memset(zone_count,0,ZONES*sizeof(*zone_count)); | 1218 | memset(zone_count,0,ZONES*sizeof(*zone_count)); |
@@ -1226,7 +1222,7 @@ void check(void) | |||
1226 | } | 1222 | } |
1227 | 1223 | ||
1228 | #ifdef HAVE_MINIX2 | 1224 | #ifdef HAVE_MINIX2 |
1229 | void | 1225 | static void |
1230 | check2 (void) | 1226 | check2 (void) |
1231 | { | 1227 | { |
1232 | memset (inode_count, 0, (INODES + 1) * sizeof (*inode_count)); | 1228 | memset (inode_count, 0, (INODES + 1) * sizeof (*inode_count)); |
@@ -1244,24 +1240,19 @@ fsck_minix_main(int argc, char ** argv) | |||
1244 | int count; | 1240 | int count; |
1245 | int retcode = 0; | 1241 | int retcode = 0; |
1246 | 1242 | ||
1247 | setlocale(LC_ALL, ""); | ||
1248 | bindtextdomain(PACKAGE, LOCALEDIR); | ||
1249 | textdomain(PACKAGE); | ||
1250 | |||
1251 | |||
1252 | if (argc && *argv) | 1243 | if (argc && *argv) |
1253 | program_name = *argv; | 1244 | program_name = *argv; |
1254 | if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE) | 1245 | if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE) |
1255 | die(_("bad inode size")); | 1246 | die("bad inode size"); |
1256 | #ifdef HAVE_MINIX2 | 1247 | #ifdef HAVE_MINIX2 |
1257 | if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) | 1248 | if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) |
1258 | die(_("bad v2 inode size")); | 1249 | die("bad v2 inode size"); |
1259 | #endif | 1250 | #endif |
1260 | while (argc-- > 1) { | 1251 | while (argc-- > 1) { |
1261 | argv++; | 1252 | argv++; |
1262 | if (argv[0][0] != '-') { | 1253 | if (argv[0][0] != '-') { |
1263 | if (device_name) | 1254 | if (device_name) |
1264 | usage(); | 1255 | show_usage(); |
1265 | else | 1256 | else |
1266 | device_name = argv[0]; | 1257 | device_name = argv[0]; |
1267 | } else while (*++argv[0]) | 1258 | } else while (*++argv[0]) |
@@ -1273,19 +1264,19 @@ fsck_minix_main(int argc, char ** argv) | |||
1273 | case 's': show=1; break; | 1264 | case 's': show=1; break; |
1274 | case 'm': warn_mode=1; break; | 1265 | case 'm': warn_mode=1; break; |
1275 | case 'f': force=1; break; | 1266 | case 'f': force=1; break; |
1276 | default: usage(); | 1267 | default: show_usage(); |
1277 | } | 1268 | } |
1278 | } | 1269 | } |
1279 | if (!device_name) | 1270 | if (!device_name) |
1280 | usage(); | 1271 | show_usage(); |
1281 | check_mount(); /* trying to check a mounted filesystem? */ | 1272 | check_mount(); /* trying to check a mounted filesystem? */ |
1282 | if (repair && !automatic) { | 1273 | if (repair && !automatic) { |
1283 | if (!isatty(0) || !isatty(1)) | 1274 | if (!isatty(0) || !isatty(1)) |
1284 | die(_("need terminal for interactive repairs")); | 1275 | die("need terminal for interactive repairs"); |
1285 | } | 1276 | } |
1286 | IN = open(device_name,repair?O_RDWR:O_RDONLY); | 1277 | IN = open(device_name,repair?O_RDWR:O_RDONLY); |
1287 | if (IN < 0) | 1278 | if (IN < 0) |
1288 | die(_("unable to open '%s'")); | 1279 | die("unable to open '%s'"); |
1289 | for (count=0 ; count<3 ; count++) | 1280 | for (count=0 ; count<3 ; count++) |
1290 | sync(); | 1281 | sync(); |
1291 | read_superblock(); | 1282 | read_superblock(); |
@@ -1296,19 +1287,18 @@ fsck_minix_main(int argc, char ** argv) | |||
1296 | * flags and whether or not the -f switch was specified on the | 1287 | * flags and whether or not the -f switch was specified on the |
1297 | * command line. | 1288 | * command line. |
1298 | */ | 1289 | */ |
1299 | printf("%s, %s / %s\n", program_name, program_version, | 1290 | printf("%s, %s\n", program_name, program_version); |
1300 | util_linux_version); | ||
1301 | if ( !(Super.s_state & MINIX_ERROR_FS) && | 1291 | if ( !(Super.s_state & MINIX_ERROR_FS) && |
1302 | (Super.s_state & MINIX_VALID_FS) && | 1292 | (Super.s_state & MINIX_VALID_FS) && |
1303 | !force ) { | 1293 | !force ) { |
1304 | if (repair) | 1294 | if (repair) |
1305 | printf(_("%s is clean, no check.\n"), device_name); | 1295 | printf("%s is clean, no check.\n", device_name); |
1306 | return retcode; | 1296 | return retcode; |
1307 | } | 1297 | } |
1308 | else if (force) | 1298 | else if (force) |
1309 | printf(_("Forcing filesystem check on %s.\n"), device_name); | 1299 | printf("Forcing filesystem check on %s.\n", device_name); |
1310 | else if (repair) | 1300 | else if (repair) |
1311 | printf(_("Filesystem on %s is dirty, needs checking.\n"),\ | 1301 | printf("Filesystem on %s is dirty, needs checking.\n",\ |
1312 | device_name); | 1302 | device_name); |
1313 | 1303 | ||
1314 | read_tables(); | 1304 | read_tables(); |
@@ -1337,29 +1327,29 @@ fsck_minix_main(int argc, char ** argv) | |||
1337 | for (i=1,free=0 ; i <= INODES ; i++) | 1327 | for (i=1,free=0 ; i <= INODES ; i++) |
1338 | if (!inode_in_use(i)) | 1328 | if (!inode_in_use(i)) |
1339 | free++; | 1329 | free++; |
1340 | printf(_("\n%6ld inodes used (%ld%%)\n"),(INODES-free), | 1330 | printf("\n%6ld inodes used (%ld%%)\n",(INODES-free), |
1341 | 100*(INODES-free)/INODES); | 1331 | 100*(INODES-free)/INODES); |
1342 | for (i=FIRSTZONE,free=0 ; i < ZONES ; i++) | 1332 | for (i=FIRSTZONE,free=0 ; i < ZONES ; i++) |
1343 | if (!zone_in_use(i)) | 1333 | if (!zone_in_use(i)) |
1344 | free++; | 1334 | free++; |
1345 | printf(_("%6ld zones used (%ld%%)\n"),(ZONES-free), | 1335 | printf("%6ld zones used (%ld%%)\n",(ZONES-free), |
1346 | 100*(ZONES-free)/ZONES); | 1336 | 100*(ZONES-free)/ZONES); |
1347 | printf(_("\n%6d regular files\n" | 1337 | printf("\n%6d regular files\n" |
1348 | "%6d directories\n" | 1338 | "%6d directories\n" |
1349 | "%6d character device files\n" | 1339 | "%6d character device files\n" |
1350 | "%6d block device files\n" | 1340 | "%6d block device files\n" |
1351 | "%6d links\n" | 1341 | "%6d links\n" |
1352 | "%6d symbolic links\n" | 1342 | "%6d symbolic links\n" |
1353 | "------\n" | 1343 | "------\n" |
1354 | "%6d files\n"), | 1344 | "%6d files\n", |
1355 | regular,directory,chardev,blockdev, | 1345 | regular,directory,chardev,blockdev, |
1356 | links-2*directory+1,symlinks,total-2*directory+1); | 1346 | links-2*directory+1,symlinks,total-2*directory+1); |
1357 | } | 1347 | } |
1358 | if (changed) { | 1348 | if (changed) { |
1359 | write_tables(); | 1349 | write_tables(); |
1360 | printf(_( "----------------------------\n" | 1350 | printf( "----------------------------\n" |
1361 | "FILE SYSTEM HAS BEEN CHANGED\n" | 1351 | "FILE SYSTEM HAS BEEN CHANGED\n" |
1362 | "----------------------------\n")); | 1352 | "----------------------------\n"); |
1363 | for (count=0 ; count<3 ; count++) | 1353 | for (count=0 ; count<3 ; count++) |
1364 | sync(); | 1354 | sync(); |
1365 | } | 1355 | } |
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c index 7c8af7e1d..926a023b4 100644 --- a/util-linux/mkfs_minix.c +++ b/util-linux/mkfs_minix.c | |||
@@ -58,6 +58,7 @@ | |||
58 | * enforced (but it's not much fun on a character device :-). | 58 | * enforced (but it's not much fun on a character device :-). |
59 | */ | 59 | */ |
60 | 60 | ||
61 | #include "internal.h" | ||
61 | #include <stdio.h> | 62 | #include <stdio.h> |
62 | #include <time.h> | 63 | #include <time.h> |
63 | #include <unistd.h> | 64 | #include <unistd.h> |
@@ -75,9 +76,6 @@ | |||
75 | #include <linux/fs.h> | 76 | #include <linux/fs.h> |
76 | #include <linux/minix_fs.h> | 77 | #include <linux/minix_fs.h> |
77 | 78 | ||
78 | #include "nls.h" | ||
79 | #include "../version.h" | ||
80 | |||
81 | #ifdef MINIX2_SUPER_MAGIC2 | 79 | #ifdef MINIX2_SUPER_MAGIC2 |
82 | #define HAVE_MINIX2 1 | 80 | #define HAVE_MINIX2 1 |
83 | #endif | 81 | #endif |
@@ -152,8 +150,6 @@ static unsigned short good_blocks_table[MAX_GOOD_BLOCKS]; | |||
152 | static int used_good_blocks = 0; | 150 | static int used_good_blocks = 0; |
153 | static unsigned long req_nr_inodes = 0; | 151 | static unsigned long req_nr_inodes = 0; |
154 | 152 | ||
155 | #include "bitops.h" | ||
156 | |||
157 | #define inode_in_use(x) (bit(inode_map,(x))) | 153 | #define inode_in_use(x) (bit(inode_map,(x))) |
158 | #define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1)) | 154 | #define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1)) |
159 | 155 | ||
@@ -168,22 +164,16 @@ static unsigned long req_nr_inodes = 0; | |||
168 | * to compile this under minix, volatile gives a warning, as | 164 | * to compile this under minix, volatile gives a warning, as |
169 | * exit() isn't defined as volatile under minix. | 165 | * exit() isn't defined as volatile under minix. |
170 | */ | 166 | */ |
171 | volatile void fatal_error(const char * fmt_string,int status) | 167 | static volatile void die(char *str) { |
172 | { | ||
173 | fprintf(stderr,fmt_string,program_name,device_name); | ||
174 | exit(status); | ||
175 | } | ||
176 | |||
177 | volatile void die(char *str) { | ||
178 | fprintf(stderr, "%s: %s\n", program_name, str); | 168 | fprintf(stderr, "%s: %s\n", program_name, str); |
179 | exit(8); | 169 | exit(8); |
180 | } | 170 | } |
181 | 171 | ||
182 | volatile void usage() | 172 | static volatile void show_usage() |
183 | { | 173 | { |
184 | fprintf(stderr, "%s (%s)\n", program_name, util_linux_version); | 174 | fprintf(stderr, "%s\n", program_name); |
185 | fprintf(stderr, | 175 | fprintf(stderr, |
186 | _("Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n"), | 176 | "Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n", |
187 | program_name); | 177 | program_name); |
188 | exit(16); | 178 | exit(16); |
189 | } | 179 | } |
@@ -207,7 +197,7 @@ static void check_mount(void) | |||
207 | if (!mnt) | 197 | if (!mnt) |
208 | return; | 198 | return; |
209 | 199 | ||
210 | die(_("%s is mounted; will not make a filesystem here!")); | 200 | die("%s is mounted; will not make a filesystem here!"); |
211 | } | 201 | } |
212 | 202 | ||
213 | static long valid_offset (int fd, int offset) | 203 | static long valid_offset (int fd, int offset) |
@@ -261,43 +251,43 @@ static int get_size(const char *file) | |||
261 | return size; | 251 | return size; |
262 | } | 252 | } |
263 | 253 | ||
264 | void write_tables(void) | 254 | static void write_tables(void) |
265 | { | 255 | { |
266 | /* Mark the super block valid. */ | 256 | /* Mark the super block valid. */ |
267 | Super.s_state |= MINIX_VALID_FS; | 257 | Super.s_state |= MINIX_VALID_FS; |
268 | Super.s_state &= ~MINIX_ERROR_FS; | 258 | Super.s_state &= ~MINIX_ERROR_FS; |
269 | 259 | ||
270 | if (lseek(DEV, 0, SEEK_SET)) | 260 | if (lseek(DEV, 0, SEEK_SET)) |
271 | die(_("seek to boot block failed in write_tables")); | 261 | die("seek to boot block failed in write_tables"); |
272 | if (512 != write(DEV, boot_block_buffer, 512)) | 262 | if (512 != write(DEV, boot_block_buffer, 512)) |
273 | die(_("unable to clear boot sector")); | 263 | die("unable to clear boot sector"); |
274 | if (BLOCK_SIZE != lseek(DEV, BLOCK_SIZE, SEEK_SET)) | 264 | if (BLOCK_SIZE != lseek(DEV, BLOCK_SIZE, SEEK_SET)) |
275 | die(_("seek failed in write_tables")); | 265 | die("seek failed in write_tables"); |
276 | if (BLOCK_SIZE != write(DEV, super_block_buffer, BLOCK_SIZE)) | 266 | if (BLOCK_SIZE != write(DEV, super_block_buffer, BLOCK_SIZE)) |
277 | die(_("unable to write super-block")); | 267 | die("unable to write super-block"); |
278 | if (IMAPS*BLOCK_SIZE != write(DEV,inode_map,IMAPS*BLOCK_SIZE)) | 268 | if (IMAPS*BLOCK_SIZE != write(DEV,inode_map,IMAPS*BLOCK_SIZE)) |
279 | die(_("unable to write inode map")); | 269 | die("unable to write inode map"); |
280 | if (ZMAPS*BLOCK_SIZE != write(DEV,zone_map,ZMAPS*BLOCK_SIZE)) | 270 | if (ZMAPS*BLOCK_SIZE != write(DEV,zone_map,ZMAPS*BLOCK_SIZE)) |
281 | die(_("unable to write zone map")); | 271 | die("unable to write zone map"); |
282 | if (INODE_BUFFER_SIZE != write(DEV,inode_buffer,INODE_BUFFER_SIZE)) | 272 | if (INODE_BUFFER_SIZE != write(DEV,inode_buffer,INODE_BUFFER_SIZE)) |
283 | die(_("unable to write inodes")); | 273 | die("unable to write inodes"); |
284 | 274 | ||
285 | } | 275 | } |
286 | 276 | ||
287 | void write_block(int blk, char * buffer) | 277 | static void write_block(int blk, char * buffer) |
288 | { | 278 | { |
289 | if (blk*BLOCK_SIZE != lseek(DEV, blk*BLOCK_SIZE, SEEK_SET)) | 279 | if (blk*BLOCK_SIZE != lseek(DEV, blk*BLOCK_SIZE, SEEK_SET)) |
290 | die(_("seek failed in write_block")); | 280 | die("seek failed in write_block"); |
291 | if (BLOCK_SIZE != write(DEV, buffer, BLOCK_SIZE)) | 281 | if (BLOCK_SIZE != write(DEV, buffer, BLOCK_SIZE)) |
292 | die(_("write failed in write_block")); | 282 | die("write failed in write_block"); |
293 | } | 283 | } |
294 | 284 | ||
295 | int get_free_block(void) | 285 | static int get_free_block(void) |
296 | { | 286 | { |
297 | int blk; | 287 | int blk; |
298 | 288 | ||
299 | if (used_good_blocks+1 >= MAX_GOOD_BLOCKS) | 289 | if (used_good_blocks+1 >= MAX_GOOD_BLOCKS) |
300 | die(_("too many bad blocks")); | 290 | die("too many bad blocks"); |
301 | if (used_good_blocks) | 291 | if (used_good_blocks) |
302 | blk = good_blocks_table[used_good_blocks-1]+1; | 292 | blk = good_blocks_table[used_good_blocks-1]+1; |
303 | else | 293 | else |
@@ -305,13 +295,13 @@ int get_free_block(void) | |||
305 | while (blk < ZONES && zone_in_use(blk)) | 295 | while (blk < ZONES && zone_in_use(blk)) |
306 | blk++; | 296 | blk++; |
307 | if (blk >= ZONES) | 297 | if (blk >= ZONES) |
308 | die(_("not enough good blocks")); | 298 | die("not enough good blocks"); |
309 | good_blocks_table[used_good_blocks] = blk; | 299 | good_blocks_table[used_good_blocks] = blk; |
310 | used_good_blocks++; | 300 | used_good_blocks++; |
311 | return blk; | 301 | return blk; |
312 | } | 302 | } |
313 | 303 | ||
314 | void mark_good_blocks(void) | 304 | static void mark_good_blocks(void) |
315 | { | 305 | { |
316 | int blk; | 306 | int blk; |
317 | 307 | ||
@@ -329,7 +319,7 @@ inline int next(int zone) | |||
329 | return 0; | 319 | return 0; |
330 | } | 320 | } |
331 | 321 | ||
332 | void make_bad_inode(void) | 322 | static void make_bad_inode(void) |
333 | { | 323 | { |
334 | struct minix_inode * inode = &Inode[MINIX_BAD_INO]; | 324 | struct minix_inode * inode = &Inode[MINIX_BAD_INO]; |
335 | int i,j,zone; | 325 | int i,j,zone; |
@@ -371,7 +361,7 @@ void make_bad_inode(void) | |||
371 | goto end_bad; | 361 | goto end_bad; |
372 | } | 362 | } |
373 | } | 363 | } |
374 | die(_("too many bad blocks")); | 364 | die("too many bad blocks"); |
375 | end_bad: | 365 | end_bad: |
376 | if (ind) | 366 | if (ind) |
377 | write_block(ind, (char *) ind_block); | 367 | write_block(ind, (char *) ind_block); |
@@ -380,7 +370,7 @@ end_bad: | |||
380 | } | 370 | } |
381 | 371 | ||
382 | #ifdef HAVE_MINIX2 | 372 | #ifdef HAVE_MINIX2 |
383 | void | 373 | static void |
384 | make_bad_inode2 (void) | 374 | make_bad_inode2 (void) |
385 | { | 375 | { |
386 | struct minix2_inode *inode = &Inode2[MINIX_BAD_INO]; | 376 | struct minix2_inode *inode = &Inode2[MINIX_BAD_INO]; |
@@ -422,7 +412,7 @@ make_bad_inode2 (void) | |||
422 | } | 412 | } |
423 | } | 413 | } |
424 | /* Could make triple indirect block here */ | 414 | /* Could make triple indirect block here */ |
425 | die (_("too many bad blocks")); | 415 | die ("too many bad blocks"); |
426 | end_bad: | 416 | end_bad: |
427 | if (ind) | 417 | if (ind) |
428 | write_block (ind, (char *) ind_block); | 418 | write_block (ind, (char *) ind_block); |
@@ -431,7 +421,7 @@ make_bad_inode2 (void) | |||
431 | } | 421 | } |
432 | #endif | 422 | #endif |
433 | 423 | ||
434 | void make_root_inode(void) | 424 | static void make_root_inode(void) |
435 | { | 425 | { |
436 | struct minix_inode * inode = &Inode[MINIX_ROOT_INO]; | 426 | struct minix_inode * inode = &Inode[MINIX_ROOT_INO]; |
437 | 427 | ||
@@ -454,7 +444,7 @@ void make_root_inode(void) | |||
454 | } | 444 | } |
455 | 445 | ||
456 | #ifdef HAVE_MINIX2 | 446 | #ifdef HAVE_MINIX2 |
457 | void | 447 | static void |
458 | make_root_inode2 (void) | 448 | make_root_inode2 (void) |
459 | { | 449 | { |
460 | struct minix2_inode *inode = &Inode2[MINIX_ROOT_INO]; | 450 | struct minix2_inode *inode = &Inode2[MINIX_ROOT_INO]; |
@@ -478,7 +468,7 @@ make_root_inode2 (void) | |||
478 | } | 468 | } |
479 | #endif | 469 | #endif |
480 | 470 | ||
481 | void setup_tables(void) | 471 | static void setup_tables(void) |
482 | { | 472 | { |
483 | int i; | 473 | int i; |
484 | unsigned long inodes; | 474 | unsigned long inodes; |
@@ -526,7 +516,7 @@ void setup_tables(void) | |||
526 | inode_map = malloc(IMAPS * BLOCK_SIZE); | 516 | inode_map = malloc(IMAPS * BLOCK_SIZE); |
527 | zone_map = malloc(ZMAPS * BLOCK_SIZE); | 517 | zone_map = malloc(ZMAPS * BLOCK_SIZE); |
528 | if (!inode_map || !zone_map) | 518 | if (!inode_map || !zone_map) |
529 | die(_("unable to allocate buffers for maps")); | 519 | die("unable to allocate buffers for maps"); |
530 | memset(inode_map,0xff,IMAPS * BLOCK_SIZE); | 520 | memset(inode_map,0xff,IMAPS * BLOCK_SIZE); |
531 | memset(zone_map,0xff,ZMAPS * BLOCK_SIZE); | 521 | memset(zone_map,0xff,ZMAPS * BLOCK_SIZE); |
532 | for (i = FIRSTZONE ; i<ZONES ; i++) | 522 | for (i = FIRSTZONE ; i<ZONES ; i++) |
@@ -535,13 +525,13 @@ void setup_tables(void) | |||
535 | unmark_inode(i); | 525 | unmark_inode(i); |
536 | inode_buffer = malloc(INODE_BUFFER_SIZE); | 526 | inode_buffer = malloc(INODE_BUFFER_SIZE); |
537 | if (!inode_buffer) | 527 | if (!inode_buffer) |
538 | die(_("unable to allocate buffer for inodes")); | 528 | die("unable to allocate buffer for inodes"); |
539 | memset(inode_buffer,0,INODE_BUFFER_SIZE); | 529 | memset(inode_buffer,0,INODE_BUFFER_SIZE); |
540 | printf(_("%ld inodes\n"),INODES); | 530 | printf("%ld inodes\n",INODES); |
541 | printf(_("%ld blocks\n"),ZONES); | 531 | printf("%ld blocks\n",ZONES); |
542 | printf(_("Firstdatazone=%ld (%ld)\n"),FIRSTZONE,NORM_FIRSTZONE); | 532 | printf("Firstdatazone=%ld (%ld)\n",FIRSTZONE,NORM_FIRSTZONE); |
543 | printf(_("Zonesize=%d\n"),BLOCK_SIZE<<ZONESIZE); | 533 | printf("Zonesize=%d\n",BLOCK_SIZE<<ZONESIZE); |
544 | printf(_("Maxsize=%ld\n\n"),MAXSIZE); | 534 | printf("Maxsize=%ld\n\n",MAXSIZE); |
545 | } | 535 | } |
546 | 536 | ||
547 | /* | 537 | /* |
@@ -555,7 +545,7 @@ long do_check(char * buffer, int try, unsigned int current_block) | |||
555 | /* Seek to the correct loc. */ | 545 | /* Seek to the correct loc. */ |
556 | if (lseek(DEV, current_block * BLOCK_SIZE, SEEK_SET) != | 546 | if (lseek(DEV, current_block * BLOCK_SIZE, SEEK_SET) != |
557 | current_block * BLOCK_SIZE ) { | 547 | current_block * BLOCK_SIZE ) { |
558 | die(_("seek failed during testing of blocks")); | 548 | die("seek failed during testing of blocks"); |
559 | } | 549 | } |
560 | 550 | ||
561 | 551 | ||
@@ -563,7 +553,7 @@ long do_check(char * buffer, int try, unsigned int current_block) | |||
563 | got = read(DEV, buffer, try * BLOCK_SIZE); | 553 | got = read(DEV, buffer, try * BLOCK_SIZE); |
564 | if (got < 0) got = 0; | 554 | if (got < 0) got = 0; |
565 | if (got & (BLOCK_SIZE - 1 )) { | 555 | if (got & (BLOCK_SIZE - 1 )) { |
566 | printf(_("Weird values in do_check: probably bugs\n")); | 556 | printf("Weird values in do_check: probably bugs\n"); |
567 | } | 557 | } |
568 | got /= BLOCK_SIZE; | 558 | got /= BLOCK_SIZE; |
569 | return got; | 559 | return got; |
@@ -571,7 +561,7 @@ long do_check(char * buffer, int try, unsigned int current_block) | |||
571 | 561 | ||
572 | static unsigned int currently_testing = 0; | 562 | static unsigned int currently_testing = 0; |
573 | 563 | ||
574 | void alarm_intr(int alnum) | 564 | static void alarm_intr(int alnum) |
575 | { | 565 | { |
576 | if (currently_testing >= ZONES) | 566 | if (currently_testing >= ZONES) |
577 | return; | 567 | return; |
@@ -583,7 +573,7 @@ void alarm_intr(int alnum) | |||
583 | fflush(stdout); | 573 | fflush(stdout); |
584 | } | 574 | } |
585 | 575 | ||
586 | void check_blocks(void) | 576 | static void check_blocks(void) |
587 | { | 577 | { |
588 | int try,got; | 578 | int try,got; |
589 | static char buffer[BLOCK_SIZE * TEST_BUFFER_BLOCKS]; | 579 | static char buffer[BLOCK_SIZE * TEST_BUFFER_BLOCKS]; |
@@ -594,7 +584,7 @@ void check_blocks(void) | |||
594 | while (currently_testing < ZONES) { | 584 | while (currently_testing < ZONES) { |
595 | if (lseek(DEV,currently_testing*BLOCK_SIZE,SEEK_SET) != | 585 | if (lseek(DEV,currently_testing*BLOCK_SIZE,SEEK_SET) != |
596 | currently_testing*BLOCK_SIZE) | 586 | currently_testing*BLOCK_SIZE) |
597 | die(_("seek failed in check_blocks")); | 587 | die("seek failed in check_blocks"); |
598 | try = TEST_BUFFER_BLOCKS; | 588 | try = TEST_BUFFER_BLOCKS; |
599 | if (currently_testing + try > ZONES) | 589 | if (currently_testing + try > ZONES) |
600 | try = ZONES-currently_testing; | 590 | try = ZONES-currently_testing; |
@@ -603,18 +593,18 @@ void check_blocks(void) | |||
603 | if (got == try) | 593 | if (got == try) |
604 | continue; | 594 | continue; |
605 | if (currently_testing < FIRSTZONE) | 595 | if (currently_testing < FIRSTZONE) |
606 | die(_("bad blocks before data-area: cannot make fs")); | 596 | die("bad blocks before data-area: cannot make fs"); |
607 | mark_zone(currently_testing); | 597 | mark_zone(currently_testing); |
608 | badblocks++; | 598 | badblocks++; |
609 | currently_testing++; | 599 | currently_testing++; |
610 | } | 600 | } |
611 | if (badblocks > 1) | 601 | if (badblocks > 1) |
612 | printf(_("%d bad blocks\n"), badblocks); | 602 | printf("%d bad blocks\n", badblocks); |
613 | else if (badblocks == 1) | 603 | else if (badblocks == 1) |
614 | printf(_("one bad block\n")); | 604 | printf("one bad block\n"); |
615 | } | 605 | } |
616 | 606 | ||
617 | void get_list_blocks(filename) | 607 | static void get_list_blocks(filename) |
618 | char *filename; | 608 | char *filename; |
619 | 609 | ||
620 | { | 610 | { |
@@ -623,7 +613,7 @@ char *filename; | |||
623 | 613 | ||
624 | listfile=fopen(filename,"r"); | 614 | listfile=fopen(filename,"r"); |
625 | if(listfile == (FILE *)NULL) { | 615 | if(listfile == (FILE *)NULL) { |
626 | die(_("can't open file of bad blocks")); | 616 | die("can't open file of bad blocks"); |
627 | } | 617 | } |
628 | while(!feof(listfile)) { | 618 | while(!feof(listfile)) { |
629 | fscanf(listfile,"%ld\n", &blockno); | 619 | fscanf(listfile,"%ld\n", &blockno); |
@@ -631,9 +621,9 @@ char *filename; | |||
631 | badblocks++; | 621 | badblocks++; |
632 | } | 622 | } |
633 | if(badblocks > 1) | 623 | if(badblocks > 1) |
634 | printf(_("%d bad blocks\n"), badblocks); | 624 | printf("%d bad blocks\n", badblocks); |
635 | else if (badblocks == 1) | 625 | else if (badblocks == 1) |
636 | printf(_("one bad block\n")); | 626 | printf("one bad block\n"); |
637 | } | 627 | } |
638 | 628 | ||
639 | extern int | 629 | extern int |
@@ -647,10 +637,10 @@ mkfs_minix_main(int argc, char ** argv) | |||
647 | if (argc && *argv) | 637 | if (argc && *argv) |
648 | program_name = *argv; | 638 | program_name = *argv; |
649 | if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE) | 639 | if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE) |
650 | die(_("bad inode size")); | 640 | die("bad inode size"); |
651 | #ifdef HAVE_MINIX2 | 641 | #ifdef HAVE_MINIX2 |
652 | if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) | 642 | if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) |
653 | die(_("bad inode size")); | 643 | die("bad inode size"); |
654 | #endif | 644 | #endif |
655 | opterr = 0; | 645 | opterr = 0; |
656 | while ((i = getopt(argc, argv, "ci:l:n:v")) != EOF) | 646 | while ((i = getopt(argc, argv, "ci:l:n:v")) != EOF) |
@@ -665,13 +655,13 @@ mkfs_minix_main(int argc, char ** argv) | |||
665 | case 'n': | 655 | case 'n': |
666 | i = strtoul(optarg,&tmp,0); | 656 | i = strtoul(optarg,&tmp,0); |
667 | if (*tmp) | 657 | if (*tmp) |
668 | usage(); | 658 | show_usage(); |
669 | if (i == 14) | 659 | if (i == 14) |
670 | magic = MINIX_SUPER_MAGIC; | 660 | magic = MINIX_SUPER_MAGIC; |
671 | else if (i == 30) | 661 | else if (i == 30) |
672 | magic = MINIX_SUPER_MAGIC2; | 662 | magic = MINIX_SUPER_MAGIC2; |
673 | else | 663 | else |
674 | usage(); | 664 | show_usage(); |
675 | namelen = i; | 665 | namelen = i; |
676 | dirsize = i+2; | 666 | dirsize = i+2; |
677 | break; | 667 | break; |
@@ -679,11 +669,12 @@ mkfs_minix_main(int argc, char ** argv) | |||
679 | #ifdef HAVE_MINIX2 | 669 | #ifdef HAVE_MINIX2 |
680 | version2 = 1; | 670 | version2 = 1; |
681 | #else | 671 | #else |
682 | fatal_error(_("%s: not compiled with minix v2 support\n"),-1); | 672 | fprintf(stderr,"%s: not compiled with minix v2 support\n",program_name,device_name); |
673 | exit(-1); | ||
683 | #endif | 674 | #endif |
684 | break; | 675 | break; |
685 | default: | 676 | default: |
686 | usage(); | 677 | show_usage(); |
687 | } | 678 | } |
688 | argc -= optind; | 679 | argc -= optind; |
689 | argv += optind; | 680 | argv += optind; |
@@ -695,15 +686,15 @@ mkfs_minix_main(int argc, char ** argv) | |||
695 | if (argc > 0) { | 686 | if (argc > 0) { |
696 | BLOCKS = strtol(argv[0],&tmp,0); | 687 | BLOCKS = strtol(argv[0],&tmp,0); |
697 | if (*tmp) { | 688 | if (*tmp) { |
698 | printf(_("strtol error: number of blocks not specified")); | 689 | printf("strtol error: number of blocks not specified"); |
699 | usage(); | 690 | show_usage(); |
700 | } | 691 | } |
701 | } | 692 | } |
702 | 693 | ||
703 | if (device_name && !BLOCKS) | 694 | if (device_name && !BLOCKS) |
704 | BLOCKS = get_size (device_name) / 1024; | 695 | BLOCKS = get_size (device_name) / 1024; |
705 | if (!device_name || BLOCKS<10) { | 696 | if (!device_name || BLOCKS<10) { |
706 | usage(); | 697 | show_usage(); |
707 | } | 698 | } |
708 | #ifdef HAVE_MINIX2 | 699 | #ifdef HAVE_MINIX2 |
709 | if (version2) { | 700 | if (version2) { |
@@ -727,13 +718,13 @@ mkfs_minix_main(int argc, char ** argv) | |||
727 | strcpy(tmp+2,".badblocks"); | 718 | strcpy(tmp+2,".badblocks"); |
728 | DEV = open(device_name,O_RDWR ); | 719 | DEV = open(device_name,O_RDWR ); |
729 | if (DEV<0) | 720 | if (DEV<0) |
730 | die(_("unable to open %s")); | 721 | die("unable to open %s"); |
731 | if (fstat(DEV,&statbuf)<0) | 722 | if (fstat(DEV,&statbuf)<0) |
732 | die(_("unable to stat %s")); | 723 | die("unable to stat %s"); |
733 | if (!S_ISBLK(statbuf.st_mode)) | 724 | if (!S_ISBLK(statbuf.st_mode)) |
734 | check=0; | 725 | check=0; |
735 | else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340) | 726 | else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340) |
736 | die(_("will not try to make filesystem on '%s'")); | 727 | die("will not try to make filesystem on '%s'"); |
737 | setup_tables(); | 728 | setup_tables(); |
738 | if (check) | 729 | if (check) |
739 | check_blocks(); | 730 | check_blocks(); |
@@ -643,4 +643,6 @@ extern int parse_mode( const char* s, mode_t* theMode) | |||
643 | } | 643 | } |
644 | #endif | 644 | #endif |
645 | 645 | ||
646 | |||
647 | |||
646 | /* END CODE */ | 648 | /* END CODE */ |