I have a minor and major numbers of a char device, and I want to turn them into dev_t
(which used to hold device numbers), but I don't want to do all the process of building and writing a module, insmod
it into the kernel and etc.
What's an easy way and fast to use the MKDEV
macro?
#include <linux/kdev_t.h>#include <linux/types.h>dev_t device_num = MKDEV(int major, int minor);
Using a standard C program will not work, obviously, because it's kernel-code/kernel-space.
Update: Writing a User-Space program does work but I can't use the dev_t
datatype, maybe because it can be used only by the kernel?
#include <linux/kdev_t.h> // MKDEV#include <linux/types.h> // dev_t#include <stdio.h> // I/Oint main(void){ int device_id = MKDEV(10, 249); printf("%d\n", device_id); // 2809 return 0;}