Skip to content

Commit

Permalink
Implement device-mapper and bio
Browse files Browse the repository at this point in the history
  • Loading branch information
cqs21 committed Feb 21, 2024
1 parent d9aa019 commit eed3136
Show file tree
Hide file tree
Showing 8 changed files with 1,254 additions and 11 deletions.
6 changes: 5 additions & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@
#![feature(unboxed_closures)]
#![feature(unsize)]

mod error;
pub mod error;
mod layers;
mod os;
mod prelude;
mod tx;
mod util;

extern crate alloc;

pub use layers::bio::{BlockId, BlockSet, Buf, BufMut, BufRef, BLOCK_SIZE};
#[cfg(feature = "linux")]
pub use os::{Arc, Mutex, Vec};
2 changes: 1 addition & 1 deletion linux/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0

KDIR ?=
KDIR ?= /home/qingsong/workspace/rust-for-linux
ifndef KDIR
$(error The kernel source directory (KDIR) is not defined)
endif
Expand Down
2 changes: 2 additions & 0 deletions linux/bindings/src/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
* Sorted alphabetically.
*/

#include <linux/bio.h>
#include <linux/delay.h>
#include <linux/device-mapper.h>
#include <linux/kthread.h>
#include <linux/lockdep_types.h>
#include <linux/refcount.h>
Expand Down
26 changes: 26 additions & 0 deletions linux/bindings/src/helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

#include <linux/atomic.h>
#include <linux/bio.h>
#include <linux/refcount.h>
#include <linux/sched/task.h>

Expand Down Expand Up @@ -58,3 +59,28 @@ void helper_put_task_struct(struct task_struct *t)
{
put_task_struct(t);
}

void helper_bio_get(struct bio *bio)
{
bio_get(bio);
}

void helper_bio_set_dev(struct bio *bio, struct block_device *bdev)
{
bio_set_dev(bio, bdev);
}

bool helper_bio_has_data(struct bio *bio)
{
return bio_has_data(bio);
}

struct page *helper_virt_to_page(void *addr)
{
return virt_to_page(addr);
}

void *helper_page_to_virt(struct page *page)
{
return page_to_virt(page);
}
Loading

0 comments on commit eed3136

Please sign in to comment.