Commit e766985b authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

msvcrt: Fix the permissions returned by fstat*() (with test).

parent 266ee43e
...@@ -1167,9 +1167,9 @@ int CDECL MSVCRT__fstat64(int fd, struct MSVCRT__stat64* buf) ...@@ -1167,9 +1167,9 @@ int CDECL MSVCRT__fstat64(int fd, struct MSVCRT__stat64* buf)
msvcrt_set_errno(ERROR_INVALID_PARAMETER); msvcrt_set_errno(ERROR_INVALID_PARAMETER);
return -1; return -1;
} }
buf->st_mode = S_IFREG | S_IREAD; buf->st_mode = S_IFREG | 0444;
if (!(hfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) if (!(hfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
buf->st_mode |= S_IWRITE; buf->st_mode |= 0222;
buf->st_size = ((__int64)hfi.nFileSizeHigh << 32) + hfi.nFileSizeLow; buf->st_size = ((__int64)hfi.nFileSizeHigh << 32) + hfi.nFileSizeLow;
RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastAccessTime, &dw); RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastAccessTime, &dw);
buf->st_atime = dw; buf->st_atime = dw;
......
...@@ -905,6 +905,7 @@ static void test_stat(void) ...@@ -905,6 +905,7 @@ static void test_stat(void)
{ {
ok(fstat(fd, &buf) == 0, "fstat failed: errno=%d", errno); ok(fstat(fd, &buf) == 0, "fstat failed: errno=%d", errno);
ok((buf.st_mode & _S_IFMT) == _S_IFREG, "bad format = %06o\n", buf.st_mode); ok((buf.st_mode & _S_IFMT) == _S_IFREG, "bad format = %06o\n", buf.st_mode);
ok((buf.st_mode & 0777) == 0666, "bad st_mode = %06o\n", buf.st_mode);
ok(buf.st_dev == 0, "st_dev is %d, expected 0\n", buf.st_dev); ok(buf.st_dev == 0, "st_dev is %d, expected 0\n", buf.st_dev);
ok(buf.st_dev == buf.st_rdev, "st_dev (%d) and st_rdev (%d) differ\n", buf.st_dev, buf.st_rdev); ok(buf.st_dev == buf.st_rdev, "st_dev (%d) and st_rdev (%d) differ\n", buf.st_dev, buf.st_rdev);
ok(buf.st_nlink == 1, "st_nlink is %d, expected 1\n", buf.st_nlink); ok(buf.st_nlink == 1, "st_nlink is %d, expected 1\n", buf.st_nlink);
...@@ -912,6 +913,7 @@ static void test_stat(void) ...@@ -912,6 +913,7 @@ static void test_stat(void)
ok(stat("stat.tst", &buf) == 0, "stat failed: errno=%d", errno); ok(stat("stat.tst", &buf) == 0, "stat failed: errno=%d", errno);
ok((buf.st_mode & _S_IFMT) == _S_IFREG, "bad format = %06o\n", buf.st_mode); ok((buf.st_mode & _S_IFMT) == _S_IFREG, "bad format = %06o\n", buf.st_mode);
ok((buf.st_mode & 0777) == 0666, "bad st_mode = %06o\n", buf.st_mode);
ok(buf.st_dev == buf.st_rdev, "st_dev (%d) and st_rdev (%d) differ\n", buf.st_dev, buf.st_rdev); ok(buf.st_dev == buf.st_rdev, "st_dev (%d) and st_rdev (%d) differ\n", buf.st_dev, buf.st_rdev);
ok(buf.st_nlink == 1, "st_nlink is %d, expected 1\n", buf.st_nlink); ok(buf.st_nlink == 1, "st_nlink is %d, expected 1\n", buf.st_nlink);
ok(buf.st_size == 0, "st_size is %d, expected 0\n", buf.st_size); ok(buf.st_size == 0, "st_size is %d, expected 0\n", buf.st_size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment