Description
Exercise 8
已開始: 9⽉27⽇ 16:38
測驗說明
問題 1 50 分數
上傳
If you are using a new platform this time (e.g., Raspberry Pi that you didn’t use before for modules), then do the following:
sudo apt update && sudo apt -y upgrade
sudo apt-get install raspberrypi-kernel-headers
Modify this (https://canvas.rice.edu/courses/59111/files/4929006/download?download_frd=1)
(https://canvas.rice.edu/courses/59111/files/4929006/download?download_frd=1&download_frd=1) module file (named hello_open.c
in Files on Canvas) according to the instructions inside the file
This will help you make a module that implements the open system call for a “fake” character device
We need a user application to call open for a fake character device we will play with
Make a C file called testmeschar.c
Include the header files stdio.h, stdlib.h, unistd.h, and fcntl.h
Inside the main function, print (using printf) a message to the console saying that we are running the program
Make a call to the C function open()
open(), which is part of the standard C library, takes two input arguments
The first input is a string that specifies the file path to our fake device we are making, which is at /dev/**** [where **** is the
device name you chose]
The second argument is O_RDWR
Capital O, not zero; Used to read/write files
The output will be an integer; No need to do anything with it
return 0
Download this (https://canvas.rice.edu/courses/59111/files/4929027/download?download_frd=1)
(https://canvas.rice.edu/courses/59111/files/4929027/download?download_frd=1&download_frd=1) Makefile (Files/Makefile for char
test/Makefile on Canvas) and replace the all capitals text appropriately
Now test it with the following commands, replacing mes with the class name you chose and meschar with the device name you
chose:
make
sudo insmod hello.ko
ls /dev
ls /dev/88* (replacing 88 with the first few letters of your device name; * is a wildcard, different from a Yellowcard
(https://en.wikipedia.org/wiki/Ocean_Avenue_(song)) )
ls /sys/class/mes/meschar
cat /sys/module/hello/parameters/multiplier
(other terminal window) tail -f /var/log/kern.log
Or: dmesg
sudo ./test (run many times) [MAKE SURE TO RUN WITH sudo!]
sudo rmmod hello.ko
Submit a screenshot of dmesg that contains text output corresponding to insmod, multiple runs of ./test, and rmmod. Also copy and
paste your c test file code and module code into the next two questions.
選擇檔案
問題 2 25 分數
Copy and paste c test code here.
沒有要保存的新數據。上次檢查於 16:39
p 0 個字 </>
問題 3 25 分數
p
Copy and paste c module code here.
0 個字 </>
提交測驗
編輯 檢視 插入 格式 ⼯具 表格
12pt 段落
編輯 檢視 插入 格式 ⼯具 表格
12pt 段落
Reviews
There are no reviews yet.