On Tue, Apr 29, 2003 at 01:15:29PM -0700, Ahmed A wrote: > > 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. If it works at all, it works the way you use. > 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. When the inode is looked up and the fs driver finds it's a special inode, it calls a special setup routine to set apropriate operations vector. IIRC it's called make_special_inode. > 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. Almost all syscall entry points are called sys_<name> and so is lseek. The real entry point is thus called sys_lseek. The specific implementation is file operations llseek, you can look it up in the file_operations struct that make_special_inode sets for relevant (block) devices. ------------------------------------------------------------------------------- Jan 'Bulb' Hudec <bulb@ucw.cz> -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/