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:
@@ -80,6 +80,7 @@ extern int new_fd_etc(struct io_context *, struct file_descriptor *, int firstIn
|
|||||||
extern int new_fd(struct io_context *, struct file_descriptor *);
|
extern int new_fd(struct io_context *, struct file_descriptor *);
|
||||||
extern struct file_descriptor *get_fd(struct io_context *, int);
|
extern struct file_descriptor *get_fd(struct io_context *, int);
|
||||||
extern void close_fd(struct file_descriptor *descriptor);
|
extern void close_fd(struct file_descriptor *descriptor);
|
||||||
|
extern status_t close_fd_index(struct io_context *context, int fd);
|
||||||
extern void put_fd(struct file_descriptor *descriptor);
|
extern void put_fd(struct file_descriptor *descriptor);
|
||||||
extern void disconnect_fd(struct file_descriptor *descriptor);
|
extern void disconnect_fd(struct file_descriptor *descriptor);
|
||||||
extern void inc_fd_ref_count(struct file_descriptor *descriptor);
|
extern void inc_fd_ref_count(struct file_descriptor *descriptor);
|
||||||
|
|||||||
+18
-16
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
static struct file_descriptor* get_fd_locked(struct io_context* context,
|
static struct file_descriptor* get_fd_locked(struct io_context* context,
|
||||||
int fd);
|
int fd);
|
||||||
|
static struct file_descriptor *remove_fd(struct io_context *context, int fd);
|
||||||
static void deselect_select_infos(file_descriptor* descriptor,
|
static void deselect_select_infos(file_descriptor* descriptor,
|
||||||
select_info* infos);
|
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
|
/** This descriptor's underlying object will be closed and freed
|
||||||
* as soon as possible (in one of the next calls to put_fd() -
|
* as soon as possible (in one of the next calls to put_fd() -
|
||||||
* get_fd() will no longer succeed on this descriptor).
|
* get_fd() will no longer succeed on this descriptor).
|
||||||
@@ -602,22 +619,7 @@ fd_vnode(struct file_descriptor *descriptor)
|
|||||||
static status_t
|
static status_t
|
||||||
common_close(int fd, bool kernel)
|
common_close(int fd, bool kernel)
|
||||||
{
|
{
|
||||||
struct io_context *io = get_current_io_context(kernel);
|
return close_fd_index(get_current_io_context(kernel), fd);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user