blob: 83ffe6da57b03ed281043205c373c3b0699e3a06 [file] [log] [blame]
Denis Vlasenko87033fb2007-01-03 00:47:47 +00001/*
2 * This is the original minix inode layout on disk.
3 * Note the 8-bit gid and atime and ctime.
4 */
5struct minix1_inode {
6 uint16_t i_mode;
7 uint16_t i_uid;
8 uint32_t i_size;
9 uint32_t i_time;
10 uint8_t i_gid;
11 uint8_t i_nlinks;
12 uint16_t i_zone[9];
13};
14
15/*
16 * The new minix inode has all the time entries, as well as
17 * long block numbers and a third indirect block (7+1+1+1
18 * instead of 7+1+1). Also, some previously 8-bit values are
19 * now 16-bit. The inode is now 64 bytes instead of 32.
20 */
21struct minix2_inode {
22 uint16_t i_mode;
23 uint16_t i_nlinks;
24 uint16_t i_uid;
25 uint16_t i_gid;
26 uint32_t i_size;
27 uint32_t i_atime;
28 uint32_t i_mtime;
29 uint32_t i_ctime;
30 uint32_t i_zone[10];
31};
32
33/*
Bernhard Reutner-Fischere1e51742008-07-21 13:33:22 +000034 * minix superblock data on disk
Denis Vlasenko87033fb2007-01-03 00:47:47 +000035 */
Bernhard Reutner-Fischere1e51742008-07-21 13:33:22 +000036struct minix_superblock {
Denis Vlasenko87033fb2007-01-03 00:47:47 +000037 uint16_t s_ninodes;
38 uint16_t s_nzones;
39 uint16_t s_imap_blocks;
40 uint16_t s_zmap_blocks;
41 uint16_t s_firstdatazone;
42 uint16_t s_log_zone_size;
43 uint32_t s_max_size;
44 uint16_t s_magic;
45 uint16_t s_state;
46 uint32_t s_zones;
47};
48
49struct minix_dir_entry {
50 uint16_t inode;
Denys Vlasenko606291b2009-09-23 23:15:43 +020051 char name[];
Denis Vlasenko87033fb2007-01-03 00:47:47 +000052};
53
54/* Believe it or not, but mount.h has this one #defined */
55#undef BLOCK_SIZE
56
57enum {
58 BLOCK_SIZE = 1024,
59 BITS_PER_BLOCK = BLOCK_SIZE << 3,
60
61 MINIX_ROOT_INO = 1,
62 MINIX_BAD_INO = 2,
63
Denys Vlasenko23961b22016-03-14 19:34:15 +010064#undef MINIX1_SUPER_MAGIC
Denis Vlasenko87033fb2007-01-03 00:47:47 +000065 MINIX1_SUPER_MAGIC = 0x137F, /* original minix fs */
Denys Vlasenko23961b22016-03-14 19:34:15 +010066#undef MINIX1_SUPER_MAGIC2
Denis Vlasenko87033fb2007-01-03 00:47:47 +000067 MINIX1_SUPER_MAGIC2 = 0x138F, /* minix fs, 30 char names */
Denys Vlasenko23961b22016-03-14 19:34:15 +010068/* bionic has this define */
69#undef MINIX2_SUPER_MAGIC
Denis Vlasenko87033fb2007-01-03 00:47:47 +000070 MINIX2_SUPER_MAGIC = 0x2468, /* minix V2 fs */
Denys Vlasenko23961b22016-03-14 19:34:15 +010071#undef MINIX2_SUPER_MAGIC2
Denis Vlasenko87033fb2007-01-03 00:47:47 +000072 MINIX2_SUPER_MAGIC2 = 0x2478, /* minix V2 fs, 30 char names */
73 MINIX_VALID_FS = 0x0001, /* clean fs */
74 MINIX_ERROR_FS = 0x0002, /* fs has errors */
75
76 INODE_SIZE1 = sizeof(struct minix1_inode),
77 INODE_SIZE2 = sizeof(struct minix2_inode),
78 MINIX1_INODES_PER_BLOCK = BLOCK_SIZE / sizeof(struct minix1_inode),
79 MINIX2_INODES_PER_BLOCK = BLOCK_SIZE / sizeof(struct minix2_inode),
80};
81
Denis Vlasenko26017b12007-06-13 12:49:46 +000082/*
83Basic test script for regressions in mkfs/fsck.
84Copies current dir into image (typically bbox build tree).
85
86#!/bin/sh
87tmpdir=/tmp/minixtest-$$
88tmpimg=/tmp/minix-img-$$
89
90mkdir $tmpdir
91dd if=/dev/zero of=$tmpimg bs=1M count=20 || exit
92./busybox mkfs.minix $tmpimg || exit
93mount -o loop $tmpimg $tmpdir || exit
94cp -a "$PWD" $tmpdir
95umount $tmpdir || exit
96./busybox fsck.minix -vfm $tmpimg || exit
97echo "Continue?"
98read junk
99./busybox fsck.minix -vfml $tmpimg || exit
100rmdir $tmpdir
101rm $tmpimg
102
103*/