mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* bug in count_open_files() or a strange granularity?
@ 2000-11-28 15:13 Tigran Aivazian
  2000-11-28 15:06 ` David S. Miller
  2000-11-28 15:44 ` Richard B. Johnson
  0 siblings, 2 replies; 14+ messages in thread
From: Tigran Aivazian @ 2000-11-28 15:13 UTC (permalink / raw)
  To: linux-kernel

Hi,

A simple experiment:

a) insert a code like this in the open() routine of some driver:

       struct files_struct *files = current->files;
       extern int count_open_files(struct files_struct *, int);

       printk(KERN_ERR "%s has %d files open\n",
                        current->comm, count_open_files(files, files->max_fdset));

b) write a program that opens that device and sleeps indefinitely. Run it,
you will see:

op has 32 files open

c)  # lsof -p 659 | nl
     1  COMMAND PID   USER   FD   TYPE DEVICE    SIZE   NODE NAME
     2  op      659 tigran  cwd    DIR    3,6    4096 225730
/home/tigran/C/files
     3  op      659 tigran  rtd    DIR    3,6    4096      2 /
     4  op      659 tigran  txt    REG    3,6   14142 225732
/home/tigran/C/files/op
     5  op      659 tigran  mem    REG    3,6  434945 295227
/lib/ld-2.1.92.so
     6  op      659 tigran  mem    REG    3,6 4776568 295234
/lib/libc-2.1.92.so
     7  op      659 tigran    0u   CHR    4,9         348027 /dev/tty9
     8  op      659 tigran    1u   CHR    4,9         348027 /dev/tty9
     9  op      659 tigran    2u   CHR    4,9         348027 /dev/tty9
    10  op      659 tigran    3r   CHR 10,184          98313
/dev/cpu/microcode

so, we see that the process has only 9 files open and yet
count_open_files() claims there are 32. Is this a bug of
count_open_files() or is this a minimal granularity (because there are 32
builtin descriptors in files_struct->fd_array[])?

I know that there is no problem due to the way it is called in
copy_files() -- it would only be above 32. But for what I want to use it,
I need the _correct_ number of open file descriptors and not some "rounded
up to 32" one.   

(kernel assumed test12-pre2)

Regards,
Tigran


-
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] 14+ messages in thread

end of thread, other threads:[~2000-11-28 18:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-11-28 15:13 bug in count_open_files() or a strange granularity? Tigran Aivazian
2000-11-28 15:06 ` David S. Miller
2000-11-28 15:40   ` Tigran Aivazian
2000-11-28 15:55     ` Alexander Viro
2000-11-28 16:09       ` Tigran Aivazian
2000-11-28 16:01         ` David S. Miller
2000-11-28 15:48   ` Alexander Viro
2000-11-28 15:55     ` Tigran Aivazian
2000-11-28 16:06       ` Alexander Viro
2000-11-28 16:25         ` Tigran Aivazian
2000-11-28 17:45           ` Alexander Viro
2000-11-28 18:05             ` Tigran Aivazian
2000-11-28 15:44 ` Richard B. Johnson
2000-11-28 16:41   ` Tigran Aivazian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®