Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I get Hard Disks(ATA) and Removable media(USB) attached to my system??



Hi Darpan,

You can use I/O Kit.  Here is the equivalent in I/O Kit.

#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/storage/IOMedia.h>
#include <IOKit/storage/IOStorageProtocolCharacteristics.h>

void callback( void * context, io_iterator_t notification )
{
    io_object_t media;

    while ( ( media = IOIteratorNext( notification ) ) )
    {
        CFDictionaryRef properties;

        properties = NULL;

IORegistryEntryCreateCFProperties( media, ( CFMutableDictionaryRef * ) &properties, kCFAllocatorDefault, 0 );

        if ( properties )
        {
            CFShow( properties );

            CFRelease( properties );
        }

properties = IORegistryEntrySearchCFProperty( media, kIOServicePlane, CFSTR( kIOPropertyProtocolCharacteristicsKey ), kCFAllocatorDefault, kIORegistryIterateParents | kIORegistryIterateRecursively );

        if ( properties )
        {
            CFShow( properties );

            CFRelease( properties );
        }

        IOObjectRelease( media );
    }
}

int main( )
{
    IONotificationPortRef port;

    port = IONotificationPortCreate( kIOMasterPortDefault );

    if ( port )
    {
        CFMutableDictionaryRef properties;

        properties = IOServiceMatching( kIOMediaClass );

        if ( properties )
        {
            io_iterator_t notification;

CFDictionaryAddValue( properties, CFSTR ( kIOMediaWholeKey ), kCFBooleanTrue );

            notification = 0;

IOServiceAddMatchingNotification( port, kIOMatchedNotification, properties, callback, NULL, &notification );

            properties = 0;

            if ( notification )
            {
                callback( NULL, notification );

CFRunLoopAddSource( CFRunLoopGetCurrent( ), IONotificationPortGetRunLoopSource( port ), kCFRunLoopDefaultMode );

                CFRunLoopRun( );

CFRunLoopRemoveSource( CFRunLoopGetCurrent( ), IONotificationPortGetRunLoopSource( port ), kCFRunLoopDefaultMode );

                IOObjectRelease( notification );
            }
        }

        IONotificationPortDestroy( port );
    }

    return 0;
}

Dan

On 10 Sep 2005, at 5:23 AM, darpan kamboj wrote:

Hi

Is there any other way I want to make my application to support Mac OS X and above.

Thanks and Regards

From: Dan Markarian <email@hidden>
To: darpan kamboj <email@hidden>
CC: ata-scsi-dev <email@hidden>
Subject: Re: How can I get Hard Disks(ATA) and Removable media (USB) attached to my system??
Date: Thu, 8 Sep 2005 16:33:47 -0400


Hi Darpan,

Disk Arbitration is private on 10.3. It is public on 10.4. Disk Arbitration is otherwise the same on 10.3 and 10.4.

You can obtain the headers though Darwin on 10.3 at:

http://www.opensource.apple.com/darwinsource/10.3.9/ DiskArbitration-129.5/DiskArbitration/DADisk.h
http://www.opensource.apple.com/darwinsource/10.3.9/ DiskArbitration-129.5/DiskArbitration/DASession.h
http://www.opensource.apple.com/darwinsource/10.3.9/ DiskArbitration-129.5/DiskArbitration/DiskArbitration.h


You can compile with a private framework on 10.3 with:

-F/System/Library/PrivateFrameworks

You can use 10.4 as another alternative, of course.

Dan

On 8 Sep 2005, at 1:44 AM, darpan kamboj wrote:

Hi
  I am running on Mac OS 10.3.3.

Thanks and Regards

From: Kevin Elliott <email@hidden>
To: darpan kamboj <email@hidden>, email@hidden, email@hidden
Subject: Re: How can I get Hard Disks(ATA) and Removable media (USB) attached to my system??
Date: Wed, 7 Sep 2005 11:56:56 -0700


What OS version on are you running on?

At 15:38 +0530  on  9/7/05, darpan kamboj wrote:

Hi all

I am using QT Programming(C++ GUI Programming Kit) on mac. I have used as per your suggestions but when i compiling my appliction there are error:

DADiskRef undeclared
DADiskCopyDescription undeclared
disk undeclared

Which files and Libs i have to include in my application plz help me.

From: Dan Markarian <email@hidden>
To: darpan kamboj <email@hidden>
CC: email@hidden
Subject: Re: How can I get Hard Disks(ATA) and Removable media (USB) attached to my system??
Date: Fri, 2 Sep 2005 12:16:00 -0400


Hi,

You might want to check out Disk Arbitration.

#include <DiskArbitration/DiskArbitration.h>

void callback( DADiskRef disk, void * context )
{
     CFDictionaryRef description;

     description = DADiskCopyDescription( disk );

     if ( description )
     {
         CFShow( description );

         CFRelease( description );
     }
}

int main( )
{
     DASessionRef session;

     session = DASessionCreate( kCFAllocatorDefault );

if ( session )
{
DASessionScheduleWithRunLoop( session, CFRunLoopGetCurrent ( ), kCFRunLoopDefaultMode );


DARegisterDiskAppearedCallback( session, kDADiskDescriptionMatchMediaWhole, callback, NULL );

         CFRunLoopRun( );

DASessionUnscheduleFromRunLoop( session, CFRunLoopGetCurrent ( ), kCFRunLoopDefaultMode );

         CFRelease( session );
     }

     return 0;
}

Dan

On 2 Sep 2005, at 5:30 AM, darpan kamboj wrote:

Hi all

I want to get the Hard disks and Removable media attached to my system and capacity of disks. Actually i want to raw read the hard disk. Currently i am picking the hard disks from "/dev/disk*" here * may be 1,2,3 depending upon the hard disks attached to system.

My problem is :
1) In case OS installed in any other language other than english then i am not able to pick the hard disks.


2) I am not able to get capacity of hard disks.

3) I am not able to differenciate whether this is removable media or hard disk.

How I can get hard disks attached,capacity,Serial no. of hard disks so that i can raw read the hard disk.


Thanks and Regards

-- ______________________________________________________ Arguing with an engineer is like wrestling with a pig in mud. After a while, you realize the pig is enjoying it. ______________________________________________________ Kevin Elliott <mailto:email@hidden> AIM/iChatAV: email@hidden (video chat available) ______________________________________________________

_______________________________________________ Do not post admin requests to the list. They will be ignored. Ata-scsi-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/ata-scsi-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: How can I get Hard Disks(ATA) and Removable media(USB) attached to my system?? (From: "darpan kamboj" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.