Skip to content

Commit 8a380ac

Browse files
authored
support mkdir (#8)
* update fuser version * remove type extension * fix lookup bug * fix mkdir not working * cleanup * update docs * fix markdown syntax * fix md syntax * add pr template
1 parent 300407c commit 8a380ac

File tree

17 files changed

+409
-230
lines changed

17 files changed

+409
-230
lines changed

.github/pull_request_template.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## overview
2+
3+
## testing instructions

.vscode/launch.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "lldb",
9+
"request": "launch",
10+
"name": "Debug executable 'tinyFS'",
11+
"cargo": {
12+
"args": [
13+
"build",
14+
"--bin=tinyFS",
15+
"--package=tinyFS"
16+
],
17+
"filter": {
18+
"name": "tinyFS",
19+
"kind": "bin"
20+
}
21+
},
22+
"args": [],
23+
"cwd": "${workspaceFolder}"
24+
},
25+
{
26+
"type": "lldb",
27+
"request": "launch",
28+
"name": "Debug unit tests in executable 'tinyFS'",
29+
"cargo": {
30+
"args": [
31+
"test",
32+
"--no-run",
33+
"--bin=tinyFS",
34+
"--package=tinyFS"
35+
],
36+
"filter": {
37+
"name": "tinyFS",
38+
"kind": "bin"
39+
}
40+
},
41+
"args": [],
42+
"cwd": "${workspaceFolder}"
43+
}
44+
]
45+
}

Cargo.lock

Lines changed: 79 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
fuse = "0.3.1"
7+
fuser = "0.15.1"
88
bincode = "1.3.3"
99
bitvec = "1"
1010
serde = { version = "1", features = ["derive"] }
11-
time = "0.1"
1211
libc = "0.2.169"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
run:
2-
sudo fusermount -u /tmp/tiny > /dev/null 2>&1
2+
- sudo fusermount -u /tmp/tiny > /dev/null 2>&1
33
cargo run

README.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ TinyFS is a little filesystem with no big plans.
99

1010
## Running
1111

12-
1. To start **tinyFS** run `cargo run` in this project's root dir
12+
1. To start **tinyFS** run `make run` in this project's root dir
1313
2. To interact with tinyFS, open another terminal and perform file operations on `/tmp/tiny` ie `stat /tmp/tiny`
1414

1515
## Resources
@@ -18,16 +18,13 @@ TinyFS is a little filesystem with no big plans.
1818
- [To FUSE or Not To Fuse](https://libfuse.github.io/doxygen/fast17-vangoor.pdf)
1919
- [Fuse Filesystems](https://zsiciarz.github.io/24daysofrust/book/vol1/day15.html)
2020

21-
## Design Docs
22-
23-
- [tinyfs intro](./design/tinyfs.md)
24-
- [format disk](./design/mkfs.md)
25-
- [initialize filesystem](./design/fs_init.md)
26-
- [stat](./design/stat.md)
27-
- [ls](./design/ls.md)
28-
- [mkdir]() Not Implemented
29-
- [rmdir]() Not Implemented
30-
- [create]() Not Implemented
31-
- [read]() Not Implemented
32-
- [write]() Not Implemented
33-
- [unlink]() Not Implemented
21+
## Supported
22+
23+
- [x] stat
24+
- [x] ls
25+
- [x] mkdir
26+
- [ ] rmdir
27+
- [ ] create
28+
- [ ] read
29+
- [ ] write
30+
- [ ] unlink

design/ls.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## ls
2+
3+
## Goals
4+
5+
## Non-Goals
6+
7+
## Design

design/mkdir.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Support mkdir
2+
3+
The `mkdir` command is used to create directories.
4+
5+
## Goals
6+
7+
- Support mkdir
8+
9+
## Non-Goals
10+
11+
## Design
12+
13+
Directory creation is handled by the `mkdir` FUSE function. The method signature specifies the **parent** directory, the
14+
directory **name** and **mode** -- permissions.
15+
16+
```rust
17+
fn mkdir(&mut self, _req: &fuse::Request, parent: u64, name: &std::ffi::OsStr, mode: u32, reply: fuse::ReplyEntry)
18+
```
19+
20+
1. Load the parent inode from disk
21+
2. Load the parent's dir data
22+
3. Create a new Inode for the new directory
23+
4. Update the parent's dir data with a new entry based on the new Inode's data

src/main.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,7 @@ fn main() {
1313

1414
let mount_path = "/tmp/tiny";
1515

16-
fuse::mount(
17-
TinyFS {
18-
disk: load_disk(path),
19-
},
20-
&mount_path,
21-
&[],
22-
)
23-
.expect("expected filesytem to mount");
16+
fuser::mount2(TinyFS { disk: load_disk(path) }, &mount_path, &[]).expect("expected filesytem to mount");
2417
}
2518

2619
fn load_disk(path: &Path) -> Disk {

src/mkfs.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@ pub fn make(path: &str) {
2020
.expect("superblock to have been serialized");
2121

2222
let mut bitmap = Bitmap::new();
23-
bitmap
24-
.save_to(&disk)
25-
.expect("bitmap to have been serialized");
23+
bitmap.save_to(&disk).expect("bitmap to have been serialized");
2624

2725
buf.flush().expect("buffer to have been flushed");
28-
disk.set_len(64 * BLOCK_SIZE as u64)
29-
.expect("to have set file size");
26+
disk.set_len(64 * BLOCK_SIZE as u64).expect("to have set file size");
3027
}

0 commit comments

Comments
 (0)