Move away from the __ARCH_WANT_SYSCALL_NO_AT system calls.
Modern architectures only get the *at(2) system calls. For example,
aarch64 doesn't have open(2), and expects userspace to use openat(2)
instead.
Change-Id: I87b4ed79790cb8a80844f5544ac1a13fda26c7b5
diff --git a/libc/bionic/open.c b/libc/bionic/access.cpp
similarity index 67%
copy from libc/bionic/open.c
copy to libc/bionic/access.cpp
index 6441dc2..360b672 100644
--- a/libc/bionic/open.c
+++ b/libc/bionic/access.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,10 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <unistd.h>
+
#include <fcntl.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
+#include <unistd.h>
-extern int __open(const char*, int, int);
-
-int open(const char* pathname, int flags, ...) {
- mode_t mode = 0;
-
- flags |= O_LARGEFILE;
-
- if (flags & O_CREAT) {
- va_list args;
- va_start(args, flags);
- mode = (mode_t) va_arg(args, int);
- va_end(args);
- }
-
- return __open(pathname, flags, mode);
-}
-
-int __open_2(const char* pathname, int flags) {
- if (__predict_false(flags & O_CREAT)) {
- __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
- }
-
- flags |= O_LARGEFILE;
-
- return __open(pathname, flags, 0);
+int access(const char* path, int mode) {
+ return faccessat(AT_FDCWD, path, mode, 0);
}
diff --git a/libc/bionic/open.c b/libc/bionic/chmod.cpp
similarity index 66%
copy from libc/bionic/open.c
copy to libc/bionic/chmod.cpp
index 6441dc2..d988f48 100644
--- a/libc/bionic/open.c
+++ b/libc/bionic/chmod.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,11 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <unistd.h>
+
#include <fcntl.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
+#include <sys/stat.h>
+#include <sys/types.h>
-extern int __open(const char*, int, int);
-
-int open(const char* pathname, int flags, ...) {
- mode_t mode = 0;
-
- flags |= O_LARGEFILE;
-
- if (flags & O_CREAT) {
- va_list args;
- va_start(args, flags);
- mode = (mode_t) va_arg(args, int);
- va_end(args);
- }
-
- return __open(pathname, flags, mode);
-}
-
-int __open_2(const char* pathname, int flags) {
- if (__predict_false(flags & O_CREAT)) {
- __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
- }
-
- flags |= O_LARGEFILE;
-
- return __open(pathname, flags, 0);
+int chmod(const char* path, mode_t mode) {
+ return fchmodat(AT_FDCWD, path, mode, 0);
}
diff --git a/libc/bionic/open.c b/libc/bionic/chown.cpp
similarity index 66%
copy from libc/bionic/open.c
copy to libc/bionic/chown.cpp
index 6441dc2..bc2e605 100644
--- a/libc/bionic/open.c
+++ b/libc/bionic/chown.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,11 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <unistd.h>
+
#include <fcntl.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
+#include <sys/stat.h>
+#include <sys/types.h>
-extern int __open(const char*, int, int);
-
-int open(const char* pathname, int flags, ...) {
- mode_t mode = 0;
-
- flags |= O_LARGEFILE;
-
- if (flags & O_CREAT) {
- va_list args;
- va_start(args, flags);
- mode = (mode_t) va_arg(args, int);
- va_end(args);
- }
-
- return __open(pathname, flags, mode);
-}
-
-int __open_2(const char* pathname, int flags) {
- if (__predict_false(flags & O_CREAT)) {
- __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
- }
-
- flags |= O_LARGEFILE;
-
- return __open(pathname, flags, 0);
+int chown(const char* path, uid_t uid, gid_t gid) {
+ return fchownat(AT_FDCWD, path, uid, gid, 0);
}
diff --git a/libc/bionic/open.c b/libc/bionic/lchown.cpp
similarity index 66%
copy from libc/bionic/open.c
copy to libc/bionic/lchown.cpp
index 6441dc2..95251db 100644
--- a/libc/bionic/open.c
+++ b/libc/bionic/lchown.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,11 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <unistd.h>
+
#include <fcntl.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
+#include <sys/stat.h>
+#include <sys/types.h>
-extern int __open(const char*, int, int);
-
-int open(const char* pathname, int flags, ...) {
- mode_t mode = 0;
-
- flags |= O_LARGEFILE;
-
- if (flags & O_CREAT) {
- va_list args;
- va_start(args, flags);
- mode = (mode_t) va_arg(args, int);
- va_end(args);
- }
-
- return __open(pathname, flags, mode);
-}
-
-int __open_2(const char* pathname, int flags) {
- if (__predict_false(flags & O_CREAT)) {
- __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
- }
-
- flags |= O_LARGEFILE;
-
- return __open(pathname, flags, 0);
+int lchown(const char* path, uid_t uid, gid_t gid) {
+ return fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW);
}
diff --git a/libc/bionic/open.c b/libc/bionic/link.cpp
similarity index 67%
copy from libc/bionic/open.c
copy to libc/bionic/link.cpp
index 6441dc2..65ad374 100644
--- a/libc/bionic/open.c
+++ b/libc/bionic/link.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,10 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <unistd.h>
+
#include <fcntl.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
+#include <unistd.h>
-extern int __open(const char*, int, int);
-
-int open(const char* pathname, int flags, ...) {
- mode_t mode = 0;
-
- flags |= O_LARGEFILE;
-
- if (flags & O_CREAT) {
- va_list args;
- va_start(args, flags);
- mode = (mode_t) va_arg(args, int);
- va_end(args);
- }
-
- return __open(pathname, flags, mode);
-}
-
-int __open_2(const char* pathname, int flags) {
- if (__predict_false(flags & O_CREAT)) {
- __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
- }
-
- flags |= O_LARGEFILE;
-
- return __open(pathname, flags, 0);
+int link(const char* old_path, const char* new_path) {
+ return linkat(AT_FDCWD, old_path, AT_FDCWD, new_path, 0);
}
diff --git a/libc/bionic/open.c b/libc/bionic/lstat.cpp
similarity index 67%
copy from libc/bionic/open.c
copy to libc/bionic/lstat.cpp
index 6441dc2..300d7fa 100644
--- a/libc/bionic/open.c
+++ b/libc/bionic/lstat.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,12 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <unistd.h>
+
#include <fcntl.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
-extern int __open(const char*, int, int);
-
-int open(const char* pathname, int flags, ...) {
- mode_t mode = 0;
-
- flags |= O_LARGEFILE;
-
- if (flags & O_CREAT) {
- va_list args;
- va_start(args, flags);
- mode = (mode_t) va_arg(args, int);
- va_end(args);
- }
-
- return __open(pathname, flags, mode);
-}
-
-int __open_2(const char* pathname, int flags) {
- if (__predict_false(flags & O_CREAT)) {
- __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
- }
-
- flags |= O_LARGEFILE;
-
- return __open(pathname, flags, 0);
+int lstat(const char* path, struct stat* sb) {
+ return fstatat(AT_FDCWD, path, sb, AT_SYMLINK_NOFOLLOW);
}
diff --git a/libc/bionic/open.c b/libc/bionic/mkdir.cpp
similarity index 66%
copy from libc/bionic/open.c
copy to libc/bionic/mkdir.cpp
index 6441dc2..90dc761 100644
--- a/libc/bionic/open.c
+++ b/libc/bionic/mkdir.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,11 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <unistd.h>
+
#include <fcntl.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
+#include <sys/stat.h>
+#include <sys/types.h>
-extern int __open(const char*, int, int);
-
-int open(const char* pathname, int flags, ...) {
- mode_t mode = 0;
-
- flags |= O_LARGEFILE;
-
- if (flags & O_CREAT) {
- va_list args;
- va_start(args, flags);
- mode = (mode_t) va_arg(args, int);
- va_end(args);
- }
-
- return __open(pathname, flags, mode);
-}
-
-int __open_2(const char* pathname, int flags) {
- if (__predict_false(flags & O_CREAT)) {
- __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
- }
-
- flags |= O_LARGEFILE;
-
- return __open(pathname, flags, 0);
+int mkdir(const char* path, mode_t mode) {
+ return mkdirat(AT_FDCWD, path, mode);
}
diff --git a/libc/bionic/open.c b/libc/bionic/mknod.cpp
similarity index 67%
copy from libc/bionic/open.c
copy to libc/bionic/mknod.cpp
index 6441dc2..68d4309 100644
--- a/libc/bionic/open.c
+++ b/libc/bionic/mknod.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,12 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <unistd.h>
+
#include <fcntl.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
-extern int __open(const char*, int, int);
-
-int open(const char* pathname, int flags, ...) {
- mode_t mode = 0;
-
- flags |= O_LARGEFILE;
-
- if (flags & O_CREAT) {
- va_list args;
- va_start(args, flags);
- mode = (mode_t) va_arg(args, int);
- va_end(args);
- }
-
- return __open(pathname, flags, mode);
-}
-
-int __open_2(const char* pathname, int flags) {
- if (__predict_false(flags & O_CREAT)) {
- __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
- }
-
- flags |= O_LARGEFILE;
-
- return __open(pathname, flags, 0);
+int mknod(const char* path, mode_t mode, dev_t dev) {
+ return mknodat(AT_FDCWD, path, mode, dev);
}
diff --git a/libc/bionic/openat.c b/libc/bionic/open.cpp
similarity index 77%
rename from libc/bionic/openat.c
rename to libc/bionic/open.cpp
index 56bb627..e0dd181 100644
--- a/libc/bionic/openat.c
+++ b/libc/bionic/open.cpp
@@ -25,13 +25,40 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <unistd.h>
+
#include <fcntl.h>
#include <stdarg.h>
#include <stdlib.h>
+#include <unistd.h>
+
#include "private/libc_logging.h"
-extern int __openat(int, const char*, int, int);
+extern "C" int __openat(int, const char*, int, int);
+
+int open(const char* pathname, int flags, ...) {
+ mode_t mode = 0;
+
+ flags |= O_LARGEFILE;
+
+ if (flags & O_CREAT) {
+ va_list args;
+ va_start(args, flags);
+ mode = (mode_t) va_arg(args, int);
+ va_end(args);
+ }
+
+ return __openat(AT_FDCWD, pathname, flags, mode);
+}
+
+int __open_2(const char* pathname, int flags) {
+ if (__predict_false(flags & O_CREAT)) {
+ __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
+ }
+
+ flags |= O_LARGEFILE;
+
+ return __openat(AT_FDCWD, pathname, flags, 0);
+}
int openat(int fd, const char *pathname, int flags, ...) {
mode_t mode = 0;
diff --git a/libc/bionic/open.c b/libc/bionic/readlink.cpp
similarity index 66%
copy from libc/bionic/open.c
copy to libc/bionic/readlink.cpp
index 6441dc2..a2c5e91 100644
--- a/libc/bionic/open.c
+++ b/libc/bionic/readlink.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,11 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <unistd.h>
+
#include <fcntl.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
+#include <sys/stat.h>
+#include <sys/types.h>
-extern int __open(const char*, int, int);
-
-int open(const char* pathname, int flags, ...) {
- mode_t mode = 0;
-
- flags |= O_LARGEFILE;
-
- if (flags & O_CREAT) {
- va_list args;
- va_start(args, flags);
- mode = (mode_t) va_arg(args, int);
- va_end(args);
- }
-
- return __open(pathname, flags, mode);
-}
-
-int __open_2(const char* pathname, int flags) {
- if (__predict_false(flags & O_CREAT)) {
- __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
- }
-
- flags |= O_LARGEFILE;
-
- return __open(pathname, flags, 0);
+ssize_t readlink(const char* path, char* buf, size_t size) {
+ return readlinkat(AT_FDCWD, path, buf, size);
}
diff --git a/libc/bionic/open.c b/libc/bionic/rename.cpp
similarity index 66%
copy from libc/bionic/open.c
copy to libc/bionic/rename.cpp
index 6441dc2..8295559 100644
--- a/libc/bionic/open.c
+++ b/libc/bionic/rename.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,10 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <unistd.h>
+
#include <fcntl.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
+#include <stdio.h>
-extern int __open(const char*, int, int);
-
-int open(const char* pathname, int flags, ...) {
- mode_t mode = 0;
-
- flags |= O_LARGEFILE;
-
- if (flags & O_CREAT) {
- va_list args;
- va_start(args, flags);
- mode = (mode_t) va_arg(args, int);
- va_end(args);
- }
-
- return __open(pathname, flags, mode);
-}
-
-int __open_2(const char* pathname, int flags) {
- if (__predict_false(flags & O_CREAT)) {
- __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
- }
-
- flags |= O_LARGEFILE;
-
- return __open(pathname, flags, 0);
+int rename(const char* old_path, const char* new_path) {
+ return renameat(AT_FDCWD, old_path, AT_FDCWD, new_path);
}
diff --git a/libc/bionic/open.c b/libc/bionic/rmdir.cpp
similarity index 67%
copy from libc/bionic/open.c
copy to libc/bionic/rmdir.cpp
index 6441dc2..e7a9808 100644
--- a/libc/bionic/open.c
+++ b/libc/bionic/rmdir.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,10 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <unistd.h>
+
#include <fcntl.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
+#include <unistd.h>
-extern int __open(const char*, int, int);
-
-int open(const char* pathname, int flags, ...) {
- mode_t mode = 0;
-
- flags |= O_LARGEFILE;
-
- if (flags & O_CREAT) {
- va_list args;
- va_start(args, flags);
- mode = (mode_t) va_arg(args, int);
- va_end(args);
- }
-
- return __open(pathname, flags, mode);
-}
-
-int __open_2(const char* pathname, int flags) {
- if (__predict_false(flags & O_CREAT)) {
- __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
- }
-
- flags |= O_LARGEFILE;
-
- return __open(pathname, flags, 0);
+int rmdir(const char* path) {
+ return unlinkat(AT_FDCWD, path, AT_REMOVEDIR);
}
diff --git a/libc/bionic/open.c b/libc/bionic/stat.cpp
similarity index 67%
rename from libc/bionic/open.c
rename to libc/bionic/stat.cpp
index 6441dc2..62387c5 100644
--- a/libc/bionic/open.c
+++ b/libc/bionic/stat.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,12 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <unistd.h>
+
#include <fcntl.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
-extern int __open(const char*, int, int);
-
-int open(const char* pathname, int flags, ...) {
- mode_t mode = 0;
-
- flags |= O_LARGEFILE;
-
- if (flags & O_CREAT) {
- va_list args;
- va_start(args, flags);
- mode = (mode_t) va_arg(args, int);
- va_end(args);
- }
-
- return __open(pathname, flags, mode);
-}
-
-int __open_2(const char* pathname, int flags) {
- if (__predict_false(flags & O_CREAT)) {
- __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
- }
-
- flags |= O_LARGEFILE;
-
- return __open(pathname, flags, 0);
+int stat(const char* path, struct stat* sb) {
+ return fstatat(AT_FDCWD, path, sb, 0);
}
diff --git a/libc/bionic/open.c b/libc/bionic/symlink.cpp
similarity index 67%
copy from libc/bionic/open.c
copy to libc/bionic/symlink.cpp
index 6441dc2..83cda47 100644
--- a/libc/bionic/open.c
+++ b/libc/bionic/symlink.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,10 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <unistd.h>
+
#include <fcntl.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
+#include <unistd.h>
-extern int __open(const char*, int, int);
-
-int open(const char* pathname, int flags, ...) {
- mode_t mode = 0;
-
- flags |= O_LARGEFILE;
-
- if (flags & O_CREAT) {
- va_list args;
- va_start(args, flags);
- mode = (mode_t) va_arg(args, int);
- va_end(args);
- }
-
- return __open(pathname, flags, mode);
-}
-
-int __open_2(const char* pathname, int flags) {
- if (__predict_false(flags & O_CREAT)) {
- __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
- }
-
- flags |= O_LARGEFILE;
-
- return __open(pathname, flags, 0);
+int symlink(const char* old_path, const char* new_path) {
+ return symlinkat(old_path, AT_FDCWD, new_path);
}
diff --git a/libc/bionic/open.c b/libc/bionic/unlink.cpp
similarity index 67%
copy from libc/bionic/open.c
copy to libc/bionic/unlink.cpp
index 6441dc2..b1ab15c 100644
--- a/libc/bionic/open.c
+++ b/libc/bionic/unlink.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,10 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <unistd.h>
+
#include <fcntl.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
+#include <unistd.h>
-extern int __open(const char*, int, int);
-
-int open(const char* pathname, int flags, ...) {
- mode_t mode = 0;
-
- flags |= O_LARGEFILE;
-
- if (flags & O_CREAT) {
- va_list args;
- va_start(args, flags);
- mode = (mode_t) va_arg(args, int);
- va_end(args);
- }
-
- return __open(pathname, flags, mode);
-}
-
-int __open_2(const char* pathname, int flags) {
- if (__predict_false(flags & O_CREAT)) {
- __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
- }
-
- flags |= O_LARGEFILE;
-
- return __open(pathname, flags, 0);
+int unlink(const char* path) {
+ return unlinkat(AT_FDCWD, path, 0);
}
diff --git a/libc/bionic/open.c b/libc/bionic/utimes.cpp
similarity index 66%
copy from libc/bionic/open.c
copy to libc/bionic/utimes.cpp
index 6441dc2..315765a 100644
--- a/libc/bionic/open.c
+++ b/libc/bionic/utimes.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,26 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <unistd.h>
+
#include <fcntl.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include "private/libc_logging.h"
+#include <sys/stat.h>
+#include <sys/time.h>
-extern int __open(const char*, int, int);
+int utimes(const char* path, const timeval tv[2]) {
+ timespec ts[2];
-int open(const char* pathname, int flags, ...) {
- mode_t mode = 0;
+ // Whole seconds can just be copied.
+ ts[0].tv_sec = tv[0].tv_sec;
+ ts[1].tv_sec = tv[1].tv_sec;
- flags |= O_LARGEFILE;
-
- if (flags & O_CREAT) {
- va_list args;
- va_start(args, flags);
- mode = (mode_t) va_arg(args, int);
- va_end(args);
+ // But we might overflow when converting microseconds to nanoseconds.
+ if (tv[0].tv_usec >= 1000000 || tv[0].tv_usec < 0 ||
+ tv[1].tv_usec >= 1000000 || tv[1].tv_usec < 0) {
+ errno = EINVAL;
+ return -1;
}
+ ts[0].tv_nsec = tv[0].tv_usec * 1000;
+ ts[1].tv_nsec = tv[1].tv_usec * 1000;
- return __open(pathname, flags, mode);
-}
-
-int __open_2(const char* pathname, int flags) {
- if (__predict_false(flags & O_CREAT)) {
- __fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
- }
-
- flags |= O_LARGEFILE;
-
- return __open(pathname, flags, 0);
+ return utimensat(AT_FDCWD, path, ts, 0);
}