History log of /haiku-fatelf/src/system/kernel/fs/fd.cpp
Revision Date Author Comments
# a735bdeb 31-Oct-2011 Michael Lotz <mmlr@mlotz.ch>

Align all filesystem relevant places to use B_UNSUPPORTED for unsupported
instead of a mix of B_NOT_SUPPORTED and B_UNSUPPORTED. This allows checking for
a specific error code. Probably one of those should be phased out...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43025 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 24df6592 11-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged signals-merge branch into trunk with the following changes:
* Reorganized the kernel locking related to threads and teams.
* We now discriminate correctly between process and thread signals. Signal
handlers have been moved to teams. Fixes #5679.
* Implemented real-time signal support, including signal queuing, SA_SIGINFO
support, sigqueue(), sigwaitinfo(), sigtimedwait(), waitid(), and the addition
of the real-time signal range. Closes #1935 and #2695.
* Gave SIGBUS a separate signal number. Fixes #6704.
* Implemented <time.h> clock and timer support, and fixed/completed alarm() and
[set]itimer(). Closes #5682.
* Implemented support for thread cancellation. Closes #5686.
* Moved send_signal() from <signal.h> to <OS.h>. Fixes #7554.
* Lots over smaller more or less related changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42116 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 548836e4 02-Mar-2011 Jérôme Duval <korli@users.berlios.de>

* if ioctl hook wasn't found, now returns B_DEV_INVALID_IOCTL
* in case fd_ioctl() was about to return B_DEV_INVALID_IOCTL, translate to ENOTTY to satisfy #7279.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40787 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fa90700d 26-Feb-2011 Jérôme Duval <korli@users.berlios.de>

reverted r40686


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40699 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3116b031 25-Feb-2011 Jérôme Duval <korli@users.berlios.de>

FIONBIO and FIONREAD don't apply to directories, files, attributes: returns ENOTTY in these cases. This fixes #7279.
ENOTTY could also be replaced with a B_ error code.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40686 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4535495d 10-Jan-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged the signals branch into trunk, with these changes:
* The team and thread kernel structures have been renamed to Team and Thread
respectively and moved into the new BKernel namespace.
* Several (kernel add-on) sources have been converted from C to C++ since
private kernel headers are included that are no longer C compatible.

Changes after merging:
* Fixed gcc 2 build (warnings mainly in the scary firewire bus manager).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40196 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8e855d52 02-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Changed some POSIX error codes to native ones.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37842 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9d570af7 24-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Changed the type of the "op" parameter of the fs_vnode_ops::ioctl() hook and
the _kern_ioctl() syscall from ulong to uint32.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36927 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 74fc3e9a 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

bonefish+mmlr:
* Add file descriptor and IO context tracing.
* Some minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36272 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 57dc0e2a 15-Aug-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Changed the FD selection/deselection handling a bit:
* B_EVENT_INVALID is no longer passed to the FD's select()/deselect() hooks.
* Now we always attach the select info to the I/O context, even if no event has
been selected. The reasoning is that B_EVENT_INVALID is always automatically
selected and handled by the VFS, so we need the handle to notify on close().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32417 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7435db9f 14-Aug-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* _user_read_dir(): Allocate a temporary heap buffer passed into the kernel
instead of using the user buffer. This frees the VFS and FS implementations
from handling user buffers.
* Adjusted fix_dirent() accordingly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32384 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f7a6506e 06-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Replaced all "status < B_OK" with != B_OK - this should make the VFS layer
more robust against broken (userland) file systems.
* 80 character column cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32184 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b538ceb8 10-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Added dup_foreign_fd() to duplicate a FD from another team.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29468 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 43b2ca91 02-Mar-2009 Axel Dörfler <axeld@pinc-software.de>

* Fixed wrong use of MutexLocker as pointed out by Korli - nice catch! This
could have caused a number of problems.
* Fixed coding style violation Ingo introduced.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29378 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d3e2a6d7 03-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed build with tracing enabled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26772 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a8f9741c 04-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

