devfs_get_cdevpriv (9)
Leading comments
Copyright (c) 2008 Konstantin Belousov All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/o...
NAME
devfs_set_cdevpriv devfs_get_cdevpriv devfs_clear_cdevpriv - manage per-open filedescriptor data for devicesSYNOPSIS
In sys/param.h In sys/conf.htypedef void (*cdevpriv_dtr_t)(void *data);Ft int Fn devfs_get_cdevpriv void **datap Ft int Fn devfs_set_cdevpriv void *priv cdevpriv_dtr_t dtr Ft void Fn devfs_clear_cdevpriv void
DESCRIPTION
The Fn devfs_xxx_cdevpriv family of functions allows the Fa cdev driver methods to associate some driver-specific data with each user process open(2) of the device special file. Currently, functioning of these functions is restricted to the context of the Fa cdevsw switch method calls performed as devfs(5) operations in response to system calls that use filedescriptors.The Fn 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 performed on this filedescriptor, by the Fn devfs_get_cdevpriv function. The Fn devfs_clear_cdevpriv disassociates previously attached data from context. Immediately after Fn devfs_clear_cdevpriv finished operating, the dtr callback is called, with private data supplied data argument. The Fn 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 Fn devfs_clear_cdevpriv call.
If successful, the functions return 0.
The function Fn devfs_set_cdevpriv returns the following values on error:
- Bq Er ENOENT
- The current call is not associated with some filedescriptor.
- Bq Er EBUSY
- The private driver data is already associated with current filedescriptor.
The function Fn devfs_get_cdevpriv returns the following values on error:
- Bq Er EBADF
- The current call is not associated with some filedescriptor.
- Bq Er ENOENT
- The private driver data was not associated with current filedescriptor, or Fn devfs_clear_cdevpriv was called.