changeset 28852:7b5f5a1b4b41

chg: add sockdirfd to cmdserveropts As part of the series to support long socket paths, we need to add the fd of the directory to the cmdserveropts structure so we can use basenames instead of full paths for sockname, redirectsockname, and lockfile.
author Jun Wu <quark@fb.com>
date Sun, 10 Apr 2016 23:56:00 +0100
parents 584e0716c7af
children d11548b4ae45
files contrib/chg/chg.c
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/chg/chg.c	Sun Apr 10 21:56:05 2016 +0100
+++ b/contrib/chg/chg.c	Sun Apr 10 23:56:00 2016 +0100
@@ -36,17 +36,23 @@
 	size_t argsize;
 	const char **args;
 	int lockfd;
+	int sockdirfd;
 };
 
 static void initcmdserveropts(struct cmdserveropts *opts) {
 	memset(opts, 0, sizeof(struct cmdserveropts));
 	opts->lockfd = -1;
+	opts->sockdirfd = AT_FDCWD;
 }
 
 static void freecmdserveropts(struct cmdserveropts *opts) {
 	free(opts->args);
 	opts->args = NULL;
 	opts->argsize = 0;
+	if (opts->sockdirfd != AT_FDCWD) {
+		close(opts->sockdirfd);
+		opts->sockdirfd = AT_FDCWD;
+	}
 }
 
 /*