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

A single value copy

When it comes to copying single and simple variables, such as char and int, but not larger data types, such as structures or arrays, the kernel offers dedicated macros in order to quickly perform the desired operation. These macros are put_user(x, ptr) and get_user(x, ptr), which are explained as follows:

  • put_user(x, ptr);: This macro copies a variable from kernel space to user space. x represents the value to copy to user space, and ptr is the destination address in user space. The macro returns 0 on success, or -EFAULT on error. x must be assignable to the result of dereferencing ptr. In other words, they must have (or point to) the same type.
  • get_user(x, ptr);: This macro copies a variable from user space to kernel ...
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