1
0
mirror of https://github.com/sgmarz/osblog.git synced 2024-11-24 02:16:19 +04:00

Added comments and shrunk string

This commit is contained in:
Stephen Marz 2020-05-15 11:11:20 -04:00
parent 69c7e6c390
commit 9d6ee9fb35

View File

@ -140,6 +140,9 @@ impl MinixFileSystem {
for i in cwd.bytes() { for i in cwd.bytes() {
new_cwd.push(i as char); new_cwd.push(i as char);
} }
// Add a directory separator between this inode and the next.
// If we're the root (inode 1), we don't want to double up the
// frontslash, so only do it for non-roots.
if inode_num != 1 { if inode_num != 1 {
new_cwd.push('/'); new_cwd.push('/');
} }
@ -149,8 +152,10 @@ impl MinixFileSystem {
} }
new_cwd.push(d.name[i] as char); new_cwd.push(d.name[i] as char);
} }
new_cwd.shrink_to_fit();
if d_ino.mode & S_IFDIR != 0 { if d_ino.mode & S_IFDIR != 0 {
// This is a directory, cache these. // This is a directory, cache these. This is a recursive call,
// which I don't really like.
Self::cache_at(btm, &new_cwd, d.inode, bdev); Self::cache_at(btm, &new_cwd, d.inode, bdev);
} }
else { else {
@ -167,7 +172,6 @@ impl MinixFileSystem {
// Let's look at the root (inode #1) // Let's look at the root (inode #1)
Self::cache_at(&mut btm, &cwd, 1, bdev); Self::cache_at(&mut btm, &cwd, 1, bdev);
Self { Self {
inode_cache: btm inode_cache: btm
} }