Fixed sshfs issue

https://github.com/PowerShell/Win32-OpenSSH/issues/586
This commit is contained in:
Manoj Ampalam 2017-04-03 13:36:29 -07:00 committed by GitHub
parent 589f2db723
commit c09ef3f1cb

View File

@ -665,25 +665,23 @@ fileio_fstat(struct w32_io* pio, struct _stat64 *buf)
int int
fileio_stat(const char *path, struct _stat64 *buf) fileio_stat(const char *path, struct _stat64 *buf)
{ {
wchar_t wpath[PATH_MAX]; wchar_t* wpath = NULL;
wchar_t* wtmp = NULL; int r = -1;
struct w32_io* pio;
if ((wtmp = utf8_to_utf16(path)) == NULL) if ((wpath = utf8_to_utf16(path)) == NULL)
fatal("failed to covert input arguments"); fatal("failed to covert input arguments");
/* If we doesn't have sufficient permissions then _wstat4() is returning r = _wstat64(wpath, buf);
* file not found so added fileio_open() which will set the errorno correctly (access denied)
/*
* If we doesn't have sufficient permissions then _wstat64() is returning "file not found"
* TODO - Replace the above call with GetFileAttributesEx
*/ */
if (NULL == (pio = fileio_open(path, O_RDONLY, 0)))
return -1;
fileio_close(pio); cleanup:
if (wpath)
wcscpy(&wpath[0], wtmp); free(wpath);
free(wtmp); return r;
return _wstat64(wpath, buf);
} }
long long