2002-08-10 00:48:30 +04:00
|
|
|
/* Operations on file descriptors
|
|
|
|
**
|
2004-06-15 19:28:33 +04:00
|
|
|
** Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
2002-08-10 00:48:30 +04:00
|
|
|
** Distributed under the terms of the OpenBeOS License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <fd.h>
|
2002-09-30 07:31:42 +04:00
|
|
|
|
|
|
|
#include <OS.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <Errors.h>
|
2002-09-30 07:31:42 +04:00
|
|
|
|
|
|
|
#include <vfs.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <debug.h>
|
2002-09-30 07:31:42 +04:00
|
|
|
|
2002-10-30 02:07:06 +03:00
|
|
|
#include <malloc.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
2004-06-15 19:28:33 +04:00
|
|
|
//#define TRACE_FD
|
|
|
|
#ifdef TRACE_FD
|
2002-07-17 11:55:51 +04:00
|
|
|
# define TRACE(x) dprintf x
|
|
|
|
# define PRINT(x) dprintf x
|
|
|
|
#else
|
|
|
|
# define TRACE(x)
|
|
|
|
# define PRINT(x)
|
|
|
|
#endif
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*** General fd routines ***/
|
|
|
|
|
|
|
|
|
2002-07-17 11:55:51 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
void dump_fd(int fd, struct file_descriptor *descriptor);
|
|
|
|
|
|
|
|
void
|
|
|
|
dump_fd(int fd,struct file_descriptor *descriptor)
|
|
|
|
{
|
2002-11-28 17:41:06 +03:00
|
|
|
dprintf("fd[%d] = %p: type = %ld, ref_count = %ld, ops = %p, u.vnode = %p, u.mount = %p, cookie = %p, open_mode = %lx, pos = %Ld\n",
|
2002-09-30 07:31:42 +04:00
|
|
|
fd, descriptor, descriptor->type, descriptor->ref_count, descriptor->ops,
|
2002-11-28 17:41:06 +03:00
|
|
|
descriptor->u.vnode, descriptor->u.mount, descriptor->cookie, descriptor->open_mode, descriptor->pos);
|
2002-07-17 11:55:51 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
/** Allocates and initializes a new file_descriptor */
|
|
|
|
|
|
|
|
struct file_descriptor *
|
|
|
|
alloc_fd(void)
|
|
|
|
{
|
2002-08-05 09:37:17 +04:00
|
|
|
struct file_descriptor *descriptor;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-10-30 02:07:06 +03:00
|
|
|
descriptor = malloc(sizeof(struct file_descriptor));
|
2002-08-05 09:37:17 +04:00
|
|
|
if (descriptor == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2002-09-26 07:52:10 +04:00
|
|
|
descriptor->u.vnode = NULL;
|
2002-08-05 09:37:17 +04:00
|
|
|
descriptor->cookie = NULL;
|
|
|
|
descriptor->ref_count = 1;
|
|
|
|
descriptor->open_mode = 0;
|
2002-10-08 04:42:17 +04:00
|
|
|
descriptor->pos = 0;
|
2002-08-05 09:37:17 +04:00
|
|
|
|
|
|
|
return descriptor;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2002-07-20 04:16:12 +04:00
|
|
|
new_fd(struct io_context *context, struct file_descriptor *descriptor)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
int fd = -1;
|
2003-09-04 08:20:42 +04:00
|
|
|
uint32 i;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-07-20 04:16:12 +04:00
|
|
|
mutex_lock(&context->io_mutex);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-07-20 04:16:12 +04:00
|
|
|
for (i = 0; i < context->table_size; i++) {
|
|
|
|
if (!context->fds[i]) {
|
2002-07-09 16:24:59 +04:00
|
|
|
fd = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fd < 0) {
|
2002-10-08 07:24:51 +04:00
|
|
|
fd = B_NO_MORE_FDS;
|
2002-07-09 16:24:59 +04:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2002-07-20 04:16:12 +04:00
|
|
|
context->fds[fd] = descriptor;
|
|
|
|
context->num_used_fds++;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
err:
|
2002-07-20 04:16:12 +04:00
|
|
|
mutex_unlock(&context->io_mutex);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
return fd;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-30 07:31:42 +04:00
|
|
|
/** Reduces the descriptor's reference counter, and frees all resources
|
|
|
|
* if necessary.
|
|
|
|
*/
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
void
|
2002-07-17 11:55:51 +04:00
|
|
|
put_fd(struct file_descriptor *descriptor)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2003-06-28 08:23:24 +04:00
|
|
|
TRACE(("put_fd(descriptor = %p [ref = %ld, cookie = %p])\n", descriptor, descriptor->ref_count, descriptor->cookie));
|
|
|
|
|
2002-09-30 07:31:42 +04:00
|
|
|
// free the descriptor if we don't need it anymore
|
2002-07-17 11:55:51 +04:00
|
|
|
if (atomic_add(&descriptor->ref_count, -1) == 1) {
|
2003-06-28 08:23:24 +04:00
|
|
|
// close the underlying object (and free any resources allocated there)
|
2002-07-17 11:55:51 +04:00
|
|
|
if (descriptor->ops->fd_close)
|
|
|
|
descriptor->ops->fd_close(descriptor);
|
|
|
|
if (descriptor->ops->fd_free)
|
|
|
|
descriptor->ops->fd_free(descriptor);
|
|
|
|
|
2002-10-30 02:07:06 +03:00
|
|
|
free(descriptor);
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct file_descriptor *
|
2002-07-20 04:16:12 +04:00
|
|
|
get_fd(struct io_context *context, int fd)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2002-07-20 04:16:12 +04:00
|
|
|
struct file_descriptor *descriptor = NULL;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-07-20 04:16:12 +04:00
|
|
|
if (fd < 0)
|
|
|
|
return NULL;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-07-20 04:16:12 +04:00
|
|
|
mutex_lock(&context->io_mutex);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-09-04 08:20:42 +04:00
|
|
|
if ((uint32)fd < context->table_size)
|
2002-07-20 04:16:12 +04:00
|
|
|
descriptor = context->fds[fd];
|
|
|
|
|
|
|
|
if (descriptor != NULL) // fd is valid
|
|
|
|
atomic_add(&descriptor->ref_count, 1);
|
2002-07-17 11:55:51 +04:00
|
|
|
|
2002-07-20 04:16:12 +04:00
|
|
|
mutex_unlock(&context->io_mutex);
|
|
|
|
|
|
|
|
return descriptor;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-30 07:31:42 +04:00
|
|
|
/** Removes the file descriptor in the specified slot, and
|
|
|
|
* reduces its reference counter.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2002-07-20 04:16:12 +04:00
|
|
|
remove_fd(struct io_context *context, int fd)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2002-07-20 04:16:12 +04:00
|
|
|
struct file_descriptor *descriptor = NULL;
|
|
|
|
|
|
|
|
if (fd < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mutex_lock(&context->io_mutex);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-09-04 08:20:42 +04:00
|
|
|
if ((uint32)fd < context->table_size)
|
2002-07-20 04:16:12 +04:00
|
|
|
descriptor = context->fds[fd];
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-07-20 04:16:12 +04:00
|
|
|
if (descriptor) { // fd is valid
|
|
|
|
context->fds[fd] = NULL;
|
|
|
|
context->num_used_fds--;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2002-07-20 04:16:12 +04:00
|
|
|
mutex_unlock(&context->io_mutex);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-07-20 04:16:12 +04:00
|
|
|
if (descriptor)
|
|
|
|
put_fd(descriptor);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2002-10-29 06:54:07 +03:00
|
|
|
dup_fd(int fd, bool kernel)
|
2002-07-20 04:16:12 +04:00
|
|
|
{
|
|
|
|
struct io_context *context = get_current_io_context(kernel);
|
|
|
|
struct file_descriptor *descriptor;
|
|
|
|
int status;
|
|
|
|
|
2002-10-29 06:54:07 +03:00
|
|
|
TRACE(("dup_fd: fd = %d\n", fd));
|
2002-07-20 04:16:12 +04:00
|
|
|
|
|
|
|
// Try to get the fd structure
|
|
|
|
descriptor = get_fd(context, fd);
|
|
|
|
if (descriptor == NULL)
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-07-20 04:16:12 +04:00
|
|
|
|
|
|
|
// now put the fd in place
|
|
|
|
status = new_fd(context, descriptor);
|
|
|
|
if (status < 0)
|
|
|
|
put_fd(descriptor);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2002-10-29 06:54:07 +03:00
|
|
|
dup2_fd(int oldfd, int newfd, bool kernel)
|
2002-07-20 04:16:12 +04:00
|
|
|
{
|
|
|
|
struct file_descriptor *evicted = NULL;
|
|
|
|
struct io_context *context;
|
|
|
|
|
2002-10-29 06:54:07 +03:00
|
|
|
TRACE(("dup2_fd: ofd = %d, nfd = %d\n", oldfd, newfd));
|
2002-07-20 04:16:12 +04:00
|
|
|
|
|
|
|
// quick check
|
|
|
|
if (oldfd < 0 || newfd < 0)
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-07-20 04:16:12 +04:00
|
|
|
|
|
|
|
// Get current I/O context and lock it
|
|
|
|
context = get_current_io_context(kernel);
|
|
|
|
mutex_lock(&context->io_mutex);
|
|
|
|
|
|
|
|
// Check if the fds are valid (mutex must be locked because
|
|
|
|
// the table size could be changed)
|
2003-09-04 08:20:42 +04:00
|
|
|
if ((uint32)oldfd >= context->table_size
|
|
|
|
|| (uint32)newfd >= context->table_size
|
2002-07-20 04:16:12 +04:00
|
|
|
|| context->fds[oldfd] == NULL) {
|
|
|
|
mutex_unlock(&context->io_mutex);
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-07-20 04:16:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check for identity, note that it cannot be made above
|
|
|
|
// because we always want to return an error on invalid
|
|
|
|
// handles
|
|
|
|
if (oldfd != newfd) {
|
|
|
|
// Now do the work
|
|
|
|
evicted = context->fds[newfd];
|
|
|
|
atomic_add(&context->fds[oldfd]->ref_count, 1);
|
2002-09-02 18:57:33 +04:00
|
|
|
context->fds[newfd] = context->fds[oldfd];
|
2002-07-20 04:16:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
mutex_unlock(&context->io_mutex);
|
|
|
|
|
|
|
|
// Say bye bye to the evicted fd
|
|
|
|
if (evicted)
|
|
|
|
put_fd(evicted);
|
|
|
|
|
|
|
|
return newfd;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-29 06:54:07 +03:00
|
|
|
status_t
|
|
|
|
select_fd(int fd, uint8 event, uint32 ref, struct select_sync *sync, bool kernel)
|
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor;
|
|
|
|
status_t status;
|
|
|
|
|
2002-11-03 06:19:34 +03:00
|
|
|
TRACE(("select_fd(fd = %d, event = %u, ref = %lu, selectsync = %p)\n", fd, event, ref, sync));
|
2002-10-29 06:54:07 +03:00
|
|
|
|
|
|
|
descriptor = get_fd(get_current_io_context(kernel), fd);
|
|
|
|
if (descriptor == NULL)
|
|
|
|
return B_FILE_ERROR;
|
|
|
|
|
|
|
|
if (descriptor->ops->fd_select) {
|
|
|
|
status = descriptor->ops->fd_select(descriptor, event, ref, sync);
|
|
|
|
} else {
|
|
|
|
// if the I/O subsystem doesn't support select(), we will
|
|
|
|
// immediately notify the select call
|
2002-11-03 06:19:34 +03:00
|
|
|
status = notify_select_event((void *)sync, ref, event);
|
2002-10-29 06:54:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
put_fd(descriptor);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
deselect_fd(int fd, uint8 event, struct select_sync *sync, bool kernel)
|
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor;
|
|
|
|
status_t status;
|
|
|
|
|
2002-11-03 06:19:34 +03:00
|
|
|
TRACE(("deselect_fd(fd = %d, event = %u, selectsync = %p)\n", fd, event, sync));
|
2002-10-29 06:54:07 +03:00
|
|
|
|
|
|
|
descriptor = get_fd(get_current_io_context(kernel), fd);
|
|
|
|
if (descriptor == NULL)
|
|
|
|
return B_FILE_ERROR;
|
|
|
|
|
|
|
|
if (descriptor->ops->fd_deselect)
|
|
|
|
status = descriptor->ops->fd_deselect(descriptor, event, sync);
|
|
|
|
else
|
|
|
|
status = B_OK;
|
|
|
|
|
|
|
|
put_fd(descriptor);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** This function checks if the specified fd is valid in the current
|
|
|
|
* context. It can be used for a quick check; the fd is not locked
|
|
|
|
* so it could become invalid immediately after this check.
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool
|
|
|
|
fd_is_valid(int fd, bool kernel)
|
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor = get_fd(get_current_io_context(kernel), fd);
|
|
|
|
if (descriptor == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
put_fd(descriptor);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
// #pragma mark -
|
|
|
|
/*** USER routines ***/
|
|
|
|
|
|
|
|
|
|
|
|
ssize_t
|
2004-06-15 19:28:33 +04:00
|
|
|
_user_read(int fd, off_t pos, void *buffer, size_t length)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor;
|
2004-06-15 19:28:33 +04:00
|
|
|
ssize_t bytesRead;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
/* This is a user_function, so abort if we have a kernel address */
|
2004-02-22 17:52:59 +03:00
|
|
|
if (!IS_USER_ADDRESS(buffer))
|
2002-10-29 06:54:07 +03:00
|
|
|
return B_BAD_ADDRESS;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
descriptor = get_fd(get_current_io_context(false), fd);
|
|
|
|
if (!descriptor)
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-06-15 19:28:33 +04:00
|
|
|
if (pos == -1)
|
|
|
|
pos = descriptor->pos;
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
if (descriptor->ops->fd_read) {
|
2004-06-15 19:28:33 +04:00
|
|
|
bytesRead = descriptor->ops->fd_read(descriptor, pos, buffer, &length);
|
|
|
|
if (bytesRead >= B_OK) {
|
|
|
|
if (length > 0x7fffffff)
|
|
|
|
bytesRead = 0x7fffffff;
|
|
|
|
else
|
|
|
|
bytesRead = (ssize_t)length;
|
|
|
|
|
|
|
|
descriptor->pos = pos + length;
|
|
|
|
}
|
2002-07-09 16:24:59 +04:00
|
|
|
} else
|
2004-06-15 19:28:33 +04:00
|
|
|
bytesRead = B_BAD_VALUE;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
put_fd(descriptor);
|
2004-06-15 19:28:33 +04:00
|
|
|
return bytesRead;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ssize_t
|
2004-06-15 19:28:33 +04:00
|
|
|
_user_write(int fd, off_t pos, const void *buffer, size_t length)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor;
|
2004-06-15 19:28:33 +04:00
|
|
|
ssize_t bytesWritten = 0;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-06-15 19:28:33 +04:00
|
|
|
if (IS_KERNEL_ADDRESS(buffer))
|
|
|
|
return B_BAD_ADDRESS;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
descriptor = get_fd(get_current_io_context(false), fd);
|
|
|
|
if (!descriptor)
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-06-15 19:28:33 +04:00
|
|
|
if (pos == -1)
|
|
|
|
pos = descriptor->pos;
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
if (descriptor->ops->fd_write) {
|
2004-06-15 19:28:33 +04:00
|
|
|
bytesWritten = descriptor->ops->fd_write(descriptor, pos, buffer, &length);
|
|
|
|
if (bytesWritten >= B_OK) {
|
|
|
|
if (length > 0x7fffffff)
|
|
|
|
bytesWritten = 0x7fffffff;
|
|
|
|
else
|
|
|
|
bytesWritten = (ssize_t)length;
|
|
|
|
|
|
|
|
descriptor->pos = pos + length;
|
|
|
|
}
|
2002-07-09 16:24:59 +04:00
|
|
|
} else
|
2004-06-15 19:28:33 +04:00
|
|
|
bytesWritten = B_BAD_VALUE;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
put_fd(descriptor);
|
2004-06-15 19:28:33 +04:00
|
|
|
return bytesWritten;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-17 11:55:51 +04:00
|
|
|
off_t
|
2004-06-15 19:28:33 +04:00
|
|
|
_user_seek(int fd, off_t pos, int seekType)
|
2002-07-14 09:15:34 +04:00
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor;
|
|
|
|
|
|
|
|
descriptor = get_fd(get_current_io_context(false), fd);
|
|
|
|
if (!descriptor)
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-07-14 09:15:34 +04:00
|
|
|
|
2002-10-29 06:54:07 +03:00
|
|
|
TRACE(("user_seek(descriptor = %p)\n", descriptor));
|
2002-07-17 11:55:51 +04:00
|
|
|
|
2002-07-14 09:15:34 +04:00
|
|
|
if (descriptor->ops->fd_seek)
|
2002-07-17 11:55:51 +04:00
|
|
|
pos = descriptor->ops->fd_seek(descriptor, pos, seekType);
|
2002-07-14 09:15:34 +04:00
|
|
|
else
|
2002-07-17 11:55:51 +04:00
|
|
|
pos = ESPIPE;
|
2002-07-14 09:15:34 +04:00
|
|
|
|
|
|
|
put_fd(descriptor);
|
2002-07-17 11:55:51 +04:00
|
|
|
return pos;
|
2002-07-14 09:15:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-15 19:28:33 +04:00
|
|
|
status_t
|
|
|
|
_user_ioctl(int fd, ulong op, void *buffer, size_t length)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor;
|
|
|
|
int status;
|
|
|
|
|
2004-06-15 19:28:33 +04:00
|
|
|
if (IS_KERNEL_ADDRESS(buffer))
|
|
|
|
return B_BAD_ADDRESS;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
PRINT(("user_ioctl: fd %d\n", fd));
|
|
|
|
|
|
|
|
descriptor = get_fd(get_current_io_context(false), fd);
|
|
|
|
if (!descriptor)
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
if (descriptor->ops->fd_ioctl)
|
|
|
|
status = descriptor->ops->fd_ioctl(descriptor, op, buffer, length);
|
|
|
|
else
|
|
|
|
status = EOPNOTSUPP;
|
|
|
|
|
2002-07-14 09:15:34 +04:00
|
|
|
put_fd(descriptor);
|
2002-07-09 16:24:59 +04:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ssize_t
|
2004-06-15 19:28:33 +04:00
|
|
|
_user_read_dir(int fd, struct dirent *buffer, size_t bufferSize, uint32 maxCount)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor;
|
|
|
|
ssize_t retval;
|
|
|
|
|
2004-06-15 19:28:33 +04:00
|
|
|
if (IS_KERNEL_ADDRESS(buffer))
|
|
|
|
return B_BAD_ADDRESS;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-11-03 06:19:34 +03:00
|
|
|
PRINT(("user_read_dir(fd = %d, buffer = %p, bufferSize = %ld, count = %lu)\n", fd, buffer, bufferSize, maxCount));
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
descriptor = get_fd(get_current_io_context(false), fd);
|
|
|
|
if (descriptor == NULL)
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
if (descriptor->ops->fd_read_dir) {
|
2002-07-11 01:47:38 +04:00
|
|
|
uint32 count = maxCount;
|
2002-10-29 06:54:07 +03:00
|
|
|
retval = descriptor->ops->fd_read_dir(descriptor, buffer, bufferSize, &count);
|
2002-07-09 16:24:59 +04:00
|
|
|
if (retval >= 0)
|
|
|
|
retval = count;
|
|
|
|
} else
|
|
|
|
retval = EOPNOTSUPP;
|
|
|
|
|
|
|
|
put_fd(descriptor);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
2004-06-15 19:28:33 +04:00
|
|
|
_user_rewind_dir(int fd)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor;
|
|
|
|
status_t status;
|
|
|
|
|
2002-10-29 06:54:07 +03:00
|
|
|
PRINT(("user_rewind_dir(fd = %d)\n", fd));
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
descriptor = get_fd(get_current_io_context(false), fd);
|
|
|
|
if (descriptor == NULL)
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
if (descriptor->ops->fd_rewind_dir)
|
|
|
|
status = descriptor->ops->fd_rewind_dir(descriptor);
|
|
|
|
else
|
|
|
|
status = EOPNOTSUPP;
|
|
|
|
|
|
|
|
put_fd(descriptor);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-10 18:33:17 +04:00
|
|
|
status_t
|
|
|
|
_user_read_stat(int fd, struct stat *userStat, size_t statSize)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor;
|
2002-08-10 00:20:28 +04:00
|
|
|
status_t status;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-05-10 18:33:17 +04:00
|
|
|
if (statSize > sizeof(struct stat))
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
/* This is a user_function, so abort if we have a kernel address */
|
2004-06-15 19:28:33 +04:00
|
|
|
if (IS_KERNEL_ADDRESS(userStat))
|
|
|
|
return B_BAD_ADDRESS;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
descriptor = get_fd(get_current_io_context(false), fd);
|
|
|
|
if (descriptor == NULL)
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-05-10 18:33:17 +04:00
|
|
|
TRACE(("_user_read_stat(descriptor = %p)\n", descriptor));
|
2002-07-17 11:55:51 +04:00
|
|
|
|
2002-10-17 07:09:25 +04:00
|
|
|
if (descriptor->ops->fd_read_stat) {
|
2002-07-09 16:24:59 +04:00
|
|
|
// we're using the stat buffer on the stack to not have to
|
|
|
|
// lock the given stat buffer in memory
|
2002-10-17 07:09:25 +04:00
|
|
|
struct stat stat;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-10-17 07:09:25 +04:00
|
|
|
status = descriptor->ops->fd_read_stat(descriptor, &stat);
|
2002-08-10 00:20:28 +04:00
|
|
|
if (status >= 0)
|
2004-05-10 18:33:17 +04:00
|
|
|
status = user_memcpy(userStat, &stat, statSize);
|
2002-10-17 07:09:25 +04:00
|
|
|
} else
|
|
|
|
status = EOPNOTSUPP;
|
|
|
|
|
|
|
|
put_fd(descriptor);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-10 18:33:17 +04:00
|
|
|
status_t
|
|
|
|
_user_write_stat(int fd, const struct stat *userStat, size_t statSize, int statMask)
|
2002-10-17 07:09:25 +04:00
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor;
|
|
|
|
status_t status;
|
|
|
|
|
2004-05-10 18:33:17 +04:00
|
|
|
if (statSize > sizeof(struct stat))
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
|
2004-06-15 19:28:33 +04:00
|
|
|
if (IS_KERNEL_ADDRESS(userStat))
|
|
|
|
return B_BAD_ADDRESS;
|
2002-10-17 07:09:25 +04:00
|
|
|
|
|
|
|
descriptor = get_fd(get_current_io_context(false), fd);
|
|
|
|
if (descriptor == NULL)
|
|
|
|
return B_FILE_ERROR;
|
|
|
|
|
2004-05-10 18:33:17 +04:00
|
|
|
TRACE(("_user_write_stat(descriptor = %p)\n", descriptor));
|
2002-10-17 07:09:25 +04:00
|
|
|
|
|
|
|
if (descriptor->ops->fd_write_stat) {
|
|
|
|
// we're using the stat buffer on the stack to not have to
|
|
|
|
// lock the given stat buffer in memory
|
|
|
|
struct stat stat;
|
2004-05-10 18:33:17 +04:00
|
|
|
if (sizeof(struct stat) != statSize)
|
|
|
|
memset((uint8 *)&stat + statSize, 0, sizeof(struct stat) - statSize);
|
|
|
|
|
|
|
|
status = user_memcpy(&stat, userStat, statSize);
|
2002-10-17 07:09:25 +04:00
|
|
|
if (status == B_OK)
|
|
|
|
status = descriptor->ops->fd_write_stat(descriptor, &stat, statMask);
|
2002-07-09 16:24:59 +04:00
|
|
|
} else
|
2002-08-10 00:20:28 +04:00
|
|
|
status = EOPNOTSUPP;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
put_fd(descriptor);
|
2002-08-10 00:20:28 +04:00
|
|
|
return status;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-15 19:28:33 +04:00
|
|
|
status_t
|
|
|
|
_user_close(int fd)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2002-07-17 11:55:51 +04:00
|
|
|
struct io_context *io = get_current_io_context(false);
|
|
|
|
struct file_descriptor *descriptor = get_fd(io, fd);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
if (descriptor == NULL)
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-10-29 06:54:07 +03:00
|
|
|
TRACE(("user_close(descriptor = %p)\n", descriptor));
|
2002-07-17 11:55:51 +04:00
|
|
|
|
|
|
|
remove_fd(io, fd);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
put_fd(descriptor);
|
2002-07-17 11:55:51 +04:00
|
|
|
return B_OK;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-20 04:16:12 +04:00
|
|
|
int
|
2004-06-15 19:28:33 +04:00
|
|
|
_user_dup(int fd)
|
2002-07-20 04:16:12 +04:00
|
|
|
{
|
2002-10-29 06:54:07 +03:00
|
|
|
return dup_fd(fd, false);
|
2002-07-20 04:16:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2004-06-15 19:28:33 +04:00
|
|
|
_user_dup2(int ofd, int nfd)
|
2002-07-20 04:16:12 +04:00
|
|
|
{
|
2002-10-29 06:54:07 +03:00
|
|
|
return dup2_fd(ofd, nfd, false);
|
2002-07-20 04:16:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
// #pragma mark -
|
|
|
|
/*** SYSTEM functions ***/
|
|
|
|
|
|
|
|
|
|
|
|
ssize_t
|
2004-06-15 19:28:33 +04:00
|
|
|
_kern_read(int fd, off_t pos, void *buffer, size_t length)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor;
|
2004-06-15 19:28:33 +04:00
|
|
|
ssize_t bytesRead;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
descriptor = get_fd(get_current_io_context(true), fd);
|
|
|
|
if (!descriptor)
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-06-15 19:28:33 +04:00
|
|
|
if (pos == -1)
|
|
|
|
pos = descriptor->pos;
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
if (descriptor->ops->fd_read) {
|
2004-06-15 19:28:33 +04:00
|
|
|
bytesRead = descriptor->ops->fd_read(descriptor, pos, buffer, &length);
|
|
|
|
if (bytesRead >= B_OK) {
|
|
|
|
if (length > 0x7fffffff)
|
|
|
|
bytesRead = 0x7fffffff;
|
|
|
|
else
|
|
|
|
bytesRead = (ssize_t)length;
|
|
|
|
|
|
|
|
descriptor->pos = pos + length;
|
|
|
|
}
|
2002-07-09 16:24:59 +04:00
|
|
|
} else
|
2004-06-15 19:28:33 +04:00
|
|
|
bytesRead = B_BAD_VALUE;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
put_fd(descriptor);
|
2004-06-15 19:28:33 +04:00
|
|
|
return bytesRead;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ssize_t
|
2004-06-15 19:28:33 +04:00
|
|
|
_kern_write(int fd, off_t pos, const void *buffer, size_t length)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor;
|
2004-06-15 19:28:33 +04:00
|
|
|
ssize_t bytesWritten;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
descriptor = get_fd(get_current_io_context(true), fd);
|
|
|
|
if (descriptor == NULL)
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-06-15 19:28:33 +04:00
|
|
|
if (pos == -1)
|
|
|
|
pos = descriptor->pos;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-06-15 19:28:33 +04:00
|
|
|
if (descriptor->ops->fd_write) {
|
|
|
|
bytesWritten = descriptor->ops->fd_write(descriptor, pos, buffer, &length);
|
|
|
|
if (bytesWritten >= B_OK) {
|
|
|
|
if (length > 0x7fffffff)
|
|
|
|
bytesWritten = 0x7fffffff;
|
|
|
|
else
|
|
|
|
bytesWritten = (ssize_t)length;
|
|
|
|
|
|
|
|
descriptor->pos = pos + length;
|
|
|
|
}
|
2002-07-09 16:24:59 +04:00
|
|
|
} else
|
2004-06-15 19:28:33 +04:00
|
|
|
bytesWritten = B_BAD_VALUE;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
put_fd(descriptor);
|
2004-06-15 19:28:33 +04:00
|
|
|
return bytesWritten;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-17 11:55:51 +04:00
|
|
|
off_t
|
2004-06-15 19:28:33 +04:00
|
|
|
_kern_seek(int fd, off_t pos, int seekType)
|
2002-07-14 09:15:34 +04:00
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor;
|
|
|
|
|
|
|
|
descriptor = get_fd(get_current_io_context(true), fd);
|
|
|
|
if (!descriptor)
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-07-14 09:15:34 +04:00
|
|
|
|
|
|
|
if (descriptor->ops->fd_seek)
|
2002-07-17 11:55:51 +04:00
|
|
|
pos = descriptor->ops->fd_seek(descriptor, pos, seekType);
|
2002-07-14 09:15:34 +04:00
|
|
|
else
|
2002-07-17 11:55:51 +04:00
|
|
|
pos = ESPIPE;
|
2002-07-14 09:15:34 +04:00
|
|
|
|
|
|
|
put_fd(descriptor);
|
2002-07-17 11:55:51 +04:00
|
|
|
return pos;
|
2002-07-14 09:15:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-15 19:28:33 +04:00
|
|
|
status_t
|
|
|
|
_kern_ioctl(int fd, ulong op, void *buffer, size_t length)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
PRINT(("sys_ioctl: fd %d\n", fd));
|
|
|
|
|
|
|
|
descriptor = get_fd(get_current_io_context(true), fd);
|
|
|
|
if (descriptor == NULL)
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
if (descriptor->ops->fd_ioctl)
|
|
|
|
status = descriptor->ops->fd_ioctl(descriptor, op, buffer, length);
|
|
|
|
else
|
|
|
|
status = EOPNOTSUPP;
|
|
|
|
|
|
|
|
put_fd(descriptor);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ssize_t
|
2004-06-15 19:28:33 +04:00
|
|
|
_kern_read_dir(int fd, struct dirent *buffer, size_t bufferSize, uint32 maxCount)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor;
|
|
|
|
ssize_t retval;
|
|
|
|
|
2002-11-03 06:19:34 +03:00
|
|
|
PRINT(("sys_read_dir(fd = %d, buffer = %p, bufferSize = %ld, count = %lu)\n",fd, buffer, bufferSize, maxCount));
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-07-14 09:15:34 +04:00
|
|
|
descriptor = get_fd(get_current_io_context(true), fd);
|
2002-07-09 16:24:59 +04:00
|
|
|
if (descriptor == NULL)
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
if (descriptor->ops->fd_read_dir) {
|
2002-07-11 01:47:38 +04:00
|
|
|
uint32 count = maxCount;
|
2002-10-29 06:54:07 +03:00
|
|
|
retval = descriptor->ops->fd_read_dir(descriptor, buffer, bufferSize, &count);
|
2002-07-09 16:24:59 +04:00
|
|
|
if (retval >= 0)
|
|
|
|
retval = count;
|
|
|
|
} else
|
|
|
|
retval = EOPNOTSUPP;
|
|
|
|
|
|
|
|
put_fd(descriptor);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
2004-06-15 19:28:33 +04:00
|
|
|
_kern_rewind_dir(int fd)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor;
|
|
|
|
status_t status;
|
|
|
|
|
2002-07-17 11:55:51 +04:00
|
|
|
PRINT(("sys_rewind_dir(fd = %d)\n",fd));
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-07-14 09:15:34 +04:00
|
|
|
descriptor = get_fd(get_current_io_context(true), fd);
|
2002-07-09 16:24:59 +04:00
|
|
|
if (descriptor == NULL)
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
if (descriptor->ops->fd_rewind_dir)
|
|
|
|
status = descriptor->ops->fd_rewind_dir(descriptor);
|
|
|
|
else
|
|
|
|
status = EOPNOTSUPP;
|
|
|
|
|
|
|
|
put_fd(descriptor);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-10 18:33:17 +04:00
|
|
|
status_t
|
|
|
|
_kern_read_stat(int fd, struct stat *stat, size_t statSize)
|
2002-10-17 07:09:25 +04:00
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor;
|
|
|
|
status_t status;
|
|
|
|
|
2004-05-10 18:33:17 +04:00
|
|
|
if (statSize > sizeof(struct stat))
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
|
2002-10-17 07:09:25 +04:00
|
|
|
descriptor = get_fd(get_current_io_context(true), fd);
|
|
|
|
if (descriptor == NULL)
|
|
|
|
return B_FILE_ERROR;
|
|
|
|
|
2004-05-10 18:33:17 +04:00
|
|
|
TRACE(("_kern_read_stat(descriptor = %p)\n", descriptor));
|
|
|
|
|
|
|
|
if (descriptor->ops->fd_read_stat) {
|
|
|
|
// this supports different stat extensions
|
|
|
|
struct stat completeStat;
|
|
|
|
struct stat *originalStat = NULL;
|
2002-10-17 07:09:25 +04:00
|
|
|
|
2004-05-10 18:33:17 +04:00
|
|
|
if (statSize < sizeof(struct stat)) {
|
|
|
|
originalStat = stat;
|
|
|
|
stat = &completeStat;
|
|
|
|
}
|
2002-10-17 07:09:25 +04:00
|
|
|
status = descriptor->ops->fd_read_stat(descriptor, stat);
|
2004-05-10 18:33:17 +04:00
|
|
|
|
|
|
|
if (originalStat != NULL)
|
|
|
|
memcpy(originalStat, stat, statSize);
|
|
|
|
} else
|
2002-10-17 07:09:25 +04:00
|
|
|
status = EOPNOTSUPP;
|
|
|
|
|
|
|
|
put_fd(descriptor);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-10 18:33:17 +04:00
|
|
|
status_t
|
|
|
|
_kern_write_stat(int fd, const struct stat *stat, size_t statSize, int statMask)
|
2002-08-10 00:20:28 +04:00
|
|
|
{
|
|
|
|
struct file_descriptor *descriptor;
|
|
|
|
status_t status;
|
|
|
|
|
2004-05-10 18:33:17 +04:00
|
|
|
if (statSize > sizeof(struct stat))
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
|
2002-08-10 00:20:28 +04:00
|
|
|
descriptor = get_fd(get_current_io_context(true), fd);
|
|
|
|
if (descriptor == NULL)
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-08-10 00:20:28 +04:00
|
|
|
|
2004-05-10 18:33:17 +04:00
|
|
|
TRACE(("_kern_write_stat(descriptor = %p)\n", descriptor));
|
|
|
|
|
|
|
|
if (descriptor->ops->fd_write_stat) {
|
|
|
|
// this supports different stat extensions
|
|
|
|
struct stat completeStat;
|
2002-08-10 00:20:28 +04:00
|
|
|
|
2004-05-10 18:33:17 +04:00
|
|
|
if (statSize < sizeof(struct stat)) {
|
|
|
|
memset((uint8 *)&completeStat + statSize, 0, sizeof(struct stat) - statSize);
|
|
|
|
memcpy(&completeStat, stat, statSize);
|
|
|
|
stat = &completeStat;
|
|
|
|
}
|
2002-10-17 07:09:25 +04:00
|
|
|
status = descriptor->ops->fd_write_stat(descriptor, stat, statMask);
|
2004-05-10 18:33:17 +04:00
|
|
|
} else
|
2002-08-10 00:20:28 +04:00
|
|
|
status = EOPNOTSUPP;
|
|
|
|
|
|
|
|
put_fd(descriptor);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-15 19:28:33 +04:00
|
|
|
status_t
|
|
|
|
_kern_close(int fd)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2002-07-17 11:55:51 +04:00
|
|
|
struct io_context *io = get_current_io_context(true);
|
|
|
|
struct file_descriptor *descriptor = get_fd(io, fd);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
if (descriptor == NULL)
|
2002-10-08 07:24:51 +04:00
|
|
|
return B_FILE_ERROR;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-07-17 11:55:51 +04:00
|
|
|
remove_fd(io, fd);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
put_fd(descriptor);
|
2002-07-17 11:55:51 +04:00
|
|
|
return B_OK;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2002-07-20 04:16:12 +04:00
|
|
|
|
|
|
|
int
|
2004-06-15 19:28:33 +04:00
|
|
|
_kern_dup(int fd)
|
2002-07-20 04:16:12 +04:00
|
|
|
{
|
2002-10-29 06:54:07 +03:00
|
|
|
return dup_fd(fd, true);
|
2002-07-20 04:16:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2004-06-15 19:28:33 +04:00
|
|
|
_kern_dup2(int ofd, int nfd)
|
2002-07-20 04:16:12 +04:00
|
|
|
{
|
2002-10-29 06:54:07 +03:00
|
|
|
return dup2_fd(ofd, nfd, true);
|
2002-07-20 04:16:12 +04:00
|
|
|
}
|
|
|
|
|