Skip to Content
Linux Device Drivers Development
book

Linux Device Drivers Development

by John Madieu
October 2017
Intermediate to advanced
586 pages
14h 8m
English
Packt Publishing
Content preview from Linux Device Drivers Development

Generating ioctl numbers (command)

You should generate their own ioctl number in a dedicated header file. It is not mandatory, but it is recommended, since this header should be available in user space too. In other words, you should duplicate the ioctl header file so that there is one in the kernel and one in the user space, which you can include in user apps. Let's now generate ioctl numbers in a real example:

The eep_ioctl.h file is as follows:

#ifndef PACKT_IOCTL_H #define PACKT_IOCTL_H /* * We need to choose a magic number for our driver, and sequential numbers * for each command: */ #define EEP_MAGIC 'E' #define ERASE_SEQ_NO 0x01 #define RENAME_SEQ_NO 0x02 #define ClEAR_BYTE_SEQ_NO 0x03 #define GET_SIZE 0x04 /* * Partition name must ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Device Drivers, Second Edition

Linux Device Drivers, Second Edition

Jonathan Corbet, Alessandro Rubini
Linux Device Drivers, 3rd Edition

Linux Device Drivers, 3rd Edition

Jonathan Corbet, Alessandro Rubini, Greg Kroah-Hartman

Publisher Resources

ISBN: 9781785280009Supplemental Content