-#define INODE_BUFFER_SIZE (INODE_BLOCKS * BLOCK_SIZE)
-
-#define BITS_PER_BLOCK (BLOCK_SIZE<<3)
-
-static char * program_name = "fsck.minix";
-static char * program_version = "1.2 - 11/11/96";
-static char * device_name = NULL;
-static int IN;
-static int repair=0, automatic=0, verbose=0, list=0, show=0, warn_mode=0,
- force=0;
-static int directory=0, regular=0, blockdev=0, chardev=0, links=0,
- symlinks=0, total=0;
-
-static int changed = 0; /* flags if the filesystem has been changed */
-static int errors_uncorrected = 0; /* flag if some error was not corrected */
-static int dirsize = 16;
-static int namelen = 14;
-static int version2 = 0;
-static struct termios termios;
-static int termios_set = 0;
-
-/* File-name data */
-#define MAX_DEPTH 50
-static int name_depth = 0;
-static char name_list[MAX_DEPTH][PATH_MAX + 1];
-
-static char * inode_buffer = NULL;
-#define Inode (((struct minix_inode *) inode_buffer)-1)
+ smallint changed; /* is filesystem modified? */
+ smallint errors_uncorrected; /* flag if some error was not corrected */
+ smallint termios_set;
+ smallint dirsize;
+ smallint namelen;
+ const char *device_name;
+ int directory, regular, blockdev, chardev, links, symlinks, total;
+ char *inode_buffer;
+
+ char *inode_map;
+ char *zone_map;
+
+ unsigned char *inode_count;
+ unsigned char *zone_count;
+
+ /* File-name data */
+ int name_depth;
+ char *name_component[MAX_DEPTH+1];
+
+ /* Bigger stuff */
+ struct termios sv_termios;
+ char superblock_buffer[BLOCK_SIZE];
+ char add_zone_ind_blk[BLOCK_SIZE];
+ char add_zone_dind_blk[BLOCK_SIZE];
+ USE_FEATURE_MINIX2(char add_zone_tind_blk[BLOCK_SIZE];)
+ char check_file_blk[BLOCK_SIZE];
+
+ /* File-name data */
+ char current_name[MAX_DEPTH * MINIX_NAME_MAX];
+};
+
+#define G (*ptr_to_globals)
+#if ENABLE_FEATURE_MINIX2
+#define version2 (G.version2 )
+#endif
+#define changed (G.changed )
+#define errors_uncorrected (G.errors_uncorrected )
+#define termios_set (G.termios_set )
+#define dirsize (G.dirsize )
+#define namelen (G.namelen )
+#define device_name (G.device_name )
+#define directory (G.directory )
+#define regular (G.regular )
+#define blockdev (G.blockdev )
+#define chardev (G.chardev )
+#define links (G.links )
+#define symlinks (G.symlinks )
+#define total (G.total )
+#define inode_buffer (G.inode_buffer )
+#define inode_map (G.inode_map )
+#define zone_map (G.zone_map )
+#define inode_count (G.inode_count )
+#define zone_count (G.zone_count )
+#define name_depth (G.name_depth )
+#define name_component (G.name_component )
+#define sv_termios (G.sv_termios )
+#define superblock_buffer (G.superblock_buffer )
+#define add_zone_ind_blk (G.add_zone_ind_blk )
+#define add_zone_dind_blk (G.add_zone_dind_blk )
+#define add_zone_tind_blk (G.add_zone_tind_blk )
+#define check_file_blk (G.check_file_blk )
+#define current_name (G.current_name )
+#define INIT_G() do { \
+ SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
+ dirsize = 16; \
+ namelen = 14; \
+ current_name[0] = '/'; \
+ /*current_name[1] = '\0';*/ \
+ name_component[0] = ¤t_name[0]; \
+} while (0)
+
+
+#define OPTION_STR "larvsmf"
+enum {
+ OPT_l = (1 << 0),
+ OPT_a = (1 << 1),
+ OPT_r = (1 << 2),
+ OPT_v = (1 << 3),
+ OPT_s = (1 << 4),
+ OPT_w = (1 << 5),
+ OPT_f = (1 << 6),
+};
+#define OPT_list (option_mask32 & OPT_l)
+#define OPT_automatic (option_mask32 & OPT_a)
+#define OPT_repair (option_mask32 & OPT_r)
+#define OPT_verbose (option_mask32 & OPT_v)
+#define OPT_show (option_mask32 & OPT_s)
+#define OPT_warn_mode (option_mask32 & OPT_w)
+#define OPT_force (option_mask32 & OPT_f)
+/* non-automatic repairs requested? */
+#define OPT_manual ((option_mask32 & (OPT_a|OPT_r)) == OPT_r)
+
+
+#define Inode1 (((struct minix1_inode *) inode_buffer)-1)