#define Inode2 (((struct minix2_inode *) inode_buffer) - 1)
static char *device_name;
-static int IN;
+static int device_fd;
static int repair, automatic, verbose, list, show, warn_mode, force;
static int directory, regular, blockdev, chardev, links, symlinks, total;
memset(addr, 0, MINIX_BLOCK_SIZE);
return;
}
- if (MINIX_BLOCK_SIZE * nr != lseek(IN, MINIX_BLOCK_SIZE * nr, SEEK_SET)) {
+ if (MINIX_BLOCK_SIZE * nr != lseek(device_fd, MINIX_BLOCK_SIZE * nr, SEEK_SET)) {
get_current_name();
printf(_("Read error: unable to seek to block in file '%s'\n"),
current_name);
memset(addr, 0, MINIX_BLOCK_SIZE);
errors_uncorrected = 1;
- } else if (MINIX_BLOCK_SIZE != read(IN, addr, MINIX_BLOCK_SIZE)) {
+ } else if (MINIX_BLOCK_SIZE != read(device_fd, addr, MINIX_BLOCK_SIZE)) {
get_current_name();
printf(_("Read error: bad block in file '%s'\n"), current_name);
memset(addr, 0, MINIX_BLOCK_SIZE);
errors_uncorrected = 1;
return;
}
- if (MINIX_BLOCK_SIZE * nr != lseek(IN, MINIX_BLOCK_SIZE * nr, SEEK_SET))
+ if (MINIX_BLOCK_SIZE * nr != lseek(device_fd, MINIX_BLOCK_SIZE * nr, SEEK_SET))
die(_("seek failed in write_block"));
- if (MINIX_BLOCK_SIZE != write(IN, addr, MINIX_BLOCK_SIZE)) {
+ if (MINIX_BLOCK_SIZE != write(device_fd, addr, MINIX_BLOCK_SIZE)) {
get_current_name();
printf(_("Write error: bad block in file '%s'\n"),
current_name);
else
Super.s_state &= ~MINIX_ERROR_FS;
- if (MINIX_BLOCK_SIZE != lseek(IN, MINIX_BLOCK_SIZE, SEEK_SET))
+ if (MINIX_BLOCK_SIZE != lseek(device_fd, MINIX_BLOCK_SIZE, SEEK_SET))
die(_("seek failed in write_super_block"));
- if (MINIX_BLOCK_SIZE != write(IN, super_block_buffer, MINIX_BLOCK_SIZE))
+ if (MINIX_BLOCK_SIZE != write(device_fd, super_block_buffer, MINIX_BLOCK_SIZE))
die(_("unable to write super-block"));
return;
}
write_super_block();
- if (write_all(IN, inode_map, imaps * MINIX_BLOCK_SIZE))
+ if (write_all(device_fd, inode_map, imaps * MINIX_BLOCK_SIZE))
die(_("Unable to write inode map"));
- if (write_all(IN, zone_map, zmaps * MINIX_BLOCK_SIZE))
+ if (write_all(device_fd, zone_map, zmaps * MINIX_BLOCK_SIZE))
die(_("Unable to write zone map"));
- if (write_all(IN, inode_buffer, buffsz))
+ if (write_all(device_fd, inode_buffer, buffsz))
die(_("Unable to write inodes"));
}
static void
read_superblock(void) {
- if (MINIX_BLOCK_SIZE != lseek(IN, MINIX_BLOCK_SIZE, SEEK_SET))
+ if (MINIX_BLOCK_SIZE != lseek(device_fd, MINIX_BLOCK_SIZE, SEEK_SET))
die(_("seek failed"));
super_block_buffer = calloc(1, MINIX_BLOCK_SIZE);
if (!super_block_buffer)
die(_("unable to alloc buffer for superblock"));
- if (MINIX_BLOCK_SIZE != read(IN, super_block_buffer, MINIX_BLOCK_SIZE))
+ if (MINIX_BLOCK_SIZE != read(device_fd, super_block_buffer, MINIX_BLOCK_SIZE))
die(_("unable to read super block"));
if (MAGIC == MINIX_SUPER_MAGIC) {
namelen = 14;
if (!zone_count)
die(_("Unable to allocate buffer for zone count"));
- rc = read(IN, inode_map, imaps * MINIX_BLOCK_SIZE);
+ rc = read(device_fd, inode_map, imaps * MINIX_BLOCK_SIZE);
if (rc < 0 || imaps * MINIX_BLOCK_SIZE != (size_t) rc)
die(_("Unable to read inode map"));
- rc = read(IN, zone_map, zmaps * MINIX_BLOCK_SIZE);
+ rc = read(device_fd, zone_map, zmaps * MINIX_BLOCK_SIZE);
if (rc < 0 || zmaps * MINIX_BLOCK_SIZE != (size_t) rc)
die(_("Unable to read zone map"));
- rc = read(IN, inode_buffer, buffsz);
+ rc = read(device_fd, inode_buffer, buffsz);
if (rc < 0 || buffsz != (size_t) rc)
die(_("Unable to read inodes"));
if (norm_first_zone != first_zone) {
bad_zone(int i) {
char buffer[1024];
- if (MINIX_BLOCK_SIZE * i != lseek(IN, MINIX_BLOCK_SIZE * i, SEEK_SET))
+ if (MINIX_BLOCK_SIZE * i != lseek(device_fd, MINIX_BLOCK_SIZE * i, SEEK_SET))
die(_("seek failed in bad_zone"));
- return (MINIX_BLOCK_SIZE != read(IN, buffer, MINIX_BLOCK_SIZE));
+ return (MINIX_BLOCK_SIZE != read(device_fd, buffer, MINIX_BLOCK_SIZE));
}
static void
if (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO))
die(_("need terminal for interactive repairs"));
}
- IN = open(device_name, repair ? O_RDWR : O_RDONLY);
- if (IN < 0)
+ device_fd = open(device_name, repair ? O_RDWR : O_RDONLY);
+ if (device_fd < 0)
die(_("cannot open %s: %s"), device_name, strerror(errno));
for (count = 0; count < 3; count++)
sync();
if (repair && !automatic)
tcsetattr(STDIN_FILENO, TCSANOW, &termios);
- if (close_fd(IN) != 0)
+ if (close_fd(device_fd) != 0)
err(FSCK_EX_ERROR, _("write failed"));
if (changed)
retcode += 3;