Subject: bin/18909: audioplay plays only regular files
To: None <>
From: Christian Biere <>
List: netbsd-bugs
Date: 11/04/2002 01:20:59
>Number:         18909
>Category:       bin
>Synopsis:       audioplay plays only regular files
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 03 16:22:01 PST 2002
>Originator:     Christian Biere
>Release:        NetBSD 1.6J
NetBSD localhost 1.6J NetBSD 1.6J (UNICRON) #5: Mon Oct 28 17:05:26 CET
2002     root@localhost:/usr/src/sys/arch/i386/compile/UNICRON i386

audioplay refuses to play files like /dev/stdin, /dev/urandom etc. because
fstat() sets sb.st_size to zero in such cases.  I've fixed this by falling
back to play_fd() for non-regular files.

ktruss audioplay -f /dev/urandom


Content-Type: text/plain;
Content-Disposition: attachment;
Content-Transfer-Encoding: 7bit

Index: play.c
RCS file: /cvsroot/basesrc/usr.bin/audio/play/play.c,v
retrieving revision 1.39
diff -u -r1.39 play.c
--- play.c	2002/11/03 19:35:00	1.39
+++ play.c	2002/11/03 23:00:48
@@ -230,6 +230,11 @@
 	if (fstat(fd, &sb) < 0)
 		err(1, "could not fstat %s", file);
+	if ((sb.st_rdev & S_IFMT) != S_IFREG) {
+		play_fd(file, fd);
+		close(fd);
+		return;
+	}
 	filesize = sb.st_size;
 	oaddr = addr = mmap(0, (size_t)filesize, PROT_READ,

 This is a multi-part message in MIME format.
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: 7bit