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.
--- 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;
+ }
}
/*