* enforced (but it's not much fun on a character device :-).
*/
-#include "internal.h"
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <termios.h>
#include <mntent.h>
#include <sys/param.h>
+#include "busybox.h"
typedef unsigned char u8;
typedef unsigned int u32;
-#define MINIX_ROOT_INO 1
-#define MINIX_LINK_MAX 250
-#define MINIX2_LINK_MAX 65530
+static const int MINIX_ROOT_INO = 1;
+static const int MINIX_LINK_MAX = 250;
+static const int MINIX2_LINK_MAX = 65530;
-#define MINIX_I_MAP_SLOTS 8
-#define MINIX_Z_MAP_SLOTS 64
-#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
-#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
-#define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 fs */
-#define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2 fs, 30 char names */
-#define MINIX_VALID_FS 0x0001 /* Clean fs. */
-#define MINIX_ERROR_FS 0x0002 /* fs has errors. */
+static const int MINIX_I_MAP_SLOTS = 8;
+static const int MINIX_Z_MAP_SLOTS = 64;
+static const int MINIX_SUPER_MAGIC = 0x137F; /* original minix fs */
+static const int MINIX_SUPER_MAGIC2 = 0x138F; /* minix fs, 30 char names */
+static const int MINIX2_SUPER_MAGIC = 0x2468; /* minix V2 fs */
+static const int MINIX2_SUPER_MAGIC2 = 0x2478; /* minix V2 fs, 30 char names */
+static const int MINIX_VALID_FS = 0x0001; /* Clean fs. */
+static const int MINIX_ERROR_FS = 0x0002; /* fs has errors. */
#define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode)))
#define MINIX2_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix2_inode)))
-#define MINIX_V1 0x0001 /* original minix fs */
-#define MINIX_V2 0x0002 /* minix V2 fs */
+static const int MINIX_V1 = 0x0001; /* original minix fs */
+static const int MINIX_V2 = 0x0002; /* minix V2 fs */
#define INODE_VERSION(inode) inode->i_sb->u.minix_sb.s_version
#define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode)))
-#define MINIX_VALID_FS 0x0001 /* Clean fs. */
-#define MINIX_ERROR_FS 0x0002 /* fs has errors. */
-
-#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
-#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
-
#ifndef BLKGETSIZE
#define BLKGETSIZE _IO(0x12,96) /* return device size */
#endif
#define volatile
#endif
-#define ROOT_INO 1
+static const int ROOT_INO = 1;
#define UPPER(size,n) ((size+((n)-1))/(n))
#define INODE_SIZE (sizeof(struct minix_inode))
static int termios_set = 0;
/* File-name data */
-#define MAX_DEPTH 32
+static const int MAX_DEPTH = 32;
static int name_depth = 0;
// static char name_list[MAX_DEPTH][BUFSIZ + 1];
static char **name_list = NULL;
exit(status);
}
-static void show_usage(void)
-{
- usage(fsck_minix_usage);
-}
-
static void die(const char *str)
{
- errorMsg("%s\n", str);
+ error_msg("%s", str);
leave(8);
}
}
}
-struct minix_inode *get_inode(unsigned int nr)
+static struct minix_inode *get_inode(unsigned int nr)
{
struct minix_inode *inode;
}
#ifdef BB_FEATURE_MINIX2
-struct minix2_inode *get_inode2(unsigned int nr)
+static struct minix2_inode *get_inode2(unsigned int nr)
{
struct minix2_inode *inode;
die("need terminal for interactive repairs");
}
IN = open(device_name, repair ? O_RDWR : O_RDONLY);
- if (IN < 0)
- die("unable to open '%s'");
+ if (IN < 0){
+ fprintf(stderr,"unable to open device '%s'.\n",device_name);
+ leave(8);
+ }
for (count = 0; count < 3; count++)
sync();
read_superblock();
check();
}
if (verbose) {
- int i, free;
+ int i, free_cnt;
- for (i = 1, free = 0; i <= INODES; i++)
+ for (i = 1, free_cnt = 0; i <= INODES; i++)
if (!inode_in_use(i))
- free++;
- printf("\n%6ld inodes used (%ld%%)\n", (INODES - free),
- 100 * (INODES - free) / INODES);
- for (i = FIRSTZONE, free = 0; i < ZONES; i++)
+ free_cnt++;
+ printf("\n%6ld inodes used (%ld%%)\n", (INODES - free_cnt),
+ 100 * (INODES - free_cnt) / INODES);
+ for (i = FIRSTZONE, free_cnt = 0; i < ZONES; i++)
if (!zone_in_use(i))
- free++;
- printf("%6ld zones used (%ld%%)\n", (ZONES - free),
- 100 * (ZONES - free) / ZONES);
+ free_cnt++;
+ printf("%6ld zones used (%ld%%)\n", (ZONES - free_cnt),
+ 100 * (ZONES - free_cnt) / ZONES);
printf("\n%6d regular files\n"
"%6d directories\n"
"%6d character device files\n"