use crate::{
bindings,
- block::mq::{raw_writer::RawWriter, Operations, TagSet},
+ block::mq::{Operations, TagSet},
error::{self, from_err_ptr, Result},
+ prelude::*,
static_lock_class,
+ str::NullTerminatedFormatter,
sync::Arc,
};
use core::fmt::{self, Write};
// SAFETY: `gendisk` is a valid pointer as we initialized it above
unsafe { (*gendisk).fops = &TABLE };
- let mut raw_writer = RawWriter::from_array(
+ let mut writer = NullTerminatedFormatter::new(
// SAFETY: `gendisk` points to a valid and initialized instance. We
// have exclusive access, since the disk is not added to the VFS
// yet.
unsafe { &mut (*gendisk).disk_name },
- )?;
- raw_writer.write_fmt(name)?;
- raw_writer.write_char('\0')?;
+ )
+ .ok_or(EINVAL)?;
+ writer.write_fmt(name)?;
// SAFETY: `gendisk` points to a valid and initialized instance of
// `struct gendisk`. `set_capacity` takes a lock to synchronize this
Ok(Self { buffer, pos: 0 })
}
+ #[expect(dead_code)]
pub(crate) fn from_array<const N: usize>(
a: &'a mut [crate::ffi::c_char; N],
) -> Result<RawWriter<'a>> {
impl<'a> NullTerminatedFormatter<'a> {
/// Create a new [`Self`] instance.
- #[expect(dead_code)]
pub(crate) fn new(buffer: &'a mut [u8]) -> Option<NullTerminatedFormatter<'a>> {
*(buffer.first_mut()?) = 0;