New sources layout
Change-Id: Ic716f336b7071063997cf5b4dae6d50e0b4631e9
This commit is contained in:
@@ -32,15 +32,11 @@ SUBDIR= \
|
||||
\
|
||||
zic
|
||||
|
||||
.if defined(__MINIX)
|
||||
# LSC MINIX Specific
|
||||
SUBDIR+= mkfs.mfs \
|
||||
mkproto
|
||||
.else
|
||||
.if !defined(__MINIX)
|
||||
.if ${MKMAKEMANDB} != "no"
|
||||
SUBDIR+= makemandb
|
||||
.endif
|
||||
.endif # defined(__MINIX)
|
||||
.endif # !defined(__MINIX)
|
||||
|
||||
.if (${MKYP} != "no")
|
||||
SUBDIR+= rpc.yppasswdd ypbind yppoll ypserv ypset
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
SUBDIR= v3
|
||||
|
||||
.if !defined(HOSTPROGNAME)
|
||||
#SUBDIR+= v1 v2 # Original V1 and V2 file systems
|
||||
#SUBDIR+= v1l v2l # Linux-extended variants
|
||||
#SUBDIR+= mfs3v2 # V2 as handled by regular MINIX 3.x; hacky
|
||||
.endif
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
@@ -1,21 +0,0 @@
|
||||
SRCS= mkfs.c
|
||||
BINDIR?= /usr/sbin
|
||||
MAN?=
|
||||
|
||||
.include <bsd.own.mk>
|
||||
.include "${.PARSEDIR}/../Makefile.inc"
|
||||
|
||||
.PATH: ${.CURDIR}/..
|
||||
|
||||
CPPFLAGS+= -I${.CURDIR}
|
||||
|
||||
.if ${HOST_OSTYPE:C/\-.*//:U} == "Minix" || !defined(HOSTPROGNAME)
|
||||
#LSC: FIXME This should not be required, more so only on Minix...
|
||||
LDADD+= -lminlib -lcompat_minix
|
||||
DPADD+= ${MINLIB} ${COMPAT_MINIX}
|
||||
.endif
|
||||
|
||||
NOGCCERROR?= yes
|
||||
NOCLANGERROR?= yes
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -1,3 +0,0 @@
|
||||
PROG= mkfs.mfs3v2
|
||||
|
||||
.include <../Makefile.mkfs>
|
||||
@@ -1,15 +0,0 @@
|
||||
/* "V2" minixFS as handled by MINIX 3.x
|
||||
*
|
||||
* The difference with the normal V2 file systems is due to the use of
|
||||
* the V3 declaration for the super block (struct super) and the directory
|
||||
* entries (struct direct); this allows to use more than 65,535 inodes
|
||||
* and filenames of up to 60 characters.
|
||||
* A normal MINIX 2.0.x installation cannot read these file systems.
|
||||
*
|
||||
* The differences with a V3 file system with a block-size of 1024 are
|
||||
* limited to the use of a different magic number, since the inodes
|
||||
* have the same layout in both V2 and V3 file systems.
|
||||
*/
|
||||
|
||||
/* Constants; unchanged from regular V2... */
|
||||
#include "../v2/const.h"
|
||||
@@ -1,2 +0,0 @@
|
||||
/* Directory entry structure; unchanged from V3 */
|
||||
#include "../v3/mfsdir.h"
|
||||
@@ -1,2 +0,0 @@
|
||||
/* Super block; unchanged from regular V3 */
|
||||
#include "../v3/super.h"
|
||||
@@ -1,2 +0,0 @@
|
||||
/* Inode structure; unchanged from regular V2; V3 is identical anyway */
|
||||
#include "../v2/type.h"
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +0,0 @@
|
||||
PROG= mkfs.mfsv1
|
||||
|
||||
.include <../Makefile.mkfs>
|
||||
@@ -1,49 +0,0 @@
|
||||
#ifndef _MKFS_MFS_CONST_H__
|
||||
#define _MKFS_MFS_CONST_H__
|
||||
|
||||
/* Tables sizes */
|
||||
#define NR_DZONES 7 /* # direct zone numbers in a V1 inode */
|
||||
#define NR_TZONES 9 /* total # zone numbers in a V1 inode */
|
||||
|
||||
/* V1 file systems are special in that zone numbers are only 16-bit */
|
||||
#define zone_t uint16_t
|
||||
|
||||
/* Blocks are of a fixed size */
|
||||
#define MFS_STATIC_BLOCK_SIZE 1024
|
||||
|
||||
#define SUPER_BLOCK_BYTES MFS_STATIC_BLOCK_SIZE /* 1 block */
|
||||
|
||||
/* The type of sizeof may be (unsigned) long. Use the following macro for
|
||||
* taking the sizes of small objects so that there are no surprises like
|
||||
* (small) long constants being passed to routines expecting an int.
|
||||
*/
|
||||
#define usizeof(t) ((unsigned) sizeof(t))
|
||||
|
||||
/* File system types: magic number contained in super-block. */
|
||||
#define SUPER_V1 0x137F /* magic # for V1 file systems */
|
||||
#define SUPER_MAGIC SUPER_V1
|
||||
|
||||
/* Miscellaneous constants */
|
||||
#define SU_UID ((uid_t) 0) /* super_user's uid_t */
|
||||
#define SECTOR_SIZE 512
|
||||
|
||||
#define BOOT_BLOCK ((block_t) 0) /* block number of boot block */
|
||||
#define SUPER_BLOCK ((block_t) 1) /* block number of super block */
|
||||
#define START_BLOCK ((block_t) 2) /* first block of FS (not counting SB) */
|
||||
|
||||
#define ROOT_INODE ((ino_t) 1) /* inode number for root directory */
|
||||
|
||||
/* Derived sizes pertaining to the file system. */
|
||||
#define FS_BITMAP_CHUNKS(b) ((b)/usizeof(bitchunk_t)) /*# map chunks/blk*/
|
||||
#define FS_BITCHUNK_BITS (usizeof(bitchunk_t) * CHAR_BIT)
|
||||
#define FS_BITS_PER_BLOCK(b) (FS_BITMAP_CHUNKS(b) * FS_BITCHUNK_BITS)
|
||||
|
||||
#define ZONE_NUM_SIZE usizeof (zone_t) /* # bytes in zone */
|
||||
#define INODE_SIZE usizeof (struct inode) /* bytes in dsk ino */
|
||||
#define INODES_PER_BLOCK(b) ((b)/INODE_SIZE) /* # V2 dsk inodes/blk */
|
||||
#define INDIRECTS(b) ((b)/ZONE_NUM_SIZE) /* # zones/indir block */
|
||||
|
||||
#define DIR_ENTRY_SIZE usizeof(struct direct) /* # bytes/dir entry */
|
||||
#define NR_DIR_ENTRIES(b) ((b)/DIR_ENTRY_SIZE) /* # dir entries/blk */
|
||||
|
||||
#endif
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef _MKFS_MFSDIR_H
|
||||
#define _MKFS_MFSDIR_H
|
||||
|
||||
/* Minix MFS V1/V2 on-disk directory filename. */
|
||||
#define MFS_DIRSIZ 14
|
||||
|
||||
struct direct {
|
||||
uint16_t d_ino;
|
||||
char d_name[MFS_DIRSIZ];
|
||||
} __packed;
|
||||
|
||||
#endif /* _MKFS_MFSDIR_H */
|
||||
@@ -1,39 +0,0 @@
|
||||
#ifndef _MKFS_MFS_SUPER_H__
|
||||
#define _MKFS_MFS_SUPER_H__
|
||||
|
||||
/* Super block table. The entry holds information about the sizes of the bit
|
||||
* maps and inodes. The s_ninodes field gives the number of inodes available
|
||||
* for files and directories, including the root directory. Inode 0 is
|
||||
* on the disk, but not used. Thus s_ninodes = 4 means that 5 bits will be
|
||||
* used in the bit map, bit 0, which is always 1 and not used, and bits 1-4
|
||||
* for files and directories. The disk layout is:
|
||||
*
|
||||
* Item # blocks
|
||||
* boot block 1
|
||||
* super block 1
|
||||
* inode map s_imap_blocks
|
||||
* zone map s_zmap_blocks
|
||||
* inodes (s_ninodes + 'inodes per block' - 1)/'inodes per block'
|
||||
* unused whatever is needed to fill out the current zone
|
||||
* data zones (s_zones - s_firstdatazone) << s_log_zone_size
|
||||
*/
|
||||
|
||||
struct super_block {
|
||||
uint16_t s_ninodes; /* # usable inodes on the minor device */
|
||||
uint16_t s_nzones; /* total device size, including bit maps etc */
|
||||
int16_t s_imap_blocks; /* # of blocks used by inode bit map */
|
||||
int16_t s_zmap_blocks; /* # of blocks used by zone bit map */
|
||||
uint16_t s_firstdatazone; /* number of first data zone (small) */
|
||||
int16_t s_log_zone_size; /* log2 of blocks/zone */
|
||||
uint32_t s_max_size; /* maximum file size on this device */
|
||||
int16_t s_magic; /* magic number to recognize super-blocks */
|
||||
} superblock;
|
||||
|
||||
/* Some members have been overidden in later versions: */
|
||||
#define s_firstdatazone_old s_firstdatazone
|
||||
#define s_zones s_nzones
|
||||
|
||||
#undef MFSFLAG_CLEAN
|
||||
#undef MFSFLAG_MANDATORY_MASK
|
||||
|
||||
#endif
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef _MKFS_MFS_TYPE_H__
|
||||
#define _MKFS_MFS_TYPE_H__
|
||||
|
||||
/* Declaration of the V1 inode as it is on the disk (not in core). */
|
||||
struct inode { /* V1 disk inode */
|
||||
uint16_t i_mode; /* file type, protection, etc. */
|
||||
uint16_t i_uid; /* user id of the file's owner. */
|
||||
uint32_t i_size; /* current file size in bytes */
|
||||
uint32_t i_mtime; /* when was file data last changed */
|
||||
uint8_t i_gid; /* group number */
|
||||
uint8_t i_nlinks; /* how many links to this file. */
|
||||
uint16_t i_zone[NR_TZONES]; /* zone nums for direct, ind, and dbl ind */
|
||||
};
|
||||
|
||||
/* Note: in V1 there was only one kind of timestamp kept in inodes! */
|
||||
#define MFS_INODE_ONLY_MTIME
|
||||
|
||||
#endif
|
||||
@@ -1,3 +0,0 @@
|
||||
PROG= mkfs.mfsv1l
|
||||
|
||||
.include <../Makefile.mkfs>
|
||||
@@ -1,13 +0,0 @@
|
||||
/* Extended V1 minixFS as defined by Linux
|
||||
* The difference with the normal V1 file systems as used on MINIX are the
|
||||
* size of the file names in the directoru entries, which are extended
|
||||
* to 30 characters (instead of 14.)
|
||||
*/
|
||||
|
||||
/* Constants; unchanged from regular V1... */
|
||||
#include "../v1/const.h"
|
||||
|
||||
/* ... except for magic number contained in super-block: */
|
||||
#define SUPER_V1L 0x138F /* magic # for "Linux" extended V1 minixFS */
|
||||
#undef SUPER_MAGIC
|
||||
#define SUPER_MAGIC SUPER_V1L
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef _MKFS_MFSDIR_H
|
||||
#define _MKFS_MFSDIR_H
|
||||
|
||||
/* Linux-extended Minix MFS V1/V2 on-disk directory entry. */
|
||||
#define MFS_DIRSIZ 30
|
||||
|
||||
struct direct {
|
||||
uint16_t d_ino;
|
||||
char d_name[MFS_DIRSIZ];
|
||||
} __packed;
|
||||
|
||||
#endif /* _MKFS_MFSDIR_H */
|
||||
@@ -1,2 +0,0 @@
|
||||
/* Super block; unchanged from regular V1 */
|
||||
#include "../v1/super.h"
|
||||
@@ -1,2 +0,0 @@
|
||||
/* Inode structure; unchanged from regular V1 */
|
||||
#include "../v1/type.h"
|
||||
@@ -1,3 +0,0 @@
|
||||
PROG= mkfs.mfsv2
|
||||
|
||||
.include <../Makefile.mkfs>
|
||||
@@ -1,45 +0,0 @@
|
||||
#ifndef _MKFS_MFS_CONST_H__
|
||||
#define _MKFS_MFS_CONST_H__
|
||||
|
||||
/* Tables sizes */
|
||||
#define NR_DZONES 7 /* # direct zone numbers in a V2 inode */
|
||||
#define NR_TZONES 10 /* total # zone numbers in a V2 inode */
|
||||
|
||||
/* Blocks are of a fixed size */
|
||||
#define MFS_STATIC_BLOCK_SIZE 1024
|
||||
|
||||
#define SUPER_BLOCK_BYTES MFS_STATIC_BLOCK_SIZE /* 1 block */
|
||||
|
||||
/* The type of sizeof may be (unsigned) long. Use the following macro for
|
||||
* taking the sizes of small objects so that there are no surprises like
|
||||
* (small) long constants being passed to routines expecting an int.
|
||||
*/
|
||||
#define usizeof(t) ((unsigned) sizeof(t))
|
||||
|
||||
/* File system types: magic number contained in super-block. */
|
||||
#define SUPER_V2 0x2468 /* magic # for V2 file systems */
|
||||
#define SUPER_MAGIC SUPER_V2
|
||||
|
||||
/* Miscellaneous constants */
|
||||
#define SU_UID ((uid_t) 0) /* super_user's uid_t */
|
||||
#define SECTOR_SIZE 512
|
||||
|
||||
#define BOOT_BLOCK ((block_t) 0) /* block number of boot block */
|
||||
#define SUPER_BLOCK ((block_t) 1) /* block number of super block */
|
||||
#define START_BLOCK ((block_t) 2) /* first block of FS (not counting SB) */
|
||||
|
||||
#define ROOT_INODE ((ino_t) 1) /* inode number for root directory */
|
||||
|
||||
/* Derived sizes pertaining to the file system. */
|
||||
#define FS_BITMAP_CHUNKS(b) ((b)/usizeof (uint32_t))/* # map chunks/blk */
|
||||
#define FS_BITCHUNK_BITS (usizeof(uint32_t) * CHAR_BIT)
|
||||
#define FS_BITS_PER_BLOCK(b) (FS_BITMAP_CHUNKS(b) * FS_BITCHUNK_BITS)
|
||||
|
||||
#define ZONE_NUM_SIZE usizeof (zone_t) /* # bytes in zone */
|
||||
#define INODE_SIZE usizeof (struct inode) /* bytes in dsk ino */
|
||||
#define INODES_PER_BLOCK(b) ((b)/INODE_SIZE) /* # V2 dsk inodes/blk */
|
||||
#define INDIRECTS(b) ((b)/ZONE_NUM_SIZE) /* # zones/indir block */
|
||||
|
||||
#define DIR_ENTRY_SIZE usizeof(struct direct) /* # bytes/dir entry */
|
||||
#define NR_DIR_ENTRIES(b) ((b)/DIR_ENTRY_SIZE) /* # dir entries/blk */
|
||||
#endif
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef _MKFS_MFSDIR_H
|
||||
#define _MKFS_MFSDIR_H
|
||||
|
||||
/* Minix MFS V1/V2 on-disk directory filename. */
|
||||
#define MFS_DIRSIZ 14
|
||||
|
||||
struct direct {
|
||||
uint16_t d_ino;
|
||||
char d_name[MFS_DIRSIZ];
|
||||
} __packed;
|
||||
|
||||
#endif /* _MKFS_MFSDIR_H */
|
||||
@@ -1,39 +0,0 @@
|
||||
#ifndef _MKFS_MFS_SUPER_H__
|
||||
#define _MKFS_MFS_SUPER_H__
|
||||
|
||||
/* Super block table. The entry holds information about the sizes of the bit
|
||||
* maps and inodes. The s_ninodes field gives the number of inodes available
|
||||
* for files and directories, including the root directory. Inode 0 is
|
||||
* on the disk, but not used. Thus s_ninodes = 4 means that 5 bits will be
|
||||
* used in the bit map, bit 0, which is always 1 and not used, and bits 1-4
|
||||
* for files and directories. The disk layout is:
|
||||
*
|
||||
* Item # blocks
|
||||
* boot block 1
|
||||
* super block 1
|
||||
* inode map s_imap_blocks
|
||||
* zone map s_zmap_blocks
|
||||
* inodes (s_ninodes + 'inodes per block' - 1)/'inodes per block'
|
||||
* unused whatever is needed to fill out the current zone
|
||||
* data zones (s_zones - s_firstdatazone) << s_log_zone_size
|
||||
*/
|
||||
|
||||
struct super_block {
|
||||
uint16_t s_ninodes; /* # usable inodes on the minor device */
|
||||
uint16_t s_nzones; /* total device size, including bit maps etc */
|
||||
int16_t s_imap_blocks; /* # of blocks used by inode bit map */
|
||||
int16_t s_zmap_blocks; /* # of blocks used by zone bit map */
|
||||
uint16_t s_firstdatazone; /* number of first data zone (small) */
|
||||
int16_t s_log_zone_size; /* log2 of blocks/zone */
|
||||
uint32_t s_max_size; /* maximum file size on this device */
|
||||
int16_t s_magic; /* magic number to recognize super-blocks */
|
||||
int16_t s_pad; /* try to avoid compiler-dependent padding */
|
||||
uint32_t s_zones; /* number of zones (replaces s_nzones in V2) */
|
||||
} superblock;
|
||||
|
||||
#define s_firstdatazone_old s_firstdatazone
|
||||
|
||||
#undef MFSFLAG_CLEAN
|
||||
#undef MFSFLAG_MANDATORY_MASK
|
||||
|
||||
#endif
|
||||
@@ -1,16 +0,0 @@
|
||||
#ifndef _MKFS_MFS_TYPE_H__
|
||||
#define _MKFS_MFS_TYPE_H__
|
||||
|
||||
/* Declaration of the V2/V3 inode as it is on the disk (not in core). */
|
||||
struct inode { /* V2/V3 disk inode */
|
||||
uint16_t i_mode; /* file type, protection, etc. */
|
||||
uint16_t i_nlinks; /* how many links to this file. */
|
||||
uint16_t i_uid; /* user id of the file's owner. */
|
||||
uint16_t i_gid; /* group number */
|
||||
uint32_t i_size; /* current file size in bytes */
|
||||
uint32_t i_atime; /* when was file data last accessed */
|
||||
uint32_t i_mtime; /* when was file data last changed */
|
||||
uint32_t i_ctime; /* when was inode data last changed */
|
||||
uint32_t i_zone[NR_TZONES]; /* zone nums for direct, ind, and dbl ind */
|
||||
};
|
||||
#endif
|
||||
@@ -1,3 +0,0 @@
|
||||
PROG= mkfs.mfsv2l
|
||||
|
||||
.include <../Makefile.mkfs>
|
||||
@@ -1,13 +0,0 @@
|
||||
/* Extended V2 minixFS as defined by Linux
|
||||
* The difference with the normal V2 file systems as used on MINIX are the
|
||||
* size of the file names in the directoru entries, which are extended
|
||||
* to 30 characters (instead of 14.)
|
||||
*/
|
||||
|
||||
/* Constants; unchanged from regular V2... */
|
||||
#include "../v2/const.h"
|
||||
|
||||
/* ... except for magic number contained in super-block: */
|
||||
#define SUPER_V2L 0x2478 /* magic # for "Linux" extended V2 minixFS */
|
||||
#undef SUPER_MAGIC
|
||||
#define SUPER_MAGIC SUPER_V2L
|
||||
@@ -1,2 +0,0 @@
|
||||
/* Directory entry structure; unchanged from V1L */
|
||||
#include "../v1l/mfsdir.h"
|
||||
@@ -1,2 +0,0 @@
|
||||
/* Super block; unchanged from regular V2 */
|
||||
#include "../v2/super.h"
|
||||
@@ -1,2 +0,0 @@
|
||||
/* Inode structure; unchanged from regular V2 */
|
||||
#include "../v2/type.h"
|
||||
@@ -1,13 +0,0 @@
|
||||
PROG= mkfs.mfsv3
|
||||
|
||||
# XXX consider section 8
|
||||
MAN= mkfs.mfs.1
|
||||
|
||||
.if !defined(HOSTPROGNAME)
|
||||
# The default MFS version is v3
|
||||
SYMLINKS+= ${BINDIR}/${PROG} /usr/sbin/newfs_mfs
|
||||
SYMLINKS+= ${BINDIR}/${PROG} /sbin/mkfs.mfs
|
||||
MLINKS+= mkfs.mfs.1 newfs_mfs.1
|
||||
.endif
|
||||
|
||||
.include <../Makefile.mkfs>
|
||||
@@ -1,43 +0,0 @@
|
||||
#ifndef _MKFS_MFS_CONST_H__
|
||||
#define _MKFS_MFS_CONST_H__
|
||||
|
||||
/* Tables sizes */
|
||||
#define NR_DZONES 7 /* # direct zone numbers in a V2 inode */
|
||||
#define NR_TZONES 10 /* total # zone numbers in a V2 inode */
|
||||
|
||||
#define MIN_BLOCK_SIZE 1024
|
||||
#define DEFAULT_BLOCK_SIZE 4096
|
||||
|
||||
/* The type of sizeof may be (unsigned) long. Use the following macro for
|
||||
* taking the sizes of small objects so that there are no surprises like
|
||||
* (small) long constants being passed to routines expecting an int.
|
||||
*/
|
||||
#define usizeof(t) ((unsigned) sizeof(t))
|
||||
|
||||
/* File system types: magic number contained in super-block. */
|
||||
#define SUPER_V3 0x4d5a /* magic # for V3 file systems */
|
||||
#define SUPER_MAGIC SUPER_V3
|
||||
|
||||
/* Miscellaneous constants */
|
||||
#define SU_UID ((uid_t) 0) /* super_user's uid_t */
|
||||
#define SECTOR_SIZE 512
|
||||
|
||||
#define ROOT_INODE ((ino_t) 1) /* inode number for root directory */
|
||||
|
||||
#define BOOT_BLOCK ((blkcnt_t) 0) /* block number of boot block */
|
||||
#define SUPER_BLOCK_BYTES (1024) /* bytes offset */
|
||||
#define START_BLOCK ((blkcnt_t) 2) /* first block of FS (not counting SB) */
|
||||
|
||||
#define FS_BITMAP_CHUNKS(b) ((b)/usizeof(bitchunk_t)) /*# map chunks/blk*/
|
||||
#define FS_BITCHUNK_BITS (usizeof(bitchunk_t) * CHAR_BIT)
|
||||
#define FS_BITS_PER_BLOCK(b) (FS_BITMAP_CHUNKS(b) * FS_BITCHUNK_BITS)
|
||||
|
||||
/* Derived sizes pertaining to the file system. */
|
||||
#define ZONE_NUM_SIZE usizeof (zone_t) /* # bytes in zone */
|
||||
#define INODE_SIZE usizeof (struct inode) /* bytes in dsk ino */
|
||||
#define INDIRECTS(b) ((b)/ZONE_NUM_SIZE) /* # zones/indir block */
|
||||
#define INODES_PER_BLOCK(b) ((b)/INODE_SIZE) /* # V2 dsk inodes/blk */
|
||||
|
||||
#define DIR_ENTRY_SIZE usizeof(struct direct) /* # bytes/dir entry */
|
||||
#define NR_DIR_ENTRIES(b) ((b)/DIR_ENTRY_SIZE) /* # dir entries/blk */
|
||||
#endif
|
||||
@@ -1,16 +0,0 @@
|
||||
#ifndef _MKFS_MFSDIR_H
|
||||
#define _MKFS_MFSDIR_H
|
||||
|
||||
/* Maximum Minix MFS on-disk directory filename.
|
||||
* MFS uses 'struct direct' to write and parse
|
||||
* directory entries, so this can't be changed
|
||||
* without breaking filesystems.
|
||||
*/
|
||||
#define MFS_DIRSIZ 60
|
||||
|
||||
struct direct {
|
||||
uint32_t d_ino;
|
||||
char d_name[MFS_DIRSIZ];
|
||||
} __packed;
|
||||
|
||||
#endif /* _MKFS_MFSDIR_H */
|
||||
@@ -1,127 +0,0 @@
|
||||
.Dd April 28, 2013
|
||||
.Dt MKFS.MFS 1
|
||||
.Os MINIX 3
|
||||
.Sh NAME
|
||||
.Nm mkfs.mfs
|
||||
.Nd make a file system
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl ldtv
|
||||
.Op Fl B Ar blocksize
|
||||
.Op Fl i Ar inodes
|
||||
.Op Fl b Ar blocks
|
||||
.Op Fl z Ar zone_shift
|
||||
.Op Fl x Ar extra_space
|
||||
.Op Fl I Ar fs_offset
|
||||
.Op Fl T Ar timestamp
|
||||
.Ar special
|
||||
.Op Ar prototype
|
||||
.Sh OPTIONS
|
||||
The following options are available:
|
||||
.Bl -tag -width indent
|
||||
.It Fl l
|
||||
Make a listing on standard output
|
||||
.It Fl d
|
||||
Use mod time of
|
||||
.Nm
|
||||
binary for all files
|
||||
.It Fl t
|
||||
Do not test if file system fits on the medium
|
||||
.It Fl v
|
||||
Be verbose on standard error stream; more
|
||||
.It Fl v
|
||||
options add to verbosity
|
||||
.It Fl i Ar inodes
|
||||
Number of i-nodes (files)
|
||||
.It Fl B Ar blocksize
|
||||
Filesystem block size (in bytes)
|
||||
.It Fl b Ar blocks
|
||||
Filesystem size (in blocks)
|
||||
.It Fl I Ar fs_offset
|
||||
Write filesystem starting at offset (in bytes)
|
||||
.It Fl T Ar timestamp
|
||||
Use timestamp for inode times
|
||||
.It Fl x Ar extra_space
|
||||
Extra space after dynamic sizing (blocks and inodes)
|
||||
.It Fl z Ar zone_shift
|
||||
Logarithm of the size of a zone with respect to a zone.
|
||||
With the default value of 0 zones are of the same size as blocks;
|
||||
with 1, each zone is made of two blocks; etc.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
.Bl -enum
|
||||
.It
|
||||
Make a file system on
|
||||
.Pa /dev/ram1
|
||||
.Bd
|
||||
.Nm
|
||||
.Cm /dev/ram1 proto
|
||||
.Ed
|
||||
.It
|
||||
Make empty 300,000-block file system
|
||||
.Bd
|
||||
.Nm
|
||||
.Cm -b 300000 /dev/c0d0p0s0
|
||||
.Ed
|
||||
.It
|
||||
Alternate way to specify the size
|
||||
.Bd
|
||||
.Nm
|
||||
.Cm /dev/c0d0p0s0 300000
|
||||
.Ed
|
||||
.El
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
builds a file system and copies specified files to it.
|
||||
The prototype file tells which directories and files to copy to it.
|
||||
If the prototype file cannot be opened, and its name is just a string of
|
||||
digits, an empty file system will be made with the specified number of
|
||||
blocks.
|
||||
A sample prototype file follows.
|
||||
The text following the \fI#\fR sign in the example below is comment.
|
||||
In real prototype files, comments are not allowed.
|
||||
.Bd -literal
|
||||
boot # boot block file (ignored)
|
||||
360 63 # blocks and i-nodes
|
||||
d--755 1 1 # root directory
|
||||
bin d--755 \|2 1 # bin dir: mode (755), uid (2), gid (1)
|
||||
sh \|---755 2 1 /user/bin/shell # shell has mode \fIrwxr-xr-x\fP
|
||||
mv -u-755 2 1 /user/bin/mv # u = SETUID bit
|
||||
login -ug755 2 1 /user/bin/login # SETUID and SETGID
|
||||
$ # end of \fI/bin\fP
|
||||
dev d--755 2 1 # special files: tty (char), fd0 (block)
|
||||
tty c--777 2 1 4 0 # uid=2, gid=1, major=4, minor=0
|
||||
fd0 b--644 2 1 2 0 360 # uid, gid, major, minor, blocks
|
||||
$ # end of \fI/dev\fP
|
||||
user d--755 12 1 # user dir: mode (755), uid (12), gid (1)
|
||||
ast d--755 12 1 # \fI/user/ast\fP
|
||||
$ # \fI/user/ast\fP is empty
|
||||
$ # end of \fI/user\fP
|
||||
$ # end of root directory
|
||||
.Ed
|
||||
.Pp
|
||||
The first entry on each line (except the first 3 and the $ lines, which
|
||||
terminate directories) is the name the file or directory will get on the
|
||||
new file system.
|
||||
Next comes its mode, with the first character being
|
||||
.Cm -dbcs
|
||||
for regular files, directories, block special files, character
|
||||
special files, and symlinks, respectively.
|
||||
The next two characters are used to specify the SETUID and SETGID bits, as
|
||||
shown above.
|
||||
The last three characters of the mode are the
|
||||
.Cm rwx
|
||||
protection bits, in octal notation.
|
||||
.Pp
|
||||
Following the mode are the uid and gid.
|
||||
For special files, the major and minor devices are needed.
|
||||
.Sh "SEE ALSO"
|
||||
.Xr mkproto 1 ,
|
||||
.Xr fsck.mfs 1 ,
|
||||
.Xr mount 1 .
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
utility was written by
|
||||
.An Andy Tanenbaum, Paul Ogilvie, Frans Meulenbroeks, Bruce Evans
|
||||
@@ -1,74 +0,0 @@
|
||||
#ifndef _MKFS_MFS_SUPER_H__
|
||||
#define _MKFS_MFS_SUPER_H__
|
||||
|
||||
/* Super block table. The entry holds information about the sizes of the bit
|
||||
* maps and inodes. The s_ninodes field gives the number of inodes available
|
||||
* for files and directories, including the root directory. Inode 0 is
|
||||
* on the disk, but not used. Thus s_ninodes = 4 means that 5 bits will be
|
||||
* used in the bit map, bit 0, which is always 1 and not used, and bits 1-4
|
||||
* for files and directories. The disk layout is:
|
||||
*
|
||||
* Item # blocks
|
||||
* boot block 1
|
||||
* super block 1 (offset 1kB)
|
||||
* inode map s_imap_blocks
|
||||
* zone map s_zmap_blocks
|
||||
* inodes (s_ninodes + 'inodes per block' - 1)/'inodes per block'
|
||||
* unused whatever is needed to fill out the current zone
|
||||
* data zones (s_zones - s_firstdatazone) << s_log_zone_size
|
||||
*/
|
||||
|
||||
struct super_block {
|
||||
uint32_t s_ninodes; /* # usable inodes on the minor device */
|
||||
uint16_t s_nzones; /* total device size, including bit maps etc */
|
||||
int16_t s_imap_blocks; /* # of blocks used by inode bit map */
|
||||
int16_t s_zmap_blocks; /* # of blocks used by zone bit map */
|
||||
uint16_t s_firstdatazone_old; /* number of first data zone (small) */
|
||||
uint16_t s_log_zone_size; /* log2 of blocks/zone */
|
||||
uint16_t s_flags; /* FS state flags */
|
||||
int32_t s_max_size; /* maximum file size on this device */
|
||||
uint32_t s_zones; /* number of zones (replaces s_nzones in V2) */
|
||||
int16_t s_magic; /* magic number to recognize super-blocks */
|
||||
|
||||
/* The following items are valid on disk only for V3 and above */
|
||||
|
||||
int16_t s_pad2; /* try to avoid compiler-dependent padding */
|
||||
/* The block size in bytes. Minimum MIN_BLOCK SIZE. SECTOR_SIZE multiple.*/
|
||||
uint16_t s_block_size; /* block size in bytes. */
|
||||
int8_t s_disk_version; /* filesystem format sub-version */
|
||||
|
||||
/* The following items are only used when the super_block is in memory.
|
||||
* If this ever changes, i.e. more fields after s_disk_version has to go to
|
||||
* disk, update LAST_ONDISK_FIELD in servers/mfs/super.c as that controls
|
||||
* which part of the struct is copied to and from disk.
|
||||
*/
|
||||
/* XXX padding inserted here... */
|
||||
|
||||
unsigned s_inodes_per_block; /* precalculated from magic number */
|
||||
uint32_t s_firstdatazone; /* number of first data zone (big) */
|
||||
} superblock;
|
||||
|
||||
/* s_flags contents; undefined flags are guaranteed to be zero on disk
|
||||
* (not counting future versions of mfs setting them!)
|
||||
*/
|
||||
#define MFSFLAG_CLEAN (1L << 0) /* 0: dirty; 1: FS was unmounted cleanly */
|
||||
|
||||
/* Future compatability (or at least, graceful failure):
|
||||
* if any of these bits are on, and the MFS or fsck
|
||||
* implementation doesn't understand them, do not mount/fsck
|
||||
* the FS.
|
||||
*/
|
||||
#define MFSFLAG_MANDATORY_MASK 0xff00
|
||||
|
||||
/* The block size should be registered on disk, even
|
||||
* multiple. If V1 or V2 filesystem, this should be
|
||||
* initialised to STATIC_BLOCK_SIZE.
|
||||
*/
|
||||
#define MFS_SUPER_BLOCK_SIZE s_block_size
|
||||
|
||||
/* To keep the super block on disk clean, the MFS server only read/write up to
|
||||
* and including this field:
|
||||
*/
|
||||
#define LAST_ONDISK_FIELD s_disk_version
|
||||
|
||||
#endif
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef _MKFS_MFS_TYPE_H__
|
||||
#define _MKFS_MFS_TYPE_H__
|
||||
|
||||
/* Declaration of the V2 inode as it is on the disk (not in core). */
|
||||
/* The same structure is used for V3. */
|
||||
struct inode { /* V2/V3 disk inode */
|
||||
uint16_t i_mode; /* file type, protection, etc. */
|
||||
uint16_t i_nlinks; /* how many links to this file. */
|
||||
int16_t i_uid; /* user id of the file's owner. */
|
||||
uint16_t i_gid; /* group number */
|
||||
uint32_t i_size; /* current file size in bytes */
|
||||
uint32_t i_atime; /* when was file data last accessed */
|
||||
uint32_t i_mtime; /* when was file data last changed */
|
||||
uint32_t i_ctime; /* when was inode data last changed */
|
||||
uint32_t i_zone[NR_TZONES]; /* zone nums for direct, ind, and dbl ind */
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,10 +0,0 @@
|
||||
PROG= mkproto
|
||||
MAN=
|
||||
|
||||
LDADD+= -lminlib
|
||||
DPADD+= ${LIBMINLIB}
|
||||
|
||||
NOGCCERROR?= yes
|
||||
NOCLANGERROR?= yes
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -1,340 +0,0 @@
|
||||
/* mkproto - make an mkfs prototype Author: Andrew Cagney */
|
||||
|
||||
/* Submitted by: cagney@chook.ua.oz (Andrew Cagney - aka Noid) */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <minix/minlib.h>
|
||||
#include <limits.h>
|
||||
#include <dirent.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <err.h>
|
||||
|
||||
/* The default values for the prototype file */
|
||||
#define DEF_UID 2 /* bin */
|
||||
#define DEF_GID 1 /* daemon group */
|
||||
#define DEF_PROT 0555 /* a=re */
|
||||
#define DEF_BLOCKS 360
|
||||
#define DEF_INODES 63
|
||||
#define DEF_INDENTSTR "\t"
|
||||
|
||||
#ifndef major
|
||||
#define major(x) ( (x>>8) & 0377)
|
||||
#define minor(x) (x & 0377)
|
||||
#endif
|
||||
|
||||
/* Globals. */
|
||||
int count, origlen, tabs;
|
||||
int gid, uid, prot, same_uid, same_gid, same_prot, blocks, inodes;
|
||||
int block_given, inode_given, dprot;
|
||||
char *indentstr;
|
||||
char *proto_file, *top;
|
||||
FILE *outfile;
|
||||
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
int main(int argc, char **argv);
|
||||
void descend(char *dirname);
|
||||
void display_attrib(const char *name, struct stat *st);
|
||||
void usage(char *binname);
|
||||
void open_outfile(void);
|
||||
|
||||
/* Returned by minix_readdir */
|
||||
#define ME_MAXNAME 256
|
||||
struct me_dirent {
|
||||
char d_name[ME_MAXNAME];
|
||||
};
|
||||
|
||||
struct me_dirent *minix_readdir(DIR *, int *n);
|
||||
void minix_free_readdir(struct me_dirent *md, int n);
|
||||
|
||||
|
||||
/* Compare dirent objects for order */
|
||||
static int cmp_dirent(const void *d1, const void *d2)
|
||||
{
|
||||
struct me_dirent *dp1 = (struct me_dirent *) d1,
|
||||
*dp2 = (struct me_dirent *) d2;
|
||||
return strcmp(dp1->d_name, dp2->d_name);
|
||||
}
|
||||
|
||||
/* Return array of me_dirents. */
|
||||
struct me_dirent *minix_readdir(DIR *dirp, int *n)
|
||||
{
|
||||
struct dirent *rdp;
|
||||
struct me_dirent *dp;
|
||||
struct me_dirent *dirents = NULL;
|
||||
int reserved_dirents = 0;
|
||||
int entries = 0;
|
||||
|
||||
while((rdp = readdir(dirp)) != NULL) {
|
||||
if(entries >= reserved_dirents) {
|
||||
struct me_dirent *newdirents;
|
||||
int newreserved = (2*(reserved_dirents+1));
|
||||
if(!(newdirents = realloc(dirents, newreserved *
|
||||
sizeof(*dirents)))) {
|
||||
free(dirents);
|
||||
return NULL;
|
||||
}
|
||||
dirents = newdirents;
|
||||
reserved_dirents = newreserved;
|
||||
}
|
||||
|
||||
assert(entries < reserved_dirents);
|
||||
assert(strlen(rdp->d_name) < sizeof(dp->d_name));
|
||||
dp = &dirents[entries];
|
||||
memset(dp, 0, sizeof(*dp));
|
||||
strcpy(dp->d_name, rdp->d_name);
|
||||
entries++;
|
||||
}
|
||||
|
||||
/* Assume directories contain at least "." and "..", and
|
||||
* therefore the array exists.
|
||||
*/
|
||||
assert(entries > 0);
|
||||
assert(dirents);
|
||||
|
||||
/* normalize (sort) them */
|
||||
qsort(dirents, entries, sizeof(*dp), cmp_dirent);
|
||||
|
||||
/* Return no. of entries. */
|
||||
*n = entries;
|
||||
|
||||
return dirents;
|
||||
}
|
||||
|
||||
void minix_free_readdir(struct me_dirent *md, int n)
|
||||
{
|
||||
free(md);
|
||||
}
|
||||
|
||||
int main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
char *dir = __UNCONST("");
|
||||
struct stat st;
|
||||
int op;
|
||||
|
||||
gid = DEF_GID;
|
||||
uid = DEF_UID;
|
||||
prot = DEF_PROT;
|
||||
blocks = DEF_BLOCKS;
|
||||
inodes = DEF_INODES;
|
||||
indentstr = __UNCONST(DEF_INDENTSTR);
|
||||
inode_given = 0;
|
||||
block_given = 0;
|
||||
top = 0;
|
||||
same_uid = 0;
|
||||
same_gid = 0;
|
||||
same_prot = 0;
|
||||
while ((op = getopt(argc, argv, "b:g:i:p:t:u:d:s")) != EOF) {
|
||||
switch (op) {
|
||||
case 'b':
|
||||
blocks = atoi(optarg);
|
||||
block_given = 1;
|
||||
break;
|
||||
case 'g':
|
||||
gid = atoi(optarg);
|
||||
if (gid == 0) usage(argv[0]);
|
||||
same_gid = 0;
|
||||
break;
|
||||
case 'i':
|
||||
inodes = atoi(optarg);
|
||||
inode_given = 1;
|
||||
break;
|
||||
case 'p':
|
||||
sscanf(optarg, "%o", &prot);
|
||||
if (prot == 0) usage(argv[0]);
|
||||
same_prot = 0;
|
||||
break;
|
||||
case 's':
|
||||
same_prot = 1;
|
||||
same_uid = 1;
|
||||
same_gid = 1;
|
||||
break;
|
||||
case 't': top = optarg; break;
|
||||
case 'u':
|
||||
uid = atoi(optarg);
|
||||
if (uid == 0) usage(argv[0]);
|
||||
same_uid = 0;
|
||||
break;
|
||||
case 'd': indentstr = optarg; break;
|
||||
default: /* Illegal options */
|
||||
usage(argv[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind >= argc) {
|
||||
usage(argv[0]);
|
||||
} else {
|
||||
dir = argv[optind];
|
||||
optind++;
|
||||
proto_file = argv[optind];
|
||||
}
|
||||
if (!top) top = dir;
|
||||
open_outfile();
|
||||
if (block_given && !inode_given) inodes = (blocks / 3) + 8;
|
||||
if (!block_given && inode_given) usage(argv[0]);
|
||||
count = 1;
|
||||
tabs = 0;
|
||||
origlen = strlen(dir);
|
||||
|
||||
/* Check that it really is a directory */
|
||||
stat(dir, &st);
|
||||
if ((st.st_mode & S_IFMT) != S_IFDIR) {
|
||||
fprintf(stderr, "mkproto: %s must be a directory\n", dir);
|
||||
usage(argv[0]);
|
||||
}
|
||||
fprintf(outfile, "boot\n%d %d\n", blocks, inodes);
|
||||
display_attrib("", &st);
|
||||
fprintf(outfile, "\n");
|
||||
descend(dir);
|
||||
fprintf(outfile, "$\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Output the prototype spec for this directory. */
|
||||
void descend(dirname)
|
||||
char *dirname;
|
||||
{
|
||||
struct me_dirent *dirents;
|
||||
DIR *dirp;
|
||||
char *name, *temp, *tempend;
|
||||
int i;
|
||||
struct stat st;
|
||||
mode_t mode;
|
||||
int entries = 0, orig_entries;
|
||||
struct me_dirent *dp;
|
||||
|
||||
dirp = opendir(dirname);
|
||||
if (dirp == NULL) {
|
||||
fprintf(stderr, "unable to open directory %s\n", dirname);
|
||||
return;
|
||||
}
|
||||
tabs++;
|
||||
temp = (char *) malloc(sizeof(char) * strlen(dirname) +1 + PATH_MAX);
|
||||
strcpy(temp, dirname);
|
||||
strcat(temp, "/");
|
||||
tempend = &temp[strlen(temp)];
|
||||
|
||||
/* read all directory entries */
|
||||
if(!(dirents = minix_readdir(dirp, &entries)))
|
||||
errx(1, "minix_readdir failed");
|
||||
orig_entries = entries;
|
||||
closedir(dirp);
|
||||
|
||||
for (dp = dirents; entries > 0; dp++, entries--) {
|
||||
name = dp->d_name;
|
||||
|
||||
count++;
|
||||
strcpy(tempend, name);
|
||||
|
||||
if (lstat(temp, &st) == -1) {
|
||||
fprintf(stderr, "cant get status of '%s' \n", temp);
|
||||
continue;
|
||||
}
|
||||
if (name[0] == '.' && (name[1] == 0 ||
|
||||
(name[1] == '.' && name[2] == 0)))
|
||||
continue;
|
||||
|
||||
display_attrib(name, &st);
|
||||
|
||||
mode = st.st_mode & S_IFMT;
|
||||
if (mode == S_IFDIR) {
|
||||
fprintf(outfile, "\n");
|
||||
descend(temp);
|
||||
for (i = 0; i < tabs; i++) {
|
||||
fprintf(outfile, "%s", indentstr);
|
||||
}
|
||||
fprintf(outfile, "$\n");
|
||||
continue;
|
||||
}
|
||||
if (mode == S_IFBLK || mode == S_IFCHR) {
|
||||
fprintf(outfile, " %d %d\n", major(st.st_rdev), minor(st.st_rdev));
|
||||
continue;
|
||||
}
|
||||
if (mode == S_IFREG) {
|
||||
i = origlen;
|
||||
fprintf(outfile, "%s%s", indentstr, top);
|
||||
while (temp[i] != '\0') {
|
||||
fputc(temp[i], outfile);
|
||||
i++;
|
||||
}
|
||||
fprintf(outfile, "\n");
|
||||
continue;
|
||||
}
|
||||
if (mode == S_IFLNK) {
|
||||
char linkcontent[PATH_MAX];
|
||||
memset(linkcontent, 0, sizeof(linkcontent));
|
||||
if(readlink(temp, linkcontent, sizeof(linkcontent)) < 0) {
|
||||
perror("readlink");
|
||||
exit(1);
|
||||
}
|
||||
fprintf(outfile, "%s%s\n", indentstr, linkcontent);
|
||||
continue;
|
||||
}
|
||||
fprintf(outfile, " /dev/null");
|
||||
fprintf(stderr,"File\n\t%s\n has an invalid mode, made empty.\n",temp);
|
||||
}
|
||||
free(temp);
|
||||
minix_free_readdir(dirents, orig_entries);
|
||||
tabs--;
|
||||
}
|
||||
|
||||
|
||||
void display_attrib(name, st)
|
||||
const char *name;
|
||||
struct stat *st;
|
||||
{
|
||||
/* Output the specification for a single file */
|
||||
|
||||
int i;
|
||||
|
||||
if (same_uid) uid = st->st_uid;
|
||||
if (same_gid) gid = st->st_gid;
|
||||
if (same_prot)
|
||||
prot = st->st_mode & 0777; /***** This one is a bit shady *****/
|
||||
for (i = 0; i < tabs; i++) fprintf(outfile, "%s", indentstr);
|
||||
fprintf(outfile, "%s%s%c%c%c%03o %d %d",
|
||||
name,
|
||||
*name == '\0' ? "" : indentstr, /* stop the tab for a null name */
|
||||
(st->st_mode & S_IFMT) == S_IFDIR ? 'd' :
|
||||
(st->st_mode & S_IFMT) == S_IFCHR ? 'c' :
|
||||
(st->st_mode & S_IFMT) == S_IFBLK ? 'b' :
|
||||
(st->st_mode & S_IFMT) == S_IFLNK ? 's' :
|
||||
'-', /* file type */
|
||||
(st->st_mode & S_ISUID) ? 'u' : '-', /* set uid */
|
||||
(st->st_mode & S_ISGID) ? 'g' : '-', /* set gid */
|
||||
prot,
|
||||
uid,
|
||||
gid);
|
||||
}
|
||||
|
||||
void usage(binname)
|
||||
char *binname;
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [options] source_directory [prototype_file]\n", binname);
|
||||
fprintf(stderr, "options:\n");
|
||||
fprintf(stderr, " -b n\t\t file system size is n blocks (default %d)\n", DEF_BLOCKS);
|
||||
fprintf(stderr, " -d STRING\t define the indentation characters (default %s)\n", "(none)");
|
||||
fprintf(stderr, " -g n\t\t use n as the gid on all files (default %d)\n", DEF_GID);
|
||||
fprintf(stderr, " -i n\t\t file system gets n i-nodes (default %d)\n", DEF_INODES);
|
||||
fprintf(stderr, " -p nnn\t use nnn (octal) as mode on all files (default %o)\n", DEF_PROT);
|
||||
fprintf(stderr, " -s \t\t use the same uid, gid and mode as originals have\n");
|
||||
fprintf(stderr, " -t ROOT\t inital path prefix for each entry\n");
|
||||
fprintf(stderr, " -u n\t\t use nnn as the uid on all files (default %d)\n", DEF_UID);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void open_outfile()
|
||||
{
|
||||
if (proto_file == NULL)
|
||||
outfile = stdout;
|
||||
else if ((outfile = fopen(proto_file, "w")) == NULL)
|
||||
fprintf(stderr, "Cannot create %s\n ", proto_file);
|
||||
}
|
||||
Reference in New Issue
Block a user