From e028208e53fb94c7c6c2873a116f680e234784ec Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 22 Nov 2019 12:48:35 -0800 Subject: Fix dev_minor()/dev_major()/dev_makedev() for Mac. Major/minor device encoding is not portable. No two BSDs agree with each other, and Darwin is different again. Everyone does agree on having major()/minor()/makedev() macros, but they disagree whether they should be in (the BSDs including Darwin, and old versions of glibc) or (glibc >= 2.26 and bionic). This fixes `ls -l /dev/zero` and `stat /dev/zero` on Mac. --- lib/portability.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/portability.h') diff --git a/lib/portability.h b/lib/portability.h index 481e3f04..24cd1297 100644 --- a/lib/portability.h +++ b/lib/portability.h @@ -350,3 +350,8 @@ struct signame { char *name; }; void xsignal_all_killers(void *handler); + +// Different OSes encode major/minor device numbers differently. +int dev_minor(int dev); +int dev_major(int dev); +int dev_makedev(int major, int minor); -- cgit v1.2.3