kern/53025: [PATCH] ugen does not allow O_NONBLOCK for interrupt endpts.

Yeasah Pell yeasah at apocalypse.org
Sat Jun 7 17:10:16 PDT 2003


>Number:         53025
>Category:       kern
>Synopsis:       [PATCH] ugen does not allow O_NONBLOCK for interrupt endpts.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jun 07 17:10:14 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Yeasah Pell
>Release:        FreeBSD 5.1-RELEASE i386
>Organization:
Venture Technologies, Inc.
>Environment:
System: FreeBSD turing.schwide.net 5.1-RELEASE FreeBSD 5.1-RELEASE #27: Sat Jun\
 7 14:08:43 EDT 2003 root at turing.schwide.net:/usr/obj/usr/src/sys/SCHWIDE i386

>Description:

        The ugen driver currently does not allow the user to set an
        interrupt endpoint into nonblocking I/O mode. Although it does
        handle the FIONBIO command, it returns EINVAL for the FIOASYNC
        command even if it requested to be turned off. Unfortunately,
        fcntl and open set FIONBIO and FIOASYNC together, so any attempt
        to set nonblocking mode through the usual mechanisms will fail.

        The included patch simply accepts the FIOASYNC command when it
        is not enabling async.

        This patch was made against 4.8-RELEASE, but it seems to be
        pretty general (there's not much to it) -- it also applies cleanly
        to this 5.1 box.

>How-To-Repeat:

        Open an interrupt endpoint ugen device with the O_NONBLOCK flag,
        attempt to read when no data is available. Watch the fd block.

>Fix:

--- ugen.c.orig	Tue May 13 20:07:04 2003
+++ ugen.c	Tue May 13 20:18:56 2003
@@ -1100,6 +1100,14 @@
 	case FIONBIO:
 		/* All handled in the upper FS layer. */
 		return (0);
+        case FIOASYNC:
+                /* YGP: fcntl(F_SETFL) will set both FIONBIO and FIOASYNC
+                   together, even if O_ASYNC is not set. This will allow
+                   non-blocking I/O to work (for interrupt endpoints.) */
+               if (*(int *)addr)
+                   return (0);
+               else
+                   return (EINVAL);
 	case USB_SET_SHORT_XFER:
 		/* This flag only affects read */
 		if (endpt == USB_CONTROL_ENDPOINT)
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list