Subject: bin/18909: audioplay plays only regular files
To: None <gnats-bugs@gnats.netbsd.org>
From: Christian Biere <christianbiere@gmx.de>
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
>Closed-Date:
>Last-Modified:
>Originator:     Christian Biere
>Release:        NetBSD 1.6J
>Organization:
       
>Environment:
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

>Description:
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.

>How-To-Repeat:
ktruss audioplay -f /dev/urandom

>Fix:


--Multipart_Mon__4_Nov_2002_01:20:59_+0100_08170c00
Content-Type: text/plain;
 name="play.c.udif"
Content-Disposition: attachment;
 filename="play.c.udif"
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,

--Multipart_Mon__4_Nov_2002_01:20:59_+0100_08170c00--
>Release-Note:
>Audit-Trail:
>Unformatted:
 This is a multi-part message in MIME format.
 
 --Multipart_Mon__4_Nov_2002_01:20:59_+0100_08170c00
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: 7bit