[haiku-commits] r33976 - in haiku/trunk: headers/posix src/system/libroot/posix src/system/libroot/posix/unistd

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 10 Nov 2009 12:15:36 +0100 (CET)

Author: bonefish
Date: 2009-11-10 12:15:35 +0100 (Tue, 10 Nov 2009)
New Revision: 33976
Changeset: http://dev.haiku-os.org/changeset/33976/haiku

Added:
   haiku/trunk/src/system/libroot/posix/fcntl.cpp
Removed:
   haiku/trunk/src/system/libroot/posix/unistd/fcntl.c
   haiku/trunk/src/system/libroot/posix/unistd/open.c
Modified:
   haiku/trunk/headers/posix/fcntl.h
   haiku/trunk/src/system/libroot/posix/Jamfile
   haiku/trunk/src/system/libroot/posix/unistd/Jamfile
Log:
* src/system/libroot/posix: Moved open.c and fcntl.c out of the unistd
  directory, where they were misplaced, and joined them to fcntl.cpp.
* Added openat().


Modified: haiku/trunk/headers/posix/fcntl.h
===================================================================
--- haiku/trunk/headers/posix/fcntl.h   2009-11-10 11:08:14 UTC (rev 33975)
+++ haiku/trunk/headers/posix/fcntl.h   2009-11-10 11:15:35 UTC (rev 33976)
@@ -64,7 +64,9 @@
 #define O_SHLOCK               0x01000000      /* obtain shared lock */
 #define O_EXLOCK               0x02000000      /* obtain exclusive lock */
 
+#define AT_FDCWD               (-1)            /* CWD FD for the *at() 
functions */
 
+
 /* advisory file locking */
 
 struct flock {
@@ -81,9 +83,10 @@
 #endif
 
 extern int     creat(const char *path, mode_t mode);
-extern int     open(const char *pathname, int oflags, ...);
+extern int     open(const char *path, int openMode, ...);
        /* the third argument is the permissions of the created file when 
O_CREAT
           is passed in oflags */
+extern int     openat(int fd, const char *path, int openMode, ...);
 
 extern int     fcntl(int fd, int op, ...);
 

Modified: haiku/trunk/src/system/libroot/posix/Jamfile
===================================================================
--- haiku/trunk/src/system/libroot/posix/Jamfile        2009-11-10 11:08:14 UTC 
(rev 33975)
+++ haiku/trunk/src/system/libroot/posix/Jamfile        2009-11-10 11:15:35 UTC 
(rev 33976)
@@ -16,6 +16,7 @@
        dlfcn.c
        dirent.c
        errno.c
+       fcntl.cpp
        fnmatch.c
        glob.c
        inttypes.c

Copied: haiku/trunk/src/system/libroot/posix/fcntl.cpp (from rev 33971, 
haiku/trunk/src/system/libroot/posix/unistd/open.c)
===================================================================
--- haiku/trunk/src/system/libroot/posix/fcntl.cpp                              
(rev 0)
+++ haiku/trunk/src/system/libroot/posix/fcntl.cpp      2009-11-10 11:15:35 UTC 
(rev 33976)
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2002-2009, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
+ * Distributed under the terms of the MIT License.
+ *
+ * Copyright 2001, Manuel J. Petit. All rights reserved.
+ * Distributed under the terms of the NewOS License.
+ */
+
+
+#include <stdarg.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include <syscalls.h>
+#include <syscall_utils.h>
+#include <umask.h>
+
+
+int
+creat(const char *path, mode_t mode)
+{
+       int status = _kern_open(-1, path, O_CREAT | O_TRUNC | O_WRONLY,
+               mode & ~__gUmask);
+               // adapt the permissions as required by POSIX
+       if (status < 0) {
+               errno = status;
+               return -1;
+       }
+       return status;
+}
+
+
+int
+open(const char *path, int openMode, ...)
+{
+       int perms = 0;
+       if (openMode & O_CREAT) {
+               va_list args;
+               va_start(args, openMode);
+               perms = va_arg(args, int) & ~__gUmask;
+                       // adapt the permissions as required by POSIX
+               va_end(args);
+       }
+
+       int status = _kern_open(-1, path, openMode, perms);
+       if (status < 0) {
+               errno = status;
+               return -1;
+       }
+       return status;
+}
+
+
+int
+openat(int fd, const char *path, int openMode, ...)
+{
+       int perms = 0;
+       if (openMode & O_CREAT) {
+               va_list args;
+               va_start(args, openMode);
+               perms = va_arg(args, int) & ~__gUmask;
+                       // adapt the permissions as required by POSIX
+               va_end(args);
+       }
+
+       int status = _kern_open(fd, path, openMode, perms);
+       if (status < 0) {
+               errno = status;
+               return -1;
+       }
+       return status;
+}
+
+
+int
+fcntl(int fd, int op, ...)
+{
+       va_list args;
+       va_start(args, op);
+       uint32 argument = va_arg(args, uint32);
+       va_end(args);
+
+       RETURN_AND_SET_ERRNO(_kern_fcntl(fd, op, argument));
+}


Property changes on: haiku/trunk/src/system/libroot/posix/fcntl.cpp
___________________________________________________________________
Added: svn:mergeinfo
   + 

Modified: haiku/trunk/src/system/libroot/posix/unistd/Jamfile
===================================================================
--- haiku/trunk/src/system/libroot/posix/unistd/Jamfile 2009-11-10 11:08:14 UTC 
(rev 33975)
+++ haiku/trunk/src/system/libroot/posix/unistd/Jamfile 2009-11-10 11:15:35 UTC 
(rev 33976)
@@ -14,7 +14,6 @@
        dup.c
        exec.cpp
        _exit.c
-       fcntl.c
        fork.c
        getlogin.c
        getpagesize.c
@@ -25,7 +24,6 @@
        lseek.c
        mknod.c
        mount.c
-       open.c
        pause.c
        pipe.c
        process.c


Other related posts:

  • » [haiku-commits] r33976 - in haiku/trunk: headers/posix src/system/libroot/posix src/system/libroot/posix/unistd - ingo_weinhold