Disk Device Description

  • Hello,
    I need a way to get the device description for a mounted drive.  The
    command-line program 'diskutil' does not provide this info.  Either
    the description or the vendor or device ID would be fine.  As an
    example, I'd like to have a method that did this:

    NSString *description = [DeviceManager
    descriptionForDevice:@"/Volumes/Untitled"];

    Obviously that doesn't exist, and the solution doesn't have to be
    cocoa, if it doesn't exist. Are there any elegant ways to do this, or
    command-line programs I can use NSTask on to get this information?

    Thanks,

    Michael
  • Does System Profiler provide you with what you need? Look at the
    system_profiler man pages for output formats and the like.

    Hank Heijink
    (212) 678-8761
    (646) 283-3372
    www.hankheijink.com
    <hankh...>

    On Oct 11, 2006, at 2:07 PM, Michael Marmarou wrote:

    > Hello,
    > I need a way to get the device description for a mounted drive.  The
    > command-line program 'diskutil' does not provide this info.  Either
    > the description or the vendor or device ID would be fine.  As an
    > example, I'd like to have a method that did this:
    >
    > NSString *description = [DeviceManager
    > descriptionForDevice:@"/Volumes/Untitled"];
    >
    > Obviously that doesn't exist, and the solution doesn't have to be
    > cocoa, if it doesn't exist. Are there any elegant ways to do this, or
    > command-line programs I can use NSTask on to get this information?
    >
    > Thanks,
    >
    > Michael
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/<hankh...>
    >
    > This email sent to <hankh...>
    >
  • Sort of, but that's not what I am looking for here.  In this case,
    there is no mount_point so I would have no way of knowing which is the
    one I want.  Also, that is overkill and is very slow.

    On 10/11/06, Hank Heijink <hankh...> wrote:
    > Does System Profiler provide you with what you need? Look at the
    > system_profiler man pages for output formats and the like.
    >
    > Hank Heijink
    > (212) 678-8761
    > (646) 283-3372
    > www.hankheijink.com
    > <hankh...>
    >
    > On Oct 11, 2006, at 2:07 PM, Michael Marmarou wrote:
    >
    >> Hello,
    >> I need a way to get the device description for a mounted drive.  The
    >> command-line program 'diskutil' does not provide this info.  Either
    >> the description or the vendor or device ID would be fine.  As an
    >> example, I'd like to have a method that did this:
    >>
    >> NSString *description = [DeviceManager
    >> descriptionForDevice:@"/Volumes/Untitled"];
    >>
    >> Obviously that doesn't exist, and the solution doesn't have to be
    >> cocoa, if it doesn't exist. Are there any elegant ways to do this, or
    >> command-line programs I can use NSTask on to get this information?
    >>
    >> Thanks,
    >>
    >> Michael
    >> _______________________________________________
    >> Do not post admin requests to the list. They will be ignored.
    >> Cocoa-dev mailing list      (<Cocoa-dev...>)
    >> Help/Unsubscribe/Update your Subscription:
    >> http://lists.apple.com/mailman/options/cocoa-dev/<hankh...>
    >>
    >> This email sent to <hankh...>
    >>
    >
    >
  • From the system_profiler output on my MacBook (only one drive though):

    <snip>

              Volumes:
                Macintosh HD:
                  Capacity: 55.57 GB
                  Available: 9.2 GB
                  Writable: Yes
                  File System: Journaled HFS+
                  BSD Name: disk0s2
                  Mount Point: /

    <snip>

    Mount point and BSD device file. What are you missing? It's not fast
    though, you're right about that. If you want the quickest way to get
    at the vendor ID,  I'd start looking at the IOKit documentation.

    Hank

    On Oct 11, 2006, at 4:01 PM, Michael Marmarou wrote:

    > Sort of, but that's not what I am looking for here.  In this case,
    > there is no mount_point so I would have no way of knowing which is the
    > one I want.  Also, that is overkill and is very slow.
    >

    Hank Heijink
    www.hankheijink.com
    <hankh...>
  • DiskArbitration has everything you need.

    You probably want to use something like statfs, then
    DADiskCreateFromBSDName and then DADiskCopyDescription and you'll
    find one the properties returned is what you want. You'll probably
    want to trim the trailing 's' bit off whatever you get back from
    statfs before calling DADiskCreateFromBSDName.

    Note that Disk Arbitration is a private framework in 10.3 (although
    you can still use it with a bit of effort).

    - Chris

    On 12/10/2006, at 4:07 AM, Michael Marmarou wrote:

    > Hello,
    > I need a way to get the device description for a mounted drive.  The
    > command-line program 'diskutil' does not provide this info.  Either
    > the description or the vendor or device ID would be fine.  As an
    > example, I'd like to have a method that did this:
    >
    > NSString *description = [DeviceManager
    > descriptionForDevice:@"/Volumes/Untitled"];
    >
    > Obviously that doesn't exist, and the solution doesn't have to be
    > cocoa, if it doesn't exist. Are there any elegant ways to do this, or
    > command-line programs I can use NSTask on to get this information?
    >
    > Thanks,
    >
    > Michael
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/<chris...>-
    > systems.com
    >
    > This email sent to <chris...>
    >
  • Michael,

    Here are some starting points... The function
    IORegistryEntryCreateCFProperties() to retrieve the properties of a
    device:

    IORegistryEntryCreateCFProperties
    (device,&properties,kCFAllocatorDefault, kNilOptions);

    'properties' is a NSDictionary*. device can be retrieved in the
    following way  (using bsdname (e.g.. disk0s2)):

      CFMutableDictionaryRef    matchingDict;
      kern_return_t        kernResult;
      io_iterator_t         iter;
      io_registry_entry_t        device;

      matchingDict = IOBSDNameMatching(kIOMasterPortDefault, 0, bsdName);
    kernResult = IOServiceGetMatchingServices(kIOMasterPortDefault,
    matchingDict, &iter);

    device = IOIteratorNext(iter);  // There should only be 1 match

    The VendorID can be retrieved using something like:

    int vendorID =  [[properties objectForKey:[NSString
    stringWithCString: kIOHIDVendorIDKey]] intValue];

    Kind regards,

    Diederik
    www.obviousmatter.com

    On 11-okt-2006, at 22:01, Michael Marmarou wrote:

    > Sort of, but that's not what I am looking for here.  In this case,
    > there is no mount_point so I would have no way of knowing which is the
    > one I want.  Also, that is overkill and is very slow.
    >
    > On 10/11/06, Hank Heijink <hankh...> wrote:
    >> Does System Profiler provide you with what you need? Look at the
    >> system_profiler man pages for output formats and the like.
    >>
    >> Hank Heijink
    >> (212) 678-8761
    >> (646) 283-3372
    >> www.hankheijink.com
    >> <hankh...>
    >>
    >> On Oct 11, 2006, at 2:07 PM, Michael Marmarou wrote:
    >>
    >>> Hello,
    >>> I need a way to get the device description for a mounted drive.
    >> The
    >>> command-line program 'diskutil' does not provide this info.  Either
    >>> the description or the vendor or device ID would be fine.  As an
    >>> example, I'd like to have a method that did this:
    >>>
    >>> NSString *description = [DeviceManager
    >>> descriptionForDevice:@"/Volumes/Untitled"];
    >>>
    >>> Obviously that doesn't exist, and the solution doesn't have to be
    >>> cocoa, if it doesn't exist. Are there any elegant ways to do
    >> this, or
    >>> command-line programs I can use NSTask on to get this information?
    >>>
    >>> Thanks,
    >>>
    >>> Michael
    >>> _______________________________________________
    >>> Do not post admin requests to the list. They will be ignored.
    >>> Cocoa-dev mailing list      (<Cocoa-dev...>)
    >>> Help/Unsubscribe/Update your Subscription:
    >>> http://lists.apple.com/mailman/options/cocoa-dev/<hankh...>
    >>>
    >>> This email sent to <hankh...>
    >>>
    >>
    >>
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/mailings%
    > 40obviousmatter.com
    >
    > This email sent to <mailings...>
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today