Stop using the legacy path format in fpath
For fbbootlog, fbcon and the disk drivers there is no load bearing use of the fpath output. And for chan relibc already handles both the legacy and new format.
This commit is contained in:
@@ -197,7 +197,7 @@ impl SchemeSync for FbbootlogScheme {
|
||||
}
|
||||
|
||||
fn fpath(&mut self, _id: usize, buf: &mut [u8], _ctx: &CallerCtx) -> Result<usize> {
|
||||
FpathWriter::with_legacy(buf, "fbbootlog", |_| Ok(()))
|
||||
FpathWriter::with(buf, "fbbootlog", |_| Ok(()))
|
||||
}
|
||||
|
||||
fn fsync(&mut self, _id: usize, _ctx: &CallerCtx) -> Result<()> {
|
||||
|
||||
@@ -163,7 +163,7 @@ impl SchemeSync for FbconScheme {
|
||||
}
|
||||
|
||||
fn fpath(&mut self, id: usize, buf: &mut [u8], _ctx: &CallerCtx) -> Result<usize> {
|
||||
FpathWriter::with_legacy(buf, "fbcon", |w| {
|
||||
FpathWriter::with(buf, "fbcon", |w| {
|
||||
let handle = self.get_vt_handle_mut(id)?;
|
||||
write!(w, "{}", handle.vt_i.0).unwrap();
|
||||
Ok(())
|
||||
|
||||
@@ -559,7 +559,7 @@ impl<T: Disk> SchemeAsync for DiskSchemeInner<T> {
|
||||
}
|
||||
|
||||
async fn fpath(&mut self, id: usize, buf: &mut [u8], _ctx: &CallerCtx) -> Result<usize> {
|
||||
FpathWriter::with_legacy(buf, &self.scheme_name, |w| {
|
||||
FpathWriter::with(buf, &self.scheme_name, |w| {
|
||||
match *self.handles.get(id)? {
|
||||
Handle::List(_) => (),
|
||||
Handle::Disk(number) => {
|
||||
|
||||
+1
-1
@@ -331,7 +331,7 @@ impl<'sock> SchemeSync for ChanScheme<'sock> {
|
||||
}
|
||||
}
|
||||
fn fpath(&mut self, id: usize, buf: &mut [u8], _ctx: &CallerCtx) -> Result<usize> {
|
||||
FpathWriter::with_legacy(buf, "chan", |w| {
|
||||
FpathWriter::with(buf, "chan", |w| {
|
||||
let handle = self.handles.get(&id).ok_or(Error::new(EBADF))?;
|
||||
if let Extra::SchemeRoot = handle.extra {
|
||||
return Ok(());
|
||||
|
||||
@@ -92,17 +92,6 @@ impl<'a> FpathWriter<'a> {
|
||||
Ok(w.written)
|
||||
}
|
||||
|
||||
pub fn with_legacy(
|
||||
buf: &'a mut [u8],
|
||||
scheme_name: &str,
|
||||
f: impl FnOnce(&mut Self) -> Result<()>,
|
||||
) -> Result<usize> {
|
||||
let mut w = FpathWriter { buf, written: 0 };
|
||||
write!(w, "{scheme_name}:").unwrap();
|
||||
f(&mut w)?;
|
||||
Ok(w.written)
|
||||
}
|
||||
|
||||
pub fn push_str(&mut self, s: &str) {
|
||||
let count = core::cmp::min(s.len(), self.buf.len() - self.written);
|
||||
self.buf[self.written..self.written + count].copy_from_slice(&s.as_bytes()[..count]);
|
||||
|
||||
Reference in New Issue
Block a user