From nobody  Sat May 30 15:00:56 1998
Received: (from nobody@localhost)
          by hub.freebsd.org (8.8.8/8.8.8) id PAA11636;
          Sat, 30 May 1998 15:00:56 -0700 (PDT)
          (envelope-from nobody)
Message-Id: <199805302200.PAA11636@hub.freebsd.org>
Date: Sat, 30 May 1998 15:00:56 -0700 (PDT)
From: ian@nmsu.edu
To: freebsd-gnats-submit@freebsd.org
Subject: problem with open(2) in libc_r and opening tape device
X-Send-Pr-Version: www-1.0

>Number:         6799
>Category:       bin
>Synopsis:       [THREAD,SCSI] problem with open(2) in libc_r and opening tape device
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat May 30 15:10:00 PDT 1998
>Closed-Date:    Tue Jan 5 12:16:00 PST 1999
>Last-Modified:  Tue Jan  5 12:20:43 PST 1999
>Originator:     Ian Logan
>Release:        2.2.6 from the April-98 CDset
>Organization:
New Mexico State University
>Environment:
FreeBSD kona 2.2.6-RELEASE FreeBSD 2.2.6-RELEASE #0: Wed Mar 25 02:28:49 GMT 1998
     jkh@time.cdrom.com:/usr/src/sys/compile/GENERIC  i386

>Description:
I am trying to open a tape device for reading(or writting doesn't seem
to matter), if I link with the normal C library everything works great.  
If I link with libc_r I get a "inappropriate ioctl for device mesage".
I am using a K6, with 64MB of memory, a Buslogic BT948 SCSI card, and
a Seagate STT8000N tape drive.  Everything on the machine is straight off 
the CD.
>How-To-Repeat:
The following program demonstrates the bug everytime, here is how I'm 
compiling and running it.

% cc -DREENTRANT bug.c
% ./a.out
% cc -DREENTRANT bug.c -lc_r
% ./a.out
Open:: Inappropriate ioctl for device

And here is the source:

#include <stdio.h>
#include <errno.h>
#include <fcntl.h>

int main (void){
int handle;
handle=open("/dev/nrst0",O_RDWR);
 if(handle == -1){
   perror("Open:");
   return(1);
 }else{
   close(handle);
 }
 
}
>Fix:
I don't have a fix for it at this time.
>Release-Note:
>Audit-Trail:

From: Hans Huebner <hans@huebner.org>
To: freebsd-gnats-submit@freebsd.org, ian@nmsu.edu
Cc:  Subject: Re: bin/6799: problem with open(2) in libc_r and opening tape device
Date: Sun, 31 May 1998 13:47:20 +0200

 Apparently, the observed behaviour is a result of libc_r's attempt to
 switch the file descriptor to the tape device into asynchronous mode.
  As of now, neither the old nor the CAM SCSI subsystem support that.
 This holds true for any SCSI device, not only tapes, which renders
 FreeBSD's SCSI subsystem inaccessible to multithreaded applications.
 
 This requires substantial work to make it properly work, and it is
 unclear whether this would be warranted for the old SCSI subsystem (iff
 CAM makes it into 3.0).
 
 -Hans
 
 --
 Hans@Huebner.ORG
 
 +49-177-512 1024
 
 
 
State-Changed-From-To: open->analyzed 
State-Changed-By: jkh 
State-Changed-When: Sun May 31 09:08:29 PDT 1998 
State-Changed-Why:  
Author requested it be changed. 
State-Changed-From-To: analyzed->suspended 
State-Changed-By: phk 
State-Changed-When: Tue Jun 2 04:12:53 PDT 1998 
State-Changed-Why:  
Can be fixed in either of scsi or libc_r, I leave it to the committers to 
decide which. 
State-Changed-From-To: suspended->closed 
State-Changed-By: dt 
State-Changed-When: Tue Jan 5 12:16:00 PST 1999 
State-Changed-Why:  
Fixed in rev. 1.7 of src/lib/libc_r/uthread_fd.c by jb. 
>Unformatted:
