Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nelsbrock/dev-fibonacci
A Linux driver for a device which outputs the Fibonacci series.
https://github.com/nelsbrock/dev-fibonacci
Last synced: 5 days ago
JSON representation
A Linux driver for a device which outputs the Fibonacci series.
- Host: GitHub
- URL: https://github.com/nelsbrock/dev-fibonacci
- Owner: nelsbrock
- License: mit
- Created: 2024-05-10T19:35:33.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-05-10T20:32:05.000Z (6 months ago)
- Last Synced: 2024-05-10T21:43:57.565Z (6 months ago)
- Language: C
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# /dev/fibonacci
Just playing around with Linux Kernel Module programming.
## What is this?
A Linux driver for a device which outputs the Fibonacci series.
## Usage
*Disclaimer:* You should probably run this kernel module in a virtual machine,
as it is literally running in kernel-space, and I don't consider my Linux kernel
module programming experience high enough to confidently claim that this won't
wreak complete havoc on your machine. It works on my machine, though.### Building
Clone this repository, `cd` to it, then run `make`.
### Loading
After building the module, run `insmod fibonacci.ko` with root privileges to
load it.### Using the device
After loading the module, you can read the Fibonacci series from
`/dev/fibonacci` (you'll probably need root privileges to access the device):```sh
head -n 12 /dev/fibonacci
```Output:
```
0
1
1
2
3
5
8
13
21
34
55
89
```### Unloading
Run `rmmod fibonacci` with root privileges to unload the module.
## Notes
- The `fibonacci` device can only be read from the beginning. Reading from an
offest results in errno `EINVAL` being returned ("Invalid argument").
- Fibonacci numbers are internally represented as `long long unsigned` and
output is terminated when an overflow occurs.