Patchwork [STABLE] chg: initialize sockdirfd to -1 instead of AT_FDCWD

login
register
mail settings
Submitter Yuya Nishihara
Date April 26, 2016, 3:29 p.m.
Message ID <a1aae7b04aebd5b1e279.1461684550@mimosa>
Download mbox | patch
Permalink /patch/14794/
State Accepted
Headers show

Comments

Yuya Nishihara - April 26, 2016, 3:29 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1461501330 -32400
#      Sun Apr 24 21:35:30 2016 +0900
# Branch stable
# Node ID a1aae7b04aebd5b1e279aa17eadc87c9fec50aa2
# Parent  38292b227debf6393dc1e2c6ff886f85f6673646
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.
Sean Farley - April 26, 2016, 5:46 p.m.
Yuya Nishihara <yuya@tcha.org> writes:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1461501330 -32400
> #      Sun Apr 24 21:35:30 2016 +0900
> # Branch stable
> # Node ID a1aae7b04aebd5b1e279aa17eadc87c9fec50aa2
> # Parent  38292b227debf6393dc1e2c6ff886f85f6673646
> 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.

Sure, seems fine to me.
Matt Mackall - April 27, 2016, 8:26 p.m.
On Wed, 2016-04-27 at 00:29 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1461501330 -32400
> #      Sun Apr 24 21:35:30 2016 +0900
> # Branch stable
> # Node ID a1aae7b04aebd5b1e279aa17eadc87c9fec50aa2
> # Parent  38292b227debf6393dc1e2c6ff886f85f6673646
> chg: initialize sockdirfd to -1 instead of AT_FDCWD

Queued for stable, thanks.

-- 
Mathematics is the supreme nostalgia of our time.

Patch

diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c
--- a/contrib/chg/chg.c
+++ b/contrib/chg/chg.c
@@ -42,7 +42,7 @@  struct cmdserveropts {
 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 @@  static void freecmdserveropts(struct cmd
 	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;
 	}
 }