aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/sys/lstat.c
diff options
context:
space:
mode:
authorBrooks Davis <brooks@FreeBSD.org>2024-03-13 17:42:01 +0000
committerBrooks Davis <brooks@FreeBSD.org>2024-03-13 18:36:02 +0000
commitd7847a8d351436a4654bd2c746bc9c04401160ee (patch)
tree3bb423b59c9016c62d010941ff61124083e2e839 /lib/libc/sys/lstat.c
parentef5fddd3440cc726db2acb85ca55fdc9c996ea64 (diff)
downloadsrc-d7847a8d351436a4654bd2c746bc9c04401160ee.tar.gz
src-d7847a8d351436a4654bd2c746bc9c04401160ee.zip
lib{c,sys}: return wrapped syscall APIs to libc
These provide standard APIs, but are implemented using another system call (e.g., pipe implemented in terms of pipe2) or are interposed by the threading library to support cancelation. After discussion with kib (see D44111), I've concluded that it is better to keep most public interfaces in libc with as little as possible in libsys. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D44241
Diffstat (limited to 'lib/libc/sys/lstat.c')
-rw-r--r--lib/libc/sys/lstat.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/libc/sys/lstat.c b/lib/libc/sys/lstat.c
new file mode 100644
index 000000000000..3a6421120434
--- /dev/null
+++ b/lib/libc/sys/lstat.c
@@ -0,0 +1,40 @@
+/*-
+ * Copyright (c) 2012 Gleb Kurtsou <gleb@FreeBSD.org> All rights reserved.
+ * Copyright (c) 2017 M. Warner Losh <imp@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "namespace.h"
+#include <sys/param.h>
+#include <sys/fcntl.h>
+#include <sys/syscall.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include "libc_private.h"
+
+int
+lstat(const char *path, struct stat *sb)
+{
+
+ return (__sys_fstatat(AT_FDCWD, path, sb, AT_SYMLINK_NOFOLLOW));
+}