[Bug 218830] lseek on closed file does not trigger an error and affect other files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



https://bugzilla.kernel.org/show_bug.cgi?id=218830

Theodore Tso (tytso@xxxxxxx) changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |tytso@xxxxxxx
         Resolution|---                         |INVALID

--- Comment #1 from Theodore Tso (tytso@xxxxxxx) ---
This is a test/programming bug.   If you change reproduce.c so that it prints
fd_a  and fd_b, you'll see that they have the same value.   So the reason why
lseek didn't fail is because fd_a has the same integer value as fd_b --- and so
lseek didn't fail and affected the current position of fd_b.

This is a documented feature of the Linux/Unix/Posix interface.   File
descriptors are small integers, and if you close a file descriptor, it releases
that integer ---- think of it as an index in an array, i.e., struct file
*fd_array[MAX_FDS].   When you call open, it will find the first NULL pointer
in fd_array, and installs a pointer to the struct file, and returns that
integer as the file descriptor.

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux