Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: debugfs: support binary large objects for ScopedDir

Add support for creating binary debugfs files via ScopedDir. This
mirrors the existing functionality for Dir, but without producing an
owning handle -- files are automatically removed when the associated
Scope is dropped.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Matthew Maurer <mmaurer@google.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

+44
+44
rust/kernel/debugfs.rs
··· 530 530 self.create_file(name, data, &T::FILE_OPS) 531 531 } 532 532 533 + /// Creates a read-only binary file in this directory. 534 + /// 535 + /// The file's contents are produced by invoking [`BinaryWriter::write_to_slice`]. 536 + /// 537 + /// This function does not produce an owning handle to the file. The created file is removed 538 + /// when the [`Scope`] that this directory belongs to is dropped. 539 + pub fn read_binary_file<T: BinaryWriter + Send + Sync + 'static>( 540 + &self, 541 + name: &CStr, 542 + data: &'data T, 543 + ) { 544 + self.create_file(name, data, &T::FILE_OPS) 545 + } 546 + 533 547 /// Creates a read-only file in this directory, with contents from a callback. 534 548 /// 535 549 /// The file contents are generated by calling `f` with `data`. ··· 578 564 data: &'data T, 579 565 ) { 580 566 let vtable = &<T as ReadWriteFile<_>>::FILE_OPS; 567 + self.create_file(name, data, vtable) 568 + } 569 + 570 + /// Creates a read-write binary file in this directory. 571 + /// 572 + /// Reading the file uses the [`BinaryWriter`] implementation on `data`. Writing to the file 573 + /// uses the [`BinaryReader`] implementation on `data`. 574 + /// 575 + /// This function does not produce an owning handle to the file. The created file is removed 576 + /// when the [`Scope`] that this directory belongs to is dropped. 577 + pub fn read_write_binary_file<T: BinaryWriter + BinaryReader + Send + Sync + 'static>( 578 + &self, 579 + name: &CStr, 580 + data: &'data T, 581 + ) { 582 + let vtable = &<T as BinaryReadWriteFile<_>>::FILE_OPS; 581 583 self.create_file(name, data, vtable) 582 584 } 583 585 ··· 634 604 pub fn write_only_file<T: Reader + Send + Sync + 'static>(&self, name: &CStr, data: &'data T) { 635 605 let vtable = &<T as WriteFile<_>>::FILE_OPS; 636 606 self.create_file(name, data, vtable) 607 + } 608 + 609 + /// Creates a write-only binary file in this directory. 610 + /// 611 + /// Writing to the file uses the [`BinaryReader`] implementation on `data`. 612 + /// 613 + /// This function does not produce an owning handle to the file. The created file is removed 614 + /// when the [`Scope`] that this directory belongs to is dropped. 615 + pub fn write_binary_file<T: BinaryReader + Send + Sync + 'static>( 616 + &self, 617 + name: &CStr, 618 + data: &'data T, 619 + ) { 620 + self.create_file(name, data, &T::FILE_OPS) 637 621 } 638 622 639 623 /// Creates a write-only file in this directory, with write logic from a callback.