[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bug-218830-13602-43d0TVLX5P@https.bugzilla.kernel.org/>
Date: Mon, 13 May 2024 13:24:07 +0000
From: bugzilla-daemon@...nel.org
To: linux-ext4@...r.kernel.org
Subject: [Bug 218830] lseek on closed file does not trigger an error and
affect other files
https://bugzilla.kernel.org/show_bug.cgi?id=218830
Theodore Tso (tytso@....edu) changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |tytso@....edu
Resolution|--- |INVALID
--- Comment #1 from Theodore Tso (tytso@....edu) ---
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.
Powered by blists - more mailing lists