📄 readme
字号:
The File System Construction Kit version 0.4 12/3/98 Dominic Giampaolo dbg@be.comINTRODUCTION:Welcome to the File System Construction Kit! This is a softwarepackage that accompanies the book, Practical File System Design, whichI wrote and is published by Morgan Kaufmann (ISBN 1558604979).This package is a very simple framework in which you can experimentwith a working (but simple) file system implementation. The frameworkis designed so that you can go in and modify one part of it, such ashow the used and free disk blocks are managed, and not have to touchthe rest of the file system. And because the package creates its filesystem inside of a normal file on your hard disk, you don't have tohave a spare disk or require special (root) privileges to run theprogram. The goal is that this package should provide a convenienttest bed for trying out new file system ideas without having to gothrough the pain and difficulty of creating a real kernel based filesystem. The API is generic enough however that after an you debugyour implementation within this framework it could be moved to a realkernel based file system for the BeOS or a Unix like operating system.This package contains several parts. There is the core file systemimplementation, a kernel-like interface (complete with a full vnodelayer, etc) and several test programs that use the kernel-like api tomanipulate the file system. The three programs included are: "makefs"which can create a file system, "tstfs" which is a simple stress testthat creates, writes to, and deletes files, and "fsh", a file systemshel that lets you interactively manipulate your file system.BUILDING IT:The package should compile and build right out of the box on mostversions of Unix and the BeOS. It has been tested on the followingsystems: BeOS/PPC Release 4 BeOS/Intel Release 4 Solaris (sparc) 5.5.1 Solaris (x86) 2.6 FreeBSD (x86) 2.2.2 Linux (x86) 2.1.57 Irix 6.5so it should be reasonably portable. To build it just type "make".The result of the build should be three programs, mkfs, tstfs and fsh.If your compiler doesn't like the flags "-O7" which is in themakefile, just change that to be -O3 or whatever you want (Irix userswill have to change this).USING IT:To use the package you have to first create a file in which you willcreate a file system. By default the tools expect a file name called "big_file" On Unix you can create an empty file by doing this: dd if=/dev/zero of=big_file bs=524288 count=32That will create a 16 megabyte file called "big_file" in the currentdirectory.All the tools treat the file "big_file" like a raw disk device.After you have created "big_file" you need to initialize a file systemin it. The tool "makefs" does this. If you just run makefs it willgo ahead and initialize the file big_file with the sample filesystem. After initializing the file system, you can test it out with "fsh",the file system shell. Just run fsh and it will give you a prompt: fsh>>You can type "help" to find out what commands are available. Here isa summary of a a few of the more useful commands: dir - get an "ls -l" style directory listing make - create a file which you can then read and write to with "rd" and "wr" rd - read some data from the file. you can optionally specify how many bytes to read (default is 256). wr - write some data to a file. you can optionally specify how many bytes to write (default is 256). the data written is generated automatically. close - close the currently open file open - open the named file lat_fs - perform a test similar to the LmBench test "lat_fs" (ie. create and delete files of various sizes). create - create the number of file specified (default 100) rmall - remove all the files in a directory. optionally you can name a directory and it will only remove the files in that directory. cp - copy data to or from the file system and the host file system. the syntax is as follows: Copy data from the host file system into myfs: cp :host-file-name myfs-filename Copy data from myfs to the host file system: cp myfs-file-name :host-file-name The leading ":" indicates which file is the host file. NOTE: copying around inside of myfs is not supported. The last program, tstfs, is a simple stress test. Basically you justrun it and it will go off and randomly create and delete files in thefile system. After it is done there will be a bunch of files leftover. You can then run fsh to look at what it created. A TOUR OF THE SOURCES:The API is not quite as it was described in the appendix of the bookPractical File System Design. That's because I hadn't written the kituntil after the book was published. It still follows the appendixpretty closely however.Here are the sources that you'll find.The test programs:----------------- makefs.c fsh.c tstfs.cThe core file system code for "myfs":------------------------------------- bitmap.c bitvector.c dir.c dstream.c file.c inode.c io.c journal.c util.c mount.cThe supporting infra-structure (vnode layer, disk cache, etc):-------------------------------------------------------------- cache.c initfs.c kernel.c rootfs.cMiscellaneous support routines and porting bits:------------------------------------------------ argv.c hexdump.c sl.c stub.c sysdep.cIf you don't have "dd" for some reason:--------------------------------------- mkfile.cMODIFYING IT:Each of the major components of the file system (block management,inode management, data stream reading and writing, directorymanagement, file management, etc) are broken out into individualsource files. As long as you maintain the api defined by thecorresponding header file, the rest of the file system should continueto work. So for example if you wanted to change how directories storetheir contents, you could go modify dir.c, change it as you see fit,recompile and the rest of the file system will continue to work.The master header file for file system data structures is myfs.h.Basically any data structure that you want to modify is in there.NOTES ABOUT THE IMPLEMENTATION:This is a very simple file system. It is definitely not fast andisn't intended to be a commercial quality file system. It is intendedto be easy to go in and modify. As an example of how simple it is,every time a directory is modified, its entire contents are read intomemory, the changes made and the entire contents written back out. Ichose to do it this way so it would be easier to understand andmodify. Clearly I didn't do it to be fast.The file system has a single super block, a simple used/free blockbitmap, an i-node bitmap, and an inode table. The rest of the disk isfor storing user data. The layout of the file system is as follows: +--------------------------------------------------------------- | super | block | inode | inode | user | block | bitmap | bitmap | table | data..... +---------------------------------------------------------------Files store their data using a simple block list of direct, indirectand double indirect blocks. The data stream code (currently) does notsupport growing into the double-indirect blocks of a file (it's stillon the to-do list).There is no journaling support currently. I will probably add thissometime later. It takes a bit of work and I wanted to get thepackage out as opposed to having it sit on my hard disk for anothermonth or so. Currently there is no safe ordering for disk writessince when I implement journaling that won't matter anyway.There is no real locking done although that's not such an issue sinceit really isn't intended to be run in a multi-threaded environment.The vnode layer does implement correct locking although on a Unixsystem unless you fix stub.c, the locks don't really do much (excepttell you if try to lock an already locked lock which should neverhappen on a single threaded system). The vnode layer is actually partof an early version of the BeOS vnode layer written by CyrilMeurillon. The real BeOS vnode layer is much larger and more complexof course.The cache code is the real Release 4 BeOS disk cache code. The cachecode can support a real BFS style journal implementation so thatshould ease adding journaling support to myfs. Oh, I also have not implemented the myfs_rename function yet. Thatwill be coming shortly.REPORTING BUGS:If you fix a bug in the package, I'd like to hear about it. I can'treally help debug everyone's file system but if you discover a problemwith the package or get it working on another OS, I'd like to hearabout it. E-mail me at: dbg@be.com
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -