From 9d6ee9fb350d8594f1998052914831a3197bfb1a Mon Sep 17 00:00:00 2001 From: Stephen Marz Date: Fri, 15 May 2020 11:11:20 -0400 Subject: [PATCH] Added comments and shrunk string --- risc_v/src/fs.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/risc_v/src/fs.rs b/risc_v/src/fs.rs index 693665d..8a36a8c 100755 --- a/risc_v/src/fs.rs +++ b/risc_v/src/fs.rs @@ -140,6 +140,9 @@ impl MinixFileSystem { for i in cwd.bytes() { 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 { new_cwd.push('/'); } @@ -149,8 +152,10 @@ impl MinixFileSystem { } new_cwd.push(d.name[i] as char); } + new_cwd.shrink_to_fit(); 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); } else { @@ -167,7 +172,6 @@ impl MinixFileSystem { // Let's look at the root (inode #1) Self::cache_at(&mut btm, &cwd, 1, bdev); - Self { inode_cache: btm }