* Removed -Wno-unused from all KernelMergeObjects in kernel Jamfiles.
* Fixed most of the warnings resulting from that by removing actually not used
variables or moving declaration into the #IF. Left unused functions there
though, as I wouldn't know if they are supposed to be used again.
* Fixed two statements with no effect (clamping to MAX_ANCILLARY_DATA_LEN in
socket.cpp and unsetting fCounterSem in MessagingService.cpp).
* Some style cleanups.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26253 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cb734bee 04-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added get_open_fd() function which gets the descriptor and also
increments its open count.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25317 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9981c81f 29-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed a race condition between select_fd() and close(). Since
select_fd() first added the select info to the IO context and then
called select() on the descriptor, a close() called at the same time
could already deselect the events and close the descriptor before
select_fd() was done with select(). select_fd() does now keep an own
open reference while selecting the events and add the select info
afterwards to the IO context (if the FD is still current).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25266 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f13ba039 12-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Removed SyscallRestartWrapper comparison operators. They are not
needed, since we've got a cast operator.
* Reverted r24927-r24929. There's no potential ambiguity anymore.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24949 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0cc82d47 12-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added close_fd_index() which is pretty much like close(), but gets the
IO context in which to close the FD.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24937 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6cb51e58 12-Apr-2008 Jérôme Duval <korli@users.berlios.de>

better cast to the good type to avoid confusing gcc


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24929 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b1459ca4 12-Apr-2008 Jérôme Duval <korli@users.berlios.de>

hmm I managed to break the comparaison order...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24928 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bdfe9237 12-Apr-2008 Jérôme Duval <korli@users.berlios.de>

