]> sourceware.org Git - glibc.git/commitdiff
Add xchdir to libsupport.
authorAlexandra Hájková <ahajkova@redhat.com>
Sat, 26 Dec 2020 17:45:13 +0000 (18:45 +0100)
committerAlexandra Hájková <ahajkova@redhat.com>
Sat, 9 Jan 2021 16:47:50 +0000 (17:47 +0100)
support/Makefile
support/xchdir.c [new file with mode: 0644]
support/xunistd.h

index 80382a1a7914930ba786379ff039feb8a931c6e5..f4d157dded0e246f029b23a28e9b5c1386d0a71e 100644 (file)
@@ -87,6 +87,7 @@ libsupport-routines = \
   xasprintf \
   xbind \
   xcalloc \
+  xchdir \
   xchroot \
   xclock_gettime \
   xclose \
diff --git a/support/xchdir.c b/support/xchdir.c
new file mode 100644 (file)
index 0000000..beb4fef
--- /dev/null
@@ -0,0 +1,28 @@
+/* chdir with error checking.
+   Copyright (C) 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 <unistd.h>
+
+void
+xchdir (const char *path)
+{
+  if (chdir (path) != 0)
+    FAIL_EXIT1 ("chdir (\"%s\"): %m", path);
+}
index a219fb6a3d55391ff7e98e4c014c82514638c442..12a5ab677c2bf923e7ccee2325ad0ca005b42476 100644 (file)
@@ -45,6 +45,7 @@ long xsysconf (int name);
 long long xlseek (int fd, long long offset, int whence);
 void xftruncate (int fd, long long length);
 void xsymlink (const char *target, const char *linkpath);
+void xchdir (const char *path);
 
 /* Equivalent of "mkdir -p".  */
 void xmkdirp (const char *, mode_t);
This page took 0.048603 seconds and 5 git commands to generate.