1/*
2 * Copyright (c) 1998-2013 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24#ifndef __DISKARBITRATION_DADISK__
25#define __DISKARBITRATION_DADISK__
26
27#include <CoreFoundation/CoreFoundation.h>
28#include <IOKit/IOKitLib.h>
29
30#include <DiskArbitration/DASession.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif /* __cplusplus */
35
36extern const CFStringRef kDADiskDescriptionVolumeKindKey;      /* ( CFString     ) */
37extern const CFStringRef kDADiskDescriptionVolumeMountableKey; /* ( CFBoolean    ) */
38extern const CFStringRef kDADiskDescriptionVolumeNameKey;      /* ( CFString     ) */
39extern const CFStringRef kDADiskDescriptionVolumeNetworkKey;   /* ( CFBoolean    ) */
40extern const CFStringRef kDADiskDescriptionVolumePathKey;      /* ( CFURL        ) */
41extern const CFStringRef kDADiskDescriptionVolumeUUIDKey;      /* ( CFUUID       ) */
42
43extern const CFStringRef kDADiskDescriptionMediaBlockSizeKey;  /* ( CFNumber     ) */
44extern const CFStringRef kDADiskDescriptionMediaBSDMajorKey;   /* ( CFNumber     ) */
45extern const CFStringRef kDADiskDescriptionMediaBSDMinorKey;   /* ( CFNumber     ) */
46extern const CFStringRef kDADiskDescriptionMediaBSDNameKey;    /* ( CFString     ) */
47extern const CFStringRef kDADiskDescriptionMediaBSDUnitKey;    /* ( CFNumber     ) */
48extern const CFStringRef kDADiskDescriptionMediaContentKey;    /* ( CFString     ) */
49extern const CFStringRef kDADiskDescriptionMediaEjectableKey;  /* ( CFBoolean    ) */
50extern const CFStringRef kDADiskDescriptionMediaIconKey;       /* ( CFDictionary ) */
51extern const CFStringRef kDADiskDescriptionMediaKindKey;       /* ( CFString     ) */
52extern const CFStringRef kDADiskDescriptionMediaLeafKey;       /* ( CFBoolean    ) */
53extern const CFStringRef kDADiskDescriptionMediaNameKey;       /* ( CFString     ) */
54extern const CFStringRef kDADiskDescriptionMediaPathKey;       /* ( CFString     ) */
55extern const CFStringRef kDADiskDescriptionMediaRemovableKey;  /* ( CFBoolean    ) */
56extern const CFStringRef kDADiskDescriptionMediaSizeKey;       /* ( CFNumber     ) */
57extern const CFStringRef kDADiskDescriptionMediaTypeKey;       /* ( CFString     ) */
58extern const CFStringRef kDADiskDescriptionMediaUUIDKey;       /* ( CFUUID       ) */
59extern const CFStringRef kDADiskDescriptionMediaWholeKey;      /* ( CFBoolean    ) */
60extern const CFStringRef kDADiskDescriptionMediaWritableKey;   /* ( CFBoolean    ) */
61
62extern const CFStringRef kDADiskDescriptionDeviceGUIDKey;      /* ( CFData       ) */
63extern const CFStringRef kDADiskDescriptionDeviceInternalKey;  /* ( CFBoolean    ) */
64extern const CFStringRef kDADiskDescriptionDeviceModelKey;     /* ( CFString     ) */
65extern const CFStringRef kDADiskDescriptionDevicePathKey;      /* ( CFString     ) */
66extern const CFStringRef kDADiskDescriptionDeviceProtocolKey;  /* ( CFString     ) */
67extern const CFStringRef kDADiskDescriptionDeviceRevisionKey;  /* ( CFString     ) */
68extern const CFStringRef kDADiskDescriptionDeviceUnitKey;      /* ( CFNumber     ) */
69extern const CFStringRef kDADiskDescriptionDeviceVendorKey;    /* ( CFString     ) */
70
71extern const CFStringRef kDADiskDescriptionBusNameKey;         /* ( CFString     ) */
72extern const CFStringRef kDADiskDescriptionBusPathKey;         /* ( CFString     ) */
73
74#ifndef __DISKARBITRATIOND__
75
76/*!
77 * @typedef    DADiskRef
78 * Type of a reference to DADisk instances.
79 */
80
81typedef struct __DADisk * DADiskRef;
82
83/*!
84 * @function   DADiskGetTypeID
85 * @abstract   Returns the type identifier of all DADisk instances.
86 */
87
88extern CFTypeID DADiskGetTypeID( void );
89
90/*!
91 * @function   DADiskCreateFromBSDName
92 * @abstract   Creates a new disk object.
93 * @param      allocator The allocator object to be used to allocate memory.
94 * @param      session   The DASession in which to contact Disk Arbitration.
95 * @param      name      The BSD device name.
96 * @result     A reference to a new DADisk.
97 * @discussion
98 * The caller of this function receives a reference to the returned object.  The
99 * caller also implicitly retains the object and is responsible for releasing it
100 * with CFRelease().
101 */
102
103extern DADiskRef DADiskCreateFromBSDName( CFAllocatorRef allocator, DASessionRef session, const char * name );
104
105/*!
106 * @function   DADiskCreateFromIOMedia
107 * @abstract   Creates a new disk object.
108 * @param      allocator The allocator object to be used to allocate memory.
109 * @param      session   The DASession in which to contact Disk Arbitration.
110 * @param      media     The I/O Kit media object.
111 * @result     A reference to a new DADisk.
112 * @discussion
113 * The caller of this function receives a reference to the returned object.  The
114 * caller also implicitly retains the object and is responsible for releasing it
115 * with CFRelease().
116 */
117
118extern DADiskRef DADiskCreateFromIOMedia( CFAllocatorRef allocator, DASessionRef session, io_service_t media );
119
120/*!
121 * @function   DADiskCreateFromVolumePath
122 * @abstract   Creates a new disk object.
123 * @param      allocator The allocator object to be used to allocate memory.
124 * @param      session   The DASession in which to contact Disk Arbitration.
125 * @param      path      The BSD mount point.
126 * @result     A reference to a new DADisk.
127 * @discussion
128 * The caller of this function receives a reference to the returned object.  The
129 * caller also implicitly retains the object and is responsible for releasing it
130 * with CFRelease().
131 */
132
133extern DADiskRef DADiskCreateFromVolumePath( CFAllocatorRef allocator, DASessionRef session, CFURLRef path );
134
135/*!
136 * @function   DADiskGetBSDName
137 * @abstract   Obtains the BSD device name for the specified disk.
138 * @param      disk The DADisk for which to obtain the BSD device name.
139 * @result     The disk's BSD device name.
140 * @discussion
141 * The BSD device name can be used with opendev() to open the BSD device.
142 */
143
144extern const char * DADiskGetBSDName( DADiskRef disk );
145
146/*!
147 * @function   DADiskCopyIOMedia
148 * @abstract   Obtains the I/O Kit media object for the specified disk.
149 * @param      disk The DADisk for which to obtain the I/O Kit media object.
150 * @result     The disk's I/O Kit media object.
151 * @discussion
152 * The caller of this function receives a reference to the returned object.  The
153 * caller also implicitly retains the object and is responsible for releasing it
154 * with IOObjectRelease().
155 */
156
157extern io_service_t DADiskCopyIOMedia( DADiskRef disk );
158
159/*!
160 * @function   DADiskCopyDescription
161 * @abstract   Obtains the Disk Arbitration description of the specified disk.
162 * @param      disk The DADisk for which to obtain the Disk Arbitration description.
163 * @result     The disk's Disk Arbitration description.
164 * @discussion
165 * This function will contact Disk Arbitration to acquire the latest description
166 * of the specified disk, unless this function is called on a disk object passed
167 * within the context of a registered callback, in which case the description is
168 * current as of that callback event.
169 *
170 * The caller of this function receives a reference to the returned object.  The
171 * caller also implicitly retains the object and is responsible for releasing it
172 * with CFRelease().
173 */
174
175extern CFDictionaryRef DADiskCopyDescription( DADiskRef disk );
176
177/*!
178 * @function   DADiskCopyWholeDisk
179 * @abstract   Obtain the associated whole disk object for the specified disk.
180 * @param      disk The disk object.
181 * @result     The disk's associated whole disk object.
182 * @discussion
183 * The caller of this function receives a reference to the returned object.  The
184 * caller also implicitly retains the object and is responsible for releasing it
185 * with CFRelease().
186 */
187
188extern DADiskRef DADiskCopyWholeDisk( DADiskRef disk );
189
190#endif /* !__DISKARBITRATIOND__ */
191
192#ifdef __cplusplus
193}
194#endif /* __cplusplus */
195
196#endif /* !__DISKARBITRATION_DADISK__ */
197