diff options
Diffstat (limited to 'libbb/xfuncs_printf.c')
-rw-r--r-- | libbb/xfuncs_printf.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index b99f906df..c6db38d33 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c @@ -436,6 +436,16 @@ void FAST_FUNC xstat(const char *name, struct stat *stat_buf) bb_perror_msg_and_die("can't stat '%s'", name); } +void FAST_FUNC xfstat(int fd, struct stat *stat_buf, const char *errmsg) +{ + /* errmsg is usually a file name, but not always: + * xfstat may be called in a spot where file name is no longer + * available, and caller may give e.g. "can't stat input file" string. + */ + if (fstat(fd, stat_buf)) + bb_simple_perror_msg_and_die(errmsg); +} + // selinux_or_die() - die if SELinux is disabled. void FAST_FUNC selinux_or_die(void) { |