Open Device (Device-Driver Function 0Dh)

OPENCLOSEREQUEST STRUC

ocrLength db ? ;length of record, in bytes

ocrUnit db ? ;unit number (block device only)

ocrFunction db 0Dh ;function number

ocrStatus dw ? ;status

ocrReserved db 8 dup(?) ;reserved

OPENCLOSEREQUEST ENDS

Open Device (Device-Driver Function 0Dh) informs the device driver that a file device or character device is being opened or created.

This function can be used for both block- and character-device drivers.

Fields

ocrLength

Specifies the length, in bytes, of the OPENCLOSEREQUEST structure.

ocrUnit

Specifies which device contains the file being opened or created. This field is used with block-device drivers only.

ocrFunction

Specifies the Open Device function: 0Dh.

ocrStatus

Specifies the status of the completed function. If the function is successful, the driver must set the done bit (bit 8). Otherwise, the driver must set both the error and done bits (bits 15 and 8) and copy an error value to the low-order byte.

ocrReserved

Reserved; do not use.

Comments

MS-DOS calls this function only if bit 11 is set in the dhAttributes field of the driver's DEVICEHEADER structure. For a full description of the DEVICEHEADER structure, see Section 9.9, “Structures.”

MS-DOS calls this function whenever an application opens or creates a file or opens a device. This function can be used in conjunction with Close Device (Device-Driver Function 0Eh) to manage internal buffers and device initialization. To manage internal buffers, this function, when used in a block-device-driver, should increment the count of open files on the specified drive; Close Device decrements this count and flushes internal buffers when all files are closed. Keeping this count can also help the driver determine whether the medium in the drive has been removed before all files have been closed. To help manage device initialization, this function, when used in a character-device driver, can reset the device and send it control strings to prepare it for subsequent input. If a character-device driver offers this feature, it should also provide IOCTL Read and IOCTL Write (Device-Driver Functions 03h and 0Ch) to let programs get and set the current control strings.

See Also

Device-Driver Function 0Eh Close Device
Interrupt 21h Function 3Ch Create File with Handle
Interrupt 21h Function 3Dh Open File with Handle
Interrupt 21h Function 5Ah Create Temporary File
Interrupt 21h Function 5Bh Create New File
Interrupt 21h Function 6Ch Extended Open/Create