summaryrefslogtreecommitdiffstats
path: root/usr.bin/file/file.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2015-04-26 22:51:32 +0000
committernicm <nicm@openbsd.org>2015-04-26 22:51:32 +0000
commite24c7d59f239edb304a2e602f9e003f07f08289c (patch)
tree5e24d3a777c767fdf34c48f5a42a84ce33dd3ee3 /usr.bin/file/file.c
parentRemove panes from layout if spawning them fails, reported by Anthony J (diff)
downloadwireguard-openbsd-e24c7d59f239edb304a2e602f9e003f07f08289c.tar.xz
wireguard-openbsd-e24c7d59f239edb304a2e602f9e003f07f08289c.zip
Don't support -s on FIFOs, it doesn't work well and the workarounds are
a bit horrible.
Diffstat (limited to 'usr.bin/file/file.c')
-rw-r--r--usr.bin/file/file.c22
1 files changed, 7 insertions, 15 deletions
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);
}