From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: Sami Kerola <kerolasa@iki.fi>
Subject: [PATCH 10/12] fsck.minix: add minix v3 support
Date: Wed, 24 Jun 2015 09:15:17 +0100 [thread overview]
Message-ID: <1435133719-2971-11-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1435133719-2971-1-git-send-email-kerolasa@iki.fi>
Relates-to: a2657ae3ffb56616ac9c921886bcca8ef242499f
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
disk-utils/fsck.minix.c | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/disk-utils/fsck.minix.c b/disk-utils/fsck.minix.c
index 3c3faf0..57e5be9 100644
--- a/disk-utils/fsck.minix.c
+++ b/disk-utils/fsck.minix.c
@@ -147,8 +147,6 @@ static char name_list[MAX_DEPTH][MINIX_NAME_MAX + 1];
* is a waste of 12kB or so. */
static char current_name[MAX_DEPTH * (MINIX_NAME_MAX + 1) + 1];
-#define MAGIC (Super.s_magic)
-
static unsigned char *inode_count = NULL;
static unsigned char *zone_count = NULL;
@@ -494,6 +492,9 @@ map_block2(struct minix2_inode *inode, unsigned int blknr) {
static void
write_super_block(void) {
+ /* v3 super block does not track state */
+ if (fs_version == 3)
+ return;
/* Set the state of the filesystem based on whether or not there are
* uncorrected errors. The filesystem valid flag is unconditionally
* set if we get this far. */
@@ -534,7 +535,7 @@ get_dirsize(void) {
char blk[MINIX_BLOCK_SIZE];
size_t size;
- if (fs_version == 2)
+ if (fs_version == 2 || fs_version == 3)
block = Inode2[ROOT_INO].i_zone[0];
else
block = Inode[ROOT_INO].i_zone[0];
@@ -561,22 +562,26 @@ read_superblock(void) {
if (MINIX_BLOCK_SIZE != read(device_fd, super_block_buffer, MINIX_BLOCK_SIZE))
die(_("unable to read super block"));
- if (MAGIC == MINIX_SUPER_MAGIC) {
+ if (Super.s_magic == MINIX_SUPER_MAGIC) {
namelen = 14;
dirsize = 16;
fs_version = 1;
- } else if (MAGIC == MINIX_SUPER_MAGIC2) {
+ } else if (Super.s_magic == MINIX_SUPER_MAGIC2) {
namelen = 30;
dirsize = 32;
fs_version = 1;
- } else if (MAGIC == MINIX2_SUPER_MAGIC) {
+ } else if (Super.s_magic == MINIX2_SUPER_MAGIC) {
namelen = 14;
dirsize = 16;
fs_version = 2;
- } else if (MAGIC == MINIX2_SUPER_MAGIC2) {
+ } else if (Super.s_magic == MINIX2_SUPER_MAGIC2) {
namelen = 30;
dirsize = 32;
fs_version = 2;
+ } else if (Super3.s_magic == MINIX3_SUPER_MAGIC) {
+ namelen = 60;
+ dirsize = 64;
+ fs_version = 3;
} else
die(_("bad magic number in super-block"));
if (get_zone_size() != 0 || MINIX_BLOCK_SIZE != 1024)
@@ -637,7 +642,8 @@ read_tables(void) {
printf(_("Firstdatazone=%jd (%jd)\n"), first_zone, norm_first_zone);
printf(_("Zonesize=%d\n"), MINIX_BLOCK_SIZE << get_zone_size());
printf(_("Maxsize=%zu\n"), get_max_size());
- printf(_("Filesystem state=%d\n"), Super.s_state);
+ if (fs_version < 3)
+ printf(_("Filesystem state=%d\n"), Super.s_state);
printf(_("namelen=%zd\n\n"), namelen);
}
}
@@ -1013,17 +1019,18 @@ check_file2(struct minix2_inode *dir, unsigned int offset) {
ino_t ino;
char *name;
int block;
+ const int version_offset = fs_version == 3 ? 4 : 2;
block = map_block2(dir, offset / MINIX_BLOCK_SIZE);
read_block(block, blk);
- name = blk + (offset % MINIX_BLOCK_SIZE) + 2;
- ino = *(unsigned short *)(name - 2);
+ name = blk + (offset % MINIX_BLOCK_SIZE) + version_offset;
+ ino = *(unsigned short *)(name - version_offset);
if (ino > get_ninodes()) {
get_current_name();
printf(_("The directory '%s' contains a bad inode number "
"for file '%.*s'."), current_name, (int)namelen, name);
if (ask(_(" Remove"), 1)) {
- *(unsigned short *)(name - 2) = 0;
+ *(unsigned short *)(name - version_offset) = 0;
write_block(block, blk);
}
ino = 0;
@@ -1323,7 +1330,7 @@ main(int argc, char **argv) {
/* Determine whether or not we should continue with the checking. This
* is based on the status of the filesystem valid and error flags and
* whether or not the -f switch was specified on the command line. */
- if (!(Super.s_state & MINIX_ERROR_FS) &&
+ if (fs_version < 3 && !(Super.s_state & MINIX_ERROR_FS) &&
(Super.s_state & MINIX_VALID_FS) && !force) {
if (repair)
printf(_("%s is clean, no check.\n"), device_name);
@@ -1350,7 +1357,7 @@ main(int argc, char **argv) {
termios_set = 1;
}
- if (fs_version == 2) {
+ if (fs_version == 2 || fs_version == 3) {
check_root2();
check2();
} else {
--
2.4.4
next prev parent reply other threads:[~2015-06-24 8:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-24 8:15 [PATCH 00/12] pull: minix updates Sami Kerola
2015-06-24 8:15 ` [PATCH 01/12] mkfs.minix: increase maximum minix v2 and v3 file system sizes Sami Kerola
2015-06-24 8:15 ` [PATCH 02/12] mkfs.minix: introduce long options to the command Sami Kerola
2015-06-24 8:15 ` [PATCH 03/12] mkfs.minix: use is_mounted() from libcommon Sami Kerola
2015-06-24 8:15 ` [PATCH 04/12] mkfs.minix: remove unuseful code Sami Kerola
2015-06-24 8:15 ` [PATCH 05/12] mkfs.minix: add fs_control structure, and remove most global variables Sami Kerola
2015-06-24 8:15 ` [PATCH 06/12] mkfs.minix: check user input carefully Sami Kerola
2015-06-24 8:15 ` [PATCH 07/12] mkfs.minix: check requested blocks will not exceed available on device Sami Kerola
2015-06-24 8:15 ` [PATCH 08/12] mkfs.minix: refactor root block content creation Sami Kerola
2015-06-24 8:15 ` [PATCH 09/12] fsck.minix: rename device file descriptor variable Sami Kerola
2015-06-24 8:15 ` Sami Kerola [this message]
2015-06-24 8:15 ` [PATCH 11/12] fsck.minix: introduce long options to the command Sami Kerola
2015-06-24 8:15 ` [PATCH 12/12] docs: make fsck.minix(8) more pretty Sami Kerola
2015-07-30 9:55 ` [PATCH 00/12] pull: minix updates Karel Zak
2015-07-30 10:31 ` Sami Kerola
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1435133719-2971-11-git-send-email-kerolasa@iki.fi \
--to=kerolasa@iki.fi \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox