summaryrefslogtreecommitdiffstats
path: root/usr.bin/find
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2011-09-28 18:53:36 +0000
committered <ed@FreeBSD.org>2011-09-28 18:53:36 +0000
commit2a84e78d2ee67e2efdc4107a8a067cca7f435e1c (patch)
treeefc748c3ad32a5751cb0627cfa2b151f69147a78 /usr.bin/find
parentce36da245f8d051544101d1b63405860d1e57c4b (diff)
downloadFreeBSD-src-2a84e78d2ee67e2efdc4107a8a067cca7f435e1c.zip
FreeBSD-src-2a84e78d2ee67e2efdc4107a8a067cca7f435e1c.tar.gz
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).
Diffstat (limited to 'usr.bin/find')
-rw-r--r--usr.bin/find/find.14
-rw-r--r--usr.bin/find/ls.c3
2 files changed, 3 insertions, 4 deletions
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);
OpenPOWER on IntegriCloud