From 2a84e78d2ee67e2efdc4107a8a067cca7f435e1c Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 28 Sep 2011 18:53:36 +0000 Subject: Get rid of major/minor number distinction. As of FreeBSD 6, devices can only be opened through devfs. These device nodes don't have major and minor numbers anymore. The st_rdev field in struct stat is simply based a copy of st_ino. Simply display device numbers as hexadecimal, using "%#jx". This is allowed by POSIX, since it explicitly states things like the following (example taken from ls(1)): "If the file is a character special or block special file, the size of the file may be replaced with implementation-defined information associated with the device in question." This makes the output of these commands more compact. For example, ls(1) now uses approximately four columns less. While there, simplify the column length calculation from ls(1) by calling snprintf() with a NULL buffer. Don't be afraid; if needed one can still obtain individual major/minor numbers using stat(1). --- usr.bin/find/find.1 | 4 ++-- usr.bin/find/ls.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'usr.bin/find') diff --git a/usr.bin/find/find.1 b/usr.bin/find/find.1 index 04fe50c..10479f6 100644 --- a/usr.bin/find/find.1 +++ b/usr.bin/find/find.1 @@ -31,7 +31,7 @@ .\" @(#)find.1 8.7 (Berkeley) 5/9/95 .\" $FreeBSD$ .\" -.Dd March 17, 2010 +.Dd September 28, 2011 .Dt FIND 1 .Os .Sh NAME @@ -507,7 +507,7 @@ This primary always evaluates to true. The following information for the current file is written to standard output: its inode number, size in 512-byte blocks, file permissions, number of hard links, owner, group, size in bytes, last modification time, and pathname. -If the file is a block or character special file, the major and minor numbers +If the file is a block or character special file, the device number will be displayed instead of the size in bytes. If the file is a symbolic link, the pathname of the linked-to file will be displayed preceded by diff --git a/usr.bin/find/ls.c b/usr.bin/find/ls.c index 8e1b8d3..44d1852 100644 --- a/usr.bin/find/ls.c +++ b/usr.bin/find/ls.c @@ -70,8 +70,7 @@ printlong(char *name, char *accpath, struct stat *sb) group_from_gid(sb->st_gid, 0)); if (S_ISCHR(sb->st_mode) || S_ISBLK(sb->st_mode)) - (void)printf("%3d, %3d ", major(sb->st_rdev), - minor(sb->st_rdev)); + (void)printf("%#8jx ", (uintmax_t)sb->st_rdev); else (void)printf("%8"PRId64" ", sb->st_size); printtime(sb->st_mtime); -- cgit v1.1