سؤال

I have some code which looks like:

static int devname_read(struct cdev *dev, struct uio *uio, int ioflag)
{
   int error = modify_state();
   return (error);
}

The issue here is that modify_state() operates on global state when it really should be operating on is per open(2). In other words no reader should conflict with each other, and nothing persist when the device is close(2)ed.

How can I associate state with the file-descriptor or related identifier?

هل كانت مفيدة؟

المحلول

You probably want to use cdevpriv; see http://www.freebsd.org/cgi/man.cgi?devfs_set_cdevpriv.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top