makedev(3)
โจ makedev(3) โจ
okay bestie, welcome to makedev(3), straight outta the Library Functions Manual ๐
and the Standard C library (libc, -lc) ๐ธ
This one's about device numbers. Three lil functions, one big vibe. Let's go ๐ซถ
๐ NAME ๐
makedev, major, minor โ manage a device number ๐
๐ LIBRARY ๐
Standard C library (libc, -lc) โญ
๐ SYNOPSIS ๐
#include <sys/sysmacros.h>
dev_t makedev(unsigned int maj, unsigned int min);
unsigned int major(dev_t dev);
unsigned int minor(dev_t dev);
๐ง DESCRIPTION ๐ง
So. A device ID is literally two parts glued together, no cap:
- a major ID โ this is the class of the device, like which family it belongs to ๐
- a minor ID โ this is the specific instance of a device inside that class, the individual lil guy ๐
And a device ID as a whole? That's represented using the type dev_t. Periodt.
Give makedev() a major and a minor device ID and it combines them into one device ID, which it hands back to you as the function result. Then you can pass that device ID to mknod(2), for example. Iconic behavior, honestly โจ
Then major() and minor() do the exact opposite task: hand them a device ID and they give you back the major and minor components respectively. These macros are lowkey useful for stuff like decomposing the device IDs in that structure you got back from stat(2) ๐ฅ
๐ ATTRIBUTES ๐
Need the tea on these terms? Go look at attributes(7), bestie.
makedev(),major(),minor()โ Thread safety: MT-Safe ๐
so like... all three of them are MT-Safe. we love a thread-safe moment fr fr ๐
๐ฆ VERSIONS ๐ฆ
The BSDs expose the definitions for these macros via <sys/types.h>. noted! ๐
โญ STANDARDS โญ
None. ๐ญ yeah. none. it is what it is.
๐ HISTORY ๐
BSD, HP-UX, Solaris, AIX, Irix. an absolute legend lineup, we have to stan ๐ซถ
These interfaces are defined as macros. And since glibc 2.3.3, they've been aliases for three GNU-specific functions:
gnu_dev_makedev()gnu_dev_major()gnu_dev_minor()
Those latter names are exported and everything, but the traditional names are more portable โ so use those, bestie, trust ๐ง
Depending on the version, glibc also exposes definitions for these macros from <sys/types.h> if suitable feature test macros are defined. BUT โ and this is the important part โ
โ ๏ธ that behavior was deprecated in glibc 2.25, and since glibc 2.28, <sys/types.h> no longer provides these definitions. so don't count on it, fr ๐
๐ SEE ALSO ๐
and that's the whole page, babes ๐ this came straight from Linux man-pages 6.20, dated 2025-05-17 โ that's the source and the date, and now you know it, so go forth and make some devices ๐โจ๐
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms