[PATCH 07 of 14] chg: use openat instead of open when creating the lock file
Yuya Nishihara
yuya at tcha.org
Mon Apr 11 09:26:07 EDT 2016
On Mon, 11 Apr 2016 00:57:24 +0100, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1460327930 -3600
> # Sun Apr 10 23:38:50 2016 +0100
> # Node ID 4616bceaa941b40b39055610ba109252dee3a20c
> # Parent a0233eac2848926116ecbdb4bf44fd5f066d7f1d
> chg: use openat instead of open when creating the lock file
>
> This is a part of the series to support long socket path. Since we will switch
> to basename for the lock file soon, use openat instead of open to make sure
> it is created inside the directory.
>
> diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c
> --- a/contrib/chg/chg.c
> +++ b/contrib/chg/chg.c
> @@ -174,8 +174,8 @@
> static void lockcmdserver(struct cmdserveropts *opts)
> {
> if (opts->lockfd == -1) {
> - opts->lockfd = open(opts->lockfile,
> - O_RDWR | O_CREAT | O_NOFOLLOW, 0600);
> + opts->lockfd = openat(opts->sockdirfd, opts->lockfile,
> + O_RDWR | O_CREAT | O_NOFOLLOW, 0600);
It appears that openat() was introduced in Mac OS X 10.10, which seems too
new to use without compatibility layer.
More information about the Mercurial-devel
mailing list