summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-04-26 22:51:33 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-04-26 22:51:33 +0000
commit81f0ffcd28745bddb44fefa3672a6f0b5472f0cf (patch)
tree66626f0eb7e22f6413323835aaba9ac0224e0ed6
parent7a9bdc8defd5ece6a60f2ef6d6cc26ee8a2df28c (diff)
Don't support -s on FIFOs, it doesn't work well and the workarounds are
a bit horrible.
-rw-r--r--usr.bin/file/file.18
-rw-r--r--usr.bin/file/file.c22
2 files changed, 10 insertions, 20 deletions
diff --git a/usr.bin/file/file.1 b/usr.bin/file/file.1
index e25945a1d7a..b35eaa2118d 100644
--- a/usr.bin/file/file.1
+++ b/usr.bin/file/file.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: file.1,v 1.39 2015/04/24 20:57:51 nicm Exp $
+.\" $OpenBSD: file.1,v 1.40 2015/04/26 22:51:32 nicm Exp $
.\" $FreeBSD: src/usr.bin/file/file.1,v 1.16 2000/03/01 12:19:39 sheldonh Exp $
.\"
.\" Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: April 24 2015 $
+.Dd $Mdocdate: April 26 2015 $
.Dt FILE 1
.Os
.Sh NAME
@@ -94,9 +94,7 @@ Causes symlinks to be followed.
.It Fl s
Instructs
.Nm
-to attempt to read all files, not only those which
-.Xr stat 2
-reports are ordinary files.
+to attempt to read block and character device files, not only regular files.
.It Fl W
Displays warnings when parsing the magic file or applying its tests.
Usually used for debugging.
diff --git a/usr.bin/file/file.c b/usr.bin/file/file.c
index 84bedfff150..f271869e876 100644
--- a/usr.bin/file/file.c
+++ b/usr.bin/file/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.33 2015/04/26 19:53:50 nicm Exp $ */
+/* $OpenBSD: file.c,v 1.34 2015/04/26 22:51:32 nicm Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@@ -287,22 +287,15 @@ fill_buffer(struct input_file *inf)
static int
load_file(struct input_file *inf)
{
- int available;
-
inf->size = inf->sb.st_size;
if (inf->size > FILE_READ_SIZE)
inf->size = FILE_READ_SIZE;
- if (S_ISFIFO(inf->sb.st_mode)) {
- if (ioctl(inf->fd, FIONREAD, &available) == -1) {
- xasprintf(&inf->result, "cannot read '%s' (%s)",
- inf->path, strerror(errno));
- return (1);
- }
- inf->size = available;
- } else if (!S_ISREG(inf->sb.st_mode) && inf->size == 0)
- inf->size = FILE_READ_SIZE;
- if (inf->size == 0)
- return (0);
+ if (inf->size == 0) {
+ if (!S_ISREG(inf->sb.st_mode))
+ inf->size = FILE_READ_SIZE;
+ else
+ return (0);
+ }
inf->base = mmap(NULL, inf->size, PROT_READ, MAP_PRIVATE, inf->fd, 0);
if (inf->base == MAP_FAILED) {
@@ -329,7 +322,6 @@ try_stat(struct input_file *inf)
switch (inf->sb.st_mode & S_IFMT) {
case S_IFBLK:
case S_IFCHR:
- case S_IFIFO:
case S_IFREG:
return (0);
}