From dece71308ac416707c22fdf43c5a534453a4eb79 Mon Sep 17 00:00:00 2001 From: seantywork Date: Fri, 7 Nov 2025 03:44:42 +0000 Subject: [PATCH] update kchr store --- kchr-store/2025-1105.xyz.md | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/kchr-store/2025-1105.xyz.md b/kchr-store/2025-1105.xyz.md index 1897465..f400246 100644 --- a/kchr-store/2025-1105.xyz.md +++ b/kchr-store/2025-1105.xyz.md @@ -37,22 +37,30 @@ static struct file_operations fops = { }; ``` -# +# build kernel module and user prog + +```shell +$ make +$ cd ./user && make + +``` + +# create character device script ```shell -thy@ubuntu24-server:~/linuxyz/kchr-store$ sudo ./dev_create.sh +$ sudo ./dev_create.sh dev node created ./user/chr_store ``` ```shell +# dmesg -wH [ +39.686846] chr_store: dev_major number: 239: init ``` -# +# run with message ```shell -thy@ubuntu24-server:~/linuxyz/kchr-store/user$ sudo ./u.out "hello from the other -side" +$ sudo ./u.out "hello from the other side" cmd: [w/q] main: file opened thread: failed to open: -1 @@ -61,6 +69,7 @@ thread: failed to open: -1 ``` ```shell +# dmesg -wH [Nov 6 05:01] file opened: 1 [ +1.000207] not possible to open: already occupied: 1 [ +1.000239] not possible to open: already occupied: 1 @@ -71,7 +80,7 @@ thread: failed to open: -1 ``` -# +# closing without saving ```shell q @@ -94,7 +103,7 @@ thread: closed file ``` -# +# write to the device ```shell @@ -114,7 +123,7 @@ thread: failed to open: ``` -# +# to see if the other thread can read from device ```shell q @@ -146,10 +155,10 @@ thread: closed file ``` -# +# close file ```shell -thy@ubuntu24-server:~/linuxyz/kchr-store$ sudo ./dev_destroy.sh +$ sudo ./dev_destroy.sh dev node destroyed ``` -- 2.43.0