Discussion:
IOKit callback routines, etc.
Arun Upadhyaya Kishan
2000-08-31 22:12:36 UTC
Permalink
Hello,

Related to my previous question regarding CD-ROM, I am curious as how to
receive a call back notification when a particular IOService is
terminated. I attempted to use IOServiceAddInterestNotification,
though I did not seem to receive any feedback regarding the service
termination. I believe that I armed the notification by emptying the
returned iterator; is there anything else that I must do to setup
the notification?

I would also like to be able to eject objects marked ejectable in
the IOKit registry. With CD-ROM, I can issue an ioctl command to the
/dev/disk# node to eject the disc. However, this does not unmount
the media from the desktop. Routines available under classic MacOS,
such as PBUnmountVol and PBEject either do not work or are not
supported. What is the suggested methodology for accomplishing
this, without requiring superuser access?

--
AK
Eric Peyton
2000-09-01 11:44:38 UTC
Permalink
Post by Arun Upadhyaya Kishan
Hello,
Related to my previous question regarding CD-ROM, I am curious as how to
receive a call back notification when a particular IOService is
terminated. I attempted to use IOServiceAddInterestNotification,
though I did not seem to receive any feedback regarding the service
termination. I believe that I armed the notification by emptying the
returned iterator; is there anything else that I must do to setup
the notification?
I don't believe you will get a termination notice for an add interest
call. You need to add a IOServiceAddNotification with a notification type
of kIOTerminatedNotification. Everything else sounds fine.
Post by Arun Upadhyaya Kishan
I would also like to be able to eject objects marked ejectable in
the IOKit registry. With CD-ROM, I can issue an ioctl command to the
/dev/disk# node to eject the disc. However, this does not unmount
the media from the desktop. Routines available under classic MacOS,
such as PBUnmountVol and PBEject either do not work or are not
supported. What is the suggested methodology for accomplishing
this, without requiring superuser access?
You need to inform the autodiskmounter (the tool that controls mounts and
unmounts) - the problem is the API is currently private to do this.
(However the autodiskmount is part of diskdev_cmds in Darwin - if you know
mig you can write your own autodiskmount controlling applications). As
you found, an ioctl will eject without unmount. In Beta, I am pretty sure
that you can use PBUnmount and that will unmount and eject removable
media, and just unmount non-removable media, though this should work in
DP4 too. PBEject is not supported in Carbon AFAIK, but what happens when
you PBUnmount?

Eric
Post by Arun Upadhyaya Kishan
--
AK
_______________________________________________
MacOSX-dev mailing list
http://www.omnigroup.com/mailman/listinfo/macosx-dev
Eric Peyton
***@epicware.com

Software and Source for Mac OS X
Eric Peyton
2000-09-01 11:50:48 UTC
Permalink
A couple of other things to note - if you try to circumvent the
autodiskmounter (by issuing umount calls or unmount() calls or just
ioctl's), there is no way for the desktop and Carbon stacks to knwo the
disk has gone away. I recommend either using the Carbon calls (PBUnmount)
or learning mig, checking out the latest autodiskmount code from darwin
and notifying the autodiskmounter when you want a disk to go away. The
autodiskmounter does the due diligence and checks with applications to
make sure it's "okay" for the resource to disappear.

There is some hope that post beta the entire Disk Arbitration stack will
become part of darwin, and this includes the simple framework you link in
to your app to allow your app to control the disk mounter and a sample app
that does things like command line ejection, disk renaming, etc.

Eric
Post by Eric Peyton
Post by Arun Upadhyaya Kishan
Hello,
Related to my previous question regarding CD-ROM, I am curious as how to
receive a call back notification when a particular IOService is
terminated. I attempted to use IOServiceAddInterestNotification,
though I did not seem to receive any feedback regarding the service
termination. I believe that I armed the notification by emptying the
returned iterator; is there anything else that I must do to setup
the notification?
I don't believe you will get a termination notice for an add interest
call. You need to add a IOServiceAddNotification with a notification type
of kIOTerminatedNotification. Everything else sounds fine.
Post by Arun Upadhyaya Kishan
I would also like to be able to eject objects marked ejectable in
the IOKit registry. With CD-ROM, I can issue an ioctl command to the
/dev/disk# node to eject the disc. However, this does not unmount
the media from the desktop. Routines available under classic MacOS,
such as PBUnmountVol and PBEject either do not work or are not
supported. What is the suggested methodology for accomplishing
this, without requiring superuser access?
You need to inform the autodiskmounter (the tool that controls mounts and
unmounts) - the problem is the API is currently private to do this.
(However the autodiskmount is part of diskdev_cmds in Darwin - if you know
mig you can write your own autodiskmount controlling applications). As
you found, an ioctl will eject without unmount. In Beta, I am pretty sure
that you can use PBUnmount and that will unmount and eject removable
media, and just unmount non-removable media, though this should work in
DP4 too. PBEject is not supported in Carbon AFAIK, but what happens when
you PBUnmount?
Eric
Post by Arun Upadhyaya Kishan
--
AK
_______________________________________________
MacOSX-dev mailing list
http://www.omnigroup.com/mailman/listinfo/macosx-dev
Eric Peyton
Software and Source for Mac OS X
_______________________________________________
MacOSX-dev mailing list
http://www.omnigroup.com/mailman/listinfo/macosx-dev
Eric Peyton
***@epicware.com

Software and Source for Mac OS X

Loading...