|
|
87c1f6 |
commit 7a7226543611897103c7483bec160547294dcf0d
|
|
|
87c1f6 |
Author: Alexandra Hájková <ahajkova@redhat.com>
|
|
|
87c1f6 |
Date: Sat Dec 26 20:44:34 2020 +0100
|
|
|
87c1f6 |
|
|
|
87c1f6 |
Add xfchmod to libsupport
|
|
|
87c1f6 |
|
|
|
87c1f6 |
diff --git a/support/Makefile b/support/Makefile
|
|
|
87c1f6 |
index d2b95539403e416c..4875f52495ef292d 100644
|
|
|
87c1f6 |
--- a/support/Makefile
|
|
|
87c1f6 |
+++ b/support/Makefile
|
|
|
87c1f6 |
@@ -91,6 +91,7 @@ libsupport-routines = \
|
|
|
87c1f6 |
xdlfcn \
|
|
|
87c1f6 |
xdlmopen \
|
|
|
87c1f6 |
xdup2 \
|
|
|
87c1f6 |
+ xfchmod \
|
|
|
87c1f6 |
xfclose \
|
|
|
87c1f6 |
xfopen \
|
|
|
87c1f6 |
xfork \
|
|
|
87c1f6 |
diff --git a/support/xfchmod.c b/support/xfchmod.c
|
|
|
87c1f6 |
new file mode 100644
|
|
|
87c1f6 |
index 0000000000000000..4323b9ca8e078c98
|
|
|
87c1f6 |
--- /dev/null
|
|
|
87c1f6 |
+++ b/support/xfchmod.c
|
|
|
87c1f6 |
@@ -0,0 +1,28 @@
|
|
|
87c1f6 |
+/* fchmod with error checking.
|
|
|
87c1f6 |
+ Copyright (C) 2021 Free Software Foundation, Inc.
|
|
|
87c1f6 |
+ This file is part of the GNU C Library.
|
|
|
87c1f6 |
+
|
|
|
87c1f6 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
87c1f6 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
87c1f6 |
+ License as published by the Free Software Foundation; either
|
|
|
87c1f6 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
87c1f6 |
+
|
|
|
87c1f6 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
87c1f6 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
87c1f6 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
87c1f6 |
+ Lesser General Public License for more details.
|
|
|
87c1f6 |
+
|
|
|
87c1f6 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
87c1f6 |
+ License along with the GNU C Library; if not, see
|
|
|
87c1f6 |
+ <https://www.gnu.org/licenses/>. */
|
|
|
87c1f6 |
+
|
|
|
87c1f6 |
+#include <support/check.h>
|
|
|
87c1f6 |
+#include <support/xunistd.h>
|
|
|
87c1f6 |
+#include <sys/stat.h>
|
|
|
87c1f6 |
+
|
|
|
87c1f6 |
+void
|
|
|
87c1f6 |
+xfchmod (int fd, mode_t mode)
|
|
|
87c1f6 |
+{
|
|
|
87c1f6 |
+ if (fchmod (fd, mode) != 0)
|
|
|
87c1f6 |
+ FAIL_EXIT1 ("fchmod (%d, 0%o): %m", fd, mode);
|
|
|
87c1f6 |
+}
|
|
|
87c1f6 |
diff --git a/support/xunistd.h b/support/xunistd.h
|
|
|
87c1f6 |
index 74fd2771d12c36fe..ced8cb1dd9ee356c 100644
|
|
|
87c1f6 |
--- a/support/xunistd.h
|
|
|
87c1f6 |
+++ b/support/xunistd.h
|
|
|
87c1f6 |
@@ -45,6 +45,7 @@ long long xlseek (int fd, long long offset, int whence);
|
|
|
87c1f6 |
void xftruncate (int fd, long long length);
|
|
|
87c1f6 |
void xsymlink (const char *target, const char *linkpath);
|
|
|
87c1f6 |
void xchdir (const char *path);
|
|
|
87c1f6 |
+void xfchmod (int fd, mode_t mode);
|
|
|
87c1f6 |
|
|
|
87c1f6 |
/* Equivalent of "mkdir -p". */
|
|
|
87c1f6 |
void xmkdirp (const char *, mode_t);
|