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
This commit is contained in:
parent
1571aa7ff9
commit
cb734beeee
@ -79,6 +79,7 @@ extern struct file_descriptor *alloc_fd(void);
|
||||
extern int new_fd_etc(struct io_context *, struct file_descriptor *, int firstIndex);
|
||||
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_open_fd(struct io_context *, int);
|
||||
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);
|
||||
|
@ -303,6 +303,21 @@ get_fd(struct io_context *context, int fd)
|
||||
}
|
||||
|
||||
|
||||
struct file_descriptor *
|
||||
get_open_fd(struct io_context *context, int fd)
|
||||
{
|
||||
MutexLocker(context->io_mutex);
|
||||
|
||||
file_descriptor *descriptor = get_fd_locked(context, fd);
|
||||
if (descriptor == NULL)
|
||||
return NULL;
|
||||
|
||||
atomic_add(&descriptor->open_count, 1);
|
||||
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
|
||||
/** Removes the file descriptor from the specified slot.
|
||||
*/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user