HomeFreeBSD

Implement the per-open file data for the cdev.
rS179175Unpublished

Unpublished Commit ยท Learn More

No further details are available.

Description

Implement the per-open file data for the cdev.

The patch does not change the cdevsw KBI. Management of the data is
provided by the functions
int devfs_set_cdevpriv(void *priv, cdevpriv_dtr_t dtr);
int devfs_get_cdevpriv(void **datap);
void devfs_clear_cdevpriv(void);
All of the functions are supposed to be called from the cdevsw method
contexts.

  • devfs_set_cdevpriv assigns the priv as private data for the file descriptor which is used to initiate currently performed driver operation. dtr is the function that will be called when either the last refernce to the file goes away, the device is destroyed or devfs_clear_cdevpriv is called.
  • devfs_get_cdevpriv is the obvious accessor.
  • devfs_clear_cdevpriv allows to clear the private data for the still open file.

Implementation keeps the driver-supplied pointers in the struct
cdev_privdata, that is referenced both from the struct file and struct
cdev, and cannot outlive any of the referee.

Man pages will be provided after the KPI stabilizes.

Reviewed by: jhb
Useful suggestions from: jeff, antoine
Debugging help and tested by: pho
MFC after: 1 month

Details

Provenance
kibAuthored on
Parents
rS179174: + Use the default cscope names.
Branches
Unknown
Tags
Unknown

Event Timeline