Which include should I have to have these macros IS_BLK and IS_CHR to run. I grepped the all the source files and I didnt find the occurance of these two functions ( macros). Please give me the usage of this... thanks a lot, raghu On Fri, 22 Nov 2002, Jan Hudec wrote: > On Thu, Nov 21, 2002 at 06:39:37PM -0500, Raghu R. Arur wrote: > > Hi, > > > > I have a problem. In my module I am not able to differentiate between > > whether requests are coming from a block device or character device. > > > > I am running my module on vmware and the keyboard hits are read thru > > ptty. The major number of ptty and the hard disk are both 3. I am blocking > > read system call in my module and I want to deal with the requests > > pertaining to the disk only. So given a file descriptor I am able to get > > the inode value and also the major and minor number of the device to which > > the request has to go. > > > > So in order to service only the requests of the disk i have an if > > statement > > > > if(inode && major == 3) > > { > > do my sys_read > > } > > else > > { > > do original sys_read > > } > > > > > > but every keystroke evaluates to true and does my sys_read section. I > > thought that character devices do not have inode and the ptty requests > > evaluate to false at if statement. But it is not happening so... > > > > am i missing something... > > > > please help me. > > > > thanks, > > raghu > > Every device must have an inode. Actually sys_read is called on file and > file must have an inode. It is the device inode, that is it is the inode > that makes /dev/tty<n> appear on your filesystem (even if it may be > created on the fly by kernel, it's still an inode in memory). In this > inode, the i_dev should contain the device number and the i_mode should > contain the file type, in this case either IS_CHR(i_mode) or > IS_BLK(i_mode) should be true. > > What about intercepting the function registered for char major 3? > Best way would be to patch the kernel a bit to make a hook there. > However if you find the file_operations structure registered for the > device, you can just replace the pointer in there. > > PS: Please don't send new topics as a reply to unrelated message. Many > people have threaded mail readers and such mail tend to get lost in > threads. > > ------------------------------------------------------------------------------- > 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/