# HG changeset patch # User Jun Wu # Date 1460254472 -3600 # Node ID ddef14468952c0ac5e6b42b19c0207d20e80ac7f # Parent d11548b4ae456941bf46195e11309ad73155e0c1 chg: add fchdirx as a utility function As part of the series to support long socket paths, we need to use fchdir and check its result in several places. Make it a utility function. diff -r d11548b4ae45 -r ddef14468952 contrib/chg/util.c --- a/contrib/chg/util.c Sun Apr 10 22:58:11 2016 +0100 +++ b/contrib/chg/util.c Sun Apr 10 03:14:32 2016 +0100 @@ -84,6 +84,13 @@ 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 -r d11548b4ae45 -r ddef14468952 contrib/chg/util.h --- a/contrib/chg/util.h Sun Apr 10 22:58:11 2016 +0100 +++ b/contrib/chg/util.h Sun Apr 10 03:14:32 2016 +0100 @@ -23,6 +23,7 @@ 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);