opening twice the same device file ...

From: Daniel Schüle (uval_at_rz.uni-karlsruhe.de)
Date: 05/23/04

  • Next message: viro_at_parcelfarce.linux.theplanet.co.uk: "Re: opening twice the same device file ..."
    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
    

  • Next message: viro_at_parcelfarce.linux.theplanet.co.uk: "Re: opening twice the same device file ..."

    Relevant Pages

    • Re: "Abstract" interface ?
      ... public abstract class DestinationBase: IDestination; ... public abstract class SourceBase: ISource; ... > internal interface IDestination: INode ...
      (microsoft.public.dotnet.framework)
    • Re: reiser4 plugins
      ... inodes in the attrfs. ... I prefer that interface over xattr or openat. ... Not sure I like using inode numbers, ... You can still symlink. ...
      (Linux-Kernel)
    • Re: "Abstract" interface ?
      ... > public abstract class DestinationBase: ... >> internal interface IDestination: INode ... >> internal interface ISource: INode ...
      (microsoft.public.dotnet.framework)
    • Re: "Abstract" interface ?
      ... "Error 1 Inconsistent accessibility: base interface 'Core.INode' is less ... internal interface INode ... public interface IDest: INode ...
      (microsoft.public.dotnet.framework)