Format
This commit is contained in:
parent
a40ff11ecc
commit
81dc1e64d2
@ -11,11 +11,10 @@
|
|||||||
|
|
||||||
mod errno;
|
mod errno;
|
||||||
|
|
||||||
use serde::{Serialize, Serializer, ser::{SerializeTupleVariant, SerializeStruct}};
|
|
||||||
|
|
||||||
#[stable(feature = "mikros", since = "1.80.0")]
|
#[stable(feature = "mikros", since = "1.80.0")]
|
||||||
pub use errno::Errno;
|
pub use errno::Errno;
|
||||||
|
use serde::ser::{SerializeStruct, SerializeTupleVariant};
|
||||||
|
use serde::{Serialize, Serializer};
|
||||||
|
|
||||||
#[stable(feature = "mikros", since = "1.80.0")]
|
#[stable(feature = "mikros", since = "1.80.0")]
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
@ -60,7 +59,9 @@ pub fn writable(self) -> bool {
|
|||||||
#[stable(feature = "mikros", since = "1.80.0")]
|
#[stable(feature = "mikros", since = "1.80.0")]
|
||||||
pub fn get_writing_details(self) -> Option<(FileWriteMode, FileCreationMode)> {
|
pub fn get_writing_details(self) -> Option<(FileWriteMode, FileCreationMode)> {
|
||||||
match self {
|
match self {
|
||||||
Self::Write(wr_mode, cr_mode) | Self::ReadWrite(wr_mode, cr_mode) => Some((wr_mode, cr_mode)),
|
Self::Write(wr_mode, cr_mode) | Self::ReadWrite(wr_mode, cr_mode) => {
|
||||||
|
Some((wr_mode, cr_mode))
|
||||||
|
}
|
||||||
Self::Read => None,
|
Self::Read => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,7 +87,9 @@ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|||||||
match self {
|
match self {
|
||||||
Self::NoCreate => serializer.serialize_unit_variant("FileCreationMode", 0, "NoCreate"),
|
Self::NoCreate => serializer.serialize_unit_variant("FileCreationMode", 0, "NoCreate"),
|
||||||
Self::Create => serializer.serialize_unit_variant("FileCreationMode", 1, "Create"),
|
Self::Create => serializer.serialize_unit_variant("FileCreationMode", 1, "Create"),
|
||||||
Self::ForceCreate => serializer.serialize_unit_variant("FileCreationMode", 2, "ForceCreate"),
|
Self::ForceCreate => {
|
||||||
|
serializer.serialize_unit_variant("FileCreationMode", 2, "ForceCreate")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,14 +122,14 @@ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|||||||
tv.serialize_field(wr_mode)?;
|
tv.serialize_field(wr_mode)?;
|
||||||
tv.serialize_field(cr_mode)?;
|
tv.serialize_field(cr_mode)?;
|
||||||
tv.end()
|
tv.end()
|
||||||
},
|
}
|
||||||
Self::ReadWrite(ref wr_mode, ref cr_mode) => {
|
Self::ReadWrite(ref wr_mode, ref cr_mode) => {
|
||||||
let mut tv = serializer.serialize_tuple_variant("FileOpenMode", 2, "ReadWrite", 2)?;
|
let mut tv =
|
||||||
|
serializer.serialize_tuple_variant("FileOpenMode", 2, "ReadWrite", 2)?;
|
||||||
tv.serialize_field(wr_mode)?;
|
tv.serialize_field(wr_mode)?;
|
||||||
tv.serialize_field(cr_mode)?;
|
tv.serialize_field(cr_mode)?;
|
||||||
tv.end()
|
tv.end()
|
||||||
},
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
use crate::hash::{Hash, Hasher};
|
use crate::hash::{Hash, Hasher};
|
||||||
use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom};
|
use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom};
|
||||||
use crate::os::mikros::ipc::rpc;
|
use crate::os::mikros::ipc::rpc;
|
||||||
use crate::os::mikros::{Errno, syscalls, FileOpenMode, FileCreationMode, FileWriteMode};
|
use crate::os::mikros::{Errno, FileCreationMode, FileOpenMode, FileWriteMode, syscalls};
|
||||||
use crate::path::{Component, Path, PathBuf};
|
use crate::path::{Component, Path, PathBuf};
|
||||||
use crate::sys::time::SystemTime;
|
use crate::sys::time::SystemTime;
|
||||||
use crate::sys::unsupported;
|
use crate::sys::unsupported;
|
||||||
@ -320,7 +320,6 @@ pub fn file_type(&self) -> io::Result<FileType> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl OpenOptions {
|
impl OpenOptions {
|
||||||
pub fn new() -> OpenOptions {
|
pub fn new() -> OpenOptions {
|
||||||
OpenOptions {
|
OpenOptions {
|
||||||
@ -374,10 +373,7 @@ fn get_open_mode(&self) -> io::Result<FileOpenMode> {
|
|||||||
(true, false) => FileCreationMode::Create,
|
(true, false) => FileCreationMode::Create,
|
||||||
(_, true) => FileCreationMode::ForceCreate,
|
(_, true) => FileCreationMode::ForceCreate,
|
||||||
};
|
};
|
||||||
let wr_mode = FileWriteMode {
|
let wr_mode = FileWriteMode { truncate: self.truncate, append: self.append };
|
||||||
truncate: self.truncate,
|
|
||||||
append: self.append,
|
|
||||||
};
|
|
||||||
match self.read {
|
match self.read {
|
||||||
false => Ok(FileOpenMode::Write(wr_mode, cr_mode)),
|
false => Ok(FileOpenMode::Write(wr_mode, cr_mode)),
|
||||||
true => Ok(FileOpenMode::ReadWrite(wr_mode, cr_mode)),
|
true => Ok(FileOpenMode::ReadWrite(wr_mode, cr_mode)),
|
||||||
@ -385,7 +381,6 @@ fn get_open_mode(&self) -> io::Result<FileOpenMode> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl File {
|
impl File {
|
||||||
pub fn open(path: &Path, opts: &OpenOptions) -> io::Result<File> {
|
pub fn open(path: &Path, opts: &OpenOptions) -> io::Result<File> {
|
||||||
let open_mode = opts.get_open_mode()?;
|
let open_mode = opts.get_open_mode()?;
|
||||||
@ -396,7 +391,8 @@ pub fn open(path: &Path, opts: &OpenOptions) -> io::Result<File> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let open_res: Result<(u64, u64), Errno> = postcard::from_bytes(
|
let open_res: Result<(u64, u64), Errno> = postcard::from_bytes(
|
||||||
&rpc::send_call(vfs_pid, 2, 2, &postcard::to_allocvec(&(path, open_mode)).unwrap()).get_return(),
|
&rpc::send_call(vfs_pid, 2, 2, &postcard::to_allocvec(&(path, open_mode)).unwrap())
|
||||||
|
.get_return(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let (fs_pid, fd) = open_res?;
|
let (fs_pid, fd) = open_res?;
|
||||||
|
Loading…
Reference in New Issue
Block a user