I am not subscribed to this list so I would appreciate it if you could CC me
in your responses.
I am trying to write some user code that will enable me to select one of the
four slots on my ATAPI cd changer.
I have noticed there is no explicit IOCTL for this function but that the the
acd_softc struct does indeed have both a slot entry and a struct acd_softc **
which points to the softc's of changer slots.
Also in the acdioctl function which appears to be called when the appropriate
fd is passed to ioctl [since my eject program works I assume this is the
correct behavior I am witnessing] has a section:
if (cdp->changer_info && cdp->slot != cdp->changer_info->current_slot) {
acd_select_slot(cdp);
tsleep(&cdp->changer_info, PRIBIO, "acdctl", 0);
acd_select_slot is the very function I would like to have eventually called
from userland. Since its static in atapi_cd.c it is clear that only an ioctl
can cause this to occur as that is the only user interface to this code.
[rightly so]
Anyway the parameters to acdioctl are :
dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p
The first three arguments of a generic ioctl seem to correspond with the
first three of acdioctl somewhat with the exception maybe of the first one...
My problem is that the return value of an open statement :
int fd = open ("/dev/acd0c", O_RDONLY);
is an integer which is the first argument of an ioctl.
However acdioctl takes a dev_t which I assume is some kind of pointer due to
the following code in atapi_cd.c:
static int
acdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
{
struct acd_softc *cdp = dev->si_drv1;
int error = 0;
So somewhere between the ioctl call and the acdioctl call my fd which was an
int became a pointer to a structure somewhere. This seems ok since on most 32
bit platforms the storage size of an int and a pointer are both 32 bits. It
seems like a bit of a hack though. Also I am not sure what struct I can cast
my fd from my code to in order to change the current slot of the operation I
want to perform. As a user I do not have access to the acd_softc structure
and thusly cannot cast my fd from the open statement to such a pointer.
I hope I didn't confuse you too much...
Anyway I thought it might be useful to code such an IOCTL for selecting a
disc in a changer and if I learn enough about how this system all works to do
a clean job I will submit a patch... [unless of course its all being worked
on already]. Linux had decent support for this functionality up to and
including the 2.2.14 kernel but its been somewhat broken ever since.
Any advice or help would be greatly appreciated.
Thanks and again I am not on this list so CC me if you have a reply... I
would really appreciate it!
Dave Leimbach
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message