Device Driver Tutorial

Defining the Open Device Entry Point

The open(9E) routine returns type int. The open(9E) routine should return either DDI_SUCCESS or the appropriate error number.

The open(9E) routine takes four arguments. This dummy driver is so simple that this dummy_open() routine does not use any of the open(9E) arguments. The examples in Chapter 3, Reading and Writing Data in Kernel Memory show the open(9E) routine in more detail.

The following code is the dummy_open() routine that you should enter into your dummy.c file. You can copy the name portion of this function definition directly from the declaration you entered in Declaring the User Context Entry Points. Write a message to the system log and return success.

static int
dummy_open(dev_t *devp, int flag, int otyp, cred_t *cred)
    cmn_err(CE_NOTE, "Inside dummy_open");
    return DDI_SUCCESS;