Simple Linux character device — integer generator based on constant-recursive sequences of bytes
To use the RandomDev, follow these steps:
-
Clone the repository:
git clone https://github.com/PolinaSavelyeva/RandomDev.git
-
Navigate to the RandomDev directory:
cd RandomDev
-
Build the library using Make:
make
-
Insert module and log kernel messages:
sudo insmod mymodule.ko
sudo dmesg
or use:
make test
In kernel log you can see
MAJOR
number for your future character device. -
Assign this
MAJOR
number to a new character device:sudo mknod /dev/randomdev c MAJOR 0
-
Make your device file writable and put data into it using
printf
:sudo chmod a+w /dev/randomdev
printf "\K\A_1\...\A_K\X_1\...\X_K\C" > /dev/randomdev
where,
K
is an amount of coefficients to be provided in hexadecimalA_i
andX_i
are hexadecimal coefficients, 1<=i<=KC
is a last polynomial hexadecimal coefficient
example:
K
= 3,A_1
= 5,A_2
= 2,A_3
= 1,X_1
= 3,X_2
= 3,X_3
= 7,C
= 4printf "\x03\x05\x02\x01\x03\x03\x07\x04" > /dev/randomdev
-
Read a sequence of random numbers using
xxd
:xxd /dev/randomdev
-
Remove device file:
sudo rm /dev/randomdev
-
Remove module from kernel:
sudo rmmod mymodule
- Make utility
- C compiler
Tested on linux kernel version 5.15.0-107-generic.