Skip to content
This repository was archived by the owner on Mar 7, 2021. It is now read-only.

Commit 19a2b54

Browse files
committed
Start sketching out C callbacks for filesystem API
1 parent 01dd524 commit 19a2b54

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const INCLUDED_FUNCTIONS: &[&str] = &[
1111
"unregister_filesystem",
1212
"krealloc",
1313
"kfree",
14+
"mount_nodev",
15+
"kill_litter_super",
1416
];
1517
const INCLUDED_VARS: &[&str] = &[
1618
"EINVAL",

src/filesystem.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,27 @@ impl FileSystemFlags {
4040
}
4141
}
4242

43+
extern "C" fn fill_super_callback<T: FileSystem>(
44+
sb: *mut bindings::super_block,
45+
data: *mut types::c_void,
46+
silent: types::c_int,
47+
) -> types::c_int {
48+
// T::fill_super(...)
49+
// This should actually create an object that gets dropped by
50+
// file_system_registration::kill_sb. You can point to it with
51+
// sb->s_fs_info.
52+
unimplemented!();
53+
}
54+
55+
extern "C" fn mount_callback<T: FileSystem>(
56+
fs_type: *mut bindings::file_system_type,
57+
flags: types::c_int,
58+
_dev_name: *const types::c_char,
59+
data: *mut types::c_void,
60+
) -> *mut bindings::dentry {
61+
unsafe { bindings::mount_nodev(fs_type, flags, data, Some(fill_super_callback::<T>)) }
62+
}
63+
4364
pub fn register<T: FileSystem>() -> error::KernelResult<FileSystemRegistration<T>> {
4465
if !T::NAME.ends_with('\x00') {
4566
return Err(error::Error::EINVAL);
@@ -49,6 +70,8 @@ pub fn register<T: FileSystem>() -> error::KernelResult<FileSystemRegistration<T
4970
name: T::NAME.as_ptr() as *const i8,
5071
owner: unsafe { &mut bindings::__this_module },
5172
fs_flags: T::FLAGS.bits(),
73+
mount: Some(mount_callback::<T>),
74+
kill_sb: Some(bindings::kill_litter_super),
5275

5376
..Default::default()
5477
}),

0 commit comments

Comments
 (0)