0.4.1 - Support rename in fuse

parent 80e3a346
Pipeline #7157 passed with stages
in 2 minutes and 5 seconds
......@@ -2,7 +2,7 @@
name = "redoxfs"
description = "The Redox Filesystem"
repository = "https://gitlab.redox-os.org/redox-os/redoxfs"
version = "0.4.0"
version = "0.4.1"
license-file = "LICENSE"
readme = "README.md"
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
......
......@@ -493,4 +493,38 @@ impl<D: Disk> Filesystem for Fuse<D> {
}
}
}
fn rename(&mut self, _req: &Request, orig_parent: u64, name: &OsStr, new_parent: u64, new_name: &OsStr, reply: ReplyEmpty) {
let rename_inner = |fs: &mut filesystem::FileSystem<D>| -> syscall::Result<()> {
let mut orig = fs.find_node(name.to_str().unwrap(), orig_parent)?;
if new_parent != orig_parent {
fs.remove_blocks(orig.0, 1, orig_parent)?;
}
if let Ok(node) = fs.find_node(new_name.to_str().unwrap(), new_parent) {
if node.0 != orig.0 {
fs.node_set_len(node.0, 0)?;
fs.remove_blocks(node.0, 1, new_parent)?;
fs.write_at(node.0, &Node::default())?;
fs.deallocate(node.0, BLOCK_SIZE)?;
}
}
orig.1.set_name(&new_name.to_str().unwrap())?;
orig.1.parent = new_parent;
fs.write_at(orig.0, &orig.1)?;
if new_parent != orig_parent {
fs.insert_blocks(orig.0, BLOCK_SIZE, new_parent)?;
}
Ok(())
};
match rename_inner(&mut self.fs) {
Ok(()) => reply.ok(),
Err(err) => reply.error(err.errno as i32),
}
}
}
......@@ -632,15 +632,10 @@ impl<D: Disk> Scheme for FileScheme<D> {
let orig_parent = orig.1.parent;
orig.1.set_name(&last_part)?;
orig.1.parent = parent.0;
if parent.0 != orig_parent {
fs.remove_blocks(orig.0, 1, orig_parent)?;
}
fs.write_at(orig.0, &orig.1)?;
if let Some(node) = node_opt {
if node.0 != orig.0 {
fs.node_set_len(node.0, 0)?;
......@@ -650,6 +645,10 @@ impl<D: Disk> Scheme for FileScheme<D> {
}
}
orig.1.set_name(&last_part)?;
orig.1.parent = parent.0;
fs.write_at(orig.0, &orig.1)?;
if parent.0 != orig_parent {
fs.insert_blocks(orig.0, BLOCK_SIZE, parent.0)?;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment