151 |
char superblock_buffer[BLOCK_SIZE]; |
char superblock_buffer[BLOCK_SIZE]; |
152 |
char add_zone_ind_blk[BLOCK_SIZE]; |
char add_zone_ind_blk[BLOCK_SIZE]; |
153 |
char add_zone_dind_blk[BLOCK_SIZE]; |
char add_zone_dind_blk[BLOCK_SIZE]; |
154 |
USE_FEATURE_MINIX2(char add_zone_tind_blk[BLOCK_SIZE];) |
IF_FEATURE_MINIX2(char add_zone_tind_blk[BLOCK_SIZE];) |
155 |
char check_file_blk[BLOCK_SIZE]; |
char check_file_blk[BLOCK_SIZE]; |
156 |
|
|
157 |
/* File-name data */ |
/* File-name data */ |
341 |
} |
} |
342 |
printf(def ? "%s (y/n)? " : "%s (n/y)? ", string); |
printf(def ? "%s (y/n)? " : "%s (n/y)? ", string); |
343 |
for (;;) { |
for (;;) { |
344 |
fflush(stdout); |
fflush_all(); |
345 |
c = getchar(); |
c = getchar(); |
346 |
if (c == EOF) { |
if (c == EOF) { |
347 |
if (!def) |
if (!def) |
348 |
errors_uncorrected = 1; |
errors_uncorrected = 1; |
349 |
return def; |
return def; |
350 |
} |
} |
351 |
c = toupper(c); |
if (c == '\n') |
352 |
if (c == 'Y') { |
break; |
353 |
|
c |= 0x20; /* tolower */ |
354 |
|
if (c == 'y') { |
355 |
def = 1; |
def = 1; |
356 |
break; |
break; |
357 |
} else if (c == 'N') { |
} |
358 |
|
if (c == 'n') { |
359 |
def = 0; |
def = 0; |
360 |
break; |
break; |
361 |
} else if (c == ' ' || c == '\n') |
} |
|
break; |
|
362 |
} |
} |
363 |
if (def) |
if (def) |
364 |
printf("y\n"); |
printf("y\n"); |
376 |
*/ |
*/ |
377 |
static void check_mount(void) |
static void check_mount(void) |
378 |
{ |
{ |
379 |
FILE *f; |
if (find_mount_point(device_name, 0)) { |
380 |
struct mntent *mnt; |
int cont; |
381 |
int cont; |
#if ENABLE_FEATURE_MTAB_SUPPORT |
382 |
int fd; |
/* |
383 |
//XXX:FIXME use find_mount_point() |
* If the root is mounted read-only, then /etc/mtab is |
384 |
f = setmntent(MOUNTED, "r"); |
* probably not correct; so we won't issue a warning based on |
385 |
if (f == NULL) |
* it. |
386 |
return; |
*/ |
387 |
while ((mnt = getmntent(f)) != NULL) |
int fd = open(bb_path_mtab_file, O_RDWR); |
|
if (strcmp(device_name, mnt->mnt_fsname) == 0) |
|
|
break; |
|
|
endmntent(f); |
|
|
if (!mnt) |
|
|
return; |
|
388 |
|
|
389 |
/* |
if (fd < 0 && errno == EROFS) |
390 |
* If the root is mounted read-only, then /etc/mtab is |
return; |
391 |
* probably not correct; so we won't issue a warning based on |
close(fd); |
392 |
* it. |
#endif |
393 |
*/ |
printf("%s is mounted. ", device_name); |
394 |
fd = open(MOUNTED, O_RDWR); |
cont = 0; |
395 |
if (fd < 0 && errno == EROFS) |
if (isatty(0) && isatty(1)) |
396 |
return; |
cont = ask("Do you really want to continue", 0); |
397 |
close(fd); |
if (!cont) { |
398 |
|
printf("Check aborted\n"); |
399 |
printf("%s is mounted. ", device_name); |
exit(EXIT_SUCCESS); |
400 |
cont = 0; |
} |
|
if (isatty(0) && isatty(1)) |
|
|
cont = ask("Do you really want to continue", 0); |
|
|
if (!cont) { |
|
|
printf("Check aborted\n"); |
|
|
exit(EXIT_SUCCESS); |
|
401 |
} |
} |
402 |
} |
} |
403 |
|
|
565 |
|
|
566 |
xlseek(dev_fd, BLOCK_SIZE, SEEK_SET); |
xlseek(dev_fd, BLOCK_SIZE, SEEK_SET); |
567 |
if (BLOCK_SIZE != full_write(dev_fd, superblock_buffer, BLOCK_SIZE)) |
if (BLOCK_SIZE != full_write(dev_fd, superblock_buffer, BLOCK_SIZE)) |
568 |
die("cannot write superblock"); |
die("can't write superblock"); |
569 |
} |
} |
570 |
|
|
571 |
static void write_tables(void) |
static void write_tables(void) |
573 |
write_superblock(); |
write_superblock(); |
574 |
|
|
575 |
if (IMAPS * BLOCK_SIZE != write(dev_fd, inode_map, IMAPS * BLOCK_SIZE)) |
if (IMAPS * BLOCK_SIZE != write(dev_fd, inode_map, IMAPS * BLOCK_SIZE)) |
576 |
die("cannot write inode map"); |
die("can't write inode map"); |
577 |
if (ZMAPS * BLOCK_SIZE != write(dev_fd, zone_map, ZMAPS * BLOCK_SIZE)) |
if (ZMAPS * BLOCK_SIZE != write(dev_fd, zone_map, ZMAPS * BLOCK_SIZE)) |
578 |
die("cannot write zone map"); |
die("can't write zone map"); |
579 |
if (INODE_BUFFER_SIZE != write(dev_fd, inode_buffer, INODE_BUFFER_SIZE)) |
if (INODE_BUFFER_SIZE != write(dev_fd, inode_buffer, INODE_BUFFER_SIZE)) |
580 |
die("cannot write inodes"); |
die("can't write inodes"); |
581 |
} |
} |
582 |
|
|
583 |
static void get_dirsize(void) |
static void get_dirsize(void) |
607 |
{ |
{ |
608 |
xlseek(dev_fd, BLOCK_SIZE, SEEK_SET); |
xlseek(dev_fd, BLOCK_SIZE, SEEK_SET); |
609 |
if (BLOCK_SIZE != full_read(dev_fd, superblock_buffer, BLOCK_SIZE)) |
if (BLOCK_SIZE != full_read(dev_fd, superblock_buffer, BLOCK_SIZE)) |
610 |
die("cannot read superblock"); |
die("can't read superblock"); |
611 |
/* already initialized to: |
/* already initialized to: |
612 |
namelen = 14; |
namelen = 14; |
613 |
dirsize = 16; |
dirsize = 16; |
643 |
inode_count = xmalloc(INODES + 1); |
inode_count = xmalloc(INODES + 1); |
644 |
zone_count = xmalloc(ZONES); |
zone_count = xmalloc(ZONES); |
645 |
if (IMAPS * BLOCK_SIZE != read(dev_fd, inode_map, IMAPS * BLOCK_SIZE)) |
if (IMAPS * BLOCK_SIZE != read(dev_fd, inode_map, IMAPS * BLOCK_SIZE)) |
646 |
die("cannot read inode map"); |
die("can't read inode map"); |
647 |
if (ZMAPS * BLOCK_SIZE != read(dev_fd, zone_map, ZMAPS * BLOCK_SIZE)) |
if (ZMAPS * BLOCK_SIZE != read(dev_fd, zone_map, ZMAPS * BLOCK_SIZE)) |
648 |
die("cannot read zone map"); |
die("can't read zone map"); |
649 |
if (INODE_BUFFER_SIZE != read(dev_fd, inode_buffer, INODE_BUFFER_SIZE)) |
if (INODE_BUFFER_SIZE != read(dev_fd, inode_buffer, INODE_BUFFER_SIZE)) |
650 |
die("cannot read inodes"); |
die("can't read inodes"); |
651 |
if (NORM_FIRSTZONE != FIRSTZONE) { |
if (NORM_FIRSTZONE != FIRSTZONE) { |
652 |
printf("warning: firstzone!=norm_firstzone\n"); |
printf("warning: firstzone!=norm_firstzone\n"); |
653 |
errors_uncorrected = 1; |
errors_uncorrected = 1; |