gcc4 build fix. Here is one of the two errors:
src/system/kernel/fs/fd.cpp: In function 'ssize_t common_user_vector_io(int, off_t, const iovec*, size_t, bool)':
src/system/kernel/fs/fd.cpp:727: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the
second:
headers/private/kernel/syscall_restart.h:151: note: candidate 1: bool SyscallRestartWrapper<Type>::operator<(const Type&) const [with Type = long int]
src/system/kernel/fs/fd.cpp:727: note: candidate 2: operator<(long int, int) <built-in>


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24927 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 75015ff5 11-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed THREAD_FLAGS_IOCTL_SYSCALL to THREAD_FLAGS_SYSCALL,
syscall_restart_ioctl_is_restarted() to syscall_restart_is_restarted,
IoctlSyscallFlagUnsetter to SyscallFlagUnsetter, and
IoctlSyscallRestartWrapper to SyscallRestartWrapper, as they are no
longer only used for ioctl().
* Removed unused syscall_restart_ioctl_handle_post().
* Made SyscallRestartWrapper a lot fancier. Instead of storing a
reference to the result value, it stores the value itself, and it
features all the interesting operators that make it appear like that
value. This simplifies the use of the class quite a bit.
* THREAD_FLAGS_SYSCALL is now set for all socket function and the
read[v](), write[v]() syscalls.
* Added is_syscall() function and net_stack hook to the net stack.
* Removed "kernel" parameter from all net_stack_interface and net_socket
module hooks. They aren't need any longer, since is_syscall() can be
used instead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24914 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 08b2313e 10-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed some checks for user addresses. IS_KERNEL_ADDRESS is not the
same as !IS_USER_ADDRESS.
* Use the new IoctlSyscallFlagUnsetter helper class in _kern_ioctl().
The former implementation wasn't checking correctly for a previous
syscall flag.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24904 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 360be1fc 29-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Implemented support for chroot:
- Added a "root" vnode to the io_context. It is used for resolving
paths and converting nodes to paths instead of sRoot. Some more
passing around of io_context structures was necessary.
- Introduced a new lock sIOContextRootLock to protect
io_context::root. The current uses of io_context::io_mutex
(put_vnode(), remove_vnode() while holding it) looked too suspicious
to use that mutex in vnode_path_to_vnode().
- Added _kern_change_root() syscall and chroot() libroot function.
- Added chroot coreutils program to the image. Funnily it seems to be
much easier to set up a little jail than under Linux (just copy
bash and libroot.so into respective subdirs; mount another pipefs
if you want pipe support).
With Haiku allowing direct access to directories via inode IDs
jailing is obviously not very secure at the moment.
- Added /var/empty to the image. It will be the chroot target for ssh.
* Changed vfs.cpp:get_cwd() so that the io_context::io_mutex is no
longer held when calling dir_vnode_to_path().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24673 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4048494c 17-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
* Implemented automatic syscall restarts:
- A syscall can indicate that it has been interrupted and can be
restarted by setting a respective bit in thread::flags. It can
store parameters it wants to be preserved for the restart in
thread::syscall_restart::parameters. Another thread::flags bit
indicates whether it has been restarted.
- handle_signals() clears the restart flag, if the handled signal
has a handler function installed and SA_RESTART is not set. Another
thread flag (THREAD_FLAGS_DONT_RESTART_SYSCALL) can prevent syscalls
from being restarted, even if they could be (not used yet, but we
might want to use it in resume_thread(), so that we stay
behaviorally compatible with BeOS).
- The architecture specific syscall handler restarts the syscall, if
the restart flag is set. Implemented for x86 only.
- Added some support functions in the private <syscall_restart.h> to
simplify the syscall restart code in the syscalls.
- Adjusted all syscalls that can potentially be restarted accordingly.
- _user_ioctl() sets new thread flag THREAD_FLAGS_IOCTL_SYSCALL while
calling the underlying FS's/driver's hook, so that syscall restarts
can also be supported there.
* thread_at_kernel_exit() invokes handle_signals() in a loop now, as
long as the latter indicates that the thread shall be suspended, so
that after waking up signals received in the meantime will be handled
before the thread returns to userland. Adjusted handle_signals()
accordingly -- when encountering a suspending signal we don't check
for further signals.
* Fixed sigsuspend(): Suspending the thread and rescheduling doesn't
result in the correct behavior. Instead we employ a temporary
condition variable and interruptably wait on it. The POSIX test
suite test passes, now.
* Made the switch_sem[_etc]() behavior on interruption consistent.
Depending on when the signal arrived (before the call or when already
waiting) the first semaphore would or wouldn't be released. Now we
consistently release it.
* Refactored _user_{read,write}[v]() syscalls. Use a common function for
either pair. The iovec version doesn't fail anymore, if anything could
be read/written at all. It also checks whether a complete vector
could be read/written, so that we won't skip data, if the underlying
FS/driver couldn't read/write more ATM.
* Some refactoring in the x86 syscall handler: The int 99 and sysenter
handlers use a common subroutine to avoid code duplication.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23983 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5905a0ae 02-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed _{kern|user}_{read|write}[v]() functions to not move the descriptor's
file position in case an offset was specified.
* Reverted r23828-r23830 in File.cpp: don't fix the symptoms but the cause
of the problem (hey, that has to be in the kernel, right? :))
* Cleanup of File.cpp, removed OpenBeOS namespace.
* Moved user_fd_kernel_ioctl() to the section where it belongs to (that
function should be renamed, though).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23832 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 34b3b26b 10-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged branch haiku/branches/developer/bonefish/optimization revision
23139 into trunk, with roughly the following changes (for details svn
log the branch):
* The int 99 syscall handler is now fully in assembly.
* Added a sysenter/sysexit handler and use it on Pentiums that support
it (via commpage).
* Got rid of i386_handle_trap(). A bit of functionality was moved into
the assembly handler which now uses a jump table to call C functions
handling the respective interrupt.
* Some optimizations to get user debugger support code out of the
interrupt handling path.
* Introduced a thread::flags fields which allows to skip handling of
rare events (signals, user debug enabling/disabling) on the
common interrupt handling path.
* Got rid of the explicit iframe stack. The iframes can still be
retrieved by iterating through the stack frames.
* Made the commpage an architecture independent feature. It's used for
the real time data stuff (instead of creating a separate area).
* The x86 CPU modules can now provide processor optimized versions for
common functions (currently memcpy() only). They are used in the
kernel and are provided to the userland via commpage entries.
* Introduced build system feature allowing easy use of C structure
member offsets in assembly code.

