From b55be0692fa0b50c364c45fc440e3a622c495858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sat, 19 Mar 2005 03:22:34 +0000 Subject: [PATCH] Fixed a copy&paste error that prevented _user_close() from working correctly (it would have closed kernel file descriptors instead...). Updated/improved docs a bit. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@11917 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/fs/fd.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/kernel/core/fs/fd.c b/src/kernel/core/fs/fd.c index 8e1dbe4c90..08822c28e0 100644 --- a/src/kernel/core/fs/fd.c +++ b/src/kernel/core/fs/fd.c @@ -62,6 +62,10 @@ alloc_fd(void) } +/** Searches a free slot in the FD table of the provided I/O context, and inserts + * the specified descriptor into it. + */ + int new_fd_etc(struct io_context *context, struct file_descriptor *descriptor, int firstIndex) { @@ -99,7 +103,7 @@ new_fd(struct io_context *context, struct file_descriptor *descriptor) /** Reduces the descriptor's reference counter, and frees all resources - * if necessary. + * when it's no longer used. */ void @@ -118,6 +122,10 @@ put_fd(struct file_descriptor *descriptor) } +/** Decrements the open counter of the file descriptor and invokes + * its close hook when appropriate. + */ + void close_fd(struct file_descriptor *descriptor) { @@ -150,7 +158,7 @@ get_fd(struct io_context *context, int fd) } -/** Removes the file descriptor in the specified slot. +/** Removes the file descriptor from the specified slot. */ static struct file_descriptor * @@ -332,7 +340,7 @@ common_close(int fd, bool kernel) // #pragma mark - -/*** USER routines ***/ +// User syscalls ssize_t @@ -621,7 +629,7 @@ _user_rewind_dir(int fd) status_t _user_close(int fd) { - return common_close(fd, true); + return common_close(fd, false); } @@ -640,7 +648,7 @@ _user_dup2(int ofd, int nfd) // #pragma mark - -/*** SYSTEM functions ***/ +// Kernel calls ssize_t