Re: Re[2]: cdrom ioctls
"Peter T. Breuer" <[email protected]>
| Newsgroups | gmane.linux.enbd.general |
|---|---|
| Message-ID | <[email protected]> |
"Also sprach Esmont Alexander:"
PTB> You need to read the enbd_ioctl_table.h file (2.6 kernel).
PTB> { CDROM_DRIVE_STATUS, _NEW_IOW(CDROM_DRIVE_STATUS, int), },
PTB> { CDROM_DISC_STATUS, _NEW_IO(CDROM_DISC_STATUS), },
> Change _NEW_IOW to _NEW_IOR nothing change in result.
Oh yes it does. Try again! Remember to recompile. The change makes the
ioctl an indirected ioctl which reads instead of writes. The result
will still be 0 or -ve as always, but it will, on success, return
an integer datum into an address supplied by the user.
BTW, the definition in cdrom.c is
case CDROM_DRIVE_STATUS: {
cdinfo(CD_DO_IOCTL, "entering CDROM_DRIVE_STATUS\n");
if (!(cdo->capability & CDC_DRIVE_STATUS))
return -ENOSYS;
if (!CDROM_CAN(CDC_SELECT_DISC))
return cdo->drive_status(cdi, CDSL_CURRENT);
if ((arg == CDSL_CURRENT) || (arg == CDSL_NONE))
return cdo->drive_status(cdi, CDSL_CURRENT);
if (((int)arg >= cdi->capacity))
return -EINVAL;
return cdrom_slot_status(cdi, arg);
}
which makes it a "cdrom_slot_status" call. The latter takes an integer
as second argument, NOT the address of an integer:
static int cdrom_slot_status(struct cdrom_device_info *cdi, int slot) {
...
if (info->slots[slot].disc_present)
...
So if anything is going to be returned, it is in the "cdi" item. That is a
"cd INFO" struct. I would bet that the correct definition is
...IOR(...,struct cdrom_device_info)
but you will know how cdrom ioctls are called, not I! How is the status
ioctl used in practice?
Peter