update pbs-client to nix 0.29 and rustyline 0.14

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2025-06-11 16:43:38 +02:00 committed by Thomas Lamprecht
parent 4e3f57529c
commit 2a7012f96b
5 changed files with 35 additions and 16 deletions

View File

@ -306,7 +306,7 @@ async fn restore_command(target: String, pattern: Option<String>) -> Result<(),
/// here: /// here:
pub struct Shell { pub struct Shell {
/// Readline instance handling input and callbacks /// Readline instance handling input and callbacks
rl: rustyline::Editor<CliHelper>, rl: rustyline::Editor<CliHelper, rustyline::history::MemHistory>,
/// Interactive prompt. /// Interactive prompt.
prompt: String, prompt: String,
@ -352,7 +352,10 @@ impl Shell {
archive: Accessor, archive: Accessor,
) -> Result<Self, Error> { ) -> Result<Self, Error> {
let cli_helper = CliHelper::new(catalog_shell_cli()); let cli_helper = CliHelper::new(catalog_shell_cli());
let mut rl = rustyline::Editor::<CliHelper>::new(); let mut rl = rustyline::Editor::<CliHelper, _>::with_history(
rustyline::Config::default(),
rustyline::history::MemHistory::new(),
)?;
rl.set_helper(Some(cli_helper)); rl.set_helper(Some(cli_helper));
let mut position = Vec::new(); let mut position = Vec::new();
@ -426,7 +429,7 @@ impl Shell {
let _ = let _ =
cli::handle_command_future(helper.cmd_def(), "", args, cli::CliEnvironment::new()) cli::handle_command_future(helper.cmd_def(), "", args, cli::CliEnvironment::new())
.await; .await;
this.rl.add_history_entry(line); let _ = this.rl.add_history_entry(line);
this.update_prompt(); this.update_prompt();
} }
Ok(()) Ok(())

View File

@ -630,7 +630,11 @@ impl Archiver {
let mut stat_results: Option<FileStat> = None; let mut stat_results: Option<FileStat> = None;
let get_file_mode = || { let get_file_mode = || {
nix::sys::stat::fstatat(dir_fd, file_name, nix::fcntl::AtFlags::AT_SYMLINK_NOFOLLOW) nix::sys::stat::fstatat(
Some(dir_fd),
file_name,
nix::fcntl::AtFlags::AT_SYMLINK_NOFOLLOW,
)
}; };
let match_result = self let match_result = self
@ -1309,7 +1313,7 @@ impl Archiver {
file_name: &Path, file_name: &Path,
metadata: &Metadata, metadata: &Metadata,
) -> Result<(), Error> { ) -> Result<(), Error> {
let dest = match nix::fcntl::readlinkat(fd.as_raw_fd(), &b""[..]) { let dest = match nix::fcntl::readlinkat(Some(fd.as_raw_fd()), &b""[..]) {
Ok(dest) => dest, Ok(dest) => dest,
Err(Errno::ESTALE) => { Err(Errno::ESTALE) => {
self.report_stale_file_handle(None); self.report_stale_file_handle(None);

View File

@ -41,7 +41,7 @@ impl PxarDir {
allow_existing_dirs: bool, allow_existing_dirs: bool,
) -> Result<BorrowedFd, Error> { ) -> Result<BorrowedFd, Error> {
if let Err(err) = mkdirat( if let Err(err) = mkdirat(
parent, Some(parent),
self.file_name.as_os_str(), self.file_name.as_os_str(),
perms_from_metadata(&self.metadata)?, perms_from_metadata(&self.metadata)?,
) { ) {
@ -55,7 +55,7 @@ impl PxarDir {
fn open_dir(&mut self, parent: RawFd) -> Result<BorrowedFd, Error> { fn open_dir(&mut self, parent: RawFd) -> Result<BorrowedFd, Error> {
let dir = Dir::openat( let dir = Dir::openat(
parent, Some(parent),
self.file_name.as_os_str(), self.file_name.as_os_str(),
OFlag::O_DIRECTORY | OFlag::O_CLOEXEC, OFlag::O_DIRECTORY | OFlag::O_CLOEXEC,
Mode::empty(), Mode::empty(),

View File

@ -627,7 +627,7 @@ impl Extractor {
target.as_c_str(), target.as_c_str(),
Some(parent), Some(parent),
file_name, file_name,
nix::unistd::LinkatFlags::NoSymlinkFollow, nix::fcntl::AtFlags::AT_SYMLINK_NOFOLLOW,
) )
}; };
@ -697,8 +697,13 @@ impl Extractor {
} }
let mut file = unsafe { let mut file = unsafe {
std::fs::File::from_raw_fd( std::fs::File::from_raw_fd(
nix::fcntl::openat(parent, file_name, oflags, Mode::from_bits(0o600).unwrap()) nix::fcntl::openat(
.with_context(|| format!("failed to create file {file_name:?}"))?, Some(parent),
file_name,
oflags,
Mode::from_bits(0o600).unwrap(),
)
.with_context(|| format!("failed to create file {file_name:?}"))?,
) )
}; };
@ -722,7 +727,7 @@ impl Extractor {
} }
if result.seeked_last { if result.seeked_last {
while match nix::unistd::ftruncate(file.as_raw_fd(), size as i64) { while match nix::unistd::ftruncate(&file, size as i64) {
Ok(_) => false, Ok(_) => false,
Err(nix::errno::Errno::EINTR) => true, Err(nix::errno::Errno::EINTR) => true,
Err(err) => return Err(err).context("error setting file size"), Err(err) => return Err(err).context("error setting file size"),
@ -758,8 +763,13 @@ impl Extractor {
} }
let mut file = tokio::fs::File::from_std(unsafe { let mut file = tokio::fs::File::from_std(unsafe {
std::fs::File::from_raw_fd( std::fs::File::from_raw_fd(
nix::fcntl::openat(parent, file_name, oflags, Mode::from_bits(0o600).unwrap()) nix::fcntl::openat(
.with_context(|| format!("failed to create file {file_name:?}"))?, Some(parent),
file_name,
oflags,
Mode::from_bits(0o600).unwrap(),
)
.with_context(|| format!("failed to create file {file_name:?}"))?,
) )
}); });
@ -784,7 +794,7 @@ impl Extractor {
} }
if result.seeked_last { if result.seeked_last {
while match nix::unistd::ftruncate(file.as_raw_fd(), size as i64) { while match nix::unistd::ftruncate(&file, size as i64) {
Ok(_) => false, Ok(_) => false,
Err(nix::errno::Errno::EINTR) => true, Err(nix::errno::Errno::EINTR) => true,
Err(err) => return Err(err).context("error setting file size"), Err(err) => return Err(err).context("error setting file size"),

View File

@ -1,3 +1,4 @@
use std::os::fd::{AsRawFd, IntoRawFd};
use std::pin::Pin; use std::pin::Pin;
use std::task::{Context, Poll}; use std::task::{Context, Poll};
@ -76,10 +77,11 @@ impl tower_service::Service<Uri> for VsockConnector {
)?; )?;
let sock_addr = VsockAddr::new(cid, port as u32); let sock_addr = VsockAddr::new(cid, port as u32);
connect(sock_fd, &sock_addr)?; connect(sock_fd.as_raw_fd(), &sock_addr)?;
// connect sync, but set nonblock after (tokio requires it) // connect sync, but set nonblock after (tokio requires it)
let std_stream = unsafe { std::os::unix::net::UnixStream::from_raw_fd(sock_fd) }; let std_stream =
unsafe { std::os::unix::net::UnixStream::from_raw_fd(sock_fd.into_raw_fd()) };
std_stream.set_nonblocking(true)?; std_stream.set_nonblocking(true)?;
let stream = tokio::net::UnixStream::from_std(std_stream)?; let stream = tokio::net::UnixStream::from_std(std_stream)?;