-.\" $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>
.\" 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
.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.
-/* $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>
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) {
switch (inf->sb.st_mode & S_IFMT) {
case S_IFBLK:
case S_IFCHR:
- case S_IFIFO:
case S_IFREG:
return (0);
}