Hello,
I am writing a block device driver for an SD card accessed over SPI. If the
card is write-protected (using the little switch on the side), I would like
to inform the kernel that the device is read-only, and can't be written to.
After a bit of research, I've come to the conclusion that the proper place
to inform the kernel is during the call to my open function, when I should
return an error code if the kernel tries to open my device in read-write or
write-only mode. Here is my open function's signature:
static int sdcard_open(struct inode *inode, struct file *filp);
In the 'file' struct, there is an unsigned int field called 'f_flags'. I
think this is the proper way to look up the flags used in the open system
call.
When I open my device using O_RDWR, f_flags = 0x00010002
When I open my device using O_RDONLY, f_flags = 0x00010000
This leads me to believe that the "user is requesting write access" flag is
in bit position 1 (second from the right).
Sure, I could write my driver on this assumption, but I would really like
to find a list of the flags that belong to struct file. Is there some way
to know which #define statements belong to which bitfield?
Many thanks in advance,
Matthew
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