summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc/port/sys
diff options
context:
space:
mode:
authorRoger A. Faulkner <Roger.Faulkner@Oracle.COM>2010-07-07 17:36:17 -0700
committerRoger A. Faulkner <Roger.Faulkner@Oracle.COM>2010-07-07 17:36:17 -0700
commit794f0adb050e571bbfde4d2a19b9f88b852079dd (patch)
treec1735b3eda175e9096f5b062a73614e73aa5cd9a /usr/src/lib/libc/port/sys
parent07925104db56e5c3eacc4865b918bd16af5cec59 (diff)
downloadillumos-gate-794f0adb050e571bbfde4d2a19b9f88b852079dd.tar.gz
PSARC 2010/235 POSIX 1003.1-2008 *at(2) syscalls
6910251 need support for all POSIX.1-2008 *at(2) syscalls 6964835 mknod(2) auditing omits the pathname for invalid arguments
Diffstat (limited to 'usr/src/lib/libc/port/sys')
-rw-r--r--usr/src/lib/libc/port/sys/chmod.c60
-rw-r--r--usr/src/lib/libc/port/sys/link.c (renamed from usr/src/lib/libc/port/sys/libc_link.c)40
-rw-r--r--usr/src/lib/libc/port/sys/mkdir.c46
-rw-r--r--usr/src/lib/libc/port/sys/mknod.c46
-rw-r--r--usr/src/lib/libc/port/sys/readlink.c58
-rw-r--r--usr/src/lib/libc/port/sys/symlink.c46
6 files changed, 275 insertions, 21 deletions
diff --git a/usr/src/lib/libc/port/sys/chmod.c b/usr/src/lib/libc/port/sys/chmod.c
new file mode 100644
index 0000000000..90266e55b1
--- /dev/null
+++ b/usr/src/lib/libc/port/sys/chmod.c
@@ -0,0 +1,60 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include "lint.h"
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/fcntl.h>
+
+int
+fchmodat(int fd, const char *path, mode_t mode, int flag)
+{
+ return (syscall(SYS_fchmodat, fd, path, mode, flag));
+}
+
+#pragma weak _chmod = chmod
+int
+chmod(const char *path, mode_t mode)
+{
+#if defined(_RETAIN_OLD_SYSCALLS)
+ return (syscall(SYS_chmod, path, mode));
+#else
+ return (fchmodat(AT_FDCWD, path, mode, 0));
+#endif
+}
+
+#pragma weak _fchmod = fchmod
+int
+fchmod(int fd, mode_t mode)
+{
+#if defined(_RETAIN_OLD_SYSCALLS)
+ return (syscall(SYS_fchmod, fd, mode));
+#else
+ return (fchmodat(fd, NULL, mode, 0));
+#endif
+}
diff --git a/usr/src/lib/libc/port/sys/libc_link.c b/usr/src/lib/libc/port/sys/link.c
index f0f4356871..dd1d64240e 100644
--- a/usr/src/lib/libc/port/sys/libc_link.c
+++ b/usr/src/lib/libc/port/sys/link.c
@@ -20,30 +20,26 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#pragma weak _link = link
-
#include "lint.h"
-#include <stdlib.h>
-#include <errno.h>
#include <unistd.h>
-#include <limits.h>
+#include <fcntl.h>
+#include <sys/syscall.h>
extern int __xpg4; /* defined in port/gen/xpg4.c; 0 if not xpg4/xpg4v2 */
-extern int __link(const char *existing, const char *new);
-
int
-link(const char *existing, const char *new)
+linkat(int fd1, const char *path1, int fd2, const char *path2, int flag)
{
- int sz;
- char linkbuf[PATH_MAX + 1];
+ return (syscall(SYS_linkat, fd1, path1, fd2, path2, flag));
+}
+#pragma weak _link = link
+int
+link(const char *path1, const char *path2)
+{
/*
* XPG4v2 link() requires that the link count of a symbolic
* link target be updated rather than the link itself. This
@@ -56,11 +52,13 @@ link(const char *existing, const char *new)
* non-XPG4 based environments. For a more detailed discussion,
* see bug 1256170.
*/
- if (__xpg4 != 0) {
- if ((sz = resolvepath(existing, linkbuf, PATH_MAX)) == -1)
- return (-1);
- linkbuf[sz] = '\0';
- existing = linkbuf;
- }
- return (__link(existing, new));
+ if (__xpg4 != 0)
+ return (linkat(AT_FDCWD, path1, AT_FDCWD, path2,
+ AT_SYMLINK_FOLLOW));
+
+#if defined(_RETAIN_OLD_SYSCALLS)
+ return (syscall(SYS_link, path1, path2));
+#else
+ return (linkat(AT_FDCWD, path1, AT_FDCWD, path2, 0));
+#endif
}
diff --git a/usr/src/lib/libc/port/sys/mkdir.c b/usr/src/lib/libc/port/sys/mkdir.c
new file mode 100644
index 0000000000..49f60111c4
--- /dev/null
+++ b/usr/src/lib/libc/port/sys/mkdir.c
@@ -0,0 +1,46 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include "lint.h"
+#include <sys/syscall.h>
+#include <sys/stat.h>
+#include <sys/fcntl.h>
+
+int
+mkdirat(int fd, const char *path, mode_t mode)
+{
+ return (syscall(SYS_mkdirat, fd, path, mode));
+}
+
+#pragma weak _mkdir = mkdir
+int
+mkdir(const char *path, mode_t mode)
+{
+#if defined(_RETAIN_OLD_SYSCALLS)
+ return (syscall(SYS_mkdir, path, mode));
+#else
+ return (mkdirat(AT_FDCWD, path, mode));
+#endif
+}
diff --git a/usr/src/lib/libc/port/sys/mknod.c b/usr/src/lib/libc/port/sys/mknod.c
new file mode 100644
index 0000000000..df179cfec2
--- /dev/null
+++ b/usr/src/lib/libc/port/sys/mknod.c
@@ -0,0 +1,46 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include "lint.h"
+#include <sys/syscall.h>
+#include <sys/stat.h>
+#include <sys/fcntl.h>
+
+int
+mknodat(int fd, const char *path, mode_t mode, dev_t dev)
+{
+ return (syscall(SYS_mknodat, fd, path, mode, dev));
+}
+
+#pragma weak _mknod = mknod
+int
+mknod(const char *path, mode_t mode, dev_t dev)
+{
+#if defined(_RETAIN_OLD_SYSCALLS)
+ return (syscall(SYS_mknod, path, mode, dev));
+#else
+ return (mknodat(AT_FDCWD, path, mode, dev));
+#endif
+}
diff --git a/usr/src/lib/libc/port/sys/readlink.c b/usr/src/lib/libc/port/sys/readlink.c
new file mode 100644
index 0000000000..fc58441b53
--- /dev/null
+++ b/usr/src/lib/libc/port/sys/readlink.c
@@ -0,0 +1,58 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include "lint.h"
+#include <sys/syscall.h>
+#include <sys/unistd.h>
+#include <sys/fcntl.h>
+
+ssize_t
+readlinkat(int fd, const char *path, char *buf, size_t bufsize)
+{
+ sysret_t rval;
+ int error;
+
+ error = __systemcall(&rval, SYS_readlinkat, fd, path, buf, bufsize);
+ if (error)
+ (void) __set_errno(error);
+ return ((ssize_t)rval.sys_rval1);
+}
+
+#pragma weak _readlink = readlink
+ssize_t
+readlink(const char *path, char *buf, size_t bufsize)
+{
+#if defined(_RETAIN_OLD_SYSCALLS)
+ sysret_t rval;
+ int error;
+
+ error = __systemcall(&rval, SYS_readlink, path, buf, bufsize);
+ if (error)
+ (void) __set_errno(error);
+ return ((ssize_t)rval.sys_rval1);
+#else
+ return (readlinkat(AT_FDCWD, path, buf, bufsize));
+#endif
+}
diff --git a/usr/src/lib/libc/port/sys/symlink.c b/usr/src/lib/libc/port/sys/symlink.c
new file mode 100644
index 0000000000..59a6ece2c4
--- /dev/null
+++ b/usr/src/lib/libc/port/sys/symlink.c
@@ -0,0 +1,46 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include "lint.h"
+#include <sys/syscall.h>
+#include <sys/unistd.h>
+#include <sys/fcntl.h>
+
+int
+symlinkat(const char *path1, int fd, const char *path2)
+{
+ return (syscall(SYS_symlinkat, path1, fd, path2));
+}
+
+#pragma weak _symlink = symlink
+int
+symlink(const char *path1, const char *path2)
+{
+#if defined(_RETAIN_OLD_SYSCALLS)
+ return (syscall(SYS_symlink, path1, path2));
+#else
+ return (symlinkat(path1, AT_FDCWD, path2));
+#endif
+}