Changes after merging:
* Fixed merge conflict in src/system/kernel/arch/x86/arch_debug.cpp
(caused by refactoring and introduction of "call" debugger command).



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23370 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 636bfc08 02-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed fs/vfs_select.cpp to wait_for_objects.cpp and got rid of
vfs_select.h, respectively moved most of it into the new kernel
private header wait_for_objects.h.
* Added new experimental API functions wait_for_objects[_etc](). They
work pretty much like poll(), but also for semaphores, ports, and
threads.
* Removed the "ref" parameter from notify_select_events() and the
select_sync_pool functions as well as from fd_ops::fd_[de]select(). It
is no longer needed. The FS interface select() hook still has it,
though -- the VFS will always pass 0.
* de]select_fd() take a select_info* instead of a select_sync* + ref
pair, now. Added respective functions for semaphores, ports, and
threads.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22416 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1c118ebc 01-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added a handy FDGetter AutoLocker-style class.
* In select_fd(): First get the file descriptor, then check whether any
events have to be selected at all. This has the advantage that the
caller can interpret an error return code as invalid FD. Consequently
common_poll() no longer checks FD validity separately -- this was a
race condition.
* common_poll() always selects POLLERR and POLLHUP now, which it has to
do according to the specs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22400 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 66c03dc3 30-Sep-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* fd.c -> fd.cpp
* Reworked the select support:
- The io_context additionally stores a table of lists of select_infos,
which enables it to deselect events of a pending select() when
closing a FD. This prevents a race condition potentially causing a
write to stale memory.
- The opaque selectsync* passed to FSs is now actually a select_info*.
This was necessary, since the FDs deselect() hook (unlike the
select() hook) doesn't take a "ref" argument and deselecting a
single info (e.g. caused by a premature close()) was not possible.
The select() hook's "ref" argument has become superfluous.
- It should now be relatively easy to implement a poll_on_steroids()
that can also wait for objects other than FDs (e.g. semaphores,
ports, threads etc.).
* Set/reset the signal mask in common_select(). This makes pselect()
work as required.
* Reorganized vfs_resize_fd_table().



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22391 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a735bdebb94ce14c72f56204f022038de7a49e2f 31-Oct-2011 Michael Lotz <mmlr@mlotz.ch>

Align all filesystem relevant places to use B_UNSUPPORTED for unsupported
instead of a mix of B_NOT_SUPPORTED and B_UNSUPPORTED. This allows checking for
a specific error code. Probably one of those should be phased out...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43025 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 24df65921befcd0ad0c5c7866118f922da61cb96 11-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged signals-merge branch into trunk with the following changes:
* Reorganized the kernel locking related to threads and teams.
* We now discriminate correctly between process and thread signals. Signal
handlers have been moved to teams. Fixes #5679.
* Implemented real-time signal support, including signal queuing, SA_SIGINFO
support, sigqueue(), sigwaitinfo(), sigtimedwait(), waitid(), and the addition
of the real-time signal range. Closes #1935 and #2695.
* Gave SIGBUS a separate signal number. Fixes #6704.
* Implemented <time.h> clock and timer support, and fixed/completed alarm() and
[set]itimer(). Closes #5682.
* Implemented support for thread cancellation. Closes #5686.
* Moved send_signal() from <signal.h> to <OS.h>. Fixes #7554.
* Lots over smaller more or less related changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42116 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 548836e4f8294e7ec90734f8cd79da9a9daa08a5 02-Mar-2011 Jérôme Duval <korli@users.berlios.de>

* if ioctl hook wasn't found, now returns B_DEV_INVALID_IOCTL
* in case fd_ioctl() was about to return B_DEV_INVALID_IOCTL, translate to ENOTTY to satisfy #7279.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40787 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fa90700d74ece5006f554cdf0bffb9202c3a0a71 26-Feb-2011 Jérôme Duval <korli@users.berlios.de>

reverted r40686


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40699 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3116b031dc6fc1ebce93ee10b2d22fe3506ac5f6 25-Feb-2011 Jérôme Duval <korli@users.berlios.de>

FIONBIO and FIONREAD don't apply to directories, files, attributes: returns ENOTTY in these cases. This fixes #7279.
ENOTTY could also be replaced with a B_ error code.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40686 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4535495d80c86e19e2610e7444a4fcefe3e0f8e6 10-Jan-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged the signals branch into trunk, with these changes:
* The team and thread kernel structures have been renamed to Team and Thread
respectively and moved into the new BKernel namespace.
* Several (kernel add-on) sources have been converted from C to C++ since
private kernel headers are included that are no longer C compatible.

Changes after merging:
* Fixed gcc 2 build (warnings mainly in the scary firewire bus manager).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40196 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8e855d520a06880a32d7d481b8b9bab0b8359852 02-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Changed some POSIX error codes to native ones.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37842 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9d570af7c878ba30043b23e6dce5f3ae5578aa7c 24-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Changed the type of the "op" parameter of the fs_vnode_ops::ioctl() hook and
the _kern_ioctl() syscall from ulong to uint32.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36927 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 74fc3e9a8bc4831206f84209be224cad7792dc0e 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

