From: Kefu Chai <k.chai@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox-fuse-rs 1/1] add rename operation
Date: Tue, 11 Nov 2025 22:38:00 +0800 [thread overview]
Message-ID: <20251111143800.504322-2-k.chai@proxmox.com> (raw)
In-Reply-To: <20251111143800.504322-1-k.chai@proxmox.com>
rename operation is required when implementing the rust rewrite of
pmxcfs, which delegates the rename operations to the underlying
plugin which exposes the renamed file.
Signed-off-by: Kefu Chai <k.chai@proxmox.com>
---
src/requests.rs | 25 +++++++++++++++++++++++++
src/session.rs | 32 ++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+)
diff --git a/src/requests.rs b/src/requests.rs
index 9bdab30..6799496 100644
--- a/src/requests.rs
+++ b/src/requests.rs
@@ -118,6 +118,7 @@ pub enum Request {
Rmdir(Rmdir),
Write(Write),
Readlink(Readlink),
+ Rename(Rename),
ListXAttrSize(ListXAttrSize),
ListXAttr(ListXAttr),
GetXAttrSize(GetXAttrSize),
@@ -155,6 +156,7 @@ impl FuseRequest for Request {
Request::Rmdir(r) => r.fail(errno),
Request::Write(r) => r.fail(errno),
Request::Readlink(r) => r.fail(errno),
+ Request::Rename(r) => r.fail(errno),
Request::ListXAttrSize(r) => r.fail(errno),
Request::ListXAttr(r) => r.fail(errno),
Request::GetXAttrSize(r) => r.fail(errno),
@@ -681,6 +683,29 @@ impl Rmdir {
}
}
+/// Rename a file or directory.
+#[derive(Debug)]
+pub struct Rename {
+ pub(crate) request: RequestGuard,
+ pub parent: u64,
+ pub name: OsString,
+ pub new_parent: u64,
+ pub new_name: OsString,
+ pub flags: libc::c_int,
+}
+
+impl FuseRequest for Rename {
+ fn fail(self, errno: libc::c_int) -> io::Result<()> {
+ reply_err(self.request, errno)
+ }
+}
+
+impl Rename {
+ pub fn reply(self) -> io::Result<()> {
+ reply_err(self.request, 0)
+ }
+}
+
/// Write to a file.
#[derive(Debug)]
pub struct Write {
diff --git a/src/session.rs b/src/session.rs
index 427ce46..a38593e 100644
--- a/src/session.rs
+++ b/src/session.rs
@@ -328,6 +328,32 @@ impl FuseData {
}));
}
+ extern "C" fn rename(
+ request: sys::Request,
+ parent: u64,
+ name: sys::StrPtr,
+ new_parent: u64,
+ new_name: sys::StrPtr,
+ flags: libc::c_int,
+ ) {
+ let fuse_data = unsafe { &*(sys::fuse_req_userdata(request) as *mut FuseData) };
+ let name = unsafe { CStr::from_ptr(name) };
+ let name = OsStr::from_bytes(name.to_bytes()).to_owned();
+ let new_name = unsafe { CStr::from_ptr(new_name) };
+ let new_name = OsStr::from_bytes(new_name.to_bytes()).to_owned();
+ fuse_data
+ .pending_requests
+ .borrow_mut()
+ .push_back(Request::Rename(requests::Rename {
+ request: RequestGuard::from_raw(request),
+ parent,
+ name,
+ new_parent,
+ new_name,
+ flags,
+ }));
+ }
+
extern "C" fn write(
request: sys::Request,
inode: u64,
@@ -533,6 +559,12 @@ impl FuseSessionBuilder {
self
}
+ /// Enable `Rename` requests.
+ pub fn enable_rename(mut self) -> Self {
+ self.operations.rename = Some(FuseData::rename);
+ self
+ }
+
/// Enable `Read` requests.
pub fn enable_read(mut self) -> Self {
self.operations.read = Some(FuseData::read);
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-11-11 14:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-11 14:37 [pve-devel] [PATCH proxmox-fuse-rs 0/1] Add rename operation support Kefu Chai
2025-11-11 14:38 ` Kefu Chai [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-11-11 13:53 Kefu Chai
2025-11-11 13:53 ` [pve-devel] [PATCH proxmox-fuse-rs 1/1] add rename operation Kefu Chai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251111143800.504322-2-k.chai@proxmox.com \
--to=k.chai@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.