aboutsummaryrefslogtreecommitdiff
path: root/libbb/xstat.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/xstat.c')
-rw-r--r--libbb/xstat.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libbb/xstat.c b/libbb/xstat.c
new file mode 100644
index 000000000..ca6686403
--- /dev/null
+++ b/libbb/xstat.c
@@ -0,0 +1,11 @@
+/*
+ * xstat.c - a stat() which dies on failure with meaningful error message
+ */
+#include <unistd.h>
+#include "libbb.h"
+
+void xstat(const char *name, struct stat *stat_buf)
+{
+ if (stat(name, stat_buf))
+ bb_perror_msg_and_die("Can't stat '%s'", name);
+}