bonefish+mmlr:
* Add file descriptor and IO context tracing.
* Some minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36272 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 57dc0e2a533bca0041a8a806b4f6afb7f3a9c626 15-Aug-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Changed the FD selection/deselection handling a bit:
* B_EVENT_INVALID is no longer passed to the FD's select()/deselect() hooks.
* Now we always attach the select info to the I/O context, even if no event has
been selected. The reasoning is that B_EVENT_INVALID is always automatically
selected and handled by the VFS, so we need the handle to notify on close().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32417 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7435db9ff0ca459441d8fe6f8b9eb64725de28e3 14-Aug-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* _user_read_dir(): Allocate a temporary heap buffer passed into the kernel
instead of using the user buffer. This frees the VFS and FS implementations
from handling user buffers.
* Adjusted fix_dirent() accordingly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32384 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f7a6506e0fc86667de44a90a438838787a2fe6b3 06-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Replaced all "status < B_OK" with != B_OK - this should make the VFS layer
more robust against broken (userland) file systems.
* 80 character column cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32184 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b538ceb816d1fe38a04b769f68c469ceda7b67e7 10-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Added dup_foreign_fd() to duplicate a FD from another team.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29468 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 43b2ca9108e66fb3f841f2c4fa102f83c6c5e5a0 02-Mar-2009 Axel Dörfler <axeld@pinc-software.de>

* Fixed wrong use of MutexLocker as pointed out by Korli - nice catch! This
could have caused a number of problems.
* Fixed coding style violation Ingo introduced.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29378 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d3e2a6d7cc52aba910620189e57b1ea56c1bf2b2 03-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed build with tracing enabled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26772 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a8f9741c8c2815234e87b78167738057b976b537 04-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

* Removed -Wno-unused from all KernelMergeObjects in kernel Jamfiles.
* Fixed most of the warnings resulting from that by removing actually not used
variables or moving declaration into the #IF. Left unused functions there
though, as I wouldn't know if they are supposed to be used again.
* Fixed two statements with no effect (clamping to MAX_ANCILLARY_DATA_LEN in
socket.cpp and unsetting fCounterSem in MessagingService.cpp).
* Some style cleanups.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26253 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cb734beeee7c27c72d7464d429fa67805619ba84 04-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added get_open_fd() function which gets the descriptor and also
increments its open count.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25317 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9981c81f8b726e3a028ec93e556dbe42e92ba528 29-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed a race condition between select_fd() and close(). Since
select_fd() first added the select info to the IO context and then
called select() on the descriptor, a close() called at the same time
could already deselect the events and close the descriptor before
select_fd() was done with select(). select_fd() does now keep an own
open reference while selecting the events and add the select info
afterwards to the IO context (if the FD is still current).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25266 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f13ba03959f6227a75ff8c2e129058215dea380f 12-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Removed SyscallRestartWrapper comparison operators. They are not
needed, since we've got a cast operator.
* Reverted r24927-r24929. There's no potential ambiguity anymore.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24949 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0cc82d47d4f8b425309b322bd55189479b16c670 12-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added close_fd_index() which is pretty much like close(), but gets the
IO context in which to close the FD.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24937 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6cb51e58bc5559117b23d35b19db8d3d1a3c7984 12-Apr-2008 Jérôme Duval <korli@users.berlios.de>

better cast to the good type to avoid confusing gcc


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24929 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b1459ca4b42514bfd40a887c9830f5b1c5ded016 12-Apr-2008 Jérôme Duval <korli@users.berlios.de>

hmm I managed to break the comparaison order...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24928 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bdfe92370fe472ae31c419e34d125c2db3e01569 12-Apr-2008 Jérôme Duval <korli@users.berlios.de>

