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:
Ingo Weinhold 2008-05-05 00:24:14 +00:00
parent 1571aa7ff9
commit cb734beeee
2 changed files with 16 additions and 0 deletions

View File

@ -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);

View File

@ -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.
*/