opening twice the same device file ...
From: Daniel Schüle (uval_at_rz.uni-karlsruhe.de)
Date: 05/23/04
- Previous message: Kasper Dupont: "Re: Creating an operating system"
- Next in thread: viro_at_parcelfarce.linux.theplanet.co.uk: "Re: opening twice the same device file ..."
- Reply: viro_at_parcelfarce.linux.theplanet.co.uk: "Re: opening twice the same device file ..."
- Reply: LEE Sau Dan: "Re: opening twice the same device file ..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 23 May 2004 03:08:41 +0200
Hello @all,
i need a little clarification to fully understand what is going on
the situation is the following
i insmod my module.o, which provides file_operations interface (fops)
to the kernel with
register_chrdev(major, module_name, &fops);
everything runs just fine
from my user space application i open the same device twice
open("./my_device0", O_RDWR);
my device_open function doesnt do much but printing some debug informations
which get logged to /var/warn (by klogd)
especially i print the addres of file object
the interface of the open function as defined in linux/fs.h in
struct file_operations
{..
int (*open)(struct inode * inode, struct file * file);
..
};
int device_open(struct inode * inode, struct file * file)
{
printk(KERN_WARNING "%p\n", file); // debug informations
return 0;
}
fops->open = device_open;
now my question ..
i thought that opening the same device file twice (or more times)
doesnt create (somewhere in the kernel) multiple file object, so i expected
to see in the log files both times the same addres of "file"
but i see different addreses, how can that be?
maybe i heavily misunderstand something
can someone please clarify
thx folks
-- Daniel
- Previous message: Kasper Dupont: "Re: Creating an operating system"
- Next in thread: viro_at_parcelfarce.linux.theplanet.co.uk: "Re: opening twice the same device file ..."
- Reply: viro_at_parcelfarce.linux.theplanet.co.uk: "Re: opening twice the same device file ..."
- Reply: LEE Sau Dan: "Re: opening twice the same device file ..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|