124df6592SIngo Weinhold/*
2e701d86aSIngo Weinhold * Copyright 2002-2007, Axel D��rfler, axeld@pinc-software.de. All rights reserved.
3e701d86aSIngo Weinhold * Distributed under the terms of the MIT License.
424df6592SIngo Weinhold *
5e701d86aSIngo Weinhold * Copyright 2001, Manuel J. Petit. All rights reserved.
6e701d86aSIngo Weinhold * Distributed under the terms of the NewOS License.
7e701d86aSIngo Weinhold */
8bc45af20SAxel Dörfler
9bc45af20SAxel Dörfler
10bc45af20SAxel Dörfler#include <unistd.h>
1124df6592SIngo Weinhold
12bc45af20SAxel Dörfler#include <errno.h>
1324df6592SIngo Weinhold#include <pthread.h>
14bc45af20SAxel Dörfler
1524df6592SIngo Weinhold#include <syscall_utils.h>
16bc45af20SAxel Dörfler
17ae901935SOliver Tappe#include <errno_private.h>
1824df6592SIngo Weinhold#include <syscalls.h>
19bc45af20SAxel Dörfler
20bc45af20SAxel Dörfler
21bc45af20SAxel Dörflerssize_t
22bc45af20SAxel Dörflerwrite(int fd, void const *buffer, size_t bufferSize)
23bc45af20SAxel Dörfler{
24b1753651SAxel Dörfler	int status = _kern_write(fd, -1, buffer, bufferSize);
25bc45af20SAxel Dörfler
2624df6592SIngo Weinhold	RETURN_AND_SET_ERRNO_TEST_CANCEL(status);
27bc45af20SAxel Dörfler}
28bc45af20SAxel Dörfler
29bc45af20SAxel Dörfler
30bc45af20SAxel Dörflerssize_t
31bc45af20SAxel Dörflerwrite_pos(int fd, off_t pos, const void *buffer, size_t bufferSize)
32bc45af20SAxel Dörfler{
3324df6592SIngo Weinhold	if (pos < 0)
3424df6592SIngo Weinhold		RETURN_AND_SET_ERRNO_TEST_CANCEL(B_BAD_VALUE);
3524df6592SIngo Weinhold
3624df6592SIngo Weinhold	RETURN_AND_SET_ERRNO_TEST_CANCEL(_kern_write(fd, pos, buffer, bufferSize));
37bc45af20SAxel Dörfler}
38bc45af20SAxel Dörfler
39bc45af20SAxel Dörfler
40bc45af20SAxel Dörflerssize_t
41bc45af20SAxel Dörflerpwrite(int fd, const void *buffer, size_t bufferSize, off_t pos)
42bc45af20SAxel Dörfler{
4324df6592SIngo Weinhold	if (pos < 0)
4424df6592SIngo Weinhold		RETURN_AND_SET_ERRNO_TEST_CANCEL(B_BAD_VALUE);
4524df6592SIngo Weinhold
4624df6592SIngo Weinhold	RETURN_AND_SET_ERRNO_TEST_CANCEL(_kern_write(fd, pos, buffer, bufferSize));
47bc45af20SAxel Dörfler}
48