Creating a device-file node

Creating a device-file node presents A device-driver example, The Linux commands, Removing a device-file, LKM’s have full privileges, Developers disapprove, ‘Open Source’ philosophy, How to invoke ‘unlink’, Use ‘man’ for prototypes. | Creating a device-file node An introduction to some privileged Linux system-calls (needed for an upcoming programming exercise) A device-driver example • We want to build a simple device-driver, one that would let ordinary applications read and/or write to the CMOS memory (. to adjust the date or time-of-day) • This will require that we have a so-called device ‘special’ file in the ‘/dev’ directory • Creating such a file normally requires the privileges of a System Administrator – but could be accomplished via a suitable LKM The Linux commands • If a System Administrator wanted to setup a device-file in the ‘/dev’ directory named ‘cmos’ that has read-and-write privileges, the following commands would be used: root# mknod /dev/cmos c 70 0 root# chmod a+rw /dev/cmos • Here the ‘c’ argument indicates that the file-node is for a ‘character-mode’ device • Values 70 and 0 are arbitrary id-numbers Removing a device-file • To delete a file from the ‘/dev’ directory, the SysAdmin uses the ‘unlink’ command: root# unlink /dev/cmos • Because of standard privilege-restrictions on the ‘/dev’ directory, these commands will fail if executed by unprivileged users • Students have not been given sufficient privileges to successfully execute these ‘mknod’, ‘chmod’ and ‘unlink’ commands LKM’s have full privileges • But CS students in this class DO possess privileges that allow them to install, and to remove, Linux kernel modules: user$ /sbin/insmod user$ /sbin/rmmod • While installed, modules execute inside the kernel itself, with no privilege barriers • Hence we should be able to perform the steps necessary to create a .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.