Quote:> > I am writing a custom char device driver and would like to check which
> > file access mode (reading only ,writing only, etc.) a process that opens
> > the char file requests. Which member of the file data structure holds this
> > information and which are the possible types?
> The f_mode field. I suggest you see how
> sys_read and sys_write check that field.
> (linux/fs/read_write.c)
Kasper's answer is correct for testing permissions, but
this is not how I interpret Fredric's question.
He probably was looking for something like this:
static int ymf_open(struct inode *inode, struct file *file)
{
.................
if (file->f_mode & FMODE_WRITE) {
.... Program device for write
}
if (file->f_mode & FMODE_READ) {
.... Program device for read
}
return 0;
Quote:}
Note that both flags may be set if the process is using O_RDWR.
-- Pete