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:
+18
-16
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user