[openbeos] Re: parallel driver

Ok so it's not a bug, it's a feature.
What is wrong with this anyway ?
just use (ret<0)?(errno):(ret)
or isn't errno virtualised in respect to multithreading ?

Btw there seems to be something else about the parallel driver...
in file:///boot/develop/headers/be/drivers/Drivers.h 

/* ---
        Be-defined device types returned by B_GET_GEOMETRY.  Use these if it 
makes
        sense for your device.
--- */

enum {
        B_DISK = 0,                                             /* Hard disks, 
floppy disks, etc. */
        B_TAPE,                                                 /* Tape drives 
*/
        B_PRINTER,                                              /* Printers */
        B_CPU,                                                  /* CPU devices 
*/
        B_WORM,                                                 /* Write-once, 
read-many devives */
        B_CD,                                                   /* CD ROMS */
        B_SCANNER,                                              /* Scanners */
        B_OPTICAL,                                              /* Optical 
devices */
        B_JUKEBOX,                                              /* Jukeboxes */
        B_NETWORK                                               /* Network 
devices */
};

Is it intended to be implemented by the parallel driver or it's just for things 
like USB ?

En réponse à philippe.houdoin@xxxxxxx:

> From experience.
> In a /dev/misc/test R5 driver control hook code:
> 
> swith(op) {
> case MY_DRIVER_OP:
>   return B_BAD_VALUE;
> ...
> };
> 
> In a userland app:
> 
> int fd, rc;
> fd = open("/dev/misc/test", O_RDWR);
> if (fd < 0)
>   return;
> rc = ioctl(fd, MY_DRIVER_OP, NULL, 0);
> printf("ioctl() returns %d\n", rc);
> close(fd);
> 
> Under both vanilla and BONE R5 BeOS kernels, you will get:
> "ioctl() returns -1".
> 
> But... B_BAD_VALUE != B_ERROR ;-)
> 
> In fact, it's not a BUG at all. 
> From ioctl() man page:
> [...]
> RETURN VALUE
>   Usually, on success zero is returned. 
>   A few ioctls use the return value as an output parameter and return a
> 
>   nonnegative value on success. On error, -1 is returned, and errno is
> 
>   set appropriately. 
> 
> It's just something to remember when you plan to use heavily ioctl() 
> to communicate with a driver code: you can't use the ioctl() returns
> value 
> to sent back a meaningfull result code.
> 
> So, one more thing to NOT fix for R1. :-p
> 
> -Philippe.
> 
> 






Other related posts: