Re: Re[8]: cdrom ioctls

"Peter T. Breuer" <[email protected]>
Newsgroups gmane.linux.enbd.general
Message-ID <[email protected]>
"Also sprach Esmont Alexander:"
> I'm sorry. My mistake. My standart template at work contains text in
> russian.

It's the "charset=Windows-XXXX" that causes the problem for me, no
matter what the XXXX is!  (1251, I think I recall).

> >> Äīįšūé äåķü Peter,

> 1) I change "enbd_ioctl_table.h" for read/write option

Well, OK - I wouldn't have done that ...  I'd have added another ioctl,
but you can go about it that way as a temporary hack.

> #ifdef CDROM_DRIVE_STATUS
>    { CDROM_DRIVE_STATUS, _NEW_IOWR(CDROM_DRIVE_STATUS, int), },
> #endif /* CDROM_DRIVE_STATUS */

You want IOR, don't you?  You are not writing, I think? Or is the
argument of the ioctl call used for something?  Anyway ...

> 2) I change in user code for getting data in the variable with
> parammeter for write (code in python)
> 
>             st = CDSL_CURRENT
>             s = ioctl(fd, CDROM_DRIVE_STATUS, st)

It should be:
                st = CDSL_CURRENT;
                errval = ioctl(fd, CDROM_DRIVE_STATUS, &st);
                s = st;

And you may wish to shorten to

                s = CDSL_CURRENT;
                errval = ioctl(fd, CDROM_DRIVE_STATUS, &s);

(and you need to check the return errval code).

But that isn't enough. YES, you need to do that, but you also need to
modify the enbd-server to send the _original_ ioctl to disk instead!


>             # s = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT)
>             _debug_('from cdrom %s ' % media.devicename)
>             _debug_('return %s' % st)
> 
> but I still not getting the right result. Value of st variable not

You wouldn't expect to!

In the nbd/fileserver.c code, in ioctlfile(), you will want to intercept
your hacked ioctl call and suobstitute the real/right/corrected call:

      # warning Will Robinson! Gag me with a tablespoon. CDROM ioctl hack.
      case CDROM_DRIVE_STATUS:
          intval = *(unsigned long*)arg;
          err = file->ioctl(file, CDROM_DRIVE_STATUS, intval);
          *(unsigned long*)arg = err;
          return (err < 0) ? err : 0;
              
There is a built in generic interface for ioctls that need ultraspecial
treatment, but I've never used it after "designing" it, so I don't
recall how to do it! It looks as though this case of IOW ioctls which
also return a meaningful value is rare, but sufficient to require
looking at and thinking about ... I notice that there is a call to

 ioctl = enbd_ioctl_revert(ioctl);


at the start of the ioctlfile() routine, so presumably that is where
prior transformations should really take place before executing the
ioctl, and I see that there is a space after the ioctl has been called
to allow changes there too ...

       // PTB in certain cases fixup answer too
       switch(ioctl) {
       ...

You might want to decompose my suggested stanza into two parts,
"before" and "after" to better fit in with the existing code.

Peter
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.