From 924adef1dc7bc93d457af47626896edff92bd384 Mon Sep 17 00:00:00 2001 From: Deepak Sirone Date: Sun, 11 Aug 2019 15:30:09 +0530 Subject: [PATCH] Update path after frename --- src/mount/redox/resource.rs | 9 +++++++++ src/mount/redox/scheme.rs | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mount/redox/resource.rs b/src/mount/redox/resource.rs index e0ef939aea..04a3af4fd4 100644 --- a/src/mount/redox/resource.rs +++ b/src/mount/redox/resource.rs @@ -13,6 +13,7 @@ use filesystem::FileSystem; pub trait Resource { fn block(&self) -> u64; fn dup(&self) -> Result>>; + fn set_path(&mut self, path: &str); fn read(&mut self, buf: &mut [u8], fs: &mut FileSystem) -> Result; fn write(&mut self, buf: &[u8], fs: &mut FileSystem) -> Result; fn seek(&mut self, offset: usize, whence: usize, fs: &mut FileSystem) -> Result; @@ -63,6 +64,10 @@ impl Resource for DirResource { })) } + fn set_path(&mut self, path: &str) { + self.path = path.to_string(); + } + fn read(&mut self, buf: &mut [u8], _fs: &mut FileSystem) -> Result { let data = self.data.as_ref().ok_or(Error::new(EISDIR))?; let mut i = 0; @@ -284,6 +289,10 @@ impl Resource for FileResource { })) } + fn set_path(&mut self, path: &str) { + self.path = path.to_string(); + } + fn read(&mut self, buf: &mut [u8], fs: &mut FileSystem) -> Result { if self.flags & O_ACCMODE == O_RDWR || self.flags & O_ACCMODE == O_RDONLY { let count = fs.read_node(self.block, self.seek, buf)?; diff --git a/src/mount/redox/scheme.rs b/src/mount/redox/scheme.rs index 6be8e1f26d..a935237cc6 100644 --- a/src/mount/redox/scheme.rs +++ b/src/mount/redox/scheme.rs @@ -522,8 +522,8 @@ impl Scheme for FileScheme { // println!("Frename {}, {} from {}, {}", id, path, uid, gid); - let files = self.files.borrow_mut(); - if let Some(file) = files.get(&id) { + let mut files = self.files.borrow_mut(); + if let Some(file) = files.get_mut(&id) { //TODO: Check for EINVAL // The new pathname contained a path prefix of the old, or, more generally, // an attempt was made to make a directory a subdirectory of itself. @@ -607,6 +607,7 @@ impl Scheme for FileScheme { fs.insert_blocks(orig.0, BLOCK_SIZE, parent.0)?; } + file.set_path(path); Ok(0) } else { Err(Error::new(EPERM))