Solved ejecting a Kindle

When I plug a Kindle into a USB port, the Kindle's display tells me:
If you want to use your Kindle, please eject your Kindle from your computer.
On (blush) Linux, that's exactly what I do. When I'm done accessing the Kindle from the computer, I eject /media/kindle, and that text on the Kindle disappears, to be replaced with what I usually see when the Kindle is not connected to the computer.

But when I say eject /dev/msdosfs/Kindle on FreeBSD 10.1-RELEASE, I get "Inappropriate ioctl for device", although the eject command does succeed in unmounting the device.

So I looked into the source code for eject, and just to simplify the problem I wrote this:
Code:
#include <sys/cdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
int
main(void)
{
  int lo_fd;
  lo_fd=open("/dev/msdosfs/Kindle",O_RDONLY);
  if(lo_fd==-1)
  {
    perror("opening Kindle");
    exit(1);
  }
  if(ioctl(lo_fd,CDIOCEJECT)==-1)
  {
    perror("ejecting Kindle");
    exit(1);
  }
  printf("EOJ\n");
  return 0;
} /* main() */
And it bombs on the ioctl() with "Inappropriate ioctl for device", whether the Kindle is mounted at the time or no.

How do I go about ejecting the Kindle on FreeBSD?
 
I am not sure if one can correctly eject a non-CD object using the cdio library...

Here is what I do to 'eject' a Kindle:

1) If the Kindle is still mounted, then unmount it first;

2) Type
# usbconfig
to find out which usb device the Kindle is connected to, then use, e.g.
# usbconfig -d X.Y power_off
to eject it, where "X.Y" above is the "<unit>.<address>" of the device connected to the Kindle.

After that, one should be able to use that Kindle while keeping it charged. And if one wants to re-mount, just type
# usbconfig -d X.Y power_on
and
# mount -t msdosfs .....

But I have to admit that I don't know if that's the correct way to do it, although it certainly works as far as I can tell.
 
Back
Top