Open a device?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I am using the following like to open /dev/sda  (I am
guessing this is called a raw device).


fd = open ("/dev/sda", O_RDWR | O_SYNC | O_DIRECT);

I have a few questions regarding the above:

1. Can I use O_DIRECT while opening the device?  Will
it have any effect.  Or do I need to go through a file
system (which has O_DIRECT implemented) for it work.

2. Which "open" is called.  Can someone give me a
pointer to the source file where this is implemented. 
I am guessing this "open" is like a generic one, as
opposed to the ones implemented in ext2, ext3,
jfs...etc directories.

3. I am getting an error when I try to issue a lseek
on the opened device:

lseek (fd, 200, SEEK_SET);

I am getting "Invalid Argument", am I not allowed to
use SEEK_SET, if so why?


4. Again, any pointer to the source file where this
"lseek" is implemented.

Thanks a lot,
Ahmed.


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux