difference between user space and kernel space dev_t structs?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  over the next little while, i'm going to ask some fairly trivial
questions that i really should know the answer to but i just don't,
just because i want to fill in those little gaps.

  for instance, consider the kernel header file
include/linux/kdev_t.h, which defines a kernel space device file
major/minor combination thusly:

#define MINORBITS       20
#define MINORMASK       ((1U << MINORBITS) - 1)

#define MAJOR(dev)      ((unsigned int) ((dev) >> MINORBITS))
#define MINOR(dev)      ((unsigned int) ((dev) & MINORMASK))
#define MKDEV(ma,mi)    (((ma) << MINORBITS) | (mi))
... etc etc ...

  so it's clear that, these days, a device file is identified by a
32-bit value, (major,minor) = (12 bits, 20 bits).

  in addition, later definitions in that file define *old* device
files as 16-bit, (8,8).

  but at the bottom of that file, you read:

#else /* __KERNEL__ */

/*
Some programs want their definitions of MAJOR and MINOR and MKDEV
from the kernel sources. These must be the externally visible ones.
*/
#define MAJOR(dev)      ((dev)>>8)
#define MINOR(dev)      ((dev) & 0xff)
#define MKDEV(ma,mi)    ((ma)<<8 | (mi))
#endif /* __KERNEL__ */


  that means that's what exported to user space in the file
/usr/include/linux/kdev_t.h is the *old* format.  so what's the value
of that?  what's the point of having macros in user space that don't
match the actual structure of a kernel space device file identifier?

rday

-- 

========================================================================
Robert P. J. Day                               Waterloo, Ontario, CANADA

        Top-notch, inexpensive online Linux/OSS/kernel courses
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux