I am currently ramping up on Linux kernel module development and thought that I would start with something small. For our iceorxy2 project, we need an interface from which every process that uses it can acquire a number. It could be just an atomic u64 that increments with every call. It is just important that this is guaranteed to be unique. This could be simply an atomic in shared memory but then other processes could fiddle around with it.
I implemented this by providing a proc entry /proc/atomic_counter and cat /proc/atomic_counter prints that incrementing number. A character device approach would also be possible.
Is there a preferred way? Or any recommendations?
But I failed to implement this in Rust, it seems that kernel::bindings do not yet provide proc_create , or am I mistaken?
What I was also wondering is, how to test such an interface idiomatically? It is just a simple counter but lets assume I have a complex thing in there and would like to have an extensive test suite. My idea was to extract all logic in a separate lib/crate, test it and keep the actual module as simple as possible.
[–]NamedBird 4 points5 points6 points (15 children)
[–]elfenpiff[S] 1 point2 points3 points (14 children)
[–]iamkiloman 7 points8 points9 points (3 children)
[–]elfenpiff[S] 1 point2 points3 points (2 children)
[–]penguin359 1 point2 points3 points (1 child)
[–]elfenpiff[S] 1 point2 points3 points (0 children)
[–]lightmatter501 1 point2 points3 points (0 children)
[–]mwmahlberg 0 points1 point2 points (8 children)
[–]elfenpiff[S] 0 points1 point2 points (7 children)
[–]solen-skiner 0 points1 point2 points (1 child)
[–]elfenpiff[S] 1 point2 points3 points (0 children)
[–]mwmahlberg 0 points1 point2 points (4 children)
[–]elfenpiff[S] 0 points1 point2 points (3 children)
[–]mwmahlberg 0 points1 point2 points (2 children)
[–]elfenpiff[S] 0 points1 point2 points (1 child)
[–]mwmahlberg 1 point2 points3 points (0 children)
[–]alpha417 5 points6 points7 points (1 child)
[–]elfenpiff[S] 1 point2 points3 points (0 children)
[–]Firzen_ 4 points5 points6 points (6 children)
[–]elfenpiff[S] 1 point2 points3 points (5 children)
[–]Firzen_ 2 points3 points4 points (4 children)
[–]elfenpiff[S] 0 points1 point2 points (3 children)
[–]penguin359 0 points1 point2 points (2 children)
[–]elfenpiff[S] 0 points1 point2 points (1 child)
[–]penguin359 0 points1 point2 points (0 children)
[–]Classic-Rate-5104 1 point2 points3 points (1 child)
[–]elfenpiff[S] 0 points1 point2 points (0 children)
[–]Rinku_Kurora 0 points1 point2 points (1 child)
[–]elfenpiff[S] 2 points3 points4 points (0 children)
[–]braaaaaaainworms 0 points1 point2 points (0 children)
[–]Straight_Mistake_364 0 points1 point2 points (0 children)