Enabling opening files for writing

This commit is contained in:
Olivier 'reivilibre' 2022-01-24 20:21:48 +00:00
parent 58ae7a58ba
commit 0c893c02d4
3 changed files with 18 additions and 14 deletions

View File

@ -329,12 +329,10 @@ impl Filesystem for OliveFilesystem {
}; };
if open_mode.write || open_mode.append { if open_mode.write || open_mode.append {
debug!( warn!(
"[Not Implemented (because of writing)] open(ino: {:#x?}, flags: {:?})", "[DANGER: Writing is unstable!] open(ino: {:#x?}, flags: {:?})",
ino, flags ino, flags
); );
reply.error(ENOSYS);
return;
} }
self.spawn_with_error_handler( self.spawn_with_error_handler(
@ -356,15 +354,19 @@ impl Filesystem for OliveFilesystem {
// and caching up to that point. // and caching up to that point.
// We might wind up wanting to do our own buffering... // We might wind up wanting to do our own buffering...
if let Some(config) = streaming_reader_opts { if open_mode.read && !open_mode.write && !open_mode.append {
requester // Only enable streaming readers in read-only use
.start_streaming_reader(file_handle, config) if let Some(config) = streaming_reader_opts {
.await?; requester
debug!( .start_streaming_reader(file_handle, config)
"open(ino: {:#x?}) = fh {:?} (streaming reader: yes)", .await?;
ino, file_handle debug!(
); "open(ino: {:#x?}) = fh {:?} (streaming reader: yes)",
ino, file_handle
);
}
} }
debug!( debug!(
"open(ino: {:#x?}) = fh {:?} (streaming reader: no)", "open(ino: {:#x?}) = fh {:?} (streaming reader: no)",
ino, file_handle ino, file_handle

View File

@ -28,7 +28,7 @@ impl HelloMessage {
} }
} }
#[derive(Serialize, Deserialize, Debug, Clone)] #[derive(Serialize, Deserialize, Debug, Copy, Clone)]
pub struct OpenMode { pub struct OpenMode {
pub read: bool, pub read: bool,
pub write: bool, pub write: bool,

View File

@ -14,6 +14,7 @@ use std::os::unix::fs::{MetadataExt, PermissionsExt};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::sync::Arc; use std::sync::Arc;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use log::{error, warn};
use tokio::fs::{OpenOptions, ReadDir}; use tokio::fs::{OpenOptions, ReadDir};
use tokio::io::{AsyncReadExt, AsyncSeekExt, AsyncWriteExt}; use tokio::io::{AsyncReadExt, AsyncSeekExt, AsyncWriteExt};
use tokio::sync::RwLock; use tokio::sync::RwLock;
@ -413,10 +414,11 @@ impl FileAccess {
} }
if mode.write { if mode.write {
open_options.write(true); open_options.write(true);
todo!(); warn!("DANGER: file opened with write mode");
} }
if mode.append { if mode.append {
open_options.append(true); open_options.append(true);
error!("UNSUPPORTED: file opened with append mode");
todo!(); todo!();
} }
// TODO truncate? // TODO truncate?