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