git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Sixt <j.sixt@viscovery.net>
To: Alex Riesen <raa.lkml@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>,
	Dmitry Potapov <dpotapov@gmail.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Marius Storm-Olsen <marius@trolltech.com>
Subject: Re: [PATCH] Add a fast version of fstat to cygwin port
Date: Thu, 19 Mar 2009 15:54:38 +0100	[thread overview]
Message-ID: <49C25CAE.6000003@viscovery.net> (raw)
In-Reply-To: <81b0412b0903190730s40589291iea9a861ddeedcc0@mail.gmail.com>

Alex Riesen schrieb:
> Besides, the output of the fast stat and lstat is not compatible
> with cygwin's fstat with regard to uid, gid and ctime fields.

Why do you need this? I don't think that fstat() is used in a critical
path. Do you see problems with the incompatible fields?

> This is not strictly related to the other stat patches. The fstat
> code is shamelessly stolen from the mingw port, sorry.

I wouldn't call it "stolen", but "copied". Because if you copy it, it
becomes your responsibility and all copied bugs are yours ;)

> BTW, why do we have to #undef fstat, but not stat/lstat?

Because stat and lstat are #defined with an argument list, but in those
instances where the cygwin version of stat/lstat is meant, they are used
*without* argument list (see cygwin_stat/lstat_stub), and no macro
expansion happens, and therefore we don't need to #undef the macro.

OTOH, do_fstat calls into cygwin's fstat() if the file handle is not a
file and uses an argument list that would cause a macro expansion if it
were not #undef'd:

> +#undef fstat
> +static int cygwin_fstat(int fd, struct stat *buf)
> +{
> +	HANDLE fh = (HANDLE)_get_osfhandle(fd);
> +	BY_HANDLE_FILE_INFORMATION fdata;
> +
> +	if (fh == INVALID_HANDLE_VALUE) {
> +		errno = EBADF;
> +		return -1;
> +	}
> +	/* direct non-file handles to cygwin's fstat() */
> +	if (GetFileType(fh) != FILE_TYPE_DISK)
> +		return fstat(fd, buf);

We never do that for stat/lstat.

-- Hannes

  reply	other threads:[~2009-03-19 14:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-19 14:30 [PATCH] Add a fast version of fstat to cygwin port Alex Riesen
2009-03-19 14:54 ` Johannes Sixt [this message]
2009-03-19 15:14   ` Alex Riesen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49C25CAE.6000003@viscovery.net \
    --to=j.sixt@viscovery.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=dpotapov@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=marius@trolltech.com \
    --cc=raa.lkml@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).