gcc4 build fix. Here is one of the two errors:
src/system/kernel/fs/fd.cpp: In function 'ssize_t common_user_vector_io(int, off_t, const iovec*, size_t, bool)':
src/system/kernel/fs/fd.cpp:727: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the
second:
headers/private/kernel/syscall_restart.h:151: note: candidate 1: bool SyscallRestartWrapper<Type>::operator<(const Type&) const [with Type = long int]
src/system/kernel/fs/fd.cpp:727: note: candidate 2: operator<(long int, int) <built-in>


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24927 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 75015ff525050d1d716f499732c566956c6078ad 11-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed THREAD_FLAGS_IOCTL_SYSCALL to THREAD_FLAGS_SYSCALL,
syscall_restart_ioctl_is_restarted() to syscall_restart_is_restarted,
IoctlSyscallFlagUnsetter to SyscallFlagUnsetter, and
IoctlSyscallRestartWrapper to SyscallRestartWrapper, as they are no
longer only used for ioctl().
* Removed unused syscall_restart_ioctl_handle_post().
* Made SyscallRestartWrapper a lot fancier. Instead of storing a
reference to the result value, it stores the value itself, and it
features all the interesting operators that make it appear like that
value. This simplifies the use of the class quite a bit.
* THREAD_FLAGS_SYSCALL is now set for all socket function and the
read[v](), write[v]() syscalls.
* Added is_syscall() function and net_stack hook to the net stack.
* Removed "kernel" parameter from all net_stack_interface and net_socket
module hooks. They aren't need any longer, since is_syscall() can be
used instead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24914 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 08b2313e704df73d3ac33ace0bab05f221cea518 10-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed some checks for user addresses. IS_KERNEL_ADDRESS is not the
same as !IS_USER_ADDRESS.
* Use the new IoctlSyscallFlagUnsetter helper class in _kern_ioctl().
The former implementation wasn't checking correctly for a previous
syscall flag.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24904 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 360be1fc45416df27312c38d2268b466621bbae7 29-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Implemented support for chroot:
- Added a "root" vnode to the io_context. It is used for resolving
paths and converting nodes to paths instead of sRoot. Some more
passing around of io_context structures was necessary.
- Introduced a new lock sIOContextRootLock to protect
io_context::root. The current uses of io_context::io_mutex
(put_vnode(), remove_vnode() while holding it) looked too suspicious
to use that mutex in vnode_path_to_vnode().
- Added _kern_change_root() syscall and chroot() libroot function.
- Added chroot coreutils program to the image. Funnily it seems to be
much easier to set up a little jail than under Linux (just copy
bash and libroot.so into respective subdirs; mount another pipefs
if you want pipe support).
With Haiku allowing direct access to directories via inode IDs
jailing is obviously not very secure at the moment.
- Added /var/empty to the image. It will be the chroot target for ssh.
* Changed vfs.cpp:get_cwd() so that the io_context::io_mutex is no
longer held when calling dir_vnode_to_path().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24673 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4048494ce44a925d3d1e40e4ffb9abe670b4b827 17-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
* Implemented automatic syscall restarts:
- A syscall can indicate that it has been interrupted and can be
restarted by setting a respective bit in thread::flags. It can
store parameters it wants to be preserved for the restart in
thread::syscall_restart::parameters. Another thread::flags bit
indicates whether it has been restarted.
- handle_signals() clears the restart flag, if the handled signal
has a handler function installed and SA_RESTART is not set. Another
thread flag (THREAD_FLAGS_DONT_RESTART_SYSCALL) can prevent syscalls
from being restarted, even if they could be (not used yet, but we
might want to use it in resume_thread(), so that we stay
behaviorally compatible with BeOS).
- The architecture specific syscall handler restarts the syscall, if
the restart flag is set. Implemented for x86 only.
- Added some support functions in the private <syscall_restart.h> to
simplify the syscall restart code in the syscalls.
- Adjusted all syscalls that can potentially be restarted accordingly.
- _user_ioctl() sets new thread flag THREAD_FLAGS_IOCTL_SYSCALL while
calling the underlying FS's/driver's hook, so that syscall restarts
can also be supported there.
* thread_at_kernel_exit() invokes handle_signals() in a loop now, as
long as the latter indicates that the thread shall be suspended, so
that after waking up signals received in the meantime will be handled
before the thread returns to userland. Adjusted handle_signals()
accordingly -- when encountering a suspending signal we don't check
for further signals.
* Fixed sigsuspend(): Suspending the thread and rescheduling doesn't
result in the correct behavior. Instead we employ a temporary
condition variable and interruptably wait on it. The POSIX test
suite test passes, now.
* Made the switch_sem[_etc]() behavior on interruption consistent.
Depending on when the signal arrived (before the call or when already
waiting) the first semaphore would or wouldn't be released. Now we
consistently release it.
* Refactored _user_{read,write}[v]() syscalls. Use a common function for
either pair. The iovec version doesn't fail anymore, if anything could
be read/written at all. It also checks whether a complete vector
could be read/written, so that we won't skip data, if the underlying
FS/driver couldn't read/write more ATM.
* Some refactoring in the x86 syscall handler: The int 99 and sysenter
handlers use a common subroutine to avoid code duplication.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23983 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5905a0ae344fb132d1db6ff509219e286c777aa6 02-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed _{kern|user}_{read|write}[v]() functions to not move the descriptor's
file position in case an offset was specified.
* Reverted r23828-r23830 in File.cpp: don't fix the symptoms but the cause
of the problem (hey, that has to be in the kernel, right? :))
* Cleanup of File.cpp, removed OpenBeOS namespace.
* Moved user_fd_kernel_ioctl() to the section where it belongs to (that
function should be renamed, though).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23832 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 34b3b26b3b8c46ba46ddde037b10dd173f4936d6 10-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged branch haiku/branches/developer/bonefish/optimization revision
23139 into trunk, with roughly the following changes (for details svn
log the branch):
* The int 99 syscall handler is now fully in assembly.
* Added a sysenter/sysexit handler and use it on Pentiums that support
it (via commpage).
* Got rid of i386_handle_trap(). A bit of functionality was moved into
the assembly handler which now uses a jump table to call C functions
handling the respective interrupt.
* Some optimizations to get user debugger support code out of the
interrupt handling path.
* Introduced a thread::flags fields which allows to skip handling of
rare events (signals, user debug enabling/disabling) on the
common interrupt handling path.
* Got rid of the explicit iframe stack. The iframes can still be
retrieved by iterating through the stack frames.
* Made the commpage an architecture independent feature. It's used for
the real time data stuff (instead of creating a separate area).
* The x86 CPU modules can now provide processor optimized versions for
common functions (currently memcpy() only). They are used in the
kernel and are provided to the userland via commpage entries.
* Introduced build system feature allowing easy use of C structure
member offsets in assembly code.

