-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add doc about fs * Add console on diskless boot * Enumerate all disks * Avoid hardcoded allocation of root dir * Refactor ATA code * Add BlockDevice * Add mkfs command * Update readme * Add warning in the readme about disk modifications * Use all bits inside BlockBitmap data * Add makefile * Overwrite only bootloader and kernel in disk image * Update readme * Add doc about mkfs * Update mkfs command
- Loading branch information
Showing
12 changed files
with
262 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
.PHONY: setup image qemu | ||
.EXPORT_ALL_VARIABLES: | ||
|
||
setup: | ||
curl https://sh.rustup.rs -sSf | sh | ||
rustup install nightly | ||
rustup default nightly | ||
rustup component add rust-src | ||
rustup component add llvm-tools-preview | ||
cargo install cargo-xbuild bootimage | ||
|
||
output = vga | ||
keyboard = qwerty | ||
|
||
bin=target/x86_64-moros/release/bootimage-moros.bin | ||
img=disk.img | ||
|
||
$(img): | ||
qemu-img create $(img) 32M | ||
|
||
# Rebuild MOROS if the features list changed | ||
image: $(img) | ||
touch src/lib.rs | ||
cargo bootimage --no-default-features --features $(output),$(keyboard) --release | ||
dd conv=notrunc if=$(bin) of=$(img) | ||
|
||
opts = -cpu max -nic model=rtl8139 -hda $(img) | ||
ifeq ($(output),serial) | ||
opts += -display none -serial stdio | ||
endif | ||
|
||
qemu: | ||
qemu-system-x86_64 $(opts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# MOROS Filesystem | ||
|
||
## Disk | ||
|
||
A disk is separated in block of 512 bytes, grouped into three areas. The first | ||
is reserved for future uses, the second is used as a bitmap mapping the | ||
allocated blocks in the third area. The data stored on the disk use the blocks | ||
of the third area. | ||
|
||
During the first boot of the OS, the root dir will be allocated, using the | ||
first block of the data area. | ||
|
||
A location on the tree of dirs and files is named a path: | ||
|
||
- The root dir is represented by a slash: `/` | ||
- A dir inside the root will have its name appended to the slash: `/usr` | ||
- Subsequent dirs will append a slash and their names: `/usr/admin` | ||
|
||
### Creation with QEMU | ||
|
||
$ qemu-img create disk.img 128M | ||
Formatting 'disk.img', fmt=raw size=134217728 | ||
|
||
### Setup in diskless console | ||
|
||
During boot MOROS will detect the disks present on the ATA buses, then the | ||
filesystems on those disks. If no filesystem is found, MOROS will open a | ||
console in diskless mode to allow the user to create one with the `mkfs` | ||
command: | ||
|
||
> mkfs /dev/ata/0/0 | ||
|
||
## Data | ||
|
||
### BlockBitmap | ||
|
||
Bitmap of allocated blocks in the data area. | ||
|
||
### Block | ||
|
||
A block is small area of 512 bytes on a disk, and it is also part of linked | ||
list representing a file or a directory. | ||
|
||
The first 4 bytes of a block is the address of the next block on the list and | ||
the rest of block is the data stored in the block. | ||
|
||
### DirEntry | ||
|
||
A directory entry represent a file or a directory contained inside a directory. | ||
Each entry use a variable number of bytes that must fit inside the data of one | ||
block. Those bytes represent the kind of entry (file or dir), the address of | ||
the first block, the filesize (max 4GB), and the filename (max 255 chars) of | ||
the entry. | ||
|
||
Structure: | ||
|
||
- 0..1: kind | ||
- 1..5: addr | ||
- 5..10: size | ||
- 10..11: name len | ||
- 11..n: name buf | ||
|
||
### Dir | ||
|
||
A directory contains the address of the first block where its directory entries | ||
are stored. | ||
|
||
### File | ||
|
||
A file contains the address of its first block along with its filesize and | ||
filename, and a reference to its parent directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# MOROS Net | ||
# MOROS Network | ||
|
||
## NET | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.