From 7ca5dc4232b9ac5ee5cd25c8b5b33a58904cd251 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 2 Mar 2016 11:52:38 -0600 Subject: For years the man pages have said to #include to get major/minor/makedev, but glibc has vowed to break existing programs (https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html) and replace it with _another_ non-standard header (not in posix or lsb), so let's just add functions to lib/ that do the transform ourselves. --- toys/posix/ls.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'toys/posix/ls.c') diff --git a/toys/posix/ls.c b/toys/posix/ls.c index 08ae695d..4dcbe888 100644 --- a/toys/posix/ls.c +++ b/toys/posix/ls.c @@ -144,7 +144,7 @@ static void entrylen(struct dirtree *dt, unsigned *len) if (S_ISBLK(st->st_mode) || S_ISCHR(st->st_mode)) { // cheating slightly here: assuming minor is always 3 digits to avoid // tracking another column - len[5] = numlen(major(st->st_rdev))+5; + len[5] = numlen(dev_major(st->st_rdev))+5; } else if (flags & FLAG_h) { human_readable(tmp, st->st_size, 0); len[5] = strwidth(tmp); @@ -453,7 +453,8 @@ static void listfiles(int dirfd, struct dirtree *indir) // print major/minor, or size if (S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode)) - printf("% *d,% 4d", totals[5]-4, major(st->st_rdev),minor(st->st_rdev)); + printf("% *d,% 4d", totals[5]-4, dev_major(st->st_rdev), + dev_minor(st->st_rdev)); else if (flags&FLAG_h) { human_readable(tmp, st->st_size, 0); xprintf("%*s", totals[5]+1, tmp); -- cgit v1.2.3