[PATCH 01 of 14] chg: add fchdirx as a utility function
Jun Wu
quark at fb.com
Sun Apr 10 23:57:18 UTC 2016
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1460254472 -3600
# Sun Apr 10 03:14:32 2016 +0100
# Node ID cecc773636dcaeaf6d5130831f400a77fb065a96
# Parent 99a2bdad0fda4fe16830376ad81c1065a5080cb9
chg: add fchdirx as a utility function
As part of the series to support long socket path, we need to use fchdir and
check its result in several places. Make it a utility function.
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 @@
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 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);
More information about the Mercurial-devel
mailing list