Patchwork [03,of,14] chg: add sockdirfd to cmdserveropts

login
register
mail settings
Submitter Jun Wu
Date April 10, 2016, 11:57 p.m.
Message ID <400fbf5ed12b8585bea9.1460332640@x1c>
Download mbox | patch
Permalink /patch/14502/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Jun Wu - April 10, 2016, 11:57 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1460328960 -3600
#      Sun Apr 10 23:56:00 2016 +0100
# Node ID 400fbf5ed12b8585bea9fee27abb250fa4c98bd1
# Parent  97fbb23cf84c03ce59325e9de94902f40c68c8c8
chg: add sockdirfd to cmdserveropts

As part of the series to support long socket path, 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.
timeless - April 11, 2016, 3:37 a.m.
Jun Wu  wrote:
> As part of the series to support long socket path, we need to add the fd of

path => paths

> the directory to the cmdserveropts structure so we can use basenames instead
> of full paths for sockname, redirectsockname and lockfile.

and => , and

we generally use an Oxford comma

Patch

diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c
--- a/contrib/chg/chg.c
+++ b/contrib/chg/chg.c
@@ -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;
+	}
 }
 
 /*