DEVFS_SET_CDEVPRIV(9FREEBSD) - Linux man page online | System kernel interfaces
Manage per-open filedescriptor data for devices.
December 2, 2015
DEVFS_CDEVPRIV(9) BSD Kernel Developer's Manual DEVFS_CDEVPRIV(9)
BSD December 2, 2015 BSD
NAMEdevfs_set_cdevpriv, devfs_get_cdevpriv, devfs_clear_cdevpriv — manage per-open filedescrip‐ tor data for devices
SYNOPSIS#include <sys/param.h> #include <sys/conf.h> typedef void d_priv_dtor_t(void *data); int devfs_get_cdevpriv(void **datap); int devfs_set_cdevpriv(void *priv, d_priv_dtor_t *dtr); void devfs_clear_cdevpriv(void);
DESCRIPTIONThe devfs_xxx_cdevpriv() family of functions allows the cdev driver methods to associate some driver-specific data with each user process open(2) of the device special file. Cur‐ rently, functioning of these functions is restricted to the context of the cdevsw switch method calls performed as devfs(5) operations in response to system calls that use filedescriptors. The devfs_set_cdevpriv() function associates a data pointed by priv with current calling context (filedescriptor). The data may be retrieved later, possibly from another call per‐ formed on this filedescriptor, by the devfs_get_cdevpriv() function. The devfs_clear_cdevpriv() disassociates previously attached data from context. Immediately after devfs_clear_cdevpriv() finished operating, the dtr callback is called, with private data supplied data argument. The devfs_clear_cdevpriv() function will be also be called if the open callback function returns an error code. On the last filedescriptor close, system automatically arranges devfs_clear_cdevpriv() call. If successful, the functions return 0. The function devfs_set_cdevpriv() returns the following values on error: [ENOENT] The current call is not associated with some filedescriptor. [EBUSY] The private driver data is already associated with current filedescrip‐ tor. The function devfs_get_cdevpriv() returns the following values on error: [EBADF] The current call is not associated with some filedescriptor. [ENOENT] The private driver data was not associated with current filedescriptor, or devfs_clear_cdevpriv() was called.
SEE ALSOclose(2), open(2), devfs(5)
HISTORYThe devfs_cdevpriv() family of functions first appeared in FreeBSD 7.1.
|This manual||Reference||Other manuals|
|refer to||close(2) | open(2)|