chg: initialize sockdirfd to -1 instead of AT_FDCWD
As we don't use sockdirfd yet, this is the simplest workaround to compile chg
on old Unices where AT_FDCWD does not exist. Foozy pointed out Mac OS X 10.10
is required for AT_FDCWD as well as xxxat() functions.
--- a/contrib/chg/chg.c Fri Apr 22 13:38:02 2016 -0500
+++ b/contrib/chg/chg.c Sun Apr 24 21:35:30 2016 +0900
@@ -42,7 +42,7 @@
static void initcmdserveropts(struct cmdserveropts *opts) {
memset(opts, 0, sizeof(struct cmdserveropts));
opts->lockfd = -1;
- opts->sockdirfd = AT_FDCWD;
+ opts->sockdirfd = -1;
}
static void freecmdserveropts(struct cmdserveropts *opts) {
@@ -50,9 +50,9 @@
opts->args = NULL;
opts->argsize = 0;
assert(opts->lockfd == -1 && "should be closed by unlockcmdserver()");
- if (opts->sockdirfd != AT_FDCWD) {
+ if (opts->sockdirfd >= 0) {
close(opts->sockdirfd);
- opts->sockdirfd = AT_FDCWD;
+ opts->sockdirfd = -1;
}
}