Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/util-linux/fsck_minix.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/util-linux/fsck_minix.c
r821 r1770 3 3 * fsck.c - a file system consistency checker for Linux. 4 4 * 5 * (C) 1991, 1992 Linus Torvalds. This file may be redistributed 6 * as per the GNU copyleft. 5 * (C) 1991, 1992 Linus Torvalds. 6 * 7 * Licensed under GPLv2, see file LICENSE in this tarball for details. 7 8 */ 8 9 … … 87 88 */ 88 89 89 #include <stdio.h>90 #include <errno.h>91 #include <unistd.h>92 #include <string.h>93 #include <fcntl.h>94 #include <ctype.h>95 #include <stdlib.h>96 #include <termios.h>97 90 #include <mntent.h> 98 #include <sys/param.h> 99 #include "busybox.h" 100 101 /* 102 * This is the original minix inode layout on disk. 103 * Note the 8-bit gid and atime and ctime. 104 */ 105 struct minix_inode { 106 uint16_t i_mode; 107 uint16_t i_uid; 108 uint32_t i_size; 109 uint32_t i_time; 110 uint8_t i_gid; 111 uint8_t i_nlinks; 112 uint16_t i_zone[9]; 113 }; 114 115 /* 116 * The new minix inode has all the time entries, as well as 117 * long block numbers and a third indirect block (7+1+1+1 118 * instead of 7+1+1). Also, some previously 8-bit values are 119 * now 16-bit. The inode is now 64 bytes instead of 32. 120 */ 121 struct minix2_inode { 122 uint16_t i_mode; 123 uint16_t i_nlinks; 124 uint16_t i_uid; 125 uint16_t i_gid; 126 uint32_t i_size; 127 uint32_t i_atime; 128 uint32_t i_mtime; 129 uint32_t i_ctime; 130 uint32_t i_zone[10]; 131 }; 91 #include "libbb.h" 92 #include "minix.h" 93 94 #ifndef BLKGETSIZE 95 #define BLKGETSIZE _IO(0x12,96) /* return device size */ 96 #endif 132 97 133 98 enum { 134 MINIX_ROOT_INO = 1, 135 MINIX _LINK_MAX = 250,99 #ifdef UNUSED 100 MINIX1_LINK_MAX = 250, 136 101 MINIX2_LINK_MAX = 65530, 137 138 102 MINIX_I_MAP_SLOTS = 8, 139 103 MINIX_Z_MAP_SLOTS = 64, 140 MINIX_SUPER_MAGIC = 0x137F, /* original minix fs */ 141 MINIX_SUPER_MAGIC2 = 0x138F, /* minix fs, 30 char names */ 142 MINIX2_SUPER_MAGIC = 0x2468, /* minix V2 fs */ 143 MINIX2_SUPER_MAGIC2 = 0x2478, /* minix V2 fs, 30 char names */ 144 MINIX_VALID_FS = 0x0001, /* Clean fs. */ 145 MINIX_ERROR_FS = 0x0002, /* fs has errors. */ 146 147 MINIX_INODES_PER_BLOCK = ((BLOCK_SIZE)/(sizeof (struct minix_inode))), 148 MINIX2_INODES_PER_BLOCK = ((BLOCK_SIZE)/(sizeof (struct minix2_inode))), 149 150 MINIX_V1 = 0x0001, /* original minix fs */ 151 MINIX_V2 = 0x0002 /* minix V2 fs */ 104 MINIX_V1 = 0x0001, /* original minix fs */ 105 MINIX_V2 = 0x0002, /* minix V2 fs */ 106 #endif 107 MINIX_NAME_MAX = 255, /* # chars in a file name */ 152 108 }; 153 109 154 #define INODE_VERSION(inode) inode->i_sb->u.minix_sb.s_version 155 156 /* 157 * minix super-block data on disk 158 */ 159 struct minix_super_block { 160 uint16_t s_ninodes; 161 uint16_t s_nzones; 162 uint16_t s_imap_blocks; 163 uint16_t s_zmap_blocks; 164 uint16_t s_firstdatazone; 165 uint16_t s_log_zone_size; 166 uint32_t s_max_size; 167 uint16_t s_magic; 168 uint16_t s_state; 169 uint32_t s_zones; 110 #if !ENABLE_FEATURE_MINIX2 111 enum { version2 = 0 }; 112 #endif 113 114 enum { MAX_DEPTH = 32 }; 115 116 struct globals { 117 int dev_fd; 118 #if ENABLE_FEATURE_MINIX2 119 smallint version2; 120 #endif 121 smallint repair, automatic, verbose, list, show, warn_mode, force; 122 smallint changed; /* is filesystem modified? */ 123 smallint errors_uncorrected; /* flag if some error was not corrected */ 124 smallint termios_set; 125 smallint dirsize; 126 smallint namelen; 127 char *device_name; 128 int directory, regular, blockdev, chardev, links, symlinks, total; 129 char *inode_buffer; 130 131 char *inode_map; 132 char *zone_map; 133 134 unsigned char *inode_count; 135 unsigned char *zone_count; 136 137 /* File-name data */ 138 int name_depth; 139 char *name_component[MAX_DEPTH+1]; 140 141 /* Bigger stuff */ 142 struct termios sv_termios; 143 char super_block_buffer[BLOCK_SIZE]; 144 char add_zone_ind_blk[BLOCK_SIZE]; 145 char add_zone_dind_blk[BLOCK_SIZE]; 146 USE_FEATURE_MINIX2(char add_zone_tind_blk[BLOCK_SIZE];) 147 char check_file_blk[BLOCK_SIZE]; 148 149 /* File-name data */ 150 char current_name[MAX_DEPTH * MINIX_NAME_MAX]; 170 151 }; 171 152 172 struct minix_dir_entry { 173 uint16_t inode; 174 char name[0]; 175 }; 176 177 178 #define NAME_MAX 255 /* # chars in a file name */ 179 180 #define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode))) 181 182 #ifndef BLKGETSIZE 183 #define BLKGETSIZE _IO(0x12,96) /* return device size */ 184 #endif 185 186 #ifndef __linux__ 187 #define volatile 188 #endif 189 190 enum { ROOT_INO = 1 }; 191 192 #define UPPER(size,n) ((size+((n)-1))/(n)) 193 #define INODE_SIZE (sizeof(struct minix_inode)) 194 #ifdef CONFIG_FEATURE_MINIX2 195 #define INODE_SIZE2 (sizeof(struct minix2_inode)) 196 #define INODE_BLOCKS UPPER(INODES, (version2 ? MINIX2_INODES_PER_BLOCK \ 197 : MINIX_INODES_PER_BLOCK)) 153 #define G (*ptr_to_globals) 154 #define dev_fd (G.dev_fd ) 155 #if ENABLE_FEATURE_MINIX2 156 #define version2 (G.version2 ) 157 #endif 158 #define repair (G.repair ) 159 #define automatic (G.automatic ) 160 #define verbose (G.verbose ) 161 #define list (G.list ) 162 #define show (G.show ) 163 #define warn_mode (G.warn_mode ) 164 #define force (G.force ) 165 #define changed (G.changed ) 166 #define errors_uncorrected (G.errors_uncorrected ) 167 #define termios_set (G.termios_set ) 168 #define dirsize (G.dirsize ) 169 #define namelen (G.namelen ) 170 #define device_name (G.device_name ) 171 #define directory (G.directory ) 172 #define regular (G.regular ) 173 #define blockdev (G.blockdev ) 174 #define chardev (G.chardev ) 175 #define links (G.links ) 176 #define symlinks (G.symlinks ) 177 #define total (G.total ) 178 #define inode_buffer (G.inode_buffer ) 179 #define inode_map (G.inode_map ) 180 #define zone_map (G.zone_map ) 181 #define inode_count (G.inode_count ) 182 #define zone_count (G.zone_count ) 183 #define name_depth (G.name_depth ) 184 #define name_component (G.name_component ) 185 #define sv_termios (G.sv_termios ) 186 #define super_block_buffer (G.super_block_buffer ) 187 #define add_zone_ind_blk (G.add_zone_ind_blk ) 188 #define add_zone_dind_blk (G.add_zone_dind_blk ) 189 #define add_zone_tind_blk (G.add_zone_tind_blk ) 190 #define check_file_blk (G.check_file_blk ) 191 #define current_name (G.current_name ) 192 #define INIT_G() do { \ 193 PTR_TO_GLOBALS = xzalloc(sizeof(G)); \ 194 dirsize = 16; \ 195 namelen = 14; \ 196 current_name[0] = '/'; \ 197 /*current_name[1] = '\0';*/ \ 198 name_component[0] = ¤t_name[0]; \ 199 } while (0) 200 201 #define Inode1 (((struct minix1_inode *) inode_buffer)-1) 202 #define Inode2 (((struct minix2_inode *) inode_buffer)-1) 203 204 #define Super (*(struct minix_super_block *)(super_block_buffer)) 205 206 #if ENABLE_FEATURE_MINIX2 207 # define ZONES ((unsigned)(version2 ? Super.s_zones : Super.s_nzones)) 198 208 #else 199 #define INODE_BLOCKS UPPER(INODES, (MINIX_INODES_PER_BLOCK)) 200 #endif 209 # define ZONES ((unsigned)(Super.s_nzones)) 210 #endif 211 #define INODES ((unsigned)Super.s_ninodes) 212 #define IMAPS ((unsigned)Super.s_imap_blocks) 213 #define ZMAPS ((unsigned)Super.s_zmap_blocks) 214 #define FIRSTZONE ((unsigned)Super.s_firstdatazone) 215 #define ZONESIZE ((unsigned)Super.s_log_zone_size) 216 #define MAXSIZE ((unsigned)Super.s_max_size) 217 #define MAGIC (Super.s_magic) 218 219 /* gcc likes this more (code is smaller) than macro variant */ 220 static ALWAYS_INLINE unsigned div_roundup(unsigned size, unsigned n) 221 { 222 return (size + n-1) / n; 223 } 224 225 #if ENABLE_FEATURE_MINIX2 226 #define INODE_BLOCKS div_roundup(INODES, (version2 ? MINIX2_INODES_PER_BLOCK \ 227 : MINIX1_INODES_PER_BLOCK)) 228 #else 229 #define INODE_BLOCKS div_roundup(INODES, MINIX1_INODES_PER_BLOCK) 230 #endif 231 201 232 #define INODE_BUFFER_SIZE (INODE_BLOCKS * BLOCK_SIZE) 202 203 #define BITS_PER_BLOCK (BLOCK_SIZE<<3) 204 205 static char *program_version = "1.2 - 11/11/96"; 206 static char *device_name; 207 static int IN; 208 static int repair, automatic, verbose, list, show, warn_mode, force; 209 static int directory, regular, blockdev, chardev, links, symlinks, total; 210 211 static int changed; /* flags if the filesystem has been changed */ 212 static int errors_uncorrected; /* flag if some error was not corrected */ 213 static int dirsize = 16; 214 static int namelen = 14; 215 static struct termios termios; 216 static int termios_set; 217 218 static char *inode_buffer; 219 #define Inode (((struct minix_inode *) inode_buffer)-1) 220 #define Inode2 (((struct minix2_inode *) inode_buffer)-1) 221 static char super_block_buffer[BLOCK_SIZE]; 222 223 #define Super (*(struct minix_super_block *)super_block_buffer) 224 #define INODES ((unsigned long)Super.s_ninodes) 225 #ifdef CONFIG_FEATURE_MINIX2 226 static int version2; 227 #define ZONES ((unsigned long)(version2 ? Super.s_zones : Super.s_nzones)) 228 #else 229 #define ZONES ((unsigned long)(Super.s_nzones)) 230 #endif 231 #define IMAPS ((unsigned long)Super.s_imap_blocks) 232 #define ZMAPS ((unsigned long)Super.s_zmap_blocks) 233 #define FIRSTZONE ((unsigned long)Super.s_firstdatazone) 234 #define ZONESIZE ((unsigned long)Super.s_log_zone_size) 235 #define MAXSIZE ((unsigned long)Super.s_max_size) 236 #define MAGIC (Super.s_magic) 237 #define NORM_FIRSTZONE (2+IMAPS+ZMAPS+INODE_BLOCKS) 238 239 static char *inode_map; 240 static char *zone_map; 241 242 static unsigned char *inode_count; 243 static unsigned char *zone_count; 244 245 static void recursive_check(unsigned int ino); 246 #ifdef CONFIG_FEATURE_MINIX2 247 static void recursive_check2(unsigned int ino); 248 #endif 249 250 static inline int bit(char *a, unsigned int i) 251 { 252 return (a[i >> 3] & (1<<(i & 7))) != 0; 253 } 254 #define inode_in_use(x) (bit(inode_map,(x))) 255 #define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1)) 256 257 #define mark_inode(x) (setbit(inode_map,(x)),changed=1) 258 #define unmark_inode(x) (clrbit(inode_map,(x)),changed=1) 259 260 #define mark_zone(x) (setbit(zone_map,(x)-FIRSTZONE+1),changed=1) 261 #define unmark_zone(x) (clrbit(zone_map,(x)-FIRSTZONE+1),changed=1) 262 263 static void leave(int) ATTRIBUTE_NORETURN; 264 static void leave(int status) 233 #define NORM_FIRSTZONE (2 + IMAPS + ZMAPS + INODE_BLOCKS) 234 235 /* Before you ask "where they come from?": */ 236 /* setbit/clrbit are supplied by sys/param.h */ 237 238 static int minix_bit(const char *a, unsigned i) 239 { 240 return (a[i >> 3] & (1<<(i & 7))); 241 } 242 243 static void minix_setbit(char *a, unsigned i) 244 { 245 setbit(a, i); 246 changed = 1; 247 } 248 static void minix_clrbit(char *a, unsigned i) 249 { 250 clrbit(a, i); 251 changed = 1; 252 } 253 254 /* Note: do not assume 0/1, it is 0/nonzero */ 255 #define zone_in_use(x) (minix_bit(zone_map,(x)-FIRSTZONE+1)) 256 #define inode_in_use(x) (minix_bit(inode_map,(x))) 257 258 #define mark_inode(x) (minix_setbit(inode_map,(x))) 259 #define unmark_inode(x) (minix_clrbit(inode_map,(x))) 260 261 #define mark_zone(x) (minix_setbit(zone_map,(x)-FIRSTZONE+1)) 262 #define unmark_zone(x) (minix_clrbit(zone_map,(x)-FIRSTZONE+1)) 263 264 265 static void recursive_check(unsigned ino); 266 #if ENABLE_FEATURE_MINIX2 267 static void recursive_check2(unsigned ino); 268 #endif 269 270 static void die(const char *str) ATTRIBUTE_NORETURN; 271 static void die(const char *str) 265 272 { 266 273 if (termios_set) 267 tcsetattr(0, TCSANOW, &termios); 268 exit(status); 269 } 270 271 static void die(const char *str) 272 { 273 bb_error_msg("%s", str); 274 leave(8); 275 } 276 277 /* File-name data */ 278 enum { MAX_DEPTH = 32 }; 279 static int name_depth; 280 static char *current_name; 281 static char *name_component[MAX_DEPTH+1]; 282 283 /* Wed Feb 9 15:17:06 MST 2000 */ 284 /* dynamically allocate name_list (instead of making it static) */ 285 static inline void alloc_current_name(void) 286 { 287 current_name = xmalloc(MAX_DEPTH * (BUFSIZ + 1)); 288 current_name[0] = '/'; 289 current_name[1] = '\0'; 290 name_component[0] = ¤t_name[0]; 291 } 292 293 #ifdef CONFIG_FEATURE_CLEAN_UP 294 /* execute this atexit() to deallocate name_list[] */ 295 /* piptigger was here */ 296 static inline void free_current_name(void) 297 { 298 free(current_name); 299 } 300 #endif 274 tcsetattr(0, TCSANOW, &sv_termios); 275 bb_error_msg_and_die("%s", str); 276 } 301 277 302 278 static void push_filename(const char *name) … … 315 291 } 316 292 317 static void pop_filename(void) { 293 static void pop_filename(void) 294 { 318 295 name_depth--; 319 296 if (name_depth < MAX_DEPTH) { … … 331 308 332 309 if (!repair) { 333 p rintf("\n");310 puts(""); 334 311 errors_uncorrected = 1; 335 312 return 0; 336 313 } 337 314 if (automatic) { 338 p rintf("\n");315 puts(""); 339 316 if (!def) 340 317 errors_uncorrected = 1; … … 344 321 for (;;) { 345 322 fflush(stdout); 346 if ((c = getchar()) == EOF) { 323 c = getchar(); 324 if (c == EOF) { 347 325 if (!def) 348 326 errors_uncorrected = 1; … … 380 358 int fd; 381 359 382 if ((f = setmntent(MOUNTED, "r")) == NULL) 360 f = setmntent(MOUNTED, "r"); 361 if (f == NULL) 383 362 return; 384 363 while ((mnt = getmntent(f)) != NULL) … … 397 376 if (fd < 0 && errno == EROFS) 398 377 return; 399 else 400 close(fd); 378 close(fd); 401 379 402 380 printf("%s is mounted. ", device_name); … … 408 386 exit(0); 409 387 } 410 return;411 388 } 412 389 … … 417 394 * or a bad zone-number). 418 395 */ 419 static int check_zone_nr2(uint32_t *nr, int *corrected)396 static int check_zone_nr2(uint32_t *nr, smallint *corrected) 420 397 { 421 398 const char *msg; … … 436 413 } 437 414 438 static int check_zone_nr(uint16_t *nr, int *corrected)415 static int check_zone_nr(uint16_t *nr, smallint *corrected) 439 416 { 440 417 uint32_t nr32 = *nr; … … 447 424 * read-block reads block nr into the buffer at addr. 448 425 */ 449 static void read_block(unsigned intnr, char *addr)426 static void read_block(unsigned nr, char *addr) 450 427 { 451 428 if (!nr) { … … 453 430 return; 454 431 } 455 if (BLOCK_SIZE * nr != lseek( IN, BLOCK_SIZE * nr, SEEK_SET)) {456 printf("%s: unable toseek to block in file '%s'\n",432 if (BLOCK_SIZE * nr != lseek(dev_fd, BLOCK_SIZE * nr, SEEK_SET)) { 433 printf("%s: cannot seek to block in file '%s'\n", 457 434 bb_msg_read_error, current_name); 458 435 errors_uncorrected = 1; 459 436 memset(addr, 0, BLOCK_SIZE); 460 } else if (BLOCK_SIZE != read( IN, addr, BLOCK_SIZE)) {437 } else if (BLOCK_SIZE != read(dev_fd, addr, BLOCK_SIZE)) { 461 438 printf("%s: bad block in file '%s'\n", 462 439 bb_msg_read_error, current_name); … … 469 446 * write_block writes block nr to disk. 470 447 */ 471 static void write_block(unsigned intnr, char *addr)448 static void write_block(unsigned nr, char *addr) 472 449 { 473 450 if (!nr) … … 479 456 return; 480 457 } 481 if (BLOCK_SIZE * nr != lseek( IN, BLOCK_SIZE * nr, SEEK_SET))482 die(" Seek failed in write_block");483 if (BLOCK_SIZE != write( IN, addr, BLOCK_SIZE)) {458 if (BLOCK_SIZE * nr != lseek(dev_fd, BLOCK_SIZE * nr, SEEK_SET)) 459 die("seek failed in write_block"); 460 if (BLOCK_SIZE != write(dev_fd, addr, BLOCK_SIZE)) { 484 461 printf("%s: bad block in file '%s'\n", 485 462 bb_msg_write_error, current_name); … … 493 470 * any indirect blocks with errors. 494 471 */ 495 static int map_block(struct minix _inode *inode, unsigned intblknr)472 static int map_block(struct minix1_inode *inode, unsigned blknr) 496 473 { 497 474 uint16_t ind[BLOCK_SIZE >> 1]; 498 475 uint16_t dind[BLOCK_SIZE >> 1]; 499 int blk_chg, block, result; 476 int block, result; 477 smallint blk_chg; 500 478 501 479 if (blknr < 7) … … 527 505 } 528 506 529 #if def CONFIG_FEATURE_MINIX2530 static int map_block2(struct minix2_inode *inode, unsigned intblknr)507 #if ENABLE_FEATURE_MINIX2 508 static int map_block2(struct minix2_inode *inode, unsigned blknr) 531 509 { 532 510 uint32_t ind[BLOCK_SIZE >> 2]; 533 511 uint32_t dind[BLOCK_SIZE >> 2]; 534 512 uint32_t tind[BLOCK_SIZE >> 2]; 535 int blk_chg, block, result; 513 int block, result; 514 smallint blk_chg; 536 515 537 516 if (blknr < 7) … … 593 572 * unconditionally set if we get this far. 594 573 */ 595 Super.s_state |= MINIX_VALID_FS; 596 if (errors_uncorrected) 597 Super.s_state |= MINIX_ERROR_FS; 598 else 574 Super.s_state |= MINIX_VALID_FS | MINIX_ERROR_FS; 575 if (!errors_uncorrected) 599 576 Super.s_state &= ~MINIX_ERROR_FS; 600 577 601 if (BLOCK_SIZE != lseek( IN, BLOCK_SIZE, SEEK_SET))602 die(" Seek failed in write_super_block");603 if (BLOCK_SIZE != write( IN, super_block_buffer, BLOCK_SIZE))604 die(" Unable towrite super-block");578 if (BLOCK_SIZE != lseek(dev_fd, BLOCK_SIZE, SEEK_SET)) 579 die("seek failed in write_super_block"); 580 if (BLOCK_SIZE != write(dev_fd, super_block_buffer, BLOCK_SIZE)) 581 die("cannot write super-block"); 605 582 } 606 583 … … 609 586 write_super_block(); 610 587 611 if (IMAPS * BLOCK_SIZE != write( IN, inode_map, IMAPS * BLOCK_SIZE))612 die(" Unable towrite inode map");613 if (ZMAPS * BLOCK_SIZE != write( IN, zone_map, ZMAPS * BLOCK_SIZE))614 die(" Unable towrite zone map");615 if (INODE_BUFFER_SIZE != write( IN, inode_buffer, INODE_BUFFER_SIZE))616 die(" Unable towrite inodes");588 if (IMAPS * BLOCK_SIZE != write(dev_fd, inode_map, IMAPS * BLOCK_SIZE)) 589 die("cannot write inode map"); 590 if (ZMAPS * BLOCK_SIZE != write(dev_fd, zone_map, ZMAPS * BLOCK_SIZE)) 591 die("cannot write zone map"); 592 if (INODE_BUFFER_SIZE != write(dev_fd, inode_buffer, INODE_BUFFER_SIZE)) 593 die("cannot write inodes"); 617 594 } 618 595 … … 623 600 int size; 624 601 625 #if def CONFIG_FEATURE_MINIX2602 #if ENABLE_FEATURE_MINIX2 626 603 if (version2) 627 block = Inode2[ ROOT_INO].i_zone[0];604 block = Inode2[MINIX_ROOT_INO].i_zone[0]; 628 605 else 629 606 #endif 630 block = Inode [ROOT_INO].i_zone[0];607 block = Inode1[MINIX_ROOT_INO].i_zone[0]; 631 608 read_block(block, blk); 632 609 for (size = 16; size < BLOCK_SIZE; size <<= 1) { … … 642 619 static void read_superblock(void) 643 620 { 644 if (BLOCK_SIZE != lseek( IN, BLOCK_SIZE, SEEK_SET))645 die(" Seek failed");646 if (BLOCK_SIZE != read( IN, super_block_buffer, BLOCK_SIZE))647 die(" Unable toread super block");621 if (BLOCK_SIZE != lseek(dev_fd, BLOCK_SIZE, SEEK_SET)) 622 die("seek failed"); 623 if (BLOCK_SIZE != read(dev_fd, super_block_buffer, BLOCK_SIZE)) 624 die("cannot read super block"); 648 625 /* already initialized to: 649 626 namelen = 14; … … 651 628 version2 = 0; 652 629 */ 653 if (MAGIC == MINIX _SUPER_MAGIC) {654 } else if (MAGIC == MINIX _SUPER_MAGIC2) {630 if (MAGIC == MINIX1_SUPER_MAGIC) { 631 } else if (MAGIC == MINIX1_SUPER_MAGIC2) { 655 632 namelen = 30; 656 633 dirsize = 32; 657 #if def CONFIG_FEATURE_MINIX2634 #if ENABLE_FEATURE_MINIX2 658 635 } else if (MAGIC == MINIX2_SUPER_MAGIC) { 659 636 version2 = 1; … … 664 641 #endif 665 642 } else 666 die(" Bad magic number in super-block");643 die("bad magic number in super-block"); 667 644 if (ZONESIZE != 0 || BLOCK_SIZE != 1024) 668 die(" Only 1k blocks/zones supported");645 die("only 1k blocks/zones supported"); 669 646 if (IMAPS * BLOCK_SIZE * 8 < INODES + 1) 670 die(" Bad s_imap_blocks field in super-block");647 die("bad s_imap_blocks field in super-block"); 671 648 if (ZMAPS * BLOCK_SIZE * 8 < ZONES - FIRSTZONE + 1) 672 die(" Bad s_zmap_blocks field in super-block");649 die("bad s_zmap_blocks field in super-block"); 673 650 } 674 651 … … 680 657 inode_count = xmalloc(INODES + 1); 681 658 zone_count = xmalloc(ZONES); 682 if (IMAPS * BLOCK_SIZE != read( IN, inode_map, IMAPS * BLOCK_SIZE))683 die(" Unable toread inode map");684 if (ZMAPS * BLOCK_SIZE != read( IN, zone_map, ZMAPS * BLOCK_SIZE))685 die(" Unable toread zone map");686 if (INODE_BUFFER_SIZE != read( IN, inode_buffer, INODE_BUFFER_SIZE))687 die(" Unable toread inodes");659 if (IMAPS * BLOCK_SIZE != read(dev_fd, inode_map, IMAPS * BLOCK_SIZE)) 660 die("cannot read inode map"); 661 if (ZMAPS * BLOCK_SIZE != read(dev_fd, zone_map, ZMAPS * BLOCK_SIZE)) 662 die("cannot read zone map"); 663 if (INODE_BUFFER_SIZE != read(dev_fd, inode_buffer, INODE_BUFFER_SIZE)) 664 die("cannot read inodes"); 688 665 if (NORM_FIRSTZONE != FIRSTZONE) { 689 printf(" Warning: Firstzone!=Norm_firstzone\n");666 printf("warning: firstzone!=norm_firstzone\n"); 690 667 errors_uncorrected = 1; 691 668 } 692 669 get_dirsize(); 693 670 if (show) { 694 printf("% ldinodes\n"695 "% ldblocks\n"696 "Firstdatazone=% ld (%ld)\n"697 "Zonesize=% d\n"698 "Maxsize=% ld\n"699 "Filesystem state=% d\n"700 "namelen=% d\n\n",671 printf("%u inodes\n" 672 "%u blocks\n" 673 "Firstdatazone=%u (%u)\n" 674 "Zonesize=%u\n" 675 "Maxsize=%u\n" 676 "Filesystem state=%u\n" 677 "namelen=%u\n\n", 701 678 INODES, 702 679 ZONES, … … 709 686 } 710 687 711 static struct minix _inode *get_inode(unsigned intnr)712 { 713 struct minix _inode *inode;688 static struct minix1_inode *get_inode(unsigned nr) 689 { 690 struct minix1_inode *inode; 714 691 715 692 if (!nr || nr > INODES) 716 693 return NULL; 717 694 total++; 718 inode = Inode + nr;695 inode = Inode1 + nr; 719 696 if (!inode_count[nr]) { 720 697 if (!inode_in_use(nr)) { … … 724 701 if (ask("Mark as 'in use'", 1)) 725 702 mark_inode(nr); 726 } else {727 errors_uncorrected = 1;703 else 704 errors_uncorrected = 1; 728 705 } 729 706 } … … 754 731 } 755 732 756 #if def CONFIG_FEATURE_MINIX2757 static struct minix2_inode *get_inode2(unsigned intnr)733 #if ENABLE_FEATURE_MINIX2 734 static struct minix2_inode *get_inode2(unsigned nr) 758 735 { 759 736 struct minix2_inode *inode; … … 802 779 static void check_root(void) 803 780 { 804 struct minix _inode *inode = Inode +ROOT_INO;781 struct minix1_inode *inode = Inode1 + MINIX_ROOT_INO; 805 782 806 783 if (!inode || !S_ISDIR(inode->i_mode)) 807 die(" Root inode isn't a directory");808 } 809 810 #if def CONFIG_FEATURE_MINIX2784 die("root inode isn't a directory"); 785 } 786 787 #if ENABLE_FEATURE_MINIX2 811 788 static void check_root2(void) 812 789 { 813 struct minix2_inode *inode = Inode2 + ROOT_INO;790 struct minix2_inode *inode = Inode2 + MINIX_ROOT_INO; 814 791 815 792 if (!inode || !S_ISDIR(inode->i_mode)) 816 die("Root inode isn't a directory"); 817 } 818 #endif 819 820 static int add_zone(uint16_t *znr, int *corrected) 793 die("root inode isn't a directory"); 794 } 795 #else 796 void check_root2(void); 797 #endif 798 799 static int add_zone(uint16_t *znr, smallint *corrected) 821 800 { 822 801 int result; … … 848 827 } 849 828 850 #if def CONFIG_FEATURE_MINIX2851 static int add_zone2(uint32_t *znr, int *corrected)829 #if ENABLE_FEATURE_MINIX2 830 static int add_zone2(uint32_t *znr, smallint *corrected) 852 831 { 853 832 int result; … … 880 859 #endif 881 860 882 static void add_zone_ind(uint16_t *znr, int *corrected) 883 { 884 static char blk[BLOCK_SIZE]; 885 int i, chg_blk = 0; 861 static void add_zone_ind(uint16_t *znr, smallint *corrected) 862 { 863 int i; 886 864 int block; 865 smallint chg_blk = 0; 887 866 888 867 block = add_zone(znr, corrected); 889 868 if (!block) 890 869 return; 891 read_block(block, blk);870 read_block(block, add_zone_ind_blk); 892 871 for (i = 0; i < (BLOCK_SIZE >> 1); i++) 893 add_zone(i + (uint16_t *) blk, &chg_blk);872 add_zone(i + (uint16_t *) add_zone_ind_blk, &chg_blk); 894 873 if (chg_blk) 895 write_block(block, blk); 896 } 897 898 #ifdef CONFIG_FEATURE_MINIX2 899 static void add_zone_ind2(uint32_t *znr, int *corrected) 900 { 901 static char blk[BLOCK_SIZE]; 902 int i, chg_blk = 0; 874 write_block(block, add_zone_ind_blk); 875 } 876 877 #if ENABLE_FEATURE_MINIX2 878 static void add_zone_ind2(uint32_t *znr, smallint *corrected) 879 { 880 int i; 903 881 int block; 882 smallint chg_blk = 0; 904 883 905 884 block = add_zone2(znr, corrected); 906 885 if (!block) 907 886 return; 908 read_block(block, blk);887 read_block(block, add_zone_ind_blk); 909 888 for (i = 0; i < BLOCK_SIZE >> 2; i++) 910 add_zone2(i + (uint32_t *) blk, &chg_blk);889 add_zone2(i + (uint32_t *) add_zone_ind_blk, &chg_blk); 911 890 if (chg_blk) 912 write_block(block, blk); 913 } 914 #endif 915 916 static void add_zone_dind(uint16_t *znr, int *corrected) 917 { 918 static char blk[BLOCK_SIZE]; 919 int i, blk_chg = 0; 891 write_block(block, add_zone_ind_blk); 892 } 893 #endif 894 895 static void add_zone_dind(uint16_t *znr, smallint *corrected) 896 { 897 int i; 920 898 int block; 899 smallint chg_blk = 0; 921 900 922 901 block = add_zone(znr, corrected); 923 902 if (!block) 924 903 return; 925 read_block(block, blk);904 read_block(block, add_zone_dind_blk); 926 905 for (i = 0; i < (BLOCK_SIZE >> 1); i++) 927 add_zone_ind(i + (uint16_t *) blk, &blk_chg); 928 if (blk_chg) 929 write_block(block, blk); 930 } 931 932 #ifdef CONFIG_FEATURE_MINIX2 933 static void add_zone_dind2(uint32_t *znr, int *corrected) 934 { 935 static char blk[BLOCK_SIZE]; 936 int i, blk_chg = 0; 906 add_zone_ind(i + (uint16_t *) add_zone_dind_blk, &chg_blk); 907 if (chg_blk) 908 write_block(block, add_zone_dind_blk); 909 } 910 911 #if ENABLE_FEATURE_MINIX2 912 static void add_zone_dind2(uint32_t *znr, smallint *corrected) 913 { 914 int i; 937 915 int block; 916 smallint chg_blk = 0; 938 917 939 918 block = add_zone2(znr, corrected); 940 919 if (!block) 941 920 return; 942 read_block(block, blk);921 read_block(block, add_zone_dind_blk); 943 922 for (i = 0; i < BLOCK_SIZE >> 2; i++) 944 add_zone_ind2(i + (uint32_t *) blk, &blk_chg); 945 if (blk_chg) 946 write_block(block, blk); 947 } 948 949 static void add_zone_tind2(uint32_t *znr, int *corrected) 950 { 951 static char blk[BLOCK_SIZE]; 952 int i, blk_chg = 0; 923 add_zone_ind2(i + (uint32_t *) add_zone_dind_blk, &chg_blk); 924 if (chg_blk) 925 write_block(block, add_zone_dind_blk); 926 } 927 928 static void add_zone_tind2(uint32_t *znr, smallint *corrected) 929 { 930 int i; 953 931 int block; 932 smallint chg_blk = 0; 954 933 955 934 block = add_zone2(znr, corrected); 956 935 if (!block) 957 936 return; 958 read_block(block, blk);937 read_block(block, add_zone_tind_blk); 959 938 for (i = 0; i < BLOCK_SIZE >> 2; i++) 960 add_zone_dind2(i + (uint32_t *) blk, &blk_chg);961 if ( blk_chg)962 write_block(block, blk);963 } 964 #endif 965 966 static void check_zones(unsigned i nt i)967 { 968 struct minix _inode *inode;939 add_zone_dind2(i + (uint32_t *) add_zone_tind_blk, &chg_blk); 940 if (chg_blk) 941 write_block(block, add_zone_tind_blk); 942 } 943 #endif 944 945 static void check_zones(unsigned i) 946 { 947 struct minix1_inode *inode; 969 948 970 949 if (!i || i > INODES) … … 972 951 if (inode_count[i] > 1) /* have we counted this file already? */ 973 952 return; 974 inode = Inode + i;953 inode = Inode1 + i; 975 954 if (!S_ISDIR(inode->i_mode) && !S_ISREG(inode->i_mode) && 976 955 !S_ISLNK(inode->i_mode)) return; … … 981 960 } 982 961 983 #if def CONFIG_FEATURE_MINIX2984 static void check_zones2(unsigned i nt i)962 #if ENABLE_FEATURE_MINIX2 963 static void check_zones2(unsigned i) 985 964 { 986 965 struct minix2_inode *inode; … … 1002 981 #endif 1003 982 1004 static void check_file(struct minix_inode *dir, unsigned int offset) 1005 { 1006 static char blk[BLOCK_SIZE]; 1007 struct minix_inode *inode; 983 static void check_file(struct minix1_inode *dir, unsigned offset) 984 { 985 struct minix1_inode *inode; 1008 986 int ino; 1009 987 char *name; … … 1011 989 1012 990 block = map_block(dir, offset / BLOCK_SIZE); 1013 read_block(block, blk);1014 name = blk + (offset % BLOCK_SIZE) + 2;991 read_block(block, check_file_blk); 992 name = check_file_blk + (offset % BLOCK_SIZE) + 2; 1015 993 ino = *(uint16_t *) (name - 2); 1016 994 if (ino > INODES) { … … 1019 997 if (ask("Remove", 1)) { 1020 998 *(uint16_t *) (name - 2) = 0; 1021 write_block(block, blk);999 write_block(block, check_file_blk); 1022 1000 } 1023 1001 ino = 0; … … 1027 1005 pop_filename(); 1028 1006 if (!offset) { 1029 if (!inode || strcmp(".", name)) { 1030 printf("%s: bad directory: '.' isn't first\n", current_name); 1031 errors_uncorrected = 1; 1032 } else 1007 if (inode && LONE_CHAR(name, '.')) 1033 1008 return; 1009 printf("%s: bad directory: '.' isn't first\n", current_name); 1010 errors_uncorrected = 1; 1034 1011 } 1035 1012 if (offset == dirsize) { 1036 if (!inode || strcmp("..", name)) { 1037 printf("%s: bad directory: '..' isn't second\n", current_name); 1038 errors_uncorrected = 1; 1039 } else 1013 if (inode && strcmp("..", name) == 0) 1040 1014 return; 1015 printf("%s: bad directory: '..' isn't second\n", current_name); 1016 errors_uncorrected = 1; 1041 1017 } 1042 1018 if (!inode) … … 1052 1028 recursive_check(ino); 1053 1029 pop_filename(); 1054 return; 1055 } 1056 1057 #ifdef CONFIG_FEATURE_MINIX2 1058 static void check_file2(struct minix2_inode *dir, unsigned int offset) 1059 { 1060 static char blk[BLOCK_SIZE]; 1030 } 1031 1032 #if ENABLE_FEATURE_MINIX2 1033 static void check_file2(struct minix2_inode *dir, unsigned offset) 1034 { 1061 1035 struct minix2_inode *inode; 1062 1036 int ino; … … 1065 1039 1066 1040 block = map_block2(dir, offset / BLOCK_SIZE); 1067 read_block(block, blk);1068 name = blk + (offset % BLOCK_SIZE) + 2;1041 read_block(block, check_file_blk); 1042 name = check_file_blk + (offset % BLOCK_SIZE) + 2; 1069 1043 ino = *(uint16_t *) (name - 2); 1070 1044 if (ino > INODES) { … … 1073 1047 if (ask("Remove", 1)) { 1074 1048 *(uint16_t *) (name - 2) = 0; 1075 write_block(block, blk);1049 write_block(block, check_file_blk); 1076 1050 } 1077 1051 ino = 0; … … 1081 1055 pop_filename(); 1082 1056 if (!offset) { 1083 if (!inode || strcmp(".", name)) { 1084 printf("%s: bad directory: '.' isn't first\n", current_name); 1085 errors_uncorrected = 1; 1086 } else 1057 if (inode && LONE_CHAR(name, '.')) 1087 1058 return; 1059 printf("%s: bad directory: '.' isn't first\n", current_name); 1060 errors_uncorrected = 1; 1088 1061 } 1089 1062 if (offset == dirsize) { 1090 if (!inode || strcmp("..", name)) { 1091 printf("%s: bad directory: '..' isn't second\n", current_name); 1092 errors_uncorrected = 1; 1093 } else 1063 if (inode && strcmp("..", name) == 0) 1094 1064 return; 1065 printf("%s: bad directory: '..' isn't second\n", current_name); 1066 errors_uncorrected = 1; 1095 1067 } 1096 1068 if (!inode) … … 1106 1078 recursive_check2(ino); 1107 1079 pop_filename(); 1108 return; 1109 } 1110 #endif 1111 1112 static void recursive_check(unsigned int ino) 1113 { 1114 struct minix_inode *dir; 1115 unsigned int offset; 1116 1117 dir = Inode + ino; 1080 } 1081 #endif 1082 1083 static void recursive_check(unsigned ino) 1084 { 1085 struct minix1_inode *dir; 1086 unsigned offset; 1087 1088 dir = Inode1 + ino; 1118 1089 if (!S_ISDIR(dir->i_mode)) 1119 die(" Internal error");1090 die("internal error"); 1120 1091 if (dir->i_size < 2 * dirsize) { 1121 1092 printf("%s: bad directory: size<32", current_name); … … 1126 1097 } 1127 1098 1128 #if def CONFIG_FEATURE_MINIX21129 static void recursive_check2(unsigned in t ino)1099 #if ENABLE_FEATURE_MINIX2 1100 static void recursive_check2(unsigned ino) 1130 1101 { 1131 1102 struct minix2_inode *dir; 1132 unsigned intoffset;1103 unsigned offset; 1133 1104 1134 1105 dir = Inode2 + ino; 1135 1106 if (!S_ISDIR(dir->i_mode)) 1136 die(" Internal error");1107 die("internal error"); 1137 1108 if (dir->i_size < 2 * dirsize) { 1138 1109 printf("%s: bad directory: size<32", current_name); … … 1146 1117 static int bad_zone(int i) 1147 1118 { 1148 char buffer[ 1024];1149 1150 if (BLOCK_SIZE * i != lseek( IN, BLOCK_SIZE * i, SEEK_SET))1151 die(" Seek failed in bad_zone");1152 return (BLOCK_SIZE != read( IN, buffer, BLOCK_SIZE));1119 char buffer[BLOCK_SIZE]; 1120 1121 if (BLOCK_SIZE * i != lseek(dev_fd, BLOCK_SIZE * i, SEEK_SET)) 1122 die("seek failed in bad_zone"); 1123 return (BLOCK_SIZE != read(dev_fd, buffer, BLOCK_SIZE)); 1153 1124 } 1154 1125 … … 1158 1129 1159 1130 for (i = 1; i <= INODES; i++) { 1160 if (warn_mode && Inode [i].i_mode && !inode_in_use(i)) {1131 if (warn_mode && Inode1[i].i_mode && !inode_in_use(i)) { 1161 1132 printf("Inode %d has non-zero mode. ", i); 1162 1133 if (ask("Clear", 1)) { 1163 Inode [i].i_mode = 0;1134 Inode1[i].i_mode = 0; 1164 1135 changed = 1; 1165 1136 } … … 1178 1149 mark_inode(i); 1179 1150 } 1180 if (Inode [i].i_nlinks != inode_count[i]) {1151 if (Inode1[i].i_nlinks != inode_count[i]) { 1181 1152 printf("Inode %d (mode=%07o), i_nlinks=%d, counted=%d. ", 1182 i, Inode[i].i_mode, Inode[i].i_nlinks, inode_count[i]); 1153 i, Inode1[i].i_mode, Inode1[i].i_nlinks, 1154 inode_count[i]); 1183 1155 if (ask("Set i_nlinks to count", 1)) { 1184 Inode [i].i_nlinks = inode_count[i];1156 Inode1[i].i_nlinks = inode_count[i]; 1185 1157 changed = 1; 1186 1158 } … … 1188 1160 } 1189 1161 for (i = FIRSTZONE; i < ZONES; i++) { 1190 if ( zone_in_use(i) == zone_count[i])1162 if ((zone_in_use(i) != 0) == zone_count[i]) 1191 1163 continue; 1192 1164 if (!zone_count[i]) { … … 1203 1175 } 1204 1176 1205 #if def CONFIG_FEATURE_MINIX21177 #if ENABLE_FEATURE_MINIX2 1206 1178 static void check_counts2(void) 1207 1179 { … … 1231 1203 if (Inode2[i].i_nlinks != inode_count[i]) { 1232 1204 printf("Inode %d (mode=%07o), i_nlinks=%d, counted=%d. ", 1233 1234 1205 i, Inode2[i].i_mode, Inode2[i].i_nlinks, 1206 inode_count[i]); 1235 1207 if (ask("Set i_nlinks to count", 1)) { 1236 1208 Inode2[i].i_nlinks = inode_count[i]; … … 1240 1212 } 1241 1213 for (i = FIRSTZONE; i < ZONES; i++) { 1242 if ( zone_in_use(i) == zone_count[i])1214 if ((zone_in_use(i) != 0) == zone_count[i]) 1243 1215 continue; 1244 1216 if (!zone_count[i]) { … … 1260 1232 memset(inode_count, 0, (INODES + 1) * sizeof(*inode_count)); 1261 1233 memset(zone_count, 0, ZONES * sizeof(*zone_count)); 1262 check_zones( ROOT_INO);1263 recursive_check( ROOT_INO);1234 check_zones(MINIX_ROOT_INO); 1235 recursive_check(MINIX_ROOT_INO); 1264 1236 check_counts(); 1265 1237 } 1266 1238 1267 #if def CONFIG_FEATURE_MINIX21239 #if ENABLE_FEATURE_MINIX2 1268 1240 static void check2(void) 1269 1241 { 1270 1242 memset(inode_count, 0, (INODES + 1) * sizeof(*inode_count)); 1271 1243 memset(zone_count, 0, ZONES * sizeof(*zone_count)); 1272 check_zones2( ROOT_INO);1273 recursive_check2( ROOT_INO);1244 check_zones2(MINIX_ROOT_INO); 1245 recursive_check2(MINIX_ROOT_INO); 1274 1246 check_counts2(); 1275 1247 } 1276 #endif 1277 1248 #else 1249 void check2(void); 1250 #endif 1251 1252 int fsck_minix_main(int argc, char **argv); 1278 1253 int fsck_minix_main(int argc, char **argv) 1279 1254 { … … 1281 1256 int retcode = 0; 1282 1257 1283 alloc_current_name(); 1284 #ifdef CONFIG_FEATURE_CLEAN_UP 1285 /* Don't bother to free memory. Exit does 1286 * that automagically, so we can save a few bytes */ 1287 atexit(free_current_name); 1288 #endif 1289 1290 if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE) 1291 die("Bad inode size"); 1292 #ifdef CONFIG_FEATURE_MINIX2 1258 xfunc_error_retval = 8; 1259 1260 INIT_G(); 1261 1262 if (INODE_SIZE1 * MINIX1_INODES_PER_BLOCK != BLOCK_SIZE) 1263 die("bad inode size"); 1264 #if ENABLE_FEATURE_MINIX2 1293 1265 if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) 1294 die(" Bad v2 inode size");1295 #endif 1296 while ( argc-- > 1) {1266 die("bad v2 inode size"); 1267 #endif 1268 while (--argc != 0) { 1297 1269 argv++; 1298 1270 if (argv[0][0] != '-') { 1299 1271 if (device_name) 1300 1272 bb_show_usage(); 1301 else 1302 device_name = argv[0]; 1303 } else 1304 while (*++argv[0]) 1273 device_name = argv[0]; 1274 } else { 1275 while (*++argv[0]) { 1305 1276 switch (argv[0][0]) { 1306 1277 case 'l': … … 1330 1301 bb_show_usage(); 1331 1302 } 1303 } 1304 } 1332 1305 } 1333 1306 if (!device_name) 1334 1307 bb_show_usage(); 1308 1335 1309 check_mount(); /* trying to check a mounted filesystem? */ 1336 1310 if (repair && !automatic) { 1337 1311 if (!isatty(0) || !isatty(1)) 1338 die("Need terminal for interactive repairs"); 1339 } 1340 IN = open(device_name, repair ? O_RDWR : O_RDONLY); 1341 if (IN < 0){ 1342 printf("Unable to open device '%s'\n", device_name); 1343 leave(8); 1344 } 1345 sync(); /* paranoia? */ 1312 die("need terminal for interactive repairs"); 1313 } 1314 dev_fd = xopen(device_name, repair ? O_RDWR : O_RDONLY); 1315 1316 /*sync(); paranoia? */ 1346 1317 read_superblock(); 1347 1318 … … 1352 1323 * command line. 1353 1324 */ 1354 printf("%s, %s\n", bb_applet_name, program_version); 1355 if (!(Super.s_state & MINIX_ERROR_FS) && 1356 (Super.s_state & MINIX_VALID_FS) && !force) { 1325 printf("%s: %s\n", applet_name, bb_banner); 1326 1327 if (!(Super.s_state & MINIX_ERROR_FS) 1328 && (Super.s_state & MINIX_VALID_FS) && !force 1329 ) { 1357 1330 if (repair) 1358 1331 printf("%s is clean, check is skipped\n", device_name); 1359 return retcode;1332 return 0; 1360 1333 } else if (force) 1361 1334 printf("Forcing filesystem check on %s\n", device_name); … … 1367 1340 1368 1341 if (repair && !automatic) { 1369 tcgetattr(0, & termios);1370 tmp = termios;1342 tcgetattr(0, &sv_termios); 1343 tmp = sv_termios; 1371 1344 tmp.c_lflag &= ~(ICANON | ECHO); 1372 1345 tcsetattr(0, TCSANOW, &tmp); 1373 1346 termios_set = 1; 1374 1347 } 1375 #ifdef CONFIG_FEATURE_MINIX2 1348 1376 1349 if (version2) { 1377 1350 check_root2(); 1378 1351 check2(); 1379 } else 1380 #endif 1381 { 1352 } else { 1382 1353 check_root(); 1383 1354 check(); 1384 1355 } 1356 1385 1357 if (verbose) { 1386 1358 int i, free_cnt; … … 1389 1361 if (!inode_in_use(i)) 1390 1362 free_cnt++; 1391 printf("\n%6 ld inodes used (%ld%%)\n", (INODES - free_cnt),1363 printf("\n%6u inodes used (%u%%)\n", (INODES - free_cnt), 1392 1364 100 * (INODES - free_cnt) / INODES); 1393 1365 for (i = FIRSTZONE, free_cnt = 0; i < ZONES; i++) 1394 1366 if (!zone_in_use(i)) 1395 1367 free_cnt++; 1396 printf("%6 ld zones used (%ld%%)\n\n"1397 "%6 dregular files\n"1398 "%6 ddirectories\n"1399 "%6 dcharacter device files\n"1400 "%6 dblock device files\n"1401 "%6 dlinks\n"1402 "%6 dsymbolic links\n"1368 printf("%6u zones used (%u%%)\n\n" 1369 "%6u regular files\n" 1370 "%6u directories\n" 1371 "%6u character device files\n" 1372 "%6u block device files\n" 1373 "%6u links\n" 1374 "%6u symbolic links\n" 1403 1375 "------\n" 1404 "%6 dfiles\n",1376 "%6u files\n", 1405 1377 (ZONES - free_cnt), 100 * (ZONES - free_cnt) / ZONES, 1406 1378 regular, directory, chardev, blockdev, … … 1416 1388 1417 1389 if (repair && !automatic) 1418 tcsetattr(0, TCSANOW, & termios);1390 tcsetattr(0, TCSANOW, &sv_termios); 1419 1391 1420 1392 if (changed)
Note:
See TracChangeset
for help on using the changeset viewer.