From cc6a069586974fc305ff3d5c1d24cd90a72df242 Mon Sep 17 00:00:00 2001 From: WangRunji Date: Thu, 21 Mar 2019 00:37:54 +0800 Subject: [PATCH] fix split absolute path --- kernel/src/syscall/fs.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/src/syscall/fs.rs b/kernel/src/syscall/fs.rs index 378ffac..6f4f46f 100644 --- a/kernel/src/syscall/fs.rs +++ b/kernel/src/syscall/fs.rs @@ -616,7 +616,10 @@ impl Process { fn split_path(path: &str) -> (&str, &str) { let mut split = path.trim_end_matches('/').rsplitn(2, '/'); let file_name = split.next().unwrap(); - let dir_path = split.next().unwrap_or("."); + let mut dir_path = split.next().unwrap_or("."); + if dir_path == "" { + dir_path = "/"; + } (dir_path, file_name) }