From 479444364a7767024e179895558bba2fd85e1104 Mon Sep 17 00:00:00 2001 From: root <root@debian-BULLSEYE-live-builder-AMD64> Date: Wed, 18 Oct 2023 17:00:17 +0200 Subject: [PATCH] pipebis3.ko working --- work/tp3/pipebis3.c | 21 ++++++++------------- work/tp3/pipebis3.mod.c | 4 ++-- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/work/tp3/pipebis3.c b/work/tp3/pipebis3.c index 269b6b2..db529cb 100644 --- a/work/tp3/pipebis3.c +++ b/work/tp3/pipebis3.c @@ -211,7 +211,7 @@ static int block_empty_buff(void) } if (is_sig) { - module_put(THIS_MODULE); + // module_put(THIS_MODULE); return -1; } @@ -270,6 +270,11 @@ static ssize_t device_read(struct file *filp, /* see include/linux/fs.h */ mutex_unlock(&asse_buf_count_mutex); wake_up(&wait_full); + + if (asee_buf_count <= 0) { + pr_info("Read blocked\n"); + if (block_empty_buff() < 0) return 0; + } } *offset = last_read_bytes; @@ -292,7 +297,7 @@ static int block_full_buff(void) } if (is_sig) { - module_put(THIS_MODULE); + // module_put(THIS_MODULE); return -1; } } @@ -328,9 +333,9 @@ static ssize_t device_write(struct file *filp, const char __user *buff, //pr_info("Waking up empty\n"); wake_up(&wait_empty); + asee_buf_count++; if (asee_buf_count < asee_buf_size) { //pr_info("asee_buf_count++;\n"); - asee_buf_count++; mutex_unlock(&asse_buf_count_mutex); } else { //pr_info("atomic_set(&already_full, 1); \n"); @@ -340,16 +345,6 @@ static ssize_t device_write(struct file *filp, const char __user *buff, } } - mutex_lock(&asse_buf_count_mutex); - // Le probleme est ici, cela donne zero au debut - pr_info("last_read_bytes: %d", last_read_bytes); - // We change asee_buf_size :TODO handle modulo - last_read_bytes = (last_read_bytes + bytes_writen) % asee_buf_size; - pr_info("bytes_writen: %d", bytes_writen); - pr_info("asee_buf_count: %d", asee_buf_count); - - pr_info("Last read byte update to: %d", last_read_bytes); - mutex_unlock(&asse_buf_count_mutex); *off = last_writen_bytes; return bytes_writen; diff --git a/work/tp3/pipebis3.mod.c b/work/tp3/pipebis3.mod.c index d4f0c91..de6b143 100644 --- a/work/tp3/pipebis3.mod.c +++ b/work/tp3/pipebis3.mod.c @@ -35,7 +35,6 @@ MODULE_INFO(retpoline, "Y"); static const struct modversion_info ____versions[] __used __section("__versions") = { - { 0x1000e51, "schedule" }, { 0x8c26d495, "prepare_to_wait_event" }, { 0x92540fbf, "finish_wait" }, { 0xf0fdf6cb, "__stack_chk_fail" }, @@ -66,10 +65,11 @@ __used __section("__versions") = { { 0x3213f038, "mutex_unlock" }, { 0xe2c17b5d, "__SCT__might_resched" }, { 0xfe487975, "init_wait_entry" }, + { 0x1000e51, "schedule" }, { 0x76800044, "module_layout" }, }; MODULE_INFO(depends, ""); -MODULE_INFO(srcversion, "D65D0B5D00F7B86A769F376"); +MODULE_INFO(srcversion, "331261CAA2C80075E1CB7DD"); -- GitLab