source: MondoRescue/branches/2.2.9/mindi-busybox/util-linux/fsck_minix.c@ 2725

Last change on this file since 2725 was 2725, checked in by Bruno Cornec, 13 years ago
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File size: 32.3 KB
RevLine 
[821]1/* vi: set sw=4 ts=4: */
2/*
3 * fsck.c - a file system consistency checker for Linux.
4 *
[1765]5 * (C) 1991, 1992 Linus Torvalds.
6 *
[2725]7 * Licensed under GPLv2, see file LICENSE in this source tree.
[821]8 */
9
10/*
11 * 09.11.91 - made the first rudimentary functions
12 *
13 * 10.11.91 - updated, does checking, no repairs yet.
14 * Sent out to the mailing-list for testing.
15 *
16 * 14.11.91 - Testing seems to have gone well. Added some
17 * correction-code, and changed some functions.
18 *
19 * 15.11.91 - More correction code. Hopefully it notices most
20 * cases now, and tries to do something about them.
21 *
22 * 16.11.91 - More corrections (thanks to Mika Jalava). Most
23 * things seem to work now. Yeah, sure.
24 *
25 *
26 * 19.04.92 - Had to start over again from this old version, as a
27 * kernel bug ate my enhanced fsck in february.
28 *
29 * 28.02.93 - added support for different directory entry sizes..
30 *
31 * Sat Mar 6 18:59:42 1993, faith@cs.unc.edu: Output namelen with
[2725]32 * superblock information
[821]33 *
34 * Sat Oct 9 11:17:11 1993, faith@cs.unc.edu: make exit status conform
35 * to that required by fsutil
36 *
37 * Mon Jan 3 11:06:52 1994 - Dr. Wettstein (greg%wind.uucp@plains.nodak.edu)
38 * Added support for file system valid flag. Also
39 * added program_version variable and output of
40 * program name and version number when program
41 * is executed.
42 *
43 * 30.10.94 - added support for v2 filesystem
44 * (Andreas Schwab, schwab@issan.informatik.uni-dortmund.de)
45 *
46 * 10.12.94 - added test to prevent checking of mounted fs adapted
47 * from Theodore Ts'o's (tytso@athena.mit.edu) e2fsck
48 * program. (Daniel Quinlan, quinlan@yggdrasil.com)
49 *
50 * 01.07.96 - Fixed the v2 fs stuff to use the right #defines and such
51 * for modern libcs (janl@math.uio.no, Nicolai Langfeldt)
52 *
53 * 02.07.96 - Added C bit fiddling routines from rmk@ecs.soton.ac.uk
54 * (Russell King). He made them for ARM. It would seem
55 * that the ARM is powerful enough to do this in C whereas
56 * i386 and m64k must use assembly to get it fast >:-)
57 * This should make minix fsck system-independent.
58 * (janl@math.uio.no, Nicolai Langfeldt)
59 *
60 * 04.11.96 - Added minor fixes from Andreas Schwab to avoid compiler
61 * warnings. Added mc68k bitops from
62 * Joerg Dorchain <dorchain@mpi-sb.mpg.de>.
63 *
64 * 06.11.96 - Added v2 code submitted by Joerg Dorchain, but written by
65 * Andreas Schwab.
66 *
[2725]67 * 1999-02-22 Arkadiusz Mickiewicz <misiek@misiek.eu.org>
[821]68 * - added Native Language Support
69 *
70 *
71 * I've had no time to add comments - hopefully the function names
72 * are comments enough. As with all file system checkers, this assumes
73 * the file system is quiescent - don't use it on a mounted device
74 * unless you can be sure nobody is writing to it (and remember that the
75 * kernel can write to it when it searches for files).
76 *
77 * Usage: fsck [-larvsm] device
78 * -l for a listing of all the filenames
79 * -a for automatic repairs (not implemented)
80 * -r for repairs (interactive) (not implemented)
81 * -v for verbose (tells how many files)
[2725]82 * -s for superblock info
[821]83 * -m for minix-like "mode not cleared" warnings
84 * -f force filesystem check even if filesystem marked as valid
85 *
86 * The device may be a block device or a image of one, but this isn't
87 * enforced (but it's not much fun on a character device :-).
88 */
89
90#include <mntent.h>
[1765]91#include "libbb.h"
92#include "minix.h"
[821]93
[1765]94#ifndef BLKGETSIZE
95#define BLKGETSIZE _IO(0x12,96) /* return device size */
96#endif
[821]97
[2725]98struct BUG_bad_inode_size {
99 char BUG_bad_inode1_size[(INODE_SIZE1 * MINIX1_INODES_PER_BLOCK != BLOCK_SIZE) ? -1 : 1];
100#if ENABLE_FEATURE_MINIX2
101 char BUG_bad_inode2_size[(INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) ? -1 : 1];
102#endif
103};
104
[821]105enum {
[1765]106#ifdef UNUSED
107 MINIX1_LINK_MAX = 250,
[821]108 MINIX2_LINK_MAX = 65530,
109 MINIX_I_MAP_SLOTS = 8,
110 MINIX_Z_MAP_SLOTS = 64,
[1765]111 MINIX_V1 = 0x0001, /* original minix fs */
112 MINIX_V2 = 0x0002, /* minix V2 fs */
113#endif
114 MINIX_NAME_MAX = 255, /* # chars in a file name */
115};
[821]116
[2725]117
[1765]118#if !ENABLE_FEATURE_MINIX2
119enum { version2 = 0 };
120#endif
[821]121
[1765]122enum { MAX_DEPTH = 32 };
[821]123
[2725]124enum { dev_fd = 3 };
125
[1765]126struct globals {
127#if ENABLE_FEATURE_MINIX2
128 smallint version2;
129#endif
130 smallint changed; /* is filesystem modified? */
131 smallint errors_uncorrected; /* flag if some error was not corrected */
132 smallint termios_set;
133 smallint dirsize;
134 smallint namelen;
[2725]135 const char *device_name;
[1765]136 int directory, regular, blockdev, chardev, links, symlinks, total;
137 char *inode_buffer;
[821]138
[1765]139 char *inode_map;
140 char *zone_map;
[821]141
[1765]142 unsigned char *inode_count;
143 unsigned char *zone_count;
[821]144
[1765]145 /* File-name data */
146 int name_depth;
147 char *name_component[MAX_DEPTH+1];
[821]148
[1765]149 /* Bigger stuff */
150 struct termios sv_termios;
[2725]151 char superblock_buffer[BLOCK_SIZE];
[1765]152 char add_zone_ind_blk[BLOCK_SIZE];
153 char add_zone_dind_blk[BLOCK_SIZE];
[2725]154 IF_FEATURE_MINIX2(char add_zone_tind_blk[BLOCK_SIZE];)
[1765]155 char check_file_blk[BLOCK_SIZE];
[821]156
[1765]157 /* File-name data */
158 char current_name[MAX_DEPTH * MINIX_NAME_MAX];
159};
160#define G (*ptr_to_globals)
161#if ENABLE_FEATURE_MINIX2
162#define version2 (G.version2 )
[821]163#endif
[1765]164#define changed (G.changed )
165#define errors_uncorrected (G.errors_uncorrected )
166#define termios_set (G.termios_set )
167#define dirsize (G.dirsize )
168#define namelen (G.namelen )
169#define device_name (G.device_name )
170#define directory (G.directory )
171#define regular (G.regular )
172#define blockdev (G.blockdev )
173#define chardev (G.chardev )
174#define links (G.links )
175#define symlinks (G.symlinks )
176#define total (G.total )
177#define inode_buffer (G.inode_buffer )
178#define inode_map (G.inode_map )
179#define zone_map (G.zone_map )
180#define inode_count (G.inode_count )
181#define zone_count (G.zone_count )
182#define name_depth (G.name_depth )
183#define name_component (G.name_component )
184#define sv_termios (G.sv_termios )
[2725]185#define superblock_buffer (G.superblock_buffer )
[1765]186#define add_zone_ind_blk (G.add_zone_ind_blk )
187#define add_zone_dind_blk (G.add_zone_dind_blk )
188#define add_zone_tind_blk (G.add_zone_tind_blk )
189#define check_file_blk (G.check_file_blk )
190#define current_name (G.current_name )
191#define INIT_G() do { \
[2725]192 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
[1765]193 dirsize = 16; \
194 namelen = 14; \
195 current_name[0] = '/'; \
196 /*current_name[1] = '\0';*/ \
197 name_component[0] = &current_name[0]; \
198} while (0)
[821]199
[2725]200
201#define OPTION_STR "larvsmf"
202enum {
203 OPT_l = (1 << 0),
204 OPT_a = (1 << 1),
205 OPT_r = (1 << 2),
206 OPT_v = (1 << 3),
207 OPT_s = (1 << 4),
208 OPT_w = (1 << 5),
209 OPT_f = (1 << 6),
210};
211#define OPT_list (option_mask32 & OPT_l)
212#define OPT_automatic (option_mask32 & OPT_a)
213#define OPT_repair (option_mask32 & OPT_r)
214#define OPT_verbose (option_mask32 & OPT_v)
215#define OPT_show (option_mask32 & OPT_s)
216#define OPT_warn_mode (option_mask32 & OPT_w)
217#define OPT_force (option_mask32 & OPT_f)
218/* non-automatic repairs requested? */
219#define OPT_manual ((option_mask32 & (OPT_a|OPT_r)) == OPT_r)
220
221
[1765]222#define Inode1 (((struct minix1_inode *) inode_buffer)-1)
223#define Inode2 (((struct minix2_inode *) inode_buffer)-1)
[821]224
[2725]225#define Super (*(struct minix_superblock *)(superblock_buffer))
[821]226
[1765]227#if ENABLE_FEATURE_MINIX2
228# define ZONES ((unsigned)(version2 ? Super.s_zones : Super.s_nzones))
[821]229#else
[1765]230# define ZONES ((unsigned)(Super.s_nzones))
[821]231#endif
[1765]232#define INODES ((unsigned)Super.s_ninodes)
233#define IMAPS ((unsigned)Super.s_imap_blocks)
234#define ZMAPS ((unsigned)Super.s_zmap_blocks)
235#define FIRSTZONE ((unsigned)Super.s_firstdatazone)
236#define ZONESIZE ((unsigned)Super.s_log_zone_size)
237#define MAXSIZE ((unsigned)Super.s_max_size)
238#define MAGIC (Super.s_magic)
[821]239
[1765]240/* gcc likes this more (code is smaller) than macro variant */
241static ALWAYS_INLINE unsigned div_roundup(unsigned size, unsigned n)
242{
243 return (size + n-1) / n;
244}
[821]245
[2725]246#if !ENABLE_FEATURE_MINIX2
247#define INODE_BLOCKS div_roundup(INODES, MINIX1_INODES_PER_BLOCK)
[821]248#else
[2725]249#define INODE_BLOCKS div_roundup(INODES, \
250 (version2 ? MINIX2_INODES_PER_BLOCK : MINIX1_INODES_PER_BLOCK))
[821]251#endif
252
[2725]253#define INODE_BUFFER_SIZE (INODE_BLOCKS * BLOCK_SIZE)
254#define NORM_FIRSTZONE (2 + IMAPS + ZMAPS + INODE_BLOCKS)
[821]255
[1765]256/* Before you ask "where they come from?": */
257/* setbit/clrbit are supplied by sys/param.h */
[821]258
[1765]259static int minix_bit(const char *a, unsigned i)
[821]260{
[1765]261 return (a[i >> 3] & (1<<(i & 7)));
[821]262}
263
[1765]264static void minix_setbit(char *a, unsigned i)
[821]265{
[1765]266 setbit(a, i);
267 changed = 1;
[821]268}
[1765]269static void minix_clrbit(char *a, unsigned i)
[821]270{
[1765]271 clrbit(a, i);
272 changed = 1;
[821]273}
274
[1765]275/* Note: do not assume 0/1, it is 0/nonzero */
276#define zone_in_use(x) (minix_bit(zone_map,(x)-FIRSTZONE+1))
277#define inode_in_use(x) (minix_bit(inode_map,(x)))
[821]278
[1765]279#define mark_inode(x) (minix_setbit(inode_map,(x)))
280#define unmark_inode(x) (minix_clrbit(inode_map,(x)))
[821]281
[1765]282#define mark_zone(x) (minix_setbit(zone_map,(x)-FIRSTZONE+1))
283#define unmark_zone(x) (minix_clrbit(zone_map,(x)-FIRSTZONE+1))
284
285
286static void recursive_check(unsigned ino);
287#if ENABLE_FEATURE_MINIX2
288static void recursive_check2(unsigned ino);
289#endif
290
[2725]291static void die(const char *str) NORETURN;
[1765]292static void die(const char *str)
[821]293{
[1765]294 if (termios_set)
[2725]295 tcsetattr_stdin_TCSANOW(&sv_termios);
[1765]296 bb_error_msg_and_die("%s", str);
[821]297}
298
299static void push_filename(const char *name)
300{
301 // /dir/dir/dir/file
302 // ^ ^ ^
303 // [0] [1] [2] <-name_component[i]
304 if (name_depth < MAX_DEPTH) {
305 int len;
306 char *p = name_component[name_depth];
307 *p++ = '/';
308 len = sprintf(p, "%.*s", namelen, name);
309 name_component[name_depth + 1] = p + len;
310 }
311 name_depth++;
312}
313
[1765]314static void pop_filename(void)
315{
[821]316 name_depth--;
317 if (name_depth < MAX_DEPTH) {
318 *name_component[name_depth] = '\0';
319 if (!name_depth) {
320 current_name[0] = '/';
321 current_name[1] = '\0';
322 }
323 }
324}
325
326static int ask(const char *string, int def)
327{
328 int c;
329
[2725]330 if (!OPT_repair) {
331 bb_putchar('\n');
[821]332 errors_uncorrected = 1;
333 return 0;
334 }
[2725]335 if (OPT_automatic) {
336 bb_putchar('\n');
[821]337 if (!def)
338 errors_uncorrected = 1;
339 return def;
340 }
341 printf(def ? "%s (y/n)? " : "%s (n/y)? ", string);
342 for (;;) {
[2725]343 fflush_all();
[1765]344 c = getchar();
345 if (c == EOF) {
[821]346 if (!def)
347 errors_uncorrected = 1;
348 return def;
349 }
[2725]350 if (c == '\n')
351 break;
352 c |= 0x20; /* tolower */
353 if (c == 'y') {
[821]354 def = 1;
355 break;
[2725]356 }
357 if (c == 'n') {
[821]358 def = 0;
359 break;
[2725]360 }
[821]361 }
362 if (def)
363 printf("y\n");
364 else {
365 printf("n\n");
366 errors_uncorrected = 1;
367 }
368 return def;
369}
370
371/*
372 * Make certain that we aren't checking a filesystem that is on a
373 * mounted partition. Code adapted from e2fsck, Copyright (C) 1993,
374 * 1994 Theodore Ts'o. Also licensed under GPL.
375 */
376static void check_mount(void)
377{
[2725]378 if (find_mount_point(device_name, 0)) {
379 int cont;
380#if ENABLE_FEATURE_MTAB_SUPPORT
381 /*
382 * If the root is mounted read-only, then /etc/mtab is
383 * probably not correct; so we won't issue a warning based on
384 * it.
385 */
386 int fd = open(bb_path_mtab_file, O_RDWR);
[821]387
[2725]388 if (fd < 0 && errno == EROFS)
389 return;
390 close(fd);
391#endif
392 printf("%s is mounted. ", device_name);
393 cont = 0;
394 if (isatty(0) && isatty(1))
395 cont = ask("Do you really want to continue", 0);
396 if (!cont) {
397 printf("Check aborted\n");
398 exit(EXIT_SUCCESS);
399 }
[821]400 }
401}
402
403/*
404 * check_zone_nr checks to see that *nr is a valid zone nr. If it
405 * isn't, it will possibly be repaired. Check_zone_nr sets *corrected
406 * if an error was corrected, and returns the zone (0 for no zone
407 * or a bad zone-number).
408 */
[1765]409static int check_zone_nr2(uint32_t *nr, smallint *corrected)
[821]410{
411 const char *msg;
412 if (!*nr)
413 return 0;
414 if (*nr < FIRSTZONE)
415 msg = "< FIRSTZONE";
416 else if (*nr >= ZONES)
417 msg = ">= ZONES";
418 else
419 return *nr;
420 printf("Zone nr %s in file '%s'. ", msg, current_name);
421 if (ask("Remove block", 1)) {
422 *nr = 0;
423 *corrected = 1;
424 }
425 return 0;
426}
427
[1765]428static int check_zone_nr(uint16_t *nr, smallint *corrected)
[821]429{
430 uint32_t nr32 = *nr;
431 int r = check_zone_nr2(&nr32, corrected);
432 *nr = (uint16_t)nr32;
433 return r;
434}
435
436/*
437 * read-block reads block nr into the buffer at addr.
438 */
[2725]439static void read_block(unsigned nr, void *addr)
[821]440{
441 if (!nr) {
442 memset(addr, 0, BLOCK_SIZE);
443 return;
444 }
[2725]445 xlseek(dev_fd, BLOCK_SIZE * nr, SEEK_SET);
446 if (BLOCK_SIZE != full_read(dev_fd, addr, BLOCK_SIZE)) {
447 printf("%s: bad block %u in file '%s'\n",
448 bb_msg_read_error, nr, current_name);
[821]449 errors_uncorrected = 1;
450 memset(addr, 0, BLOCK_SIZE);
451 }
452}
453
454/*
455 * write_block writes block nr to disk.
456 */
[2725]457static void write_block(unsigned nr, void *addr)
[821]458{
459 if (!nr)
460 return;
461 if (nr < FIRSTZONE || nr >= ZONES) {
462 printf("Internal error: trying to write bad block\n"
463 "Write request ignored\n");
464 errors_uncorrected = 1;
465 return;
466 }
[2725]467 xlseek(dev_fd, BLOCK_SIZE * nr, SEEK_SET);
468 if (BLOCK_SIZE != full_write(dev_fd, addr, BLOCK_SIZE)) {
469 printf("%s: bad block %u in file '%s'\n",
470 bb_msg_write_error, nr, current_name);
[821]471 errors_uncorrected = 1;
472 }
473}
474
475/*
476 * map_block calculates the absolute block nr of a block in a file.
477 * It sets 'changed' if the inode has needed changing, and re-writes
478 * any indirect blocks with errors.
479 */
[1765]480static int map_block(struct minix1_inode *inode, unsigned blknr)
[821]481{
482 uint16_t ind[BLOCK_SIZE >> 1];
[1765]483 int block, result;
484 smallint blk_chg;
[821]485
486 if (blknr < 7)
487 return check_zone_nr(inode->i_zone + blknr, &changed);
488 blknr -= 7;
489 if (blknr < 512) {
490 block = check_zone_nr(inode->i_zone + 7, &changed);
[2725]491 goto common;
[821]492 }
493 blknr -= 512;
494 block = check_zone_nr(inode->i_zone + 8, &changed);
[2725]495 read_block(block, ind); /* double indirect */
[821]496 blk_chg = 0;
[2725]497 result = check_zone_nr(&ind[blknr / 512], &blk_chg);
[821]498 if (blk_chg)
[2725]499 write_block(block, ind);
[821]500 block = result;
[2725]501 common:
502 read_block(block, ind);
[821]503 blk_chg = 0;
[2725]504 result = check_zone_nr(&ind[blknr % 512], &blk_chg);
[821]505 if (blk_chg)
[2725]506 write_block(block, ind);
[821]507 return result;
508}
509
[1765]510#if ENABLE_FEATURE_MINIX2
511static int map_block2(struct minix2_inode *inode, unsigned blknr)
[821]512{
513 uint32_t ind[BLOCK_SIZE >> 2];
[1765]514 int block, result;
515 smallint blk_chg;
[821]516
517 if (blknr < 7)
518 return check_zone_nr2(inode->i_zone + blknr, &changed);
519 blknr -= 7;
520 if (blknr < 256) {
521 block = check_zone_nr2(inode->i_zone + 7, &changed);
[2725]522 goto common2;
[821]523 }
524 blknr -= 256;
[2725]525 if (blknr < 256 * 256) {
[821]526 block = check_zone_nr2(inode->i_zone + 8, &changed);
[2725]527 goto common1;
[821]528 }
529 blknr -= 256 * 256;
530 block = check_zone_nr2(inode->i_zone + 9, &changed);
[2725]531 read_block(block, ind); /* triple indirect */
[821]532 blk_chg = 0;
[2725]533 result = check_zone_nr2(&ind[blknr / (256 * 256)], &blk_chg);
[821]534 if (blk_chg)
[2725]535 write_block(block, ind);
[821]536 block = result;
[2725]537 common1:
538 read_block(block, ind); /* double indirect */
[821]539 blk_chg = 0;
[2725]540 result = check_zone_nr2(&ind[(blknr / 256) % 256], &blk_chg);
[821]541 if (blk_chg)
[2725]542 write_block(block, ind);
[821]543 block = result;
[2725]544 common2:
545 read_block(block, ind);
[821]546 blk_chg = 0;
[2725]547 result = check_zone_nr2(&ind[blknr % 256], &blk_chg);
[821]548 if (blk_chg)
[2725]549 write_block(block, ind);
[821]550 return result;
551}
552#endif
553
[2725]554static void write_superblock(void)
[821]555{
556 /*
557 * Set the state of the filesystem based on whether or not there
558 * are uncorrected errors. The filesystem valid flag is
559 * unconditionally set if we get this far.
560 */
[1765]561 Super.s_state |= MINIX_VALID_FS | MINIX_ERROR_FS;
562 if (!errors_uncorrected)
[821]563 Super.s_state &= ~MINIX_ERROR_FS;
564
[2725]565 xlseek(dev_fd, BLOCK_SIZE, SEEK_SET);
566 if (BLOCK_SIZE != full_write(dev_fd, superblock_buffer, BLOCK_SIZE))
567 die("can't write superblock");
[821]568}
569
570static void write_tables(void)
571{
[2725]572 write_superblock();
[821]573
[1765]574 if (IMAPS * BLOCK_SIZE != write(dev_fd, inode_map, IMAPS * BLOCK_SIZE))
[2725]575 die("can't write inode map");
[1765]576 if (ZMAPS * BLOCK_SIZE != write(dev_fd, zone_map, ZMAPS * BLOCK_SIZE))
[2725]577 die("can't write zone map");
[1765]578 if (INODE_BUFFER_SIZE != write(dev_fd, inode_buffer, INODE_BUFFER_SIZE))
[2725]579 die("can't write inodes");
[821]580}
581
582static void get_dirsize(void)
583{
584 int block;
585 char blk[BLOCK_SIZE];
586 int size;
587
[1765]588#if ENABLE_FEATURE_MINIX2
[821]589 if (version2)
[1765]590 block = Inode2[MINIX_ROOT_INO].i_zone[0];
[821]591 else
592#endif
[1765]593 block = Inode1[MINIX_ROOT_INO].i_zone[0];
[821]594 read_block(block, blk);
595 for (size = 16; size < BLOCK_SIZE; size <<= 1) {
596 if (strcmp(blk + size + 2, "..") == 0) {
597 dirsize = size;
598 namelen = size - 2;
599 return;
600 }
601 }
602 /* use defaults */
603}
604
605static void read_superblock(void)
606{
[2725]607 xlseek(dev_fd, BLOCK_SIZE, SEEK_SET);
608 if (BLOCK_SIZE != full_read(dev_fd, superblock_buffer, BLOCK_SIZE))
609 die("can't read superblock");
[821]610 /* already initialized to:
611 namelen = 14;
612 dirsize = 16;
613 version2 = 0;
614 */
[1765]615 if (MAGIC == MINIX1_SUPER_MAGIC) {
616 } else if (MAGIC == MINIX1_SUPER_MAGIC2) {
[821]617 namelen = 30;
618 dirsize = 32;
[1765]619#if ENABLE_FEATURE_MINIX2
[821]620 } else if (MAGIC == MINIX2_SUPER_MAGIC) {
621 version2 = 1;
622 } else if (MAGIC == MINIX2_SUPER_MAGIC2) {
623 namelen = 30;
624 dirsize = 32;
625 version2 = 1;
626#endif
627 } else
[2725]628 die("bad magic number in superblock");
[821]629 if (ZONESIZE != 0 || BLOCK_SIZE != 1024)
[1765]630 die("only 1k blocks/zones supported");
[821]631 if (IMAPS * BLOCK_SIZE * 8 < INODES + 1)
[2725]632 die("bad s_imap_blocks field in superblock");
[821]633 if (ZMAPS * BLOCK_SIZE * 8 < ZONES - FIRSTZONE + 1)
[2725]634 die("bad s_zmap_blocks field in superblock");
[821]635}
636
637static void read_tables(void)
638{
639 inode_map = xzalloc(IMAPS * BLOCK_SIZE);
640 zone_map = xzalloc(ZMAPS * BLOCK_SIZE);
641 inode_buffer = xmalloc(INODE_BUFFER_SIZE);
642 inode_count = xmalloc(INODES + 1);
643 zone_count = xmalloc(ZONES);
[1765]644 if (IMAPS * BLOCK_SIZE != read(dev_fd, inode_map, IMAPS * BLOCK_SIZE))
[2725]645 die("can't read inode map");
[1765]646 if (ZMAPS * BLOCK_SIZE != read(dev_fd, zone_map, ZMAPS * BLOCK_SIZE))
[2725]647 die("can't read zone map");
[1765]648 if (INODE_BUFFER_SIZE != read(dev_fd, inode_buffer, INODE_BUFFER_SIZE))
[2725]649 die("can't read inodes");
[821]650 if (NORM_FIRSTZONE != FIRSTZONE) {
[1765]651 printf("warning: firstzone!=norm_firstzone\n");
[821]652 errors_uncorrected = 1;
653 }
654 get_dirsize();
[2725]655 if (OPT_show) {
[1765]656 printf("%u inodes\n"
657 "%u blocks\n"
658 "Firstdatazone=%u (%u)\n"
659 "Zonesize=%u\n"
660 "Maxsize=%u\n"
661 "Filesystem state=%u\n"
662 "namelen=%u\n\n",
[821]663 INODES,
664 ZONES,
665 FIRSTZONE, NORM_FIRSTZONE,
666 BLOCK_SIZE << ZONESIZE,
667 MAXSIZE,
668 Super.s_state,
669 namelen);
670 }
671}
672
[2725]673static void get_inode_common(unsigned nr, uint16_t i_mode)
[821]674{
675 total++;
676 if (!inode_count[nr]) {
677 if (!inode_in_use(nr)) {
678 printf("Inode %d is marked as 'unused', but it is used "
679 "for file '%s'\n", nr, current_name);
[2725]680 if (OPT_repair) {
[821]681 if (ask("Mark as 'in use'", 1))
682 mark_inode(nr);
[1765]683 else
684 errors_uncorrected = 1;
[821]685 }
686 }
[2725]687 if (S_ISDIR(i_mode))
[821]688 directory++;
[2725]689 else if (S_ISREG(i_mode))
[821]690 regular++;
[2725]691 else if (S_ISCHR(i_mode))
[821]692 chardev++;
[2725]693 else if (S_ISBLK(i_mode))
[821]694 blockdev++;
[2725]695 else if (S_ISLNK(i_mode))
[821]696 symlinks++;
[2725]697 else if (S_ISSOCK(i_mode));
698 else if (S_ISFIFO(i_mode));
[821]699 else {
[2725]700 printf("%s has mode %05o\n", current_name, i_mode);
[821]701 }
702 } else
703 links++;
704 if (!++inode_count[nr]) {
705 printf("Warning: inode count too big\n");
706 inode_count[nr]--;
707 errors_uncorrected = 1;
708 }
[2725]709}
710
711static struct minix1_inode *get_inode(unsigned nr)
712{
713 struct minix1_inode *inode;
714
715 if (!nr || nr > INODES)
716 return NULL;
717 inode = Inode1 + nr;
718 get_inode_common(nr, inode->i_mode);
[821]719 return inode;
720}
721
[1765]722#if ENABLE_FEATURE_MINIX2
723static struct minix2_inode *get_inode2(unsigned nr)
[821]724{
725 struct minix2_inode *inode;
726
727 if (!nr || nr > INODES)
728 return NULL;
729 inode = Inode2 + nr;
[2725]730 get_inode_common(nr, inode->i_mode);
[821]731 return inode;
732}
733#endif
734
735static void check_root(void)
736{
[1765]737 struct minix1_inode *inode = Inode1 + MINIX_ROOT_INO;
[821]738
739 if (!inode || !S_ISDIR(inode->i_mode))
[1765]740 die("root inode isn't a directory");
[821]741}
742
[1765]743#if ENABLE_FEATURE_MINIX2
[821]744static void check_root2(void)
745{
[1765]746 struct minix2_inode *inode = Inode2 + MINIX_ROOT_INO;
[821]747
748 if (!inode || !S_ISDIR(inode->i_mode))
[1765]749 die("root inode isn't a directory");
[821]750}
[1765]751#else
752void check_root2(void);
[821]753#endif
754
[2725]755static int add_zone_common(int block, smallint *corrected)
[821]756{
757 if (!block)
758 return 0;
759 if (zone_count[block]) {
760 printf("Already used block is reused in file '%s'. ",
761 current_name);
762 if (ask("Clear", 1)) {
763 block = 0;
764 *corrected = 1;
[2725]765 return -1; /* "please zero out *znr" */
[821]766 }
767 }
768 if (!zone_in_use(block)) {
769 printf("Block %d in file '%s' is marked as 'unused'. ",
770 block, current_name);
771 if (ask("Correct", 1))
772 mark_zone(block);
773 }
774 if (!++zone_count[block])
775 zone_count[block]--;
776 return block;
777}
778
[2725]779static int add_zone(uint16_t *znr, smallint *corrected)
780{
781 int block;
782
783 block = check_zone_nr(znr, corrected);
784 block = add_zone_common(block, corrected);
785 if (block == -1) {
786 *znr = 0;
787 block = 0;
788 }
789 return block;
790}
791
[1765]792#if ENABLE_FEATURE_MINIX2
793static int add_zone2(uint32_t *znr, smallint *corrected)
[821]794{
795 int block;
796
797 block = check_zone_nr2(znr, corrected);
[2725]798 block = add_zone_common(block, corrected);
799 if (block == -1) {
800 *znr = 0;
801 block = 0;
[821]802 }
803 return block;
804}
805#endif
806
[1765]807static void add_zone_ind(uint16_t *znr, smallint *corrected)
[821]808{
[1765]809 int i;
[821]810 int block;
[1765]811 smallint chg_blk = 0;
[821]812
813 block = add_zone(znr, corrected);
814 if (!block)
815 return;
[1765]816 read_block(block, add_zone_ind_blk);
[821]817 for (i = 0; i < (BLOCK_SIZE >> 1); i++)
[1765]818 add_zone(i + (uint16_t *) add_zone_ind_blk, &chg_blk);
[821]819 if (chg_blk)
[1765]820 write_block(block, add_zone_ind_blk);
[821]821}
822
[1765]823#if ENABLE_FEATURE_MINIX2
824static void add_zone_ind2(uint32_t *znr, smallint *corrected)
[821]825{
[1765]826 int i;
[821]827 int block;
[1765]828 smallint chg_blk = 0;
[821]829
830 block = add_zone2(znr, corrected);
831 if (!block)
832 return;
[1765]833 read_block(block, add_zone_ind_blk);
[821]834 for (i = 0; i < BLOCK_SIZE >> 2; i++)
[1765]835 add_zone2(i + (uint32_t *) add_zone_ind_blk, &chg_blk);
[821]836 if (chg_blk)
[1765]837 write_block(block, add_zone_ind_blk);
[821]838}
839#endif
840
[1765]841static void add_zone_dind(uint16_t *znr, smallint *corrected)
[821]842{
[1765]843 int i;
[821]844 int block;
[1765]845 smallint chg_blk = 0;
[821]846
847 block = add_zone(znr, corrected);
848 if (!block)
849 return;
[1765]850 read_block(block, add_zone_dind_blk);
[821]851 for (i = 0; i < (BLOCK_SIZE >> 1); i++)
[1765]852 add_zone_ind(i + (uint16_t *) add_zone_dind_blk, &chg_blk);
853 if (chg_blk)
854 write_block(block, add_zone_dind_blk);
[821]855}
856
[1765]857#if ENABLE_FEATURE_MINIX2
858static void add_zone_dind2(uint32_t *znr, smallint *corrected)
[821]859{
[1765]860 int i;
[821]861 int block;
[1765]862 smallint chg_blk = 0;
[821]863
864 block = add_zone2(znr, corrected);
865 if (!block)
866 return;
[1765]867 read_block(block, add_zone_dind_blk);
[821]868 for (i = 0; i < BLOCK_SIZE >> 2; i++)
[1765]869 add_zone_ind2(i + (uint32_t *) add_zone_dind_blk, &chg_blk);
870 if (chg_blk)
871 write_block(block, add_zone_dind_blk);
[821]872}
873
[1765]874static void add_zone_tind2(uint32_t *znr, smallint *corrected)
[821]875{
[1765]876 int i;
[821]877 int block;
[1765]878 smallint chg_blk = 0;
[821]879
880 block = add_zone2(znr, corrected);
881 if (!block)
882 return;
[1765]883 read_block(block, add_zone_tind_blk);
[821]884 for (i = 0; i < BLOCK_SIZE >> 2; i++)
[1765]885 add_zone_dind2(i + (uint32_t *) add_zone_tind_blk, &chg_blk);
886 if (chg_blk)
887 write_block(block, add_zone_tind_blk);
[821]888}
889#endif
890
[1765]891static void check_zones(unsigned i)
[821]892{
[1765]893 struct minix1_inode *inode;
[821]894
895 if (!i || i > INODES)
896 return;
897 if (inode_count[i] > 1) /* have we counted this file already? */
898 return;
[1765]899 inode = Inode1 + i;
[2725]900 if (!S_ISDIR(inode->i_mode)
901 && !S_ISREG(inode->i_mode)
902 && !S_ISLNK(inode->i_mode)
903 ) {
904 return;
905 }
[821]906 for (i = 0; i < 7; i++)
907 add_zone(i + inode->i_zone, &changed);
908 add_zone_ind(7 + inode->i_zone, &changed);
909 add_zone_dind(8 + inode->i_zone, &changed);
910}
911
[1765]912#if ENABLE_FEATURE_MINIX2
913static void check_zones2(unsigned i)
[821]914{
915 struct minix2_inode *inode;
916
917 if (!i || i > INODES)
918 return;
919 if (inode_count[i] > 1) /* have we counted this file already? */
920 return;
921 inode = Inode2 + i;
922 if (!S_ISDIR(inode->i_mode) && !S_ISREG(inode->i_mode)
923 && !S_ISLNK(inode->i_mode))
924 return;
925 for (i = 0; i < 7; i++)
926 add_zone2(i + inode->i_zone, &changed);
927 add_zone_ind2(7 + inode->i_zone, &changed);
928 add_zone_dind2(8 + inode->i_zone, &changed);
929 add_zone_tind2(9 + inode->i_zone, &changed);
930}
931#endif
932
[1765]933static void check_file(struct minix1_inode *dir, unsigned offset)
[821]934{
[1765]935 struct minix1_inode *inode;
[821]936 int ino;
937 char *name;
938 int block;
939
940 block = map_block(dir, offset / BLOCK_SIZE);
[1765]941 read_block(block, check_file_blk);
942 name = check_file_blk + (offset % BLOCK_SIZE) + 2;
[821]943 ino = *(uint16_t *) (name - 2);
944 if (ino > INODES) {
945 printf("%s contains a bad inode number for file '%.*s'. ",
946 current_name, namelen, name);
947 if (ask("Remove", 1)) {
948 *(uint16_t *) (name - 2) = 0;
[1765]949 write_block(block, check_file_blk);
[821]950 }
951 ino = 0;
952 }
953 push_filename(name);
954 inode = get_inode(ino);
955 pop_filename();
956 if (!offset) {
[1765]957 if (inode && LONE_CHAR(name, '.'))
[821]958 return;
[1765]959 printf("%s: bad directory: '.' isn't first\n", current_name);
960 errors_uncorrected = 1;
[821]961 }
962 if (offset == dirsize) {
[1765]963 if (inode && strcmp("..", name) == 0)
[821]964 return;
[1765]965 printf("%s: bad directory: '..' isn't second\n", current_name);
966 errors_uncorrected = 1;
[821]967 }
968 if (!inode)
969 return;
970 push_filename(name);
[2725]971 if (OPT_list) {
972 if (OPT_verbose)
[821]973 printf("%6d %07o %3d ", ino, inode->i_mode, inode->i_nlinks);
974 printf("%s%s\n", current_name, S_ISDIR(inode->i_mode) ? ":" : "");
975 }
976 check_zones(ino);
977 if (inode && S_ISDIR(inode->i_mode))
978 recursive_check(ino);
979 pop_filename();
980}
981
[1765]982#if ENABLE_FEATURE_MINIX2
983static void check_file2(struct minix2_inode *dir, unsigned offset)
[821]984{
985 struct minix2_inode *inode;
986 int ino;
987 char *name;
988 int block;
989
990 block = map_block2(dir, offset / BLOCK_SIZE);
[1765]991 read_block(block, check_file_blk);
992 name = check_file_blk + (offset % BLOCK_SIZE) + 2;
[821]993 ino = *(uint16_t *) (name - 2);
994 if (ino > INODES) {
995 printf("%s contains a bad inode number for file '%.*s'. ",
996 current_name, namelen, name);
997 if (ask("Remove", 1)) {
998 *(uint16_t *) (name - 2) = 0;
[1765]999 write_block(block, check_file_blk);
[821]1000 }
1001 ino = 0;
1002 }
1003 push_filename(name);
1004 inode = get_inode2(ino);
1005 pop_filename();
1006 if (!offset) {
[1765]1007 if (inode && LONE_CHAR(name, '.'))
[821]1008 return;
[1765]1009 printf("%s: bad directory: '.' isn't first\n", current_name);
1010 errors_uncorrected = 1;
[821]1011 }
1012 if (offset == dirsize) {
[1765]1013 if (inode && strcmp("..", name) == 0)
[821]1014 return;
[1765]1015 printf("%s: bad directory: '..' isn't second\n", current_name);
1016 errors_uncorrected = 1;
[821]1017 }
1018 if (!inode)
1019 return;
1020 push_filename(name);
[2725]1021 if (OPT_list) {
1022 if (OPT_verbose)
[821]1023 printf("%6d %07o %3d ", ino, inode->i_mode, inode->i_nlinks);
1024 printf("%s%s\n", current_name, S_ISDIR(inode->i_mode) ? ":" : "");
1025 }
1026 check_zones2(ino);
1027 if (inode && S_ISDIR(inode->i_mode))
1028 recursive_check2(ino);
1029 pop_filename();
1030}
1031#endif
1032
[1765]1033static void recursive_check(unsigned ino)
[821]1034{
[1765]1035 struct minix1_inode *dir;
1036 unsigned offset;
[821]1037
[1765]1038 dir = Inode1 + ino;
[821]1039 if (!S_ISDIR(dir->i_mode))
[1765]1040 die("internal error");
[821]1041 if (dir->i_size < 2 * dirsize) {
1042 printf("%s: bad directory: size<32", current_name);
1043 errors_uncorrected = 1;
1044 }
1045 for (offset = 0; offset < dir->i_size; offset += dirsize)
1046 check_file(dir, offset);
1047}
1048
[1765]1049#if ENABLE_FEATURE_MINIX2
1050static void recursive_check2(unsigned ino)
[821]1051{
1052 struct minix2_inode *dir;
[1765]1053 unsigned offset;
[821]1054
1055 dir = Inode2 + ino;
1056 if (!S_ISDIR(dir->i_mode))
[1765]1057 die("internal error");
[821]1058 if (dir->i_size < 2 * dirsize) {
1059 printf("%s: bad directory: size<32", current_name);
1060 errors_uncorrected = 1;
1061 }
1062 for (offset = 0; offset < dir->i_size; offset += dirsize)
1063 check_file2(dir, offset);
1064}
1065#endif
1066
1067static int bad_zone(int i)
1068{
[1765]1069 char buffer[BLOCK_SIZE];
[821]1070
[2725]1071 xlseek(dev_fd, BLOCK_SIZE * i, SEEK_SET);
1072 return (BLOCK_SIZE != full_read(dev_fd, buffer, BLOCK_SIZE));
[821]1073}
1074
1075static void check_counts(void)
1076{
1077 int i;
1078
1079 for (i = 1; i <= INODES; i++) {
[2725]1080 if (OPT_warn_mode && Inode1[i].i_mode && !inode_in_use(i)) {
[821]1081 printf("Inode %d has non-zero mode. ", i);
1082 if (ask("Clear", 1)) {
[1765]1083 Inode1[i].i_mode = 0;
[821]1084 changed = 1;
1085 }
1086 }
1087 if (!inode_count[i]) {
1088 if (!inode_in_use(i))
1089 continue;
1090 printf("Unused inode %d is marked as 'used' in the bitmap. ", i);
1091 if (ask("Clear", 1))
1092 unmark_inode(i);
1093 continue;
1094 }
1095 if (!inode_in_use(i)) {
1096 printf("Inode %d is used, but marked as 'unused' in the bitmap. ", i);
1097 if (ask("Set", 1))
1098 mark_inode(i);
1099 }
[1765]1100 if (Inode1[i].i_nlinks != inode_count[i]) {
[821]1101 printf("Inode %d (mode=%07o), i_nlinks=%d, counted=%d. ",
[1765]1102 i, Inode1[i].i_mode, Inode1[i].i_nlinks,
1103 inode_count[i]);
[821]1104 if (ask("Set i_nlinks to count", 1)) {
[1765]1105 Inode1[i].i_nlinks = inode_count[i];
[821]1106 changed = 1;
1107 }
1108 }
1109 }
1110 for (i = FIRSTZONE; i < ZONES; i++) {
[1765]1111 if ((zone_in_use(i) != 0) == zone_count[i])
[821]1112 continue;
1113 if (!zone_count[i]) {
1114 if (bad_zone(i))
1115 continue;
1116 printf("Zone %d is marked 'in use', but no file uses it. ", i);
1117 if (ask("Unmark", 1))
1118 unmark_zone(i);
1119 continue;
1120 }
1121 printf("Zone %d: %sin use, counted=%d\n",
1122 i, zone_in_use(i) ? "" : "not ", zone_count[i]);
1123 }
1124}
1125
[1765]1126#if ENABLE_FEATURE_MINIX2
[821]1127static void check_counts2(void)
1128{
1129 int i;
1130
1131 for (i = 1; i <= INODES; i++) {
[2725]1132 if (OPT_warn_mode && Inode2[i].i_mode && !inode_in_use(i)) {
[821]1133 printf("Inode %d has non-zero mode. ", i);
1134 if (ask("Clear", 1)) {
1135 Inode2[i].i_mode = 0;
1136 changed = 1;
1137 }
1138 }
1139 if (!inode_count[i]) {
1140 if (!inode_in_use(i))
1141 continue;
1142 printf("Unused inode %d is marked as 'used' in the bitmap. ", i);
1143 if (ask("Clear", 1))
1144 unmark_inode(i);
1145 continue;
1146 }
1147 if (!inode_in_use(i)) {
1148 printf("Inode %d is used, but marked as 'unused' in the bitmap. ", i);
1149 if (ask("Set", 1))
1150 mark_inode(i);
1151 }
1152 if (Inode2[i].i_nlinks != inode_count[i]) {
1153 printf("Inode %d (mode=%07o), i_nlinks=%d, counted=%d. ",
[1765]1154 i, Inode2[i].i_mode, Inode2[i].i_nlinks,
1155 inode_count[i]);
[821]1156 if (ask("Set i_nlinks to count", 1)) {
1157 Inode2[i].i_nlinks = inode_count[i];
1158 changed = 1;
1159 }
1160 }
1161 }
1162 for (i = FIRSTZONE; i < ZONES; i++) {
[1765]1163 if ((zone_in_use(i) != 0) == zone_count[i])
[821]1164 continue;
1165 if (!zone_count[i]) {
1166 if (bad_zone(i))
1167 continue;
1168 printf("Zone %d is marked 'in use', but no file uses it. ", i);
1169 if (ask("Unmark", 1))
1170 unmark_zone(i);
1171 continue;
1172 }
1173 printf("Zone %d: %sin use, counted=%d\n",
1174 i, zone_in_use(i) ? "" : "not ", zone_count[i]);
1175 }
1176}
1177#endif
1178
1179static void check(void)
1180{
1181 memset(inode_count, 0, (INODES + 1) * sizeof(*inode_count));
1182 memset(zone_count, 0, ZONES * sizeof(*zone_count));
[1765]1183 check_zones(MINIX_ROOT_INO);
1184 recursive_check(MINIX_ROOT_INO);
[821]1185 check_counts();
1186}
1187
[1765]1188#if ENABLE_FEATURE_MINIX2
[821]1189static void check2(void)
1190{
1191 memset(inode_count, 0, (INODES + 1) * sizeof(*inode_count));
1192 memset(zone_count, 0, ZONES * sizeof(*zone_count));
[1765]1193 check_zones2(MINIX_ROOT_INO);
1194 recursive_check2(MINIX_ROOT_INO);
[821]1195 check_counts2();
1196}
[1765]1197#else
1198void check2(void);
[821]1199#endif
1200
[2725]1201int fsck_minix_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
1202int fsck_minix_main(int argc UNUSED_PARAM, char **argv)
[821]1203{
1204 struct termios tmp;
1205 int retcode = 0;
1206
[1765]1207 xfunc_error_retval = 8;
[821]1208
[1765]1209 INIT_G();
1210
[2725]1211 opt_complementary = "=1:ar"; /* one argument; -a assumes -r */
1212 getopt32(argv, OPTION_STR);
1213 argv += optind;
1214 device_name = argv[0];
[1765]1215
[2725]1216 check_mount(); /* trying to check a mounted filesystem? */
1217 if (OPT_manual) {
[821]1218 if (!isatty(0) || !isatty(1))
[1765]1219 die("need terminal for interactive repairs");
[821]1220 }
[2725]1221 xmove_fd(xopen(device_name, OPT_repair ? O_RDWR : O_RDONLY), dev_fd);
[1765]1222
1223 /*sync(); paranoia? */
[821]1224 read_superblock();
1225
1226 /*
1227 * Determine whether or not we should continue with the checking.
1228 * This is based on the status of the filesystem valid and error
1229 * flags and whether or not the -f switch was specified on the
1230 * command line.
1231 */
[1765]1232 printf("%s: %s\n", applet_name, bb_banner);
1233
1234 if (!(Super.s_state & MINIX_ERROR_FS)
[2725]1235 && (Super.s_state & MINIX_VALID_FS) && !OPT_force
[1765]1236 ) {
[2725]1237 if (OPT_repair)
[821]1238 printf("%s is clean, check is skipped\n", device_name);
[1765]1239 return 0;
[2725]1240 } else if (OPT_force)
[821]1241 printf("Forcing filesystem check on %s\n", device_name);
[2725]1242 else if (OPT_repair)
[821]1243 printf("Filesystem on %s is dirty, needs checking\n",
1244 device_name);
1245
1246 read_tables();
1247
[2725]1248 if (OPT_manual) {
[1765]1249 tcgetattr(0, &sv_termios);
1250 tmp = sv_termios;
[821]1251 tmp.c_lflag &= ~(ICANON | ECHO);
[2725]1252 tcsetattr_stdin_TCSANOW(&tmp);
[821]1253 termios_set = 1;
1254 }
[1765]1255
[821]1256 if (version2) {
1257 check_root2();
1258 check2();
[1765]1259 } else {
[821]1260 check_root();
1261 check();
1262 }
[1765]1263
[2725]1264 if (OPT_verbose) {
[821]1265 int i, free_cnt;
1266
1267 for (i = 1, free_cnt = 0; i <= INODES; i++)
1268 if (!inode_in_use(i))
1269 free_cnt++;
[1765]1270 printf("\n%6u inodes used (%u%%)\n", (INODES - free_cnt),
[821]1271 100 * (INODES - free_cnt) / INODES);
1272 for (i = FIRSTZONE, free_cnt = 0; i < ZONES; i++)
1273 if (!zone_in_use(i))
1274 free_cnt++;
[1765]1275 printf("%6u zones used (%u%%)\n\n"
1276 "%6u regular files\n"
1277 "%6u directories\n"
1278 "%6u character device files\n"
1279 "%6u block device files\n"
1280 "%6u links\n"
1281 "%6u symbolic links\n"
[821]1282 "------\n"
[1765]1283 "%6u files\n",
[821]1284 (ZONES - free_cnt), 100 * (ZONES - free_cnt) / ZONES,
1285 regular, directory, chardev, blockdev,
1286 links - 2 * directory + 1, symlinks,
1287 total - 2 * directory + 1);
1288 }
1289 if (changed) {
1290 write_tables();
1291 printf("FILE SYSTEM HAS BEEN CHANGED\n");
1292 sync();
[2725]1293 } else if (OPT_repair)
1294 write_superblock();
[821]1295
[2725]1296 if (OPT_manual)
1297 tcsetattr_stdin_TCSANOW(&sv_termios);
[821]1298
1299 if (changed)
1300 retcode += 3;
1301 if (errors_uncorrected)
1302 retcode += 4;
1303 return retcode;
1304}
Note: See TracBrowser for help on using the repository browser.