BMFS: Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
BMFS
 
Shifty (talk | contribs)
m →‎Disclaimer: I am pretty sure that it is meant to say to be on the lookout for bugs, not to be tired of them (hence the change from weary to wary)
 
(11 intermediate revisions by 3 users not shown)
Line 2:
 
BMFS is a simple file system in active development that supports regular files and directories.
 
=== Disclaimer ===
 
I am a contributor of BMFS. There's plenty of other file system implementations that could be used in an OS project.
 
BMFS, while it has existed for some time, is considered a new project. Be wary of bugs.
 
== A Little History ==
Line 11 ⟶ 17:
The development continued and the design changed a bit, and now it supports sub-directories, file permissions, user and group IDs, and more.
 
It also comes with a user space program to construct file systems and examine their contents, and a [[FUSE]] binding to use BMFS on Linux systems.
 
The project is now being constantly improved, and one of its design goals is to be used in any other operating system.
Line 44 ⟶ 50:
You can also install it to /usr/local, to avoid having to do that.
 
=== UsingInitializing the LibraryFile System ===
 
Once the project is built, and your build system has the information to use the library, you can start writing code.
Line 95 ⟶ 101:
}
}
 
=== Opening a File ===
 
With the disk and the file system initialized, you can open the file.
 
int open_fileshow_file(const char *path) {
/* Initialize disk here. */
Line 118 ⟶ 126:
}
bmfs_file_set_mode(&file, BMFS_MODE_RWBMFS_MODE_READ);
char buf[512];
/* Read from or write to the file here. */
while (bmfs_file_eof(&file)) {
bmfs_uint64 read_count = 0;
err = bmfs_file_read(&file, buf, 512, &read_count);
if (err != 0)
break;
my_print_function(buf, read_count);
}
}
 
=== Opening a Directory ===
 
Opening a directory is similar to opening a file.
 
You'll have to initialize the file system the same as you did for the file.
 
int list_dir(const char *path) {
/* Initialize the file system here. */
struct BMFSDir dir;
bmfs_dir_init(&dir);
int err = bmfs_open_dir(&bmfs, &dir, path);
if (err == BMFS_ENOTDIR) {
kprintf("Entry '%s' is not a directory.\n", path);
return -1;
} else if (err == BMFS_ENOENT) {
kprintf("Directory '%s' does not exist.\n", path);
return -1;
} else if (err != 0) {
kprintf("Failed to open directory '%s'.\n", path);
return -1;
}
for (;;) {
const struct BMFSEntry *entry = bmfs_dir_next(&dir);
if (entry == BMFS_NULL)
break;
kprintf("Entry: %s\n", entry->Name);
}
}
 
=== Creating a File System on the Development Machine ===
 
Sometimes, in creating an operating system, a file system has to be made in the development machine to transfer system files (such as programs or shared libraries).
 
For that reason, the BMFS utility program was designed. It allows a user to create a file system on a disk image and read and write to the file system.
 
To build the utility program, just use the standard 'make' and 'make install' commands in the project directory.
 
git clone https://github.com/ReturnInfinity/BMFS
cd BMFS
make
sudo make install
 
Create a disk image called 'bmfs.img' using the 'init' command.
 
bmfs init
 
To use a different name, use the `--disk` option.
 
bmfs --disk my-file-system.img init
 
Using `bmfs.img` is nice, because all the commands default to this name.
 
The rest of this tutorial assumes you have used the name 'bmfs.img'.
 
If this is not the case, just specify the name using the '--disk' option for each command.
 
To create a directory, us the 'mkdir' command.
 
bmfs mkdir /drivers
 
To transfer a file from the host system to the image, us the 'cp' command.
 
bmfs cp ahci-driver.sys /drivers/ahci.sys
 
To list the contents of a directory, us the 'ls' command.
 
bmfs ls /drivers
 
=== Reporting Bugs ===
 
If you think there is a bug in the file system implementation, report it on the project issue tracker [https://github.com/ReturnInfinity/BMFS/issues].
 
=== Going Further ===
 
The library can do even more than that and new features are added continuously.
 
Visit the Doxygen generated documentation [https://returninfinity.github.io/bmfs-doc/modules.html] for more information.
[[Category:Filesystems]]