Changes after merging:
* Fixed merge conflict in src/system/kernel/arch/x86/arch_debug.cpp
(caused by refactoring and introduction of "call" debugger command).



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23370 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 636bfc08aeaaa7f1bab813c5aa2e8e666b40ec64 02-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed fs/vfs_select.cpp to wait_for_objects.cpp and got rid of
vfs_select.h, respectively moved most of it into the new kernel
private header wait_for_objects.h.
* Added new experimental API functions wait_for_objects[_etc](). They
work pretty much like poll(), but also for semaphores, ports, and
threads.
* Removed the "ref" parameter from notify_select_events() and the
select_sync_pool functions as well as from fd_ops::fd_[de]select(). It
is no longer needed. The FS interface select() hook still has it,
though -- the VFS will always pass 0.
* de]select_fd() take a select_info* instead of a select_sync* + ref
pair, now. Added respective functions for semaphores, ports, and
threads.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22416 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1c118ebc62d7c9c89200523db98ba4fccd525d6b 01-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added a handy FDGetter AutoLocker-style class.
* In select_fd(): First get the file descriptor, then check whether any
events have to be selected at all. This has the advantage that the
caller can interpret an error return code as invalid FD. Consequently
common_poll() no longer checks FD validity separately -- this was a
race condition.
* common_poll() always selects POLLERR and POLLHUP now, which it has to
do according to the specs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22400 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 66c03dc3a92b84f0320b1c350238396cdf203cc7 30-Sep-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* fd.c -> fd.cpp
* Reworked the select support:
- The io_context additionally stores a table of lists of select_infos,
which enables it to deselect events of a pending select() when
closing a FD. This prevents a race condition potentially causing a
write to stale memory.
- The opaque selectsync* passed to FSs is now actually a select_info*.
This was necessary, since the FDs deselect() hook (unlike the
select() hook) doesn't take a "ref" argument and deselecting a
single info (e.g. caused by a premature close()) was not possible.
The select() hook's "ref" argument has become superfluous.
- It should now be relatively easy to implement a poll_on_steroids()
that can also wait for objects other than FDs (e.g. semaphores,
ports, threads etc.).
* Set/reset the signal mask in common_select(). This makes pselect()
work as required.
* Reorganized vfs_resize_fd_table().



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22391 a95241bf-73f2-0310-859d-f6bbb57e9c96