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
This commit is contained in:
Ingo Weinhold
2008-04-12 08:32:29 +00:00
parent ac4630e161
commit 0cc82d47d4
2 changed files with 19 additions and 16 deletions
+18 -16
View File
@@ -31,6 +31,7 @@
static struct file_descriptor* get_fd_locked(struct io_context* context,
int fd);
static struct file_descriptor *remove_fd(struct io_context *context, int fd);
static void deselect_select_infos(file_descriptor* descriptor,
select_info* infos);
@@ -236,6 +237,22 @@ close_fd(struct file_descriptor *descriptor)
}
status_t
close_fd_index(struct io_context *context, int fd)
{
struct file_descriptor *descriptor = remove_fd(context, fd);
if (descriptor == NULL)
return B_FILE_ERROR;
close_fd(descriptor);
put_fd(descriptor);
// the reference associated with the slot
return B_OK;
}
/** This descriptor's underlying object will be closed and freed
* as soon as possible (in one of the next calls to put_fd() -
* get_fd() will no longer succeed on this descriptor).
@@ -602,22 +619,7 @@ fd_vnode(struct file_descriptor *descriptor)
static status_t
common_close(int fd, bool kernel)
{
struct io_context *io = get_current_io_context(kernel);
struct file_descriptor *descriptor = remove_fd(io, fd);
if (descriptor == NULL)
return B_FILE_ERROR;
#ifdef TRACE_FD
if (!kernel)
TRACE(("_user_close(descriptor = %p)\n", descriptor));
#endif
close_fd(descriptor);
put_fd(descriptor);
// the reference associated with the slot
return B_OK;
return close_fd_index(get_current_io_context(kernel), fd);
}