osfmk/man/device_open.html
Function - Establish a connection to a device.
**#include<device/device.h>**** kern\_return\_t device\_open****(mach\_port\_t**master\_port, **mach\_port\_t** ledger, **dev\_mode\_t** mode, **security\_token\_t** security\_id, **dev\_name\_t** name, **mach\_port\_t** device**);****#include<device/device\_request.h> ****kern\_return\_t device\_open\_request**** (mach\_port\_t **master\_port,** mach\_port\_t **reply\_port,** mach\_port\_t **ledger,** dev\_mode\_t **mode,** security\_token\_t **security\_id,** dev\_name\_t **name** ); ****kern\_return\_t ds\_device\_open\_reply**** (mach\_port\_t **reply\_port,** kern\_return\_t **return\_code,** mach\_port\_t **device** );**
master_port[in device-master send right] The master device port. This port is provided to the bootstrap task.
reply_port[in reply receive (to be converted to send-once) right] The port to which a reply is to be sent when the device is open.
ledger[pointer to a ledger send right] Resource ledger from which the device will draw its resources.
mode[in scalar] Opening mode. This is the bit-wise OR of the following values:
D_READ Read access
D_WRITE Write access
D_NODELAY Do not delay on open
security_id[in scalar] The security ID that tasks attempting to use this device port must have. A zero value indicates all identities.
name[pointer to in array of char] Name of the device to open.
return_code[in scalar] Status of the open.
device[out device send right, in for asynchronous form] The returned device port.
The device_open function opens a device object. The open operation of the device is invoked, if the device is not already open. The open count for the device is incremented. Each open for a device returns a port, the allowed operations upon which being governed by mode. The port is not distinct.
Only generic errors apply.
Functions: device_close, device_reply_server.