diff --git a/contrib/chg/util.c b/contrib/chg/util.c --- a/contrib/chg/util.c +++ b/contrib/chg/util.c @@ -84,6 +84,13 @@ void debugmsg(const char *fmt, ...) va_end(args); } +void fchdirx(int dirfd) +{ + int r = fchdir(dirfd); + if (r == -1) + abortmsgerrno("failed to fchdir"); +} + void *mallocx(size_t size) { void *result = malloc(size); diff --git a/contrib/chg/util.h b/contrib/chg/util.h --- a/contrib/chg/util.h +++ b/contrib/chg/util.h @@ -23,6 +23,7 @@ void enablecolor(void); void enabledebugmsg(void); void debugmsg(const char *fmt, ...) PRINTF_FORMAT_; +void fchdirx(int dirfd); void *mallocx(size_t size); void *reallocx(void *ptr, size_t size);