$NetBSD: patch-aa,v 1.3 2001/06/13 12:41:09 bouyer Exp $ --- koncd/cddata.cpp.orig Wed Jun 13 12:04:10 2001 +++ koncd/cddata.cpp Wed Jun 13 13:32:12 2001 @@ -13,10 +13,39 @@ #include #include "cddata.h" +#include "config.h" + +#ifdef HAVE_GETRAWPARTITION +# include +#endif + static int CurBus; struct DEVICES *CurDev; CDdata::CDdata( QObject * , const char * ) { +#ifdef __NetBSD__ + int i; + char prog2[128]; + int raw; + + Devices = NULL; + strncpy( prog, "scsictl", sizeof( prog ) - 1); + connect( &proc, SIGNAL(receivedStdout (KProcess *, char *, int) ), + this, SLOT(slotOutput (KProcess *, char *, int) )); +#ifdef HAVE_GETRAWPARTITION + raw = getrawpartition(); +#else + raw = 'c' - 'a'; +#endif + for (i = 0; i < 8; i++) { + proc.clearArguments(); + snprintf(prog2, sizeof( prog2 ) - 1, "/dev/rcd%d%c",i, + 'a' + raw); + proc << prog << prog2 << "identify"; + proc.start( KProcess::Block, KProcess::AllOutput ); + } +#else + Devices = NULL; strncpy( prog, "cdrecord", sizeof( prog ) - 1); proc << prog << "-scanbus"; @@ -25,6 +54,7 @@ connect( &proc, SIGNAL(receivedStdout (KProcess *, char *, int) ), this, SLOT(slotOutput (KProcess *, char *, int) )); proc.start( KProcess::Block, KProcess::AllOutput ); +#endif /* __NetBSD__ */ sprintf( dummystr,"dev=unknown" ); struct DEVICES *d; @@ -100,14 +130,53 @@ char *c, *b, buf[1024]; struct DEVICES *dev; unsigned i; +#ifdef __NetBSD__ + int raw; + +#ifdef HAVE_GETRAWPARTITION + raw = getrawpartition(); +#else + raw = 'c' - 'a'; +#endif +#endif /* __NetBSD__ */ if( !n ) { return; } bzero( buf, sizeof( buf ) ); - strncpy( buf, s, n > (int) sizeof( buf ) ? sizeof(buf) - 1 : n ); + strncpy( buf, s, n >= (int) sizeof( buf ) ? sizeof(buf) - 1 : n ); output += buf; +#ifdef __NetBSD__ + if (strncmp(buf, "/dev/rcd", 8) != 0) + return; + if( (b = strstr( buf, "<" )) && (c = strstr( buf, ">" ))) { + dev = (struct DEVICES *) calloc( sizeof( struct DEVICES ), 1 ); + dev -> next = Devices; + Devices = dev; + dev -> bus = 0; + dev -> dev = buf[8] - 0x30; + sprintf( dev -> devstr, "dev=/dev/rcd%d%c", + (dev -> dev < 32) ? dev -> dev:0, 'a' + raw); + if( *b ) b++; // point to next character + for( i = 0; *b && *b != ',' && i < sizeof(dev->vendor)-1; + b++, i++ ) + dev -> vendor[i] = *b; + while(*b != ',' && *b != 0) // points to next "," + b++; + if (*b == ',') b++; // next char + for( i = 0; *b && *b != ',' && i < sizeof(dev->name)-1; + b++, i++ ) + dev -> name[i] = *b; + while(*b != ',' && *b != 0) // points to next "," + b++; + if (*b == ',') b++; // next char + for( i = 0; *b && *b != '>' && i < sizeof(dev->version)-1; + b++, i++ ) + dev -> version[i] = *b; + dev -> desc[0] = 0; + } +#else c = strtok( buf, "\n" ); while( c ) { if( (b = strstr( c, "scsibus" )) ) { @@ -139,6 +208,7 @@ } c = strtok( NULL, "\n" ); } +#endif /* __NetBSD__ */ } void CDdata::slotOutput1(KProcess *, char *s, int n) {