| 1 | |
| 2 | |
| 3 |
|
| 4 | |
| 5 | |
| 6 | |
| 7 |
|
| 8 | |
| 9 | #![cfg_attr(not(CONFIG_DEBUG_FS), allow(unused_variables))]
|
| 10 |
|
| 11 | #[cfg(CONFIG_DEBUG_FS)]
|
| 12 | use crate::sync::Arc;
|
| 13 | use crate::{
|
| 14 | fmt,
|
| 15 | prelude::*,
|
| 16 | str::CStr,
|
| 17 | uaccess::UserSliceReader, |
| 18 | };
|
| 19 |
|
| 20 | #[cfg(CONFIG_DEBUG_FS)]
|
| 21 | use core::mem::ManuallyDrop;
|
| 22 | use core::{
|
| 23 | marker::{
|
| 24 | PhantomData,
|
| 25 | PhantomPinned, |
| 26 | },
|
| 27 | ops::Deref,
|
| 28 | };
|
| 29 |
|
| 30 | mod traits;
|
| 31 | pub use traits::{
|
| 32 | BinaryReader,
|
| 33 | BinaryReaderMut,
|
| 34 | BinaryWriter,
|
| 35 | Reader,
|
| 36 | Writer, |
| 37 | };
|
| 38 |
|
| 39 | mod callback_adapters;
|
| 40 | use callback_adapters::{
|
| 41 | FormatAdapter,
|
| 42 | NoWriter,
|
| 43 | WritableAdapter, |
| 44 | };
|
| 45 |
|
| 46 | mod file_ops;
|
| 47 | use file_ops::{
|
| 48 | BinaryReadFile,
|
| 49 | BinaryReadWriteFile,
|
| 50 | BinaryWriteFile,
|
| 51 | FileOps,
|
| 52 | ReadFile,
|
| 53 | ReadWriteFile,
|
| 54 | WriteFile, |
| 55 | };
|
| 56 |
|
| 57 | #[cfg(CONFIG_DEBUG_FS)]
|
| 58 | mod entry;
|
| 59 | #[cfg(CONFIG_DEBUG_FS)]
|
| 60 | use entry::Entry;
|
| 61 |
|
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | #[derive(Clone)]
|
| 73 | pub struct Dir(#[cfg(CONFIG_DEBUG_FS)] Option<Arc<Entry<'static>>>);
|
| 74 |
|
| 75 | impl Dir {
|
| 76 | |
| 77 | fn create(name: &CStr, parent: Option<&Dir>) -> Self {
|
| 78 | #[cfg(CONFIG_DEBUG_FS)]
|
| 79 | {
|
| 80 | let parent_entry = match parent {
|
| 81 | |
| 82 | Some(Dir(None)) => return Self(None),
|
| 83 | Some(Dir(Some(entry))) => Some(entry.clone()),
|
| 84 | None => None,
|
| 85 | };
|
| 86 | Self(
|
| 87 | |
| 88 | |
| 89 | Arc::new(Entry::dynamic_dir(name, parent_entry), GFP_KERNEL).ok(),
|
| 90 | )
|
| 91 | }
|
| 92 | #[cfg(not(CONFIG_DEBUG_FS))]
|
| 93 | Self()
|
| 94 | }
|
| 95 |
|
| 96 | |
| 97 | |
| 98 | fn create_file<'a, T, E: 'a>(
|
| 99 | &'a self,
|
| 100 | name: &'a CStr,
|
| 101 | data: impl PinInit<T, E> + 'a,
|
| 102 | file_ops: &'static FileOps<T>,
|
| 103 | ) -> impl PinInit<File<T>, E> + 'a
|
| 104 | where
|
| 105 | T: Sync + 'static,
|
| 106 | {
|
| 107 | let scope = Scope::<T>::new(data, move |data| {
|
| 108 | #[cfg(CONFIG_DEBUG_FS)]
|
| 109 | if let Some(parent) = &self.0 {
|
| 110 | |
| 111 | |
| 112 | unsafe { Entry::dynamic_file(name, parent.clone(), data, file_ops) }
|
| 113 | } else {
|
| 114 | Entry::empty()
|
| 115 | }
|
| 116 | });
|
| 117 | try_pin_init! {
|
| 118 | File {
|
| 119 | scope <- scope
|
| 120 | } ? E
|
| 121 | }
|
| 122 | }
|
| 123 |
|
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | pub fn new(name: &CStr) -> Self {
|
| 133 | Dir::create(name, None)
|
| 134 | }
|
| 135 |
|
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | pub fn subdir(&self, name: &CStr) -> Self {
|
| 146 | Dir::create(name, Some(self))
|
| 147 | }
|
| 148 |
|
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | pub fn read_only_file<'a, T, E: 'a>(
|
| 166 | &'a self,
|
| 167 | name: &'a CStr,
|
| 168 | data: impl PinInit<T, E> + 'a,
|
| 169 | ) -> impl PinInit<File<T>, E> + 'a
|
| 170 | where
|
| 171 | T: Writer + Send + Sync + 'static,
|
| 172 | {
|
| 173 | let file_ops = &<T as ReadFile<_>>::FILE_OPS;
|
| 174 | self.create_file(name, data, file_ops)
|
| 175 | }
|
| 176 |
|
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | pub fn read_binary_file<'a, T, E: 'a>(
|
| 192 | &'a self,
|
| 193 | name: &'a CStr,
|
| 194 | data: impl PinInit<T, E> + 'a,
|
| 195 | ) -> impl PinInit<File<T>, E> + 'a
|
| 196 | where
|
| 197 | T: BinaryWriter + Send + Sync + 'static,
|
| 198 | {
|
| 199 | self.create_file(name, data, &T::FILE_OPS)
|
| 200 | }
|
| 201 |
|
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | pub fn read_callback_file<'a, T, E: 'a, F>(
|
| 233 | &'a self,
|
| 234 | name: &'a CStr,
|
| 235 | data: impl PinInit<T, E> + 'a,
|
| 236 | _f: &'static F,
|
| 237 | ) -> impl PinInit<File<T>, E> + 'a
|
| 238 | where
|
| 239 | T: Send + Sync + 'static,
|
| 240 | F: Fn(&T, &mut fmt::Formatter<'_>) -> fmt::Result + Send + Sync,
|
| 241 | {
|
| 242 | let file_ops = <FormatAdapter<T, F>>::FILE_OPS.adapt();
|
| 243 | self.create_file(name, data, file_ops)
|
| 244 | }
|
| 245 |
|
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | pub fn read_write_file<'a, T, E: 'a>(
|
| 251 | &'a self,
|
| 252 | name: &'a CStr,
|
| 253 | data: impl PinInit<T, E> + 'a,
|
| 254 | ) -> impl PinInit<File<T>, E> + 'a
|
| 255 | where
|
| 256 | T: Writer + Reader + Send + Sync + 'static,
|
| 257 | {
|
| 258 | let file_ops = &<T as ReadWriteFile<_>>::FILE_OPS;
|
| 259 | self.create_file(name, data, file_ops)
|
| 260 | }
|
| 261 |
|
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | pub fn read_write_binary_file<'a, T, E: 'a>(
|
| 267 | &'a self,
|
| 268 | name: &'a CStr,
|
| 269 | data: impl PinInit<T, E> + 'a,
|
| 270 | ) -> impl PinInit<File<T>, E> + 'a
|
| 271 | where
|
| 272 | T: BinaryWriter + BinaryReader + Send + Sync + 'static,
|
| 273 | {
|
| 274 | let file_ops = &<T as BinaryReadWriteFile<_>>::FILE_OPS;
|
| 275 | self.create_file(name, data, file_ops)
|
| 276 | }
|
| 277 |
|
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | pub fn read_write_callback_file<'a, T, E: 'a, F, W>(
|
| 285 | &'a self,
|
| 286 | name: &'a CStr,
|
| 287 | data: impl PinInit<T, E> + 'a,
|
| 288 | _f: &'static F,
|
| 289 | _w: &'static W,
|
| 290 | ) -> impl PinInit<File<T>, E> + 'a
|
| 291 | where
|
| 292 | T: Send + Sync + 'static,
|
| 293 | F: Fn(&T, &mut fmt::Formatter<'_>) -> fmt::Result + Send + Sync,
|
| 294 | W: Fn(&T, &mut UserSliceReader) -> Result + Send + Sync,
|
| 295 | {
|
| 296 | let file_ops =
|
| 297 | <WritableAdapter<FormatAdapter<T, F>, W> as file_ops::ReadWriteFile<_>>::FILE_OPS
|
| 298 | .adapt()
|
| 299 | .adapt();
|
| 300 | self.create_file(name, data, file_ops)
|
| 301 | }
|
| 302 |
|
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | pub fn write_only_file<'a, T, E: 'a>(
|
| 310 | &'a self,
|
| 311 | name: &'a CStr,
|
| 312 | data: impl PinInit<T, E> + 'a,
|
| 313 | ) -> impl PinInit<File<T>, E> + 'a
|
| 314 | where
|
| 315 | T: Reader + Send + Sync + 'static,
|
| 316 | {
|
| 317 | self.create_file(name, data, &T::FILE_OPS)
|
| 318 | }
|
| 319 |
|
| 320 | |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | pub fn write_binary_file<'a, T, E: 'a>(
|
| 327 | &'a self,
|
| 328 | name: &'a CStr,
|
| 329 | data: impl PinInit<T, E> + 'a,
|
| 330 | ) -> impl PinInit<File<T>, E> + 'a
|
| 331 | where
|
| 332 | T: BinaryReader + Send + Sync + 'static,
|
| 333 | {
|
| 334 | self.create_file(name, data, &T::FILE_OPS)
|
| 335 | }
|
| 336 |
|
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | pub fn write_callback_file<'a, T, E: 'a, W>(
|
| 342 | &'a self,
|
| 343 | name: &'a CStr,
|
| 344 | data: impl PinInit<T, E> + 'a,
|
| 345 | _w: &'static W,
|
| 346 | ) -> impl PinInit<File<T>, E> + 'a
|
| 347 | where
|
| 348 | T: Send + Sync + 'static,
|
| 349 | W: Fn(&T, &mut UserSliceReader) -> Result + Send + Sync,
|
| 350 | {
|
| 351 | let file_ops = <WritableAdapter<NoWriter<T>, W> as WriteFile<_>>::FILE_OPS
|
| 352 | .adapt()
|
| 353 | .adapt();
|
| 354 | self.create_file(name, data, file_ops)
|
| 355 | }
|
| 356 |
|
| 357 | |
| 358 | |
| 359 | |
| 360 | |
| 361 | |
| 362 | fn scoped_dir<'data>(&self, name: &CStr) -> ScopedDir<'data, 'static> {
|
| 363 | #[cfg(CONFIG_DEBUG_FS)]
|
| 364 | {
|
| 365 | let parent_entry = match &self.0 {
|
| 366 | None => return ScopedDir::empty(),
|
| 367 | Some(entry) => entry.clone(),
|
| 368 | };
|
| 369 | ScopedDir {
|
| 370 | entry: ManuallyDrop::new(Entry::dynamic_dir(name, Some(parent_entry))),
|
| 371 | _phantom: PhantomData,
|
| 372 | }
|
| 373 | }
|
| 374 | #[cfg(not(CONFIG_DEBUG_FS))]
|
| 375 | ScopedDir::empty()
|
| 376 | }
|
| 377 |
|
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | pub fn scope<'a, T: 'a, E: 'a, F>(
|
| 387 | &'a self,
|
| 388 | data: impl PinInit<T, E> + 'a,
|
| 389 | name: &'a CStr,
|
| 390 | init: F,
|
| 391 | ) -> impl PinInit<Scope<T>, E> + 'a
|
| 392 | where
|
| 393 | F: for<'data, 'dir> FnOnce(&'data T, &'dir ScopedDir<'data, 'dir>) + 'a,
|
| 394 | {
|
| 395 | Scope::new(data, |data| {
|
| 396 | let scoped = self.scoped_dir(name);
|
| 397 | init(data, &scoped);
|
| 398 | scoped.into_entry()
|
| 399 | })
|
| 400 | }
|
| 401 | }
|
| 402 |
|
| 403 | #[pin_data]
|
| 404 | |
| 405 | |
| 406 | |
| 407 | |
| 408 | |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | pub struct Scope<T> {
|
| 414 | |
| 415 | #[cfg(CONFIG_DEBUG_FS)]
|
| 416 | _entry: Entry<'static>,
|
| 417 | #[pin]
|
| 418 | data: T,
|
| 419 | |
| 420 | #[pin]
|
| 421 | _pin: PhantomPinned,
|
| 422 | }
|
| 423 |
|
| 424 | #[pin_data]
|
| 425 | |
| 426 | |
| 427 | |
| 428 | pub struct File<T> {
|
| 429 | #[pin]
|
| 430 | scope: Scope<T>,
|
| 431 | }
|
| 432 |
|
| 433 | #[cfg(not(CONFIG_DEBUG_FS))]
|
| 434 | impl<'b, T: 'b> Scope<T> {
|
| 435 | fn new<E: 'b, F>(data: impl PinInit<T, E> + 'b, init: F) -> impl PinInit<Self, E> + 'b
|
| 436 | where
|
| 437 | F: for<'a> FnOnce(&'a T) + 'b,
|
| 438 | {
|
| 439 | try_pin_init! {
|
| 440 | Self {
|
| 441 | data <- data,
|
| 442 | _pin: PhantomPinned
|
| 443 | } ? E
|
| 444 | }
|
| 445 | .pin_chain(|scope| {
|
| 446 | init(&scope.data);
|
| 447 | Ok(())
|
| 448 | })
|
| 449 | }
|
| 450 | }
|
| 451 |
|
| 452 | #[cfg(CONFIG_DEBUG_FS)]
|
| 453 | impl<'b, T: 'b> Scope<T> {
|
| 454 | fn entry_mut(self: Pin<&mut Self>) -> &mut Entry<'static> {
|
| 455 | |
| 456 | unsafe { &mut Pin::into_inner_unchecked(self)._entry }
|
| 457 | }
|
| 458 |
|
| 459 | fn new<E: 'b, F>(data: impl PinInit<T, E> + 'b, init: F) -> impl PinInit<Self, E> + 'b
|
| 460 | where
|
| 461 | F: for<'a> FnOnce(&'a T) -> Entry<'static> + 'b,
|
| 462 | {
|
| 463 | try_pin_init! {
|
| 464 | Self {
|
| 465 | _entry: Entry::empty(),
|
| 466 | data <- data,
|
| 467 | _pin: PhantomPinned
|
| 468 | } ? E
|
| 469 | }
|
| 470 | .pin_chain(|scope| {
|
| 471 | *scope.entry_mut() = init(&scope.data);
|
| 472 | Ok(())
|
| 473 | })
|
| 474 | }
|
| 475 | }
|
| 476 |
|
| 477 | impl<'a, T: 'a> Scope<T> {
|
| 478 | |
| 479 | |
| 480 | |
| 481 | |
| 482 | |
| 483 | |
| 484 | |
| 485 | |
| 486 | pub fn dir<E: 'a, F>(
|
| 487 | data: impl PinInit<T, E> + 'a,
|
| 488 | name: &'a CStr,
|
| 489 | init: F,
|
| 490 | ) -> impl PinInit<Self, E> + 'a
|
| 491 | where
|
| 492 | F: for<'data, 'dir> FnOnce(&'data T, &'dir ScopedDir<'data, 'dir>) + 'a,
|
| 493 | {
|
| 494 | Scope::new(data, |data| {
|
| 495 | let scoped = ScopedDir::new(name);
|
| 496 | init(data, &scoped);
|
| 497 | scoped.into_entry()
|
| 498 | })
|
| 499 | }
|
| 500 | }
|
| 501 |
|
| 502 | impl<T> Deref for Scope<T> {
|
| 503 | type Target = T;
|
| 504 | fn deref(&self) -> &T {
|
| 505 | &self.data
|
| 506 | }
|
| 507 | }
|
| 508 |
|
| 509 | impl<T> Deref for File<T> {
|
| 510 | type Target = T;
|
| 511 | fn deref(&self) -> &T {
|
| 512 | &self.scope
|
| 513 | }
|
| 514 | }
|
| 515 |
|
| 516 | |
| 517 | |
| 518 | |
| 519 | |
| 520 | |
| 521 | pub struct ScopedDir<'data, 'dir> {
|
| 522 | #[cfg(CONFIG_DEBUG_FS)]
|
| 523 | entry: ManuallyDrop<Entry<'dir>>,
|
| 524 | _phantom: PhantomData<fn(&'data ()) -> &'dir ()>,
|
| 525 | }
|
| 526 |
|
| 527 | impl<'data, 'dir> ScopedDir<'data, 'dir> {
|
| 528 | |
| 529 | |
| 530 | |
| 531 | pub fn dir<'dir2>(&'dir2 self, name: &CStr) -> ScopedDir<'data, 'dir2> {
|
| 532 | #[cfg(not(CONFIG_DEBUG_FS))]
|
| 533 | let _ = name;
|
| 534 | ScopedDir {
|
| 535 | #[cfg(CONFIG_DEBUG_FS)]
|
| 536 | entry: ManuallyDrop::new(Entry::dir(name, Some(&*self.entry))),
|
| 537 | _phantom: PhantomData,
|
| 538 | }
|
| 539 | }
|
| 540 |
|
| 541 | fn create_file<T: Sync>(&self, name: &CStr, data: &'data T, vtable: &'static FileOps<T>) {
|
| 542 | #[cfg(CONFIG_DEBUG_FS)]
|
| 543 | core::mem::forget(Entry::file(name, &self.entry, data, vtable));
|
| 544 | }
|
| 545 |
|
| 546 | |
| 547 | |
| 548 | |
| 549 | |
| 550 | |
| 551 | |
| 552 | |
| 553 | pub fn read_only_file<T: Writer + Send + Sync + 'static>(&self, name: &CStr, data: &'data T) {
|
| 554 | self.create_file(name, data, &T::FILE_OPS)
|
| 555 | }
|
| 556 |
|
| 557 | |
| 558 | |
| 559 | |
| 560 | |
| 561 | |
| 562 | |
| 563 | pub fn read_binary_file<T: BinaryWriter + Send + Sync + 'static>(
|
| 564 | &self,
|
| 565 | name: &CStr,
|
| 566 | data: &'data T,
|
| 567 | ) {
|
| 568 | self.create_file(name, data, &T::FILE_OPS)
|
| 569 | }
|
| 570 |
|
| 571 | |
| 572 | |
| 573 | |
| 574 | |
| 575 | |
| 576 | |
| 577 | |
| 578 | |
| 579 | |
| 580 | |
| 581 | |
| 582 | pub fn read_callback_file<T, F>(&self, name: &CStr, data: &'data T, _f: &'static F)
|
| 583 | where
|
| 584 | T: Send + Sync + 'static,
|
| 585 | F: Fn(&T, &mut fmt::Formatter<'_>) -> fmt::Result + Send + Sync,
|
| 586 | {
|
| 587 | let vtable = <FormatAdapter<T, F> as ReadFile<_>>::FILE_OPS.adapt();
|
| 588 | self.create_file(name, data, vtable)
|
| 589 | }
|
| 590 |
|
| 591 | |
| 592 | |
| 593 | |
| 594 | |
| 595 | |
| 596 | |
| 597 | |
| 598 | |
| 599 | pub fn read_write_file<T: Writer + Reader + Send + Sync + 'static>(
|
| 600 | &self,
|
| 601 | name: &CStr,
|
| 602 | data: &'data T,
|
| 603 | ) {
|
| 604 | let vtable = &<T as ReadWriteFile<_>>::FILE_OPS;
|
| 605 | self.create_file(name, data, vtable)
|
| 606 | }
|
| 607 |
|
| 608 | |
| 609 | |
| 610 | |
| 611 | |
| 612 | |
| 613 | |
| 614 | |
| 615 | pub fn read_write_binary_file<T: BinaryWriter + BinaryReader + Send + Sync + 'static>(
|
| 616 | &self,
|
| 617 | name: &CStr,
|
| 618 | data: &'data T,
|
| 619 | ) {
|
| 620 | let vtable = &<T as BinaryReadWriteFile<_>>::FILE_OPS;
|
| 621 | self.create_file(name, data, vtable)
|
| 622 | }
|
| 623 |
|
| 624 | |
| 625 | |
| 626 | |
| 627 | |
| 628 | |
| 629 | |
| 630 | |
| 631 | |
| 632 | |
| 633 | |
| 634 | pub fn read_write_callback_file<T, F, W>(
|
| 635 | &self,
|
| 636 | name: &CStr,
|
| 637 | data: &'data T,
|
| 638 | _f: &'static F,
|
| 639 | _w: &'static W,
|
| 640 | ) where
|
| 641 | T: Send + Sync + 'static,
|
| 642 | F: Fn(&T, &mut fmt::Formatter<'_>) -> fmt::Result + Send + Sync,
|
| 643 | W: Fn(&T, &mut UserSliceReader) -> Result + Send + Sync,
|
| 644 | {
|
| 645 | let vtable = <WritableAdapter<FormatAdapter<T, F>, W> as ReadWriteFile<_>>::FILE_OPS
|
| 646 | .adapt()
|
| 647 | .adapt();
|
| 648 | self.create_file(name, data, vtable)
|
| 649 | }
|
| 650 |
|
| 651 | |
| 652 | |
| 653 | |
| 654 | |
| 655 | |
| 656 | |
| 657 | |
| 658 | pub fn write_only_file<T: Reader + Send + Sync + 'static>(&self, name: &CStr, data: &'data T) {
|
| 659 | let vtable = &<T as WriteFile<_>>::FILE_OPS;
|
| 660 | self.create_file(name, data, vtable)
|
| 661 | }
|
| 662 |
|
| 663 | |
| 664 | |
| 665 | |
| 666 | |
| 667 | |
| 668 | |
| 669 | pub fn write_binary_file<T: BinaryReader + Send + Sync + 'static>(
|
| 670 | &self,
|
| 671 | name: &CStr,
|
| 672 | data: &'data T,
|
| 673 | ) {
|
| 674 | self.create_file(name, data, &T::FILE_OPS)
|
| 675 | }
|
| 676 |
|
| 677 | |
| 678 | |
| 679 | |
| 680 | |
| 681 | |
| 682 | |
| 683 | |
| 684 | |
| 685 | |
| 686 | |
| 687 | pub fn write_only_callback_file<T, W>(&self, name: &CStr, data: &'data T, _w: &'static W)
|
| 688 | where
|
| 689 | T: Send + Sync + 'static,
|
| 690 | W: Fn(&T, &mut UserSliceReader) -> Result + Send + Sync,
|
| 691 | {
|
| 692 | let vtable = &<WritableAdapter<NoWriter<T>, W> as WriteFile<_>>::FILE_OPS
|
| 693 | .adapt()
|
| 694 | .adapt();
|
| 695 | self.create_file(name, data, vtable)
|
| 696 | }
|
| 697 |
|
| 698 | fn empty() -> Self {
|
| 699 | ScopedDir {
|
| 700 | #[cfg(CONFIG_DEBUG_FS)]
|
| 701 | entry: ManuallyDrop::new(Entry::empty()),
|
| 702 | _phantom: PhantomData,
|
| 703 | }
|
| 704 | }
|
| 705 | #[cfg(CONFIG_DEBUG_FS)]
|
| 706 | fn into_entry(self) -> Entry<'dir> {
|
| 707 | ManuallyDrop::into_inner(self.entry)
|
| 708 | }
|
| 709 | #[cfg(not(CONFIG_DEBUG_FS))]
|
| 710 | fn into_entry(self) {}
|
| 711 | }
|
| 712 |
|
| 713 | impl<'data> ScopedDir<'data, 'static> {
|
| 714 | |
| 715 | |
| 716 | |
| 717 | fn new(name: &CStr) -> ScopedDir<'data, 'static> {
|
| 718 | ScopedDir {
|
| 719 | #[cfg(CONFIG_DEBUG_FS)]
|
| 720 | entry: ManuallyDrop::new(Entry::dir(name, None)),
|
| 721 | _phantom: PhantomData,
|
| 722 | }
|
| 723 | }
|
| 724 | }
|