Merge branch 'minix' of https://github.com/kerolasa/lelux-utiliteetit
* 'minix' of https://github.com/kerolasa/lelux-utiliteetit: libblkid: move MINIX_MAXPARTITIONS to minix.h minix: move globals and inline functions to minix_programs.h libblkid: use MINIX_BLOCK_SIZE from minix.h libblkid: use superblock structure from minix.h include: move minix.h to include directory include: remove kernel headers from minix.h include: minix.h: use data types from stdint.h Conflicts: disk-utils/Makefile.am Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
commit
e844147d17
|
@ -15,8 +15,9 @@ dist_man_MANS = isosize.8 mkfs.8 mkswap.8 \
|
|||
|
||||
sbin_PROGRAMS = mkfs mkswap fsck.minix mkfs.minix mkfs.bfs
|
||||
|
||||
fsck_minix_SOURCES = fsck.minix.c minix.h $(top_srcdir)/lib/ismounted.c
|
||||
mkfs_minix_SOURCES = mkfs.minix.c minix.h mkfs.h $(utils_common) $(top_srcdir)/lib/strutils.c
|
||||
fsck_minix_SOURCES = fsck.minix.c minix_programs.h $(top_srcdir)/lib/ismounted.c
|
||||
mkfs_minix_SOURCES = mkfs.minix.c minix_programs.h mkfs.h $(utils_common) \
|
||||
$(top_srcdir)/lib/strutils.c
|
||||
mkfs_bfs_SOURCES = mkfs.bfs.c $(utils_common) $(top_srcdir)/lib/strutils.c
|
||||
|
||||
swaplabel_SOURCES = swaplabel.c $(utils_common)
|
||||
|
|
|
@ -103,6 +103,7 @@
|
|||
#include <signal.h>
|
||||
|
||||
#include "minix.h"
|
||||
#include "minix_programs.h"
|
||||
#include "nls.h"
|
||||
#include "pathnames.h"
|
||||
#include "bitops.h"
|
||||
|
@ -345,20 +346,20 @@ check_zone_nr2 (unsigned int *nr, int *corrected) {
|
|||
static void
|
||||
read_block(unsigned int nr, char * addr) {
|
||||
if (!nr) {
|
||||
memset(addr,0,BLOCK_SIZE);
|
||||
memset(addr,0,MINIX_BLOCK_SIZE);
|
||||
return;
|
||||
}
|
||||
if (BLOCK_SIZE*nr != lseek(IN, BLOCK_SIZE*nr, SEEK_SET)) {
|
||||
if (MINIX_BLOCK_SIZE*nr != lseek(IN, 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,BLOCK_SIZE);
|
||||
memset(addr,0,MINIX_BLOCK_SIZE);
|
||||
errors_uncorrected = 1;
|
||||
} else if (BLOCK_SIZE != read(IN, addr, BLOCK_SIZE)) {
|
||||
} else if (MINIX_BLOCK_SIZE != read(IN, addr, MINIX_BLOCK_SIZE)) {
|
||||
get_current_name();
|
||||
printf(_("Read error: bad block in file '%s'\n"),
|
||||
current_name);
|
||||
memset(addr,0,BLOCK_SIZE);
|
||||
memset(addr,0,MINIX_BLOCK_SIZE);
|
||||
errors_uncorrected = 1;
|
||||
}
|
||||
}
|
||||
|
@ -376,9 +377,9 @@ write_block(unsigned int nr, char * addr) {
|
|||
errors_uncorrected = 1;
|
||||
return;
|
||||
}
|
||||
if (BLOCK_SIZE*nr != lseek(IN, BLOCK_SIZE*nr, SEEK_SET))
|
||||
if (MINIX_BLOCK_SIZE*nr != lseek(IN, MINIX_BLOCK_SIZE*nr, SEEK_SET))
|
||||
die(_("seek failed in write_block"));
|
||||
if (BLOCK_SIZE != write(IN, addr, BLOCK_SIZE)) {
|
||||
if (MINIX_BLOCK_SIZE != write(IN, addr, MINIX_BLOCK_SIZE)) {
|
||||
get_current_name();
|
||||
printf(_("Write error: bad block in file '%s'\n"),
|
||||
current_name);
|
||||
|
@ -393,8 +394,8 @@ write_block(unsigned int nr, char * addr) {
|
|||
*/
|
||||
static int
|
||||
map_block(struct minix_inode * inode, unsigned int blknr) {
|
||||
unsigned short ind[BLOCK_SIZE>>1];
|
||||
unsigned short dind[BLOCK_SIZE>>1];
|
||||
unsigned short ind[MINIX_BLOCK_SIZE>>1];
|
||||
unsigned short dind[MINIX_BLOCK_SIZE>>1];
|
||||
int blk_chg, block, result;
|
||||
|
||||
if (blknr<7)
|
||||
|
@ -427,9 +428,9 @@ map_block(struct minix_inode * inode, unsigned int blknr) {
|
|||
|
||||
static int
|
||||
map_block2 (struct minix2_inode *inode, unsigned int blknr) {
|
||||
unsigned int ind[BLOCK_SIZE >> 2];
|
||||
unsigned int dind[BLOCK_SIZE >> 2];
|
||||
unsigned int tind[BLOCK_SIZE >> 2];
|
||||
unsigned int ind[MINIX_BLOCK_SIZE >> 2];
|
||||
unsigned int dind[MINIX_BLOCK_SIZE >> 2];
|
||||
unsigned int tind[MINIX_BLOCK_SIZE >> 2];
|
||||
int blk_chg, block, result;
|
||||
|
||||
if (blknr < 7)
|
||||
|
@ -495,9 +496,9 @@ write_super_block(void) {
|
|||
else
|
||||
Super.s_state &= ~MINIX_ERROR_FS;
|
||||
|
||||
if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET))
|
||||
if (MINIX_BLOCK_SIZE != lseek(IN, MINIX_BLOCK_SIZE, SEEK_SET))
|
||||
die(_("seek failed in write_super_block"));
|
||||
if (BLOCK_SIZE != write(IN, super_block_buffer, BLOCK_SIZE))
|
||||
if (MINIX_BLOCK_SIZE != write(IN, super_block_buffer, MINIX_BLOCK_SIZE))
|
||||
die(_("unable to write super-block"));
|
||||
|
||||
return;
|
||||
|
@ -510,9 +511,9 @@ write_tables(void) {
|
|||
unsigned long imaps = get_nimaps();
|
||||
unsigned long zmaps = get_nzmaps();
|
||||
|
||||
if (imaps*BLOCK_SIZE != write(IN,inode_map, imaps*BLOCK_SIZE))
|
||||
if (imaps*MINIX_BLOCK_SIZE != write(IN,inode_map, imaps*MINIX_BLOCK_SIZE))
|
||||
die(_("Unable to write inode map"));
|
||||
if (zmaps*BLOCK_SIZE != write(IN,zone_map, zmaps*BLOCK_SIZE))
|
||||
if (zmaps*MINIX_BLOCK_SIZE != write(IN,zone_map, zmaps*MINIX_BLOCK_SIZE))
|
||||
die(_("Unable to write zone map"));
|
||||
if (buffsz != write(IN,inode_buffer, buffsz))
|
||||
die(_("Unable to write inodes"));
|
||||
|
@ -521,7 +522,7 @@ write_tables(void) {
|
|||
static void
|
||||
get_dirsize (void) {
|
||||
int block;
|
||||
char blk[BLOCK_SIZE];
|
||||
char blk[MINIX_BLOCK_SIZE];
|
||||
int size;
|
||||
|
||||
if (fs_version == 2)
|
||||
|
@ -529,7 +530,7 @@ get_dirsize (void) {
|
|||
else
|
||||
block = Inode[ROOT_INO].i_zone[0];
|
||||
read_block (block, blk);
|
||||
for (size = 16; size < BLOCK_SIZE; size <<= 1) {
|
||||
for (size = 16; size < MINIX_BLOCK_SIZE; size <<= 1) {
|
||||
if (strcmp (blk + size + 2, "..") == 0) {
|
||||
dirsize = size;
|
||||
namelen = size - 2;
|
||||
|
@ -541,14 +542,14 @@ get_dirsize (void) {
|
|||
|
||||
static void
|
||||
read_superblock(void) {
|
||||
if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET))
|
||||
if (MINIX_BLOCK_SIZE != lseek(IN, MINIX_BLOCK_SIZE, SEEK_SET))
|
||||
die(_("seek failed"));
|
||||
|
||||
super_block_buffer = calloc(1, BLOCK_SIZE);
|
||||
super_block_buffer = calloc(1, MINIX_BLOCK_SIZE);
|
||||
if (!super_block_buffer)
|
||||
die(_("unable to alloc buffer for superblock"));
|
||||
|
||||
if (BLOCK_SIZE != read(IN, super_block_buffer, BLOCK_SIZE))
|
||||
if (MINIX_BLOCK_SIZE != read(IN, super_block_buffer, MINIX_BLOCK_SIZE))
|
||||
die(_("unable to read super block"));
|
||||
if (MAGIC == MINIX_SUPER_MAGIC) {
|
||||
namelen = 14;
|
||||
|
@ -568,11 +569,11 @@ read_superblock(void) {
|
|||
fs_version = 2;
|
||||
} else
|
||||
die(_("bad magic number in super-block"));
|
||||
if (get_zone_size() != 0 || BLOCK_SIZE != 1024)
|
||||
if (get_zone_size() != 0 || MINIX_BLOCK_SIZE != 1024)
|
||||
die(_("Only 1k blocks/zones supported"));
|
||||
if (get_nimaps() * BLOCK_SIZE * 8 < get_ninodes() + 1)
|
||||
if (get_nimaps() * MINIX_BLOCK_SIZE * 8 < get_ninodes() + 1)
|
||||
die(_("bad s_imap_blocks field in super-block"));
|
||||
if (get_nzmaps() * BLOCK_SIZE * 8 < get_nzones() - get_first_zone() + 1)
|
||||
if (get_nzmaps() * MINIX_BLOCK_SIZE * 8 < get_nzones() - get_first_zone() + 1)
|
||||
die(_("bad s_zmap_blocks field in super-block"));
|
||||
}
|
||||
|
||||
|
@ -586,10 +587,10 @@ read_tables(void) {
|
|||
unsigned long imaps = get_nimaps();
|
||||
unsigned long zmaps = get_nzmaps();
|
||||
|
||||
inode_map = malloc(imaps * BLOCK_SIZE);
|
||||
inode_map = malloc(imaps * MINIX_BLOCK_SIZE);
|
||||
if (!inode_map)
|
||||
die(_("Unable to allocate buffer for inode map"));
|
||||
zone_map = malloc(zmaps * BLOCK_SIZE);
|
||||
zone_map = malloc(zmaps * MINIX_BLOCK_SIZE);
|
||||
if (!inode_map)
|
||||
die(_("Unable to allocate buffer for zone map"));
|
||||
memset(inode_map,0,sizeof(inode_map));
|
||||
|
@ -603,9 +604,9 @@ read_tables(void) {
|
|||
zone_count = malloc(zones);
|
||||
if (!zone_count)
|
||||
die(_("Unable to allocate buffer for zone count"));
|
||||
if (imaps*BLOCK_SIZE != read(IN,inode_map,imaps*BLOCK_SIZE))
|
||||
if (imaps*MINIX_BLOCK_SIZE != read(IN,inode_map,imaps*MINIX_BLOCK_SIZE))
|
||||
die(_("Unable to read inode map"));
|
||||
if (zmaps*BLOCK_SIZE != read(IN,zone_map, zmaps*BLOCK_SIZE))
|
||||
if (zmaps*MINIX_BLOCK_SIZE != read(IN,zone_map, zmaps*MINIX_BLOCK_SIZE))
|
||||
die(_("Unable to read zone map"));
|
||||
if (buffsz != read(IN,inode_buffer, buffsz))
|
||||
die(_("Unable to read inodes"));
|
||||
|
@ -618,7 +619,7 @@ read_tables(void) {
|
|||
printf(_("%ld inodes\n"), inodes);
|
||||
printf(_("%ld blocks\n"), zones);
|
||||
printf(_("Firstdatazone=%ld (%ld)\n"), first_zone, norm_first_zone);
|
||||
printf(_("Zonesize=%d\n"),BLOCK_SIZE<<get_zone_size());
|
||||
printf(_("Zonesize=%d\n"),MINIX_BLOCK_SIZE<<get_zone_size());
|
||||
printf(_("Maxsize=%ld\n"), get_max_size());
|
||||
printf(_("Filesystem state=%d\n"), Super.s_state);
|
||||
printf(_("namelen=%d\n\n"),namelen);
|
||||
|
@ -804,7 +805,7 @@ add_zone2 (unsigned int *znr, int *corrected) {
|
|||
|
||||
static void
|
||||
add_zone_ind(unsigned short * znr, int * corrected) {
|
||||
static char blk[BLOCK_SIZE];
|
||||
static char blk[MINIX_BLOCK_SIZE];
|
||||
int i, chg_blk=0;
|
||||
int block;
|
||||
|
||||
|
@ -812,7 +813,7 @@ add_zone_ind(unsigned short * znr, int * corrected) {
|
|||
if (!block)
|
||||
return;
|
||||
read_block(block, blk);
|
||||
for (i=0 ; i < (BLOCK_SIZE>>1) ; i++)
|
||||
for (i=0 ; i < (MINIX_BLOCK_SIZE>>1) ; i++)
|
||||
add_zone(i + (unsigned short *) blk, &chg_blk);
|
||||
if (chg_blk)
|
||||
write_block(block, blk);
|
||||
|
@ -820,7 +821,7 @@ add_zone_ind(unsigned short * znr, int * corrected) {
|
|||
|
||||
static void
|
||||
add_zone_ind2 (unsigned int *znr, int *corrected) {
|
||||
static char blk[BLOCK_SIZE];
|
||||
static char blk[MINIX_BLOCK_SIZE];
|
||||
int i, chg_blk = 0;
|
||||
int block;
|
||||
|
||||
|
@ -828,7 +829,7 @@ add_zone_ind2 (unsigned int *znr, int *corrected) {
|
|||
if (!block)
|
||||
return;
|
||||
read_block (block, blk);
|
||||
for (i = 0; i < BLOCK_SIZE >> 2; i++)
|
||||
for (i = 0; i < MINIX_BLOCK_SIZE >> 2; i++)
|
||||
add_zone2 (i + (unsigned int *) blk, &chg_blk);
|
||||
if (chg_blk)
|
||||
write_block (block, blk);
|
||||
|
@ -836,7 +837,7 @@ add_zone_ind2 (unsigned int *znr, int *corrected) {
|
|||
|
||||
static void
|
||||
add_zone_dind(unsigned short * znr, int * corrected) {
|
||||
static char blk[BLOCK_SIZE];
|
||||
static char blk[MINIX_BLOCK_SIZE];
|
||||
int i, blk_chg=0;
|
||||
int block;
|
||||
|
||||
|
@ -844,7 +845,7 @@ add_zone_dind(unsigned short * znr, int * corrected) {
|
|||
if (!block)
|
||||
return;
|
||||
read_block(block, blk);
|
||||
for (i=0 ; i < (BLOCK_SIZE>>1) ; i++)
|
||||
for (i=0 ; i < (MINIX_BLOCK_SIZE>>1) ; i++)
|
||||
add_zone_ind(i + (unsigned short *) blk, &blk_chg);
|
||||
if (blk_chg)
|
||||
write_block(block, blk);
|
||||
|
@ -852,7 +853,7 @@ add_zone_dind(unsigned short * znr, int * corrected) {
|
|||
|
||||
static void
|
||||
add_zone_dind2 (unsigned int *znr, int *corrected) {
|
||||
static char blk[BLOCK_SIZE];
|
||||
static char blk[MINIX_BLOCK_SIZE];
|
||||
int i, blk_chg = 0;
|
||||
int block;
|
||||
|
||||
|
@ -860,7 +861,7 @@ add_zone_dind2 (unsigned int *znr, int *corrected) {
|
|||
if (!block)
|
||||
return;
|
||||
read_block (block, blk);
|
||||
for (i = 0; i < BLOCK_SIZE >> 2; i++)
|
||||
for (i = 0; i < MINIX_BLOCK_SIZE >> 2; i++)
|
||||
add_zone_ind2 (i + (unsigned int *) blk, &blk_chg);
|
||||
if (blk_chg)
|
||||
write_block (block, blk);
|
||||
|
@ -868,7 +869,7 @@ add_zone_dind2 (unsigned int *znr, int *corrected) {
|
|||
|
||||
static void
|
||||
add_zone_tind2 (unsigned int *znr, int *corrected) {
|
||||
static char blk[BLOCK_SIZE];
|
||||
static char blk[MINIX_BLOCK_SIZE];
|
||||
int i, blk_chg = 0;
|
||||
int block;
|
||||
|
||||
|
@ -876,7 +877,7 @@ add_zone_tind2 (unsigned int *znr, int *corrected) {
|
|||
if (!block)
|
||||
return;
|
||||
read_block (block, blk);
|
||||
for (i = 0; i < BLOCK_SIZE >> 2; i++)
|
||||
for (i = 0; i < MINIX_BLOCK_SIZE >> 2; i++)
|
||||
add_zone_dind2 (i + (unsigned int *) blk, &blk_chg);
|
||||
if (blk_chg)
|
||||
write_block (block, blk);
|
||||
|
@ -921,15 +922,15 @@ check_zones2 (unsigned int i) {
|
|||
|
||||
static void
|
||||
check_file(struct minix_inode * dir, unsigned int offset) {
|
||||
static char blk[BLOCK_SIZE];
|
||||
static char blk[MINIX_BLOCK_SIZE];
|
||||
struct minix_inode * inode;
|
||||
int ino;
|
||||
char * name;
|
||||
int block;
|
||||
|
||||
block = map_block(dir,offset/BLOCK_SIZE);
|
||||
block = map_block(dir,offset/MINIX_BLOCK_SIZE);
|
||||
read_block(block, blk);
|
||||
name = blk + (offset % BLOCK_SIZE) + 2;
|
||||
name = blk + (offset % MINIX_BLOCK_SIZE) + 2;
|
||||
ino = * (unsigned short *) (name-2);
|
||||
if (ino > get_ninodes()) {
|
||||
get_current_name();
|
||||
|
@ -988,15 +989,15 @@ check_file(struct minix_inode * dir, unsigned int offset) {
|
|||
|
||||
static void
|
||||
check_file2 (struct minix2_inode *dir, unsigned int offset) {
|
||||
static char blk[BLOCK_SIZE];
|
||||
static char blk[MINIX_BLOCK_SIZE];
|
||||
struct minix2_inode *inode;
|
||||
int ino;
|
||||
char *name;
|
||||
int block;
|
||||
|
||||
block = map_block2 (dir, offset / BLOCK_SIZE);
|
||||
block = map_block2 (dir, offset / MINIX_BLOCK_SIZE);
|
||||
read_block (block, blk);
|
||||
name = blk + (offset % BLOCK_SIZE) + 2;
|
||||
name = blk + (offset % MINIX_BLOCK_SIZE) + 2;
|
||||
ino = *(unsigned short *) (name - 2);
|
||||
if (ino > get_ninodes()) {
|
||||
get_current_name();
|
||||
|
@ -1093,9 +1094,9 @@ static int
|
|||
bad_zone(int i) {
|
||||
char buffer[1024];
|
||||
|
||||
if (BLOCK_SIZE*i != lseek(IN, BLOCK_SIZE*i, SEEK_SET))
|
||||
if (MINIX_BLOCK_SIZE*i != lseek(IN, MINIX_BLOCK_SIZE*i, SEEK_SET))
|
||||
die(_("seek failed in bad_zone"));
|
||||
return (BLOCK_SIZE != read(IN, buffer, BLOCK_SIZE));
|
||||
return (MINIX_BLOCK_SIZE != read(IN, buffer, MINIX_BLOCK_SIZE));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1247,9 +1248,9 @@ main(int argc, char ** argv) {
|
|||
exit(0);
|
||||
}
|
||||
|
||||
if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE)
|
||||
if (INODE_SIZE * MINIX_INODES_PER_BLOCK != MINIX_BLOCK_SIZE)
|
||||
die(_("bad inode size"));
|
||||
if (INODE2_SIZE * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE)
|
||||
if (INODE2_SIZE * MINIX2_INODES_PER_BLOCK != MINIX_BLOCK_SIZE)
|
||||
die(_("bad v2 inode size"));
|
||||
|
||||
while (argc-- > 1) {
|
||||
|
|
|
@ -1,202 +0,0 @@
|
|||
#ifndef __MINIX_H__
|
||||
#define __MINIX_H__
|
||||
|
||||
#ifdef KERNEL_INCLUDES_ARE_CLEAN
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <linux/minix_fs.h>
|
||||
|
||||
#else
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
|
||||
struct minix_inode {
|
||||
u16 i_mode;
|
||||
u16 i_uid;
|
||||
u32 i_size;
|
||||
u32 i_time;
|
||||
u8 i_gid;
|
||||
u8 i_nlinks;
|
||||
u16 i_zone[9];
|
||||
};
|
||||
|
||||
struct minix2_inode {
|
||||
u16 i_mode;
|
||||
u16 i_nlinks;
|
||||
u16 i_uid;
|
||||
u16 i_gid;
|
||||
u32 i_size;
|
||||
u32 i_atime;
|
||||
u32 i_mtime;
|
||||
u32 i_ctime;
|
||||
u32 i_zone[10];
|
||||
};
|
||||
|
||||
struct minix_super_block {
|
||||
u16 s_ninodes;
|
||||
u16 s_nzones;
|
||||
u16 s_imap_blocks;
|
||||
u16 s_zmap_blocks;
|
||||
u16 s_firstdatazone;
|
||||
u16 s_log_zone_size;
|
||||
u32 s_max_size;
|
||||
u16 s_magic;
|
||||
u16 s_state;
|
||||
u32 s_zones;
|
||||
};
|
||||
|
||||
/* V3 minix super-block data on disk */
|
||||
struct minix3_super_block {
|
||||
u32 s_ninodes;
|
||||
u16 s_pad0;
|
||||
u16 s_imap_blocks;
|
||||
u16 s_zmap_blocks;
|
||||
u16 s_firstdatazone;
|
||||
u16 s_log_zone_size;
|
||||
u16 s_pad1;
|
||||
u32 s_max_size;
|
||||
u32 s_zones;
|
||||
u16 s_magic;
|
||||
u16 s_pad2;
|
||||
u16 s_blocksize;
|
||||
u8 s_disk_version;
|
||||
};
|
||||
|
||||
#define BLOCK_SIZE_BITS 10
|
||||
#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
|
||||
|
||||
#define NAME_MAX 255 /* # chars in a file name */
|
||||
#define MAX_INODES 65535
|
||||
|
||||
#define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode)))
|
||||
#define MINIX2_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix2_inode)))
|
||||
|
||||
#define MINIX_VALID_FS 0x0001 /* Clean fs. */
|
||||
#define MINIX_ERROR_FS 0x0002 /* fs has errors. */
|
||||
|
||||
#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
|
||||
#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
|
||||
#define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 fs */
|
||||
#define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2 fs, 30 char names */
|
||||
#define MINIX3_SUPER_MAGIC 0x4d5a /* minix V3 fs (60 char names) */
|
||||
|
||||
#endif /* KERNEL_INCLUDES_ARE_CLEAN */
|
||||
|
||||
#define Inode (((struct minix_inode *) inode_buffer)-1)
|
||||
#define Inode2 (((struct minix2_inode *) inode_buffer)-1)
|
||||
|
||||
#define INODE_SIZE (sizeof(struct minix_inode))
|
||||
#define INODE2_SIZE (sizeof(struct minix2_inode))
|
||||
|
||||
int fs_version = 1; /* this default value needs to change in a near future */
|
||||
char *super_block_buffer, *inode_buffer = NULL;
|
||||
|
||||
static char *inode_map;
|
||||
static char *zone_map;
|
||||
|
||||
#define BITS_PER_BLOCK (BLOCK_SIZE<<3)
|
||||
|
||||
#define UPPER(size,n) ((size+((n)-1))/(n))
|
||||
|
||||
/*
|
||||
* wrappers to different superblock attributes
|
||||
*/
|
||||
#define Super (*(struct minix_super_block *)super_block_buffer)
|
||||
#define Super3 (*(struct minix3_super_block *)super_block_buffer)
|
||||
|
||||
static inline unsigned long get_ninodes(void)
|
||||
{
|
||||
switch (fs_version) {
|
||||
case 3:
|
||||
return Super3.s_ninodes;
|
||||
default:
|
||||
return (unsigned long) Super.s_ninodes;
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long get_nzones(void)
|
||||
{
|
||||
switch (fs_version) {
|
||||
case 3:
|
||||
return (unsigned long) Super3.s_zones;
|
||||
case 2:
|
||||
return (unsigned long) Super.s_zones;
|
||||
default:
|
||||
return (unsigned long) Super.s_nzones;
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long get_nimaps(void)
|
||||
{
|
||||
switch (fs_version) {
|
||||
case 3:
|
||||
return (unsigned long) Super3.s_imap_blocks;
|
||||
default:
|
||||
return (unsigned long) Super.s_imap_blocks;
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long get_nzmaps(void)
|
||||
{
|
||||
switch (fs_version) {
|
||||
case 3:
|
||||
return (unsigned long) Super3.s_zmap_blocks;
|
||||
default:
|
||||
return (unsigned long) Super.s_zmap_blocks;
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long get_first_zone(void)
|
||||
{
|
||||
switch (fs_version) {
|
||||
case 3:
|
||||
return (unsigned long) Super3.s_firstdatazone;
|
||||
default:
|
||||
return (unsigned long) Super.s_firstdatazone;
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long get_zone_size(void)
|
||||
{
|
||||
switch (fs_version) {
|
||||
case 3:
|
||||
return (unsigned long) Super3.s_log_zone_size;
|
||||
default:
|
||||
return (unsigned long) Super.s_log_zone_size;
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long get_max_size(void)
|
||||
{
|
||||
switch (fs_version) {
|
||||
case 3:
|
||||
return (unsigned long) Super3.s_max_size;
|
||||
default:
|
||||
return (unsigned long) Super.s_max_size;
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned long inode_blocks(void)
|
||||
{
|
||||
switch (fs_version) {
|
||||
case 3:
|
||||
case 2:
|
||||
return UPPER(get_ninodes(), MINIX2_INODES_PER_BLOCK);
|
||||
default:
|
||||
return UPPER(get_ninodes(), MINIX_INODES_PER_BLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long first_zone_data(void)
|
||||
{
|
||||
return 2 + get_nimaps() + get_nzmaps() + inode_blocks();
|
||||
}
|
||||
|
||||
static inline unsigned long get_inode_buffer_size(void)
|
||||
{
|
||||
return inode_blocks() * BLOCK_SIZE;
|
||||
}
|
||||
|
||||
#endif /* __MINIX_H__ */
|
|
@ -0,0 +1,113 @@
|
|||
#ifndef UTIL_LINUX_MINIX_PROGRAMS_H
|
||||
#define UTIL_LINUX_MINIX_PROGRAMS_H
|
||||
|
||||
#include "minix.h"
|
||||
|
||||
/*
|
||||
* Global variables.
|
||||
*/
|
||||
static int fs_version = 1; /* this default value needs to change in a near future */
|
||||
|
||||
static char *super_block_buffer;
|
||||
static char *inode_buffer = NULL;
|
||||
|
||||
static char *inode_map;
|
||||
static char *zone_map;
|
||||
|
||||
/*
|
||||
* Inline functions.
|
||||
*/
|
||||
static inline unsigned long get_ninodes(void)
|
||||
{
|
||||
switch (fs_version) {
|
||||
case 3:
|
||||
return Super3.s_ninodes;
|
||||
default:
|
||||
return (unsigned long)Super.s_ninodes;
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long get_nzones(void)
|
||||
{
|
||||
switch (fs_version) {
|
||||
case 3:
|
||||
return (unsigned long)Super3.s_zones;
|
||||
case 2:
|
||||
return (unsigned long)Super.s_zones;
|
||||
default:
|
||||
return (unsigned long)Super.s_nzones;
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long get_nimaps(void)
|
||||
{
|
||||
switch (fs_version) {
|
||||
case 3:
|
||||
return (unsigned long)Super3.s_imap_blocks;
|
||||
default:
|
||||
return (unsigned long)Super.s_imap_blocks;
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long get_nzmaps(void)
|
||||
{
|
||||
switch (fs_version) {
|
||||
case 3:
|
||||
return (unsigned long)Super3.s_zmap_blocks;
|
||||
default:
|
||||
return (unsigned long)Super.s_zmap_blocks;
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long get_first_zone(void)
|
||||
{
|
||||
switch (fs_version) {
|
||||
case 3:
|
||||
return (unsigned long)Super3.s_firstdatazone;
|
||||
default:
|
||||
return (unsigned long)Super.s_firstdatazone;
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long get_zone_size(void)
|
||||
{
|
||||
switch (fs_version) {
|
||||
case 3:
|
||||
return (unsigned long)Super3.s_log_zone_size;
|
||||
default:
|
||||
return (unsigned long)Super.s_log_zone_size;
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long get_max_size(void)
|
||||
{
|
||||
switch (fs_version) {
|
||||
case 3:
|
||||
return (unsigned long)Super3.s_max_size;
|
||||
default:
|
||||
return (unsigned long)Super.s_max_size;
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned long inode_blocks(void)
|
||||
{
|
||||
switch (fs_version) {
|
||||
case 3:
|
||||
case 2:
|
||||
return UPPER(get_ninodes(), MINIX2_INODES_PER_BLOCK);
|
||||
default:
|
||||
return UPPER(get_ninodes(), MINIX_INODES_PER_BLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long first_zone_data(void)
|
||||
{
|
||||
return 2 + get_nimaps() + get_nzmaps() + inode_blocks();
|
||||
}
|
||||
|
||||
static inline unsigned long get_inode_buffer_size(void)
|
||||
{
|
||||
return inode_blocks() * MINIX_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
#endif /* UTIL_LINUX_MINIX_PROGRAMS_H */
|
|
@ -79,6 +79,7 @@
|
|||
|
||||
#include "blkdev.h"
|
||||
#include "minix.h"
|
||||
#include "minix_programs.h"
|
||||
#include "nls.h"
|
||||
#include "pathnames.h"
|
||||
#include "bitops.h"
|
||||
|
@ -111,7 +112,7 @@ static int dirsize = 32;
|
|||
static int magic = MINIX_SUPER_MAGIC2;
|
||||
static int version2 = 0;
|
||||
|
||||
static char root_block[BLOCK_SIZE] = "\0";
|
||||
static char root_block[MINIX_BLOCK_SIZE] = "\0";
|
||||
|
||||
static char boot_block_buffer[512];
|
||||
#define Super (*(struct minix_super_block *)super_block_buffer)
|
||||
|
@ -181,22 +182,22 @@ static void write_tables(void) {
|
|||
" in write_tables"), device_name);
|
||||
if (512 != write(DEV, boot_block_buffer, 512))
|
||||
err(MKFS_ERROR, _("%s: unable to clear boot sector"), device_name);
|
||||
if (BLOCK_SIZE != lseek(DEV, BLOCK_SIZE, SEEK_SET))
|
||||
if (MINIX_BLOCK_SIZE != lseek(DEV, MINIX_BLOCK_SIZE, SEEK_SET))
|
||||
err(MKFS_ERROR, _("%s: seek failed in write_tables"), device_name);
|
||||
if (BLOCK_SIZE != write(DEV, super_block_buffer, BLOCK_SIZE))
|
||||
if (MINIX_BLOCK_SIZE != write(DEV, super_block_buffer, MINIX_BLOCK_SIZE))
|
||||
err(MKFS_ERROR, _("%s: unable to write super-block"), device_name);
|
||||
if (imaps*BLOCK_SIZE != write(DEV,inode_map, imaps*BLOCK_SIZE))
|
||||
if (imaps*MINIX_BLOCK_SIZE != write(DEV,inode_map, imaps*MINIX_BLOCK_SIZE))
|
||||
err(MKFS_ERROR, _("%s: unable to write inode map"), device_name);
|
||||
if (zmaps*BLOCK_SIZE != write(DEV,zone_map, zmaps*BLOCK_SIZE))
|
||||
if (zmaps*MINIX_BLOCK_SIZE != write(DEV,zone_map, zmaps*MINIX_BLOCK_SIZE))
|
||||
err(MKFS_ERROR, _("%s: unable to write zone map"), device_name);
|
||||
if (buffsz != write(DEV,inode_buffer, buffsz))
|
||||
err(MKFS_ERROR, _("%s: unable to write inodes"), device_name);
|
||||
}
|
||||
|
||||
static void write_block(int blk, char * buffer) {
|
||||
if (blk*BLOCK_SIZE != lseek(DEV, blk*BLOCK_SIZE, SEEK_SET))
|
||||
if (blk*MINIX_BLOCK_SIZE != lseek(DEV, blk*MINIX_BLOCK_SIZE, SEEK_SET))
|
||||
errx(MKFS_ERROR, _("%s: seek failed in write_block"), device_name);
|
||||
if (BLOCK_SIZE != write(DEV, buffer, BLOCK_SIZE))
|
||||
if (MINIX_BLOCK_SIZE != write(DEV, buffer, MINIX_BLOCK_SIZE))
|
||||
errx(MKFS_ERROR, _("%s: write failed in write_block"), device_name);
|
||||
}
|
||||
|
||||
|
@ -244,8 +245,8 @@ static void make_bad_inode_v1(void)
|
|||
struct minix_inode * inode = &Inode[MINIX_BAD_INO];
|
||||
int i,j,zone;
|
||||
int ind=0,dind=0;
|
||||
unsigned short ind_block[BLOCK_SIZE>>1];
|
||||
unsigned short dind_block[BLOCK_SIZE>>1];
|
||||
unsigned short ind_block[MINIX_BLOCK_SIZE>>1];
|
||||
unsigned short dind_block[MINIX_BLOCK_SIZE>>1];
|
||||
|
||||
#define NEXT_BAD (zone = next(zone))
|
||||
|
||||
|
@ -255,7 +256,7 @@ static void make_bad_inode_v1(void)
|
|||
inode->i_nlinks = 1;
|
||||
inode->i_time = time(NULL);
|
||||
inode->i_mode = S_IFREG + 0000;
|
||||
inode->i_size = badblocks*BLOCK_SIZE;
|
||||
inode->i_size = badblocks*MINIX_BLOCK_SIZE;
|
||||
zone = next(0);
|
||||
for (i=0 ; i<7 ; i++) {
|
||||
inode->i_zone[i] = zone;
|
||||
|
@ -263,18 +264,18 @@ static void make_bad_inode_v1(void)
|
|||
goto end_bad;
|
||||
}
|
||||
inode->i_zone[7] = ind = get_free_block();
|
||||
memset(ind_block,0,BLOCK_SIZE);
|
||||
memset(ind_block,0,MINIX_BLOCK_SIZE);
|
||||
for (i=0 ; i<512 ; i++) {
|
||||
ind_block[i] = zone;
|
||||
if (!NEXT_BAD)
|
||||
goto end_bad;
|
||||
}
|
||||
inode->i_zone[8] = dind = get_free_block();
|
||||
memset(dind_block,0,BLOCK_SIZE);
|
||||
memset(dind_block,0,MINIX_BLOCK_SIZE);
|
||||
for (i=0 ; i<512 ; i++) {
|
||||
write_block(ind,(char *) ind_block);
|
||||
dind_block[i] = ind = get_free_block();
|
||||
memset(ind_block,0,BLOCK_SIZE);
|
||||
memset(ind_block,0,MINIX_BLOCK_SIZE);
|
||||
for (j=0 ; j<512 ; j++) {
|
||||
ind_block[j] = zone;
|
||||
if (!NEXT_BAD)
|
||||
|
@ -294,8 +295,8 @@ static void make_bad_inode_v2_v3 (void)
|
|||
struct minix2_inode *inode = &Inode2[MINIX_BAD_INO];
|
||||
int i, j, zone;
|
||||
int ind = 0, dind = 0;
|
||||
unsigned long ind_block[BLOCK_SIZE >> 2];
|
||||
unsigned long dind_block[BLOCK_SIZE >> 2];
|
||||
unsigned long ind_block[MINIX_BLOCK_SIZE >> 2];
|
||||
unsigned long dind_block[MINIX_BLOCK_SIZE >> 2];
|
||||
|
||||
if (!badblocks)
|
||||
return;
|
||||
|
@ -303,7 +304,7 @@ static void make_bad_inode_v2_v3 (void)
|
|||
inode->i_nlinks = 1;
|
||||
inode->i_atime = inode->i_mtime = inode->i_ctime = time (NULL);
|
||||
inode->i_mode = S_IFREG + 0000;
|
||||
inode->i_size = badblocks * BLOCK_SIZE;
|
||||
inode->i_size = badblocks * MINIX_BLOCK_SIZE;
|
||||
zone = next (0);
|
||||
for (i = 0; i < 7; i++) {
|
||||
inode->i_zone[i] = zone;
|
||||
|
@ -311,18 +312,18 @@ static void make_bad_inode_v2_v3 (void)
|
|||
goto end_bad;
|
||||
}
|
||||
inode->i_zone[7] = ind = get_free_block ();
|
||||
memset (ind_block, 0, BLOCK_SIZE);
|
||||
memset (ind_block, 0, MINIX_BLOCK_SIZE);
|
||||
for (i = 0; i < 256; i++) {
|
||||
ind_block[i] = zone;
|
||||
if (!NEXT_BAD)
|
||||
goto end_bad;
|
||||
}
|
||||
inode->i_zone[8] = dind = get_free_block ();
|
||||
memset (dind_block, 0, BLOCK_SIZE);
|
||||
memset (dind_block, 0, MINIX_BLOCK_SIZE);
|
||||
for (i = 0; i < 256; i++) {
|
||||
write_block (ind, (char *) ind_block);
|
||||
dind_block[i] = ind = get_free_block ();
|
||||
memset (ind_block, 0, BLOCK_SIZE);
|
||||
memset (ind_block, 0, MINIX_BLOCK_SIZE);
|
||||
for (j = 0; j < 256; j++) {
|
||||
ind_block[j] = zone;
|
||||
if (!NEXT_BAD)
|
||||
|
@ -458,7 +459,7 @@ static void setup_tables(void) {
|
|||
int i;
|
||||
unsigned long inodes, zmaps, imaps, zones;
|
||||
|
||||
super_block_buffer = calloc(1, BLOCK_SIZE);
|
||||
super_block_buffer = calloc(1, MINIX_BLOCK_SIZE);
|
||||
if (!super_block_buffer)
|
||||
err(MKFS_ERROR, _("%s: unable to alloc buffer for superblock"),
|
||||
device_name);
|
||||
|
@ -501,13 +502,13 @@ static void setup_tables(void) {
|
|||
imaps = get_nimaps();
|
||||
zmaps = get_nzmaps();
|
||||
|
||||
inode_map = malloc(imaps * BLOCK_SIZE);
|
||||
zone_map = malloc(zmaps * BLOCK_SIZE);
|
||||
inode_map = malloc(imaps * MINIX_BLOCK_SIZE);
|
||||
zone_map = malloc(zmaps * MINIX_BLOCK_SIZE);
|
||||
if (!inode_map || !zone_map)
|
||||
err(MKFS_ERROR, _("%s: unable to allocate buffers for maps"),
|
||||
device_name);
|
||||
memset(inode_map,0xff,imaps * BLOCK_SIZE);
|
||||
memset(zone_map,0xff,zmaps * BLOCK_SIZE);
|
||||
memset(inode_map,0xff,imaps * MINIX_BLOCK_SIZE);
|
||||
memset(zone_map,0xff,zmaps * MINIX_BLOCK_SIZE);
|
||||
for (i = get_first_zone() ; i<zones ; i++)
|
||||
unmark_zone(i);
|
||||
for (i = MINIX_ROOT_INO ; i<=inodes; i++)
|
||||
|
@ -520,7 +521,7 @@ static void setup_tables(void) {
|
|||
printf(_("%ld inodes\n"), inodes);
|
||||
printf(_("%ld blocks\n"), zones);
|
||||
printf(_("Firstdatazone=%ld (%ld)\n"), get_first_zone(), first_zone_data());
|
||||
printf(_("Zonesize=%d\n"),BLOCK_SIZE<<get_zone_size());
|
||||
printf(_("Zonesize=%d\n"),MINIX_BLOCK_SIZE<<get_zone_size());
|
||||
printf(_("Maxsize=%ld\n\n"),get_max_size());
|
||||
}
|
||||
|
||||
|
@ -532,18 +533,18 @@ static long do_check(char * buffer, int try, unsigned int current_block) {
|
|||
long got;
|
||||
|
||||
/* Seek to the correct loc. */
|
||||
if (lseek(DEV, current_block * BLOCK_SIZE, SEEK_SET) !=
|
||||
current_block * BLOCK_SIZE )
|
||||
if (lseek(DEV, current_block * MINIX_BLOCK_SIZE, SEEK_SET) !=
|
||||
current_block * MINIX_BLOCK_SIZE )
|
||||
err(MKFS_ERROR, _("%s: seek failed during testing of blocks"),
|
||||
device_name);
|
||||
|
||||
/* Try the read */
|
||||
got = read(DEV, buffer, try * BLOCK_SIZE);
|
||||
got = read(DEV, buffer, try * MINIX_BLOCK_SIZE);
|
||||
if (got < 0) got = 0;
|
||||
if (got & (BLOCK_SIZE - 1 )) {
|
||||
if (got & (MINIX_BLOCK_SIZE - 1 )) {
|
||||
printf(_("Weird values in do_check: probably bugs\n"));
|
||||
}
|
||||
got /= BLOCK_SIZE;
|
||||
got /= MINIX_BLOCK_SIZE;
|
||||
return got;
|
||||
}
|
||||
|
||||
|
@ -564,7 +565,7 @@ static void alarm_intr(int alnum) {
|
|||
|
||||
static void check_blocks(void) {
|
||||
int try,got;
|
||||
static char buffer[BLOCK_SIZE * TEST_BUFFER_BLOCKS];
|
||||
static char buffer[MINIX_BLOCK_SIZE * TEST_BUFFER_BLOCKS];
|
||||
unsigned long zones = get_nzones();
|
||||
unsigned long first_zone = get_first_zone();
|
||||
|
||||
|
@ -572,8 +573,8 @@ static void check_blocks(void) {
|
|||
signal(SIGALRM,alarm_intr);
|
||||
alarm(5);
|
||||
while (currently_testing < zones) {
|
||||
if (lseek(DEV,currently_testing*BLOCK_SIZE,SEEK_SET) !=
|
||||
currently_testing*BLOCK_SIZE)
|
||||
if (lseek(DEV,currently_testing*MINIX_BLOCK_SIZE,SEEK_SET) !=
|
||||
currently_testing*MINIX_BLOCK_SIZE)
|
||||
errx(MKFS_ERROR, _("%s: seek failed in check_blocks"),
|
||||
device_name);
|
||||
try = TEST_BUFFER_BLOCKS;
|
||||
|
@ -644,9 +645,9 @@ int main(int argc, char ** argv) {
|
|||
exit(0);
|
||||
}
|
||||
|
||||
if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE)
|
||||
if (INODE_SIZE * MINIX_INODES_PER_BLOCK != MINIX_BLOCK_SIZE)
|
||||
errx(MKFS_ERROR, _("%s: bad inode size"), device_name);
|
||||
if (INODE2_SIZE * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE)
|
||||
if (INODE2_SIZE * MINIX2_INODES_PER_BLOCK != MINIX_BLOCK_SIZE)
|
||||
errx(MKFS_ERROR, _("%s: bad inode size"), device_name);
|
||||
|
||||
opterr = 0;
|
||||
|
@ -733,18 +734,18 @@ int main(int argc, char ** argv) {
|
|||
if (blkdev_is_misaligned(DEV))
|
||||
warnx(_("%s: device is misaligned"), device_name);
|
||||
|
||||
if (BLOCK_SIZE < sectorsize)
|
||||
if (MINIX_BLOCK_SIZE < sectorsize)
|
||||
errx(MKFS_ERROR, _("block size smaller than physical "
|
||||
"sector size of %s"), device_name);
|
||||
if (!BLOCKS) {
|
||||
if (blkdev_get_size(DEV, &BLOCKS) == -1)
|
||||
errx(MKFS_ERROR, _("cannot determine size of %s"),
|
||||
device_name);
|
||||
BLOCKS /= BLOCK_SIZE;
|
||||
BLOCKS /= MINIX_BLOCK_SIZE;
|
||||
}
|
||||
} else if (!S_ISBLK(statbuf.st_mode)) {
|
||||
if (!BLOCKS)
|
||||
BLOCKS = statbuf.st_size / BLOCK_SIZE;
|
||||
BLOCKS = statbuf.st_size / MINIX_BLOCK_SIZE;
|
||||
check=0;
|
||||
} else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340)
|
||||
errx(MKFS_ERROR, _("will not try to make filesystem on '%s'"), device_name);
|
||||
|
|
|
@ -19,6 +19,7 @@ dist_noinst_HEADERS = \
|
|||
mangle.h \
|
||||
mbsalign.h \
|
||||
md5.h \
|
||||
minix.h \
|
||||
nls.h \
|
||||
pathnames.h \
|
||||
procutils.h \
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
#ifndef UTIL_LINUX_MINIX_H
|
||||
#define UTIL_LINUX_MINIX_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct minix_inode {
|
||||
uint16_t i_mode;
|
||||
uint16_t i_uid;
|
||||
uint32_t i_size;
|
||||
uint32_t i_time;
|
||||
uint8_t i_gid;
|
||||
uint8_t i_nlinks;
|
||||
uint16_t i_zone[9];
|
||||
};
|
||||
|
||||
struct minix2_inode {
|
||||
uint16_t i_mode;
|
||||
uint16_t i_nlinks;
|
||||
uint16_t i_uid;
|
||||
uint16_t i_gid;
|
||||
uint32_t i_size;
|
||||
uint32_t i_atime;
|
||||
uint32_t i_mtime;
|
||||
uint32_t i_ctime;
|
||||
uint32_t i_zone[10];
|
||||
};
|
||||
|
||||
struct minix_super_block {
|
||||
uint16_t s_ninodes;
|
||||
uint16_t s_nzones;
|
||||
uint16_t s_imap_blocks;
|
||||
uint16_t s_zmap_blocks;
|
||||
uint16_t s_firstdatazone;
|
||||
uint16_t s_log_zone_size;
|
||||
uint32_t s_max_size;
|
||||
uint16_t s_magic;
|
||||
uint16_t s_state;
|
||||
uint32_t s_zones;
|
||||
};
|
||||
|
||||
/* V3 minix super-block data on disk */
|
||||
struct minix3_super_block {
|
||||
uint32_t s_ninodes;
|
||||
uint16_t s_pad0;
|
||||
uint16_t s_imap_blocks;
|
||||
uint16_t s_zmap_blocks;
|
||||
uint16_t s_firstdatazone;
|
||||
uint16_t s_log_zone_size;
|
||||
uint16_t s_pad1;
|
||||
uint32_t s_max_size;
|
||||
uint32_t s_zones;
|
||||
uint16_t s_magic;
|
||||
uint16_t s_pad2;
|
||||
uint16_t s_blocksize;
|
||||
uint8_t s_disk_version;
|
||||
};
|
||||
|
||||
/*
|
||||
* Minix subpartitions are always within primary dos partition.
|
||||
*/
|
||||
#define MINIX_MAXPARTITIONS 4
|
||||
|
||||
#define MINIX_BLOCK_SIZE_BITS 10
|
||||
#define MINIX_BLOCK_SIZE (1<<MINIX_BLOCK_SIZE_BITS)
|
||||
|
||||
#define NAME_MAX 255 /* # chars in a file name */
|
||||
#define MAX_INODES 65535
|
||||
|
||||
#define MINIX_INODES_PER_BLOCK ((MINIX_BLOCK_SIZE)/(sizeof (struct minix_inode)))
|
||||
#define MINIX2_INODES_PER_BLOCK ((MINIX_BLOCK_SIZE)/(sizeof (struct minix2_inode)))
|
||||
|
||||
#define MINIX_VALID_FS 0x0001 /* Clean fs. */
|
||||
#define MINIX_ERROR_FS 0x0002 /* fs has errors. */
|
||||
|
||||
#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
|
||||
#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
|
||||
#define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 fs */
|
||||
#define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2 fs, 30 char names */
|
||||
#define MINIX3_SUPER_MAGIC 0x4d5a /* minix V3 fs (60 char names) */
|
||||
|
||||
#define Inode (((struct minix_inode *) inode_buffer)-1)
|
||||
#define Inode2 (((struct minix2_inode *) inode_buffer)-1)
|
||||
|
||||
#define INODE_SIZE (sizeof(struct minix_inode))
|
||||
#define INODE2_SIZE (sizeof(struct minix2_inode))
|
||||
|
||||
#define BITS_PER_BLOCK (MINIX_BLOCK_SIZE<<3)
|
||||
|
||||
#define UPPER(size,n) ((size+((n)-1))/(n))
|
||||
|
||||
/*
|
||||
* wrappers to different superblock attributes
|
||||
*/
|
||||
#define Super (*(struct minix_super_block *)super_block_buffer)
|
||||
#define Super3 (*(struct minix3_super_block *)super_block_buffer)
|
||||
|
||||
#endif /* UTIL_LINUX_MINIX_H */
|
|
@ -13,11 +13,7 @@
|
|||
|
||||
#include "partitions.h"
|
||||
#include "dos.h"
|
||||
|
||||
/*
|
||||
* Minix subpartitions are always within primary dos partition.
|
||||
*/
|
||||
#define MINIX_MAXPARTITIONS 4
|
||||
#include "minix.h"
|
||||
|
||||
static int probe_minix_pt(blkid_probe pr, const struct blkid_idmag *mag)
|
||||
{
|
||||
|
|
|
@ -11,38 +11,7 @@
|
|||
|
||||
#include <string.h>
|
||||
#include "superblocks.h"
|
||||
|
||||
struct minix_super_block {
|
||||
uint16_t s_ninodes;
|
||||
uint16_t s_nzones;
|
||||
uint16_t s_imap_blocks;
|
||||
uint16_t s_zmap_blocks;
|
||||
uint16_t s_firstdatazone;
|
||||
uint16_t s_log_zone_size;
|
||||
uint32_t s_max_size;
|
||||
uint16_t s_magic;
|
||||
uint16_t s_state;
|
||||
uint32_t s_zones;
|
||||
};
|
||||
|
||||
struct minix3_super_block {
|
||||
uint32_t s_ninodes;
|
||||
uint16_t s_pad0;
|
||||
uint16_t s_imap_blocks;
|
||||
uint16_t s_zmap_blocks;
|
||||
uint16_t s_firstdatazone;
|
||||
uint16_t s_log_zone_size;
|
||||
uint16_t s_pad1;
|
||||
uint32_t s_max_size;
|
||||
uint32_t s_zones;
|
||||
uint16_t s_magic;
|
||||
uint16_t s_pad2;
|
||||
uint16_t s_blocksize;
|
||||
uint8_t s_disk_version;
|
||||
};
|
||||
|
||||
#define MINIX_BLOCK_SIZE_BITS 10
|
||||
#define MINIX_BLOCK_SIZE (1 << MINIX_BLOCK_SIZE_BITS)
|
||||
#include "minix.h"
|
||||
|
||||
static int probe_minix(blkid_probe pr, const struct blkid_idmag *mag)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue