All of lore.kernel.org
 help / color / mirror / Atom feed
* Module open() problems, Linux 2.4.0
@ 2000-11-09 19:00 Richard B. Johnson
  2000-11-09 19:27 ` Brian Gerst
  0 siblings, 1 reply; 10+ messages in thread
From: Richard B. Johnson @ 2000-11-09 19:00 UTC (permalink / raw)
  To: Linux kernel


`lsmod` shows that a device is open twice when using Linux-2.4.0-test9
when, in fact, it has been opened only once.

lsmod is version 2.3.15, the latest-and-greatest.

Here are the open/close routines for a module.

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
 *  Open the device.
 */
static int device_open(struct inode *inp, struct file *fp)
{
    DEB(printk("%s open\n", info->dev));
    MOD_INC_USE_COUNT;                         /* Increment usage count */
    return 0;
} 
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
 *  Close the device.
 */
static int device_close(struct inode *inp, struct file *fp)
{
    DEB(printk("%s close\n", info->dev));
    MOD_DEC_USE_COUNT;                         /* Decrement usage count */
    return 0;
} 

When the module is closed, the use-count goes to zero as expected.
However, a single open() causes the use-count to be 2.

In a possibly-related observation, during the change-root from
an initial RAM disk to the root file system during boot, the
d_count used to be reported as '1'. It is now '3'.


Cheers,
Dick Johnson

Penguin : Linux version 2.4.0 on an i686 machine (799.54 BogoMips).

"Memory is like gasoline. You use it up when you are running. Of
course you get it all back when you reboot..."; Actual explanation
obtained from the Micro$oft help desk.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2000-11-10  0:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-11-09 19:00 Module open() problems, Linux 2.4.0 Richard B. Johnson
2000-11-09 19:27 ` Brian Gerst
2000-11-09 20:12   ` Richard B. Johnson
2000-11-09 20:22     ` Christoph Hellwig
2000-11-09 20:27     ` Jeff Garzik
2000-11-09 20:57       ` Richard B. Johnson
2000-11-09 21:02         ` Jeff Garzik
2000-11-09 21:05         ` Christoph Hellwig
2000-11-10  0:01           ` Olaf Titz
2000-11-09 20:27     ` Brian Gerst

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.