git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Add a fast version of fstat to cygwin port

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Mar 19, 2009, 14:54 UTC
Message-ID
<49C25CAE.6000003@viscovery.net>
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:

Show 13 quoted lines
> +#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
Previous: Alex RiesenNext: Alex Riesen
Message 2 of 3 in “Add a fast version of fstat to cygwin port”
  1. Add a fast version of fstat to cygwin portAlex Riesen, Mar 19, 2009
  2. Johannes SixtMar 19, 2009
  3. Alex RiesenMar 19, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.