|
|
28653a |
commit 7b9c3260bcca73781dda6bc2ddee84869bedfb8c
|
|
|
28653a |
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
28653a |
Date: Mon Dec 14 11:42:33 2020 -0300
|
|
|
28653a |
|
|
|
28653a |
support: Add xchmod wrapper
|
|
|
28653a |
|
|
|
28653a |
Checked on x86_64-linux-gnu.
|
|
|
28653a |
|
|
|
28653a |
diff --git a/support/xchmod.c b/support/xchmod.c
|
|
|
28653a |
new file mode 100644
|
|
|
28653a |
index 0000000000000000..5e403c7cc2705aef
|
|
|
28653a |
--- /dev/null
|
|
|
28653a |
+++ b/support/xchmod.c
|
|
|
28653a |
@@ -0,0 +1,30 @@
|
|
|
28653a |
+/* chmod with error checking.
|
|
|
28653a |
+ Copyright (C) 2020 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/xunistd.h>
|
|
|
28653a |
+#include <support/check.h>
|
|
|
28653a |
+
|
|
|
28653a |
+#include <sys/stat.h>
|
|
|
28653a |
+
|
|
|
28653a |
+void
|
|
|
28653a |
+xchmod (const char *pathname, mode_t mode)
|
|
|
28653a |
+{
|
|
|
28653a |
+ int r = chmod (pathname, mode);
|
|
|
28653a |
+ if (r < 0)
|
|
|
28653a |
+ FAIL_EXIT1 ("chmod (%s, %d): %m", pathname, mode);
|
|
|
28653a |
+}
|
|
|
28653a |
diff --git a/support/xunistd.h b/support/xunistd.h
|
|
|
28653a |
index ced8cb1dd9ee356c..e92056c65efe8d6a 100644
|
|
|
28653a |
--- a/support/xunistd.h
|
|
|
28653a |
+++ b/support/xunistd.h
|
|
|
28653a |
@@ -46,6 +46,7 @@ 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 |
+void xchmod (const char *pathname, mode_t mode);
|
|
|
28653a |
|
|
|
28653a |
/* Equivalent of "mkdir -p". */
|
|
|
28653a |
void xmkdirp (const char *, mode_t);
|