]> sourceware.org Git - glibc.git/commitdiff
support: Add the xlstat function
authorFlorian Weimer <fweimer@redhat.com>
Sun, 9 Feb 2020 10:50:44 +0000 (11:50 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Sun, 9 Feb 2020 10:50:44 +0000 (11:50 +0100)
support/Makefile
support/xlstat.c [new file with mode: 0644]
support/xunistd.h

index 3325feb790077d9bfca67d2d969236a4314d8885..a0304e6def64e1309ad3dc458e2d667a824544d5 100644 (file)
@@ -98,6 +98,7 @@ libsupport-routines = \
   xgetsockname \
   xlisten \
   xlseek \
+  xlstat \
   xmalloc \
   xmemstream \
   xmkdir \
diff --git a/support/xlstat.c b/support/xlstat.c
new file mode 100644 (file)
index 0000000..de45ef3
--- /dev/null
@@ -0,0 +1,28 @@
+/* lstat64 with error checking.
+   Copyright (C) 2017-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <sys/stat.h>
+
+void
+xlstat (const char *path, struct stat64 *result)
+{
+  if (lstat64 (path, result) != 0)
+    FAIL_EXIT1 ("lstat64 (\"%s\"): %m", path);
+}
index 96f498f2e53691078b397feddf4e01acf630eeda..b299db77ba63e489c76d4912d9b193f557c3922f 100644 (file)
@@ -36,6 +36,7 @@ void xpipe (int[2]);
 void xdup2 (int, int);
 int xopen (const char *path, int flags, mode_t);
 void xstat (const char *path, struct stat64 *);
+void xlstat (const char *path, struct stat64 *);
 void xfstat (int fd, struct stat64 *);
 void xmkdir (const char *path, mode_t);
 void xchroot (const char *path);
This page took 0.042656 seconds and 5 git commands to generate.