From d590ff3d360b0924cf6078caec041e63e0e74848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 5 Oct 2004 13:40:13 +0000 Subject: [PATCH] We now have a working fcntl() function. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9202 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/posix/unistd/fcntl.c | 29 ++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/kernel/libroot/posix/unistd/fcntl.c b/src/kernel/libroot/posix/unistd/fcntl.c index 7fa4b36763..fc15e72b90 100644 --- a/src/kernel/libroot/posix/unistd/fcntl.c +++ b/src/kernel/libroot/posix/unistd/fcntl.c @@ -1,18 +1,37 @@ /* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. +** Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the Haiku License. */ -#include #include +#include +#include + #include +#define RETURN_AND_SET_ERRNO(err) \ + if (err < 0) { \ + errno = err; \ + return -1; \ + } \ + return err; + + int fcntl(int fd, int op, ...) { - // ToDo: implement me! - return 0; + status_t status; + uint32 argument; + va_list args; + + va_start(args, op); + argument = va_arg(args, uint32); + va_end(args); + + status = _kern_fcntl(fd, op, argument); + + RETURN_AND_SET_ERRNO(status) }