Patch from Denis Vlasenko:
* Do not initialize globals to 0, it is done automatically * unsigned short -> uint16_t, unsigned int -> uint32_t where appropriate (did it ever work on Alphas?) * triple sync() is silly - removed * check_zone_nr uses check_zone_nr2 now * remove trailing periods from messages, uppercase first letter
This commit is contained in:
parent
9950cab8e0
commit
8a6254994c
@ -206,28 +206,26 @@ enum { ROOT_INO = 1 };
|
|||||||
#define BITS_PER_BLOCK (BLOCK_SIZE<<3)
|
#define BITS_PER_BLOCK (BLOCK_SIZE<<3)
|
||||||
|
|
||||||
static char *program_version = "1.2 - 11/11/96";
|
static char *program_version = "1.2 - 11/11/96";
|
||||||
static char *device_name = NULL;
|
static char *device_name;
|
||||||
static int IN;
|
static int IN;
|
||||||
static int repair = 0, automatic = 0, verbose = 0, list = 0, show =
|
static int repair, automatic, verbose, list, show, warn_mode, force;
|
||||||
0, warn_mode = 0, force = 0;
|
static int directory, regular, blockdev, chardev, links, symlinks, total;
|
||||||
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 changed; /* flags if the filesystem has been changed */
|
||||||
static int errors_uncorrected = 0; /* flag if some error was not corrected */
|
static int errors_uncorrected; /* flag if some error was not corrected */
|
||||||
static int dirsize = 16;
|
static int dirsize = 16;
|
||||||
static int namelen = 14;
|
static int namelen = 14;
|
||||||
static int version2 = 0;
|
static int version2;
|
||||||
static struct termios termios;
|
static struct termios termios;
|
||||||
static int termios_set = 0;
|
static int termios_set;
|
||||||
|
|
||||||
/* File-name data */
|
/* File-name data */
|
||||||
enum { MAX_DEPTH = 32 };
|
enum { MAX_DEPTH = 32 };
|
||||||
static int name_depth = 0;
|
static int name_depth;
|
||||||
// static char name_list[MAX_DEPTH][BUFSIZ + 1];
|
// static char name_list[MAX_DEPTH][BUFSIZ + 1];
|
||||||
static char **name_list = NULL;
|
static char **name_list;
|
||||||
|
|
||||||
static char *inode_buffer = NULL;
|
static char *inode_buffer;
|
||||||
|
|
||||||
#define Inode (((struct minix_inode *) inode_buffer)-1)
|
#define Inode (((struct minix_inode *) inode_buffer)-1)
|
||||||
#define Inode2 (((struct minix2_inode *) inode_buffer)-1)
|
#define Inode2 (((struct minix2_inode *) inode_buffer)-1)
|
||||||
@ -251,8 +249,8 @@ static char super_block_buffer[BLOCK_SIZE];
|
|||||||
static char *inode_map;
|
static char *inode_map;
|
||||||
static char *zone_map;
|
static char *zone_map;
|
||||||
|
|
||||||
static unsigned char *inode_count = NULL;
|
static unsigned char *inode_count;
|
||||||
static unsigned char *zone_count = NULL;
|
static unsigned char *zone_count;
|
||||||
|
|
||||||
static void recursive_check(unsigned int ino);
|
static void recursive_check(unsigned int ino);
|
||||||
#ifdef CONFIG_FEATURE_MINIX2
|
#ifdef CONFIG_FEATURE_MINIX2
|
||||||
@ -375,12 +373,11 @@ static void check_mount(void)
|
|||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
printf("%s is mounted. ", device_name);
|
printf("%s is mounted. ", device_name);
|
||||||
|
cont = 0;
|
||||||
if (isatty(0) && isatty(1))
|
if (isatty(0) && isatty(1))
|
||||||
cont = ask("Do you really want to continue", 0);
|
cont = ask("Do you really want to continue", 0);
|
||||||
else
|
|
||||||
cont = 0;
|
|
||||||
if (!cont) {
|
if (!cont) {
|
||||||
printf("check aborted.\n");
|
printf("Check aborted\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -392,7 +389,7 @@ static void check_mount(void)
|
|||||||
* if an error was corrected, and returns the zone (0 for no zone
|
* if an error was corrected, and returns the zone (0 for no zone
|
||||||
* or a bad zone-number).
|
* or a bad zone-number).
|
||||||
*/
|
*/
|
||||||
static int check_zone_nr(unsigned short *nr, int *corrected)
|
static int check_zone_nr2(uint32_t *nr, int *corrected)
|
||||||
{
|
{
|
||||||
if (!*nr)
|
if (!*nr)
|
||||||
return 0;
|
return 0;
|
||||||
@ -411,26 +408,13 @@ static int check_zone_nr(unsigned short *nr, int *corrected)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_MINIX2
|
static int check_zone_nr(uint16_t *nr, int *corrected)
|
||||||
static int check_zone_nr2(unsigned int *nr, int *corrected)
|
|
||||||
{
|
{
|
||||||
if (!*nr)
|
uint32_t nr32 = *nr;
|
||||||
return 0;
|
int r = check_zone_nr2(&nr32, corrected);
|
||||||
if (*nr < FIRSTZONE)
|
*nr = (uint16_t)nr32;
|
||||||
printf("Zone nr < FIRSTZONE in file `");
|
return r;
|
||||||
else if (*nr >= ZONES)
|
|
||||||
printf("Zone nr >= ZONES in file `");
|
|
||||||
else
|
|
||||||
return *nr;
|
|
||||||
print_current_name();
|
|
||||||
printf("'.");
|
|
||||||
if (ask("Remove block", 1)) {
|
|
||||||
*nr = 0;
|
|
||||||
*corrected = 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* read-block reads block nr into the buffer at addr.
|
* read-block reads block nr into the buffer at addr.
|
||||||
@ -445,14 +429,14 @@ static void read_block(unsigned int nr, char *addr)
|
|||||||
printf("Read error: unable to seek to block in file '");
|
printf("Read error: unable to seek to block in file '");
|
||||||
print_current_name();
|
print_current_name();
|
||||||
printf("'\n");
|
printf("'\n");
|
||||||
memset(addr, 0, BLOCK_SIZE);
|
|
||||||
errors_uncorrected = 1;
|
errors_uncorrected = 1;
|
||||||
|
memset(addr, 0, BLOCK_SIZE);
|
||||||
} else if (BLOCK_SIZE != read(IN, addr, BLOCK_SIZE)) {
|
} else if (BLOCK_SIZE != read(IN, addr, BLOCK_SIZE)) {
|
||||||
printf("Read error: bad block in file '");
|
printf("Read error: bad block in file '");
|
||||||
print_current_name();
|
print_current_name();
|
||||||
printf("'\n");
|
printf("'\n");
|
||||||
memset(addr, 0, BLOCK_SIZE);
|
|
||||||
errors_uncorrected = 1;
|
errors_uncorrected = 1;
|
||||||
|
memset(addr, 0, BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,14 +464,14 @@ static void write_block(unsigned int nr, char *addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* map-block calculates the absolute block nr of a block in a file.
|
* map_block calculates the absolute block nr of a block in a file.
|
||||||
* It sets 'changed' if the inode has needed changing, and re-writes
|
* It sets 'changed' if the inode has needed changing, and re-writes
|
||||||
* any indirect blocks with errors.
|
* any indirect blocks with errors.
|
||||||
*/
|
*/
|
||||||
static int map_block(struct minix_inode *inode, unsigned int blknr)
|
static int map_block(struct minix_inode *inode, unsigned int blknr)
|
||||||
{
|
{
|
||||||
unsigned short ind[BLOCK_SIZE >> 1];
|
uint16_t ind[BLOCK_SIZE >> 1];
|
||||||
unsigned short dind[BLOCK_SIZE >> 1];
|
uint16_t dind[BLOCK_SIZE >> 1];
|
||||||
int blk_chg, block, result;
|
int blk_chg, block, result;
|
||||||
|
|
||||||
if (blknr < 7)
|
if (blknr < 7)
|
||||||
@ -521,9 +505,9 @@ static int map_block(struct minix_inode *inode, unsigned int blknr)
|
|||||||
#ifdef CONFIG_FEATURE_MINIX2
|
#ifdef CONFIG_FEATURE_MINIX2
|
||||||
static int map_block2(struct minix2_inode *inode, unsigned int blknr)
|
static int map_block2(struct minix2_inode *inode, unsigned int blknr)
|
||||||
{
|
{
|
||||||
unsigned int ind[BLOCK_SIZE >> 2];
|
uint32_t ind[BLOCK_SIZE >> 2];
|
||||||
unsigned int dind[BLOCK_SIZE >> 2];
|
uint32_t dind[BLOCK_SIZE >> 2];
|
||||||
unsigned int tind[BLOCK_SIZE >> 2];
|
uint32_t tind[BLOCK_SIZE >> 2];
|
||||||
int blk_chg, block, result;
|
int blk_chg, block, result;
|
||||||
|
|
||||||
if (blknr < 7)
|
if (blknr < 7)
|
||||||
@ -594,8 +578,6 @@ static void write_super_block(void)
|
|||||||
die("seek failed in write_super_block");
|
die("seek failed in write_super_block");
|
||||||
if (BLOCK_SIZE != write(IN, super_block_buffer, BLOCK_SIZE))
|
if (BLOCK_SIZE != write(IN, super_block_buffer, BLOCK_SIZE))
|
||||||
die("unable to write super-block");
|
die("unable to write super-block");
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_tables(void)
|
static void write_tables(void)
|
||||||
@ -639,18 +621,15 @@ static void read_superblock(void)
|
|||||||
die("seek failed");
|
die("seek failed");
|
||||||
if (BLOCK_SIZE != read(IN, super_block_buffer, BLOCK_SIZE))
|
if (BLOCK_SIZE != read(IN, super_block_buffer, BLOCK_SIZE))
|
||||||
die("unable to read super block");
|
die("unable to read super block");
|
||||||
if (MAGIC == MINIX_SUPER_MAGIC) {
|
|
||||||
namelen = 14;
|
namelen = 14;
|
||||||
dirsize = 16;
|
dirsize = 16;
|
||||||
version2 = 0;
|
version2 = 0;
|
||||||
|
if (MAGIC == MINIX_SUPER_MAGIC) {
|
||||||
} else if (MAGIC == MINIX_SUPER_MAGIC2) {
|
} else if (MAGIC == MINIX_SUPER_MAGIC2) {
|
||||||
namelen = 30;
|
namelen = 30;
|
||||||
dirsize = 32;
|
dirsize = 32;
|
||||||
version2 = 0;
|
|
||||||
#ifdef CONFIG_FEATURE_MINIX2
|
#ifdef CONFIG_FEATURE_MINIX2
|
||||||
} else if (MAGIC == MINIX2_SUPER_MAGIC) {
|
} else if (MAGIC == MINIX2_SUPER_MAGIC) {
|
||||||
namelen = 14;
|
|
||||||
dirsize = 16;
|
|
||||||
version2 = 1;
|
version2 = 1;
|
||||||
} else if (MAGIC == MINIX2_SUPER_MAGIC2) {
|
} else if (MAGIC == MINIX2_SUPER_MAGIC2) {
|
||||||
namelen = 30;
|
namelen = 30;
|
||||||
@ -688,13 +667,20 @@ static void read_tables(void)
|
|||||||
}
|
}
|
||||||
get_dirsize();
|
get_dirsize();
|
||||||
if (show) {
|
if (show) {
|
||||||
printf("%ld inodes\n", INODES);
|
printf("%ld inodes\n"
|
||||||
printf("%ld blocks\n", ZONES);
|
"%ld blocks\n"
|
||||||
printf("Firstdatazone=%ld (%ld)\n", FIRSTZONE, NORM_FIRSTZONE);
|
"Firstdatazone=%ld (%ld)\n"
|
||||||
printf("Zonesize=%d\n", BLOCK_SIZE << ZONESIZE);
|
"Zonesize=%d\n"
|
||||||
printf("Maxsize=%ld\n", MAXSIZE);
|
"Maxsize=%ld\n"
|
||||||
printf("Filesystem state=%d\n", Super.s_state);
|
"Filesystem state=%d\n"
|
||||||
printf("namelen=%d\n\n", namelen);
|
"namelen=%d\n\n",
|
||||||
|
INODES,
|
||||||
|
ZONES,
|
||||||
|
FIRSTZONE, NORM_FIRSTZONE,
|
||||||
|
BLOCK_SIZE << ZONESIZE,
|
||||||
|
MAXSIZE,
|
||||||
|
Super.s_state,
|
||||||
|
namelen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -738,7 +724,7 @@ static struct minix_inode *get_inode(unsigned int nr)
|
|||||||
} else
|
} else
|
||||||
links++;
|
links++;
|
||||||
if (!++inode_count[nr]) {
|
if (!++inode_count[nr]) {
|
||||||
printf("Warning: inode count too big.\n");
|
printf("Warning: inode count too big\n");
|
||||||
inode_count[nr]--;
|
inode_count[nr]--;
|
||||||
errors_uncorrected = 1;
|
errors_uncorrected = 1;
|
||||||
}
|
}
|
||||||
@ -785,7 +771,7 @@ static struct minix2_inode *get_inode2(unsigned int nr)
|
|||||||
} else
|
} else
|
||||||
links++;
|
links++;
|
||||||
if (!++inode_count[nr]) {
|
if (!++inode_count[nr]) {
|
||||||
printf("Warning: inode count too big.\n");
|
printf("Warning: inode count too big\n");
|
||||||
inode_count[nr]--;
|
inode_count[nr]--;
|
||||||
errors_uncorrected = 1;
|
errors_uncorrected = 1;
|
||||||
}
|
}
|
||||||
@ -811,7 +797,7 @@ static void check_root2(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int add_zone(unsigned short *znr, int *corrected)
|
static int add_zone(uint16_t *znr, int *corrected)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
int block;
|
int block;
|
||||||
@ -828,10 +814,9 @@ static int add_zone(unsigned short *znr, int *corrected)
|
|||||||
*znr = 0;
|
*znr = 0;
|
||||||
block = 0;
|
block = 0;
|
||||||
*corrected = 1;
|
*corrected = 1;
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!block)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!zone_in_use(block)) {
|
if (!zone_in_use(block)) {
|
||||||
printf("Block %d in file `", block);
|
printf("Block %d in file `", block);
|
||||||
print_current_name();
|
print_current_name();
|
||||||
@ -845,7 +830,7 @@ static int add_zone(unsigned short *znr, int *corrected)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_MINIX2
|
#ifdef CONFIG_FEATURE_MINIX2
|
||||||
static int add_zone2(unsigned int *znr, int *corrected)
|
static int add_zone2(uint32_t *znr, int *corrected)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
int block;
|
int block;
|
||||||
@ -862,10 +847,9 @@ static int add_zone2(unsigned int *znr, int *corrected)
|
|||||||
*znr = 0;
|
*znr = 0;
|
||||||
block = 0;
|
block = 0;
|
||||||
*corrected = 1;
|
*corrected = 1;
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!block)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!zone_in_use(block)) {
|
if (!zone_in_use(block)) {
|
||||||
printf("Block %d in file `", block);
|
printf("Block %d in file `", block);
|
||||||
print_current_name();
|
print_current_name();
|
||||||
@ -879,7 +863,7 @@ static int add_zone2(unsigned int *znr, int *corrected)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void add_zone_ind(unsigned short *znr, int *corrected)
|
static void add_zone_ind(uint16_t *znr, int *corrected)
|
||||||
{
|
{
|
||||||
static char blk[BLOCK_SIZE];
|
static char blk[BLOCK_SIZE];
|
||||||
int i, chg_blk = 0;
|
int i, chg_blk = 0;
|
||||||
@ -890,13 +874,13 @@ static void add_zone_ind(unsigned short *znr, int *corrected)
|
|||||||
return;
|
return;
|
||||||
read_block(block, blk);
|
read_block(block, blk);
|
||||||
for (i = 0; i < (BLOCK_SIZE >> 1); i++)
|
for (i = 0; i < (BLOCK_SIZE >> 1); i++)
|
||||||
add_zone(i + (unsigned short *) blk, &chg_blk);
|
add_zone(i + (uint16_t *) blk, &chg_blk);
|
||||||
if (chg_blk)
|
if (chg_blk)
|
||||||
write_block(block, blk);
|
write_block(block, blk);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_MINIX2
|
#ifdef CONFIG_FEATURE_MINIX2
|
||||||
static void add_zone_ind2(unsigned int *znr, int *corrected)
|
static void add_zone_ind2(uint32_t *znr, int *corrected)
|
||||||
{
|
{
|
||||||
static char blk[BLOCK_SIZE];
|
static char blk[BLOCK_SIZE];
|
||||||
int i, chg_blk = 0;
|
int i, chg_blk = 0;
|
||||||
@ -907,13 +891,13 @@ static void add_zone_ind2(unsigned int *znr, int *corrected)
|
|||||||
return;
|
return;
|
||||||
read_block(block, blk);
|
read_block(block, blk);
|
||||||
for (i = 0; i < BLOCK_SIZE >> 2; i++)
|
for (i = 0; i < BLOCK_SIZE >> 2; i++)
|
||||||
add_zone2(i + (unsigned int *) blk, &chg_blk);
|
add_zone2(i + (uint32_t *) blk, &chg_blk);
|
||||||
if (chg_blk)
|
if (chg_blk)
|
||||||
write_block(block, blk);
|
write_block(block, blk);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void add_zone_dind(unsigned short *znr, int *corrected)
|
static void add_zone_dind(uint16_t *znr, int *corrected)
|
||||||
{
|
{
|
||||||
static char blk[BLOCK_SIZE];
|
static char blk[BLOCK_SIZE];
|
||||||
int i, blk_chg = 0;
|
int i, blk_chg = 0;
|
||||||
@ -924,13 +908,13 @@ static void add_zone_dind(unsigned short *znr, int *corrected)
|
|||||||
return;
|
return;
|
||||||
read_block(block, blk);
|
read_block(block, blk);
|
||||||
for (i = 0; i < (BLOCK_SIZE >> 1); i++)
|
for (i = 0; i < (BLOCK_SIZE >> 1); i++)
|
||||||
add_zone_ind(i + (unsigned short *) blk, &blk_chg);
|
add_zone_ind(i + (uint16_t *) blk, &blk_chg);
|
||||||
if (blk_chg)
|
if (blk_chg)
|
||||||
write_block(block, blk);
|
write_block(block, blk);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_MINIX2
|
#ifdef CONFIG_FEATURE_MINIX2
|
||||||
static void add_zone_dind2(unsigned int *znr, int *corrected)
|
static void add_zone_dind2(uint32_t *znr, int *corrected)
|
||||||
{
|
{
|
||||||
static char blk[BLOCK_SIZE];
|
static char blk[BLOCK_SIZE];
|
||||||
int i, blk_chg = 0;
|
int i, blk_chg = 0;
|
||||||
@ -941,12 +925,12 @@ static void add_zone_dind2(unsigned int *znr, int *corrected)
|
|||||||
return;
|
return;
|
||||||
read_block(block, blk);
|
read_block(block, blk);
|
||||||
for (i = 0; i < BLOCK_SIZE >> 2; i++)
|
for (i = 0; i < BLOCK_SIZE >> 2; i++)
|
||||||
add_zone_ind2(i + (unsigned int *) blk, &blk_chg);
|
add_zone_ind2(i + (uint32_t *) blk, &blk_chg);
|
||||||
if (blk_chg)
|
if (blk_chg)
|
||||||
write_block(block, blk);
|
write_block(block, blk);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_zone_tind2(unsigned int *znr, int *corrected)
|
static void add_zone_tind2(uint32_t *znr, int *corrected)
|
||||||
{
|
{
|
||||||
static char blk[BLOCK_SIZE];
|
static char blk[BLOCK_SIZE];
|
||||||
int i, blk_chg = 0;
|
int i, blk_chg = 0;
|
||||||
@ -957,7 +941,7 @@ static void add_zone_tind2(unsigned int *znr, int *corrected)
|
|||||||
return;
|
return;
|
||||||
read_block(block, blk);
|
read_block(block, blk);
|
||||||
for (i = 0; i < BLOCK_SIZE >> 2; i++)
|
for (i = 0; i < BLOCK_SIZE >> 2; i++)
|
||||||
add_zone_dind2(i + (unsigned int *) blk, &blk_chg);
|
add_zone_dind2(i + (uint32_t *) blk, &blk_chg);
|
||||||
if (blk_chg)
|
if (blk_chg)
|
||||||
write_block(block, blk);
|
write_block(block, blk);
|
||||||
}
|
}
|
||||||
@ -1012,13 +996,13 @@ static void check_file(struct minix_inode *dir, unsigned int offset)
|
|||||||
block = map_block(dir, offset / BLOCK_SIZE);
|
block = map_block(dir, offset / BLOCK_SIZE);
|
||||||
read_block(block, blk);
|
read_block(block, blk);
|
||||||
name = blk + (offset % BLOCK_SIZE) + 2;
|
name = blk + (offset % BLOCK_SIZE) + 2;
|
||||||
ino = *(unsigned short *) (name - 2);
|
ino = *(uint16_t *) (name - 2);
|
||||||
if (ino > INODES) {
|
if (ino > INODES) {
|
||||||
print_current_name();
|
print_current_name();
|
||||||
printf(" contains a bad inode number for file '");
|
printf(" contains a bad inode number for file '");
|
||||||
printf("%.*s'.", namelen, name);
|
printf("%.*s'.", namelen, name);
|
||||||
if (ask(" Remove", 1)) {
|
if (ask(" Remove", 1)) {
|
||||||
*(unsigned short *) (name - 2) = 0;
|
*(uint16_t *) (name - 2) = 0;
|
||||||
write_block(block, blk);
|
write_block(block, blk);
|
||||||
}
|
}
|
||||||
ino = 0;
|
ino = 0;
|
||||||
@ -1077,13 +1061,13 @@ static void check_file2(struct minix2_inode *dir, unsigned int offset)
|
|||||||
block = map_block2(dir, offset / BLOCK_SIZE);
|
block = map_block2(dir, offset / BLOCK_SIZE);
|
||||||
read_block(block, blk);
|
read_block(block, blk);
|
||||||
name = blk + (offset % BLOCK_SIZE) + 2;
|
name = blk + (offset % BLOCK_SIZE) + 2;
|
||||||
ino = *(unsigned short *) (name - 2);
|
ino = *(uint16_t *) (name - 2);
|
||||||
if (ino > INODES) {
|
if (ino > INODES) {
|
||||||
print_current_name();
|
print_current_name();
|
||||||
printf(" contains a bad inode number for file '");
|
printf(" contains a bad inode number for file '");
|
||||||
printf("%.*s'.", namelen, name);
|
printf("%.*s'.", namelen, name);
|
||||||
if (ask(" Remove", 1)) {
|
if (ask(" Remove", 1)) {
|
||||||
*(unsigned short *) (name - 2) = 0;
|
*(uint16_t *) (name - 2) = 0;
|
||||||
write_block(block, blk);
|
write_block(block, blk);
|
||||||
}
|
}
|
||||||
ino = 0;
|
ino = 0;
|
||||||
@ -1179,7 +1163,7 @@ static void check_counts(void)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 1; i <= INODES; i++) {
|
for (i = 1; i <= INODES; i++) {
|
||||||
if (!inode_in_use(i) && Inode[i].i_mode && warn_mode) {
|
if (warn_mode && Inode[i].i_mode && !inode_in_use(i)) {
|
||||||
printf("Inode %d mode not cleared.", i);
|
printf("Inode %d mode not cleared.", i);
|
||||||
if (ask("Clear", 1)) {
|
if (ask("Clear", 1)) {
|
||||||
Inode[i].i_mode = 0;
|
Inode[i].i_mode = 0;
|
||||||
@ -1230,7 +1214,7 @@ static void check_counts2(void)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 1; i <= INODES; i++) {
|
for (i = 1; i <= INODES; i++) {
|
||||||
if (!inode_in_use(i) && Inode2[i].i_mode && warn_mode) {
|
if (warn_mode && Inode2[i].i_mode && !inode_in_use(i)) {
|
||||||
printf("Inode %d mode not cleared.", i);
|
printf("Inode %d mode not cleared.", i);
|
||||||
if (ask("Clear", 1)) {
|
if (ask("Clear", 1)) {
|
||||||
Inode2[i].i_mode = 0;
|
Inode2[i].i_mode = 0;
|
||||||
@ -1305,7 +1289,7 @@ static void alloc_name_list(void)
|
|||||||
|
|
||||||
name_list = xmalloc(sizeof(char *) * MAX_DEPTH);
|
name_list = xmalloc(sizeof(char *) * MAX_DEPTH);
|
||||||
for (i = 0; i < MAX_DEPTH; i++)
|
for (i = 0; i < MAX_DEPTH; i++)
|
||||||
name_list[i] = xmalloc(sizeof(char) * BUFSIZ + 1);
|
name_list[i] = xmalloc(sizeof(char) * (BUFSIZ + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_CLEAN_UP
|
#ifdef CONFIG_FEATURE_CLEAN_UP
|
||||||
@ -1327,7 +1311,6 @@ static void free_name_list(void)
|
|||||||
int fsck_minix_main(int argc, char **argv)
|
int fsck_minix_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct termios tmp;
|
struct termios tmp;
|
||||||
int count;
|
|
||||||
int retcode = 0;
|
int retcode = 0;
|
||||||
|
|
||||||
alloc_name_list();
|
alloc_name_list();
|
||||||
@ -1389,11 +1372,10 @@ int fsck_minix_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
IN = open(device_name, repair ? O_RDWR : O_RDONLY);
|
IN = open(device_name, repair ? O_RDWR : O_RDONLY);
|
||||||
if (IN < 0){
|
if (IN < 0){
|
||||||
fprintf(stderr,"unable to open device '%s'.\n",device_name);
|
fprintf(stderr,"unable to open device '%s'\n",device_name);
|
||||||
leave(8);
|
leave(8);
|
||||||
}
|
}
|
||||||
for (count = 0; count < 3; count++)
|
sync(); /* paranoia? */
|
||||||
sync();
|
|
||||||
read_superblock();
|
read_superblock();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1406,12 +1388,12 @@ int fsck_minix_main(int argc, char **argv)
|
|||||||
if (!(Super.s_state & MINIX_ERROR_FS) &&
|
if (!(Super.s_state & MINIX_ERROR_FS) &&
|
||||||
(Super.s_state & MINIX_VALID_FS) && !force) {
|
(Super.s_state & MINIX_VALID_FS) && !force) {
|
||||||
if (repair)
|
if (repair)
|
||||||
printf("%s is clean, no check.\n", device_name);
|
printf("%s is clean, no check\n", device_name);
|
||||||
return retcode;
|
return retcode;
|
||||||
} else if (force)
|
} else if (force)
|
||||||
printf("Forcing filesystem check on %s.\n", device_name);
|
printf("Forcing filesystem check on %s\n", device_name);
|
||||||
else if (repair)
|
else if (repair)
|
||||||
printf("Filesystem on %s is dirty, needs checking.\n",
|
printf("Filesystem on %s is dirty, needs checking\n",
|
||||||
device_name);
|
device_name);
|
||||||
|
|
||||||
read_tables();
|
read_tables();
|
||||||
@ -1463,7 +1445,6 @@ int fsck_minix_main(int argc, char **argv)
|
|||||||
printf("----------------------------\n"
|
printf("----------------------------\n"
|
||||||
"FILE SYSTEM HAS BEEN CHANGED\n"
|
"FILE SYSTEM HAS BEEN CHANGED\n"
|
||||||
"----------------------------\n");
|
"----------------------------\n");
|
||||||
for (count = 0; count < 3; count++)
|
|
||||||
sync();
|
sync();
|
||||||
} else if (repair)
|
} else if (repair)
|
||||||
write_super_block();
|
write_super_block();
|
||||||
|
Loading…
Reference in New Issue
Block a user