mirror of
https://github.com/libuv/libuv
synced 2025-03-28 21:13:16 +00:00
win: fix the inconsistency in volume serial number
This commit is contained in:
parent
dcace2a393
commit
82cdfb75ff
@ -1788,7 +1788,7 @@ INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf,
|
||||
SetLastError(pRtlNtStatusToDosError(nt_status));
|
||||
return -1;
|
||||
} else {
|
||||
stat_info.VolumeSerialNumber.QuadPart = volume_info.VolumeSerialNumber;
|
||||
stat_info.VolumeSerialNumber.LowPart = volume_info.VolumeSerialNumber;
|
||||
}
|
||||
|
||||
stat_info.DeviceType = device_info.DeviceType;
|
||||
@ -1839,7 +1839,7 @@ INLINE static void fs__stat_assign_statbuf_null(uv_stat_t* statbuf) {
|
||||
|
||||
INLINE static void fs__stat_assign_statbuf(uv_stat_t* statbuf,
|
||||
FILE_STAT_BASIC_INFORMATION stat_info, int do_lstat) {
|
||||
statbuf->st_dev = stat_info.VolumeSerialNumber.QuadPart;
|
||||
statbuf->st_dev = stat_info.VolumeSerialNumber.LowPart;
|
||||
|
||||
/* Todo: st_mode should probably always be 0666 for everyone. We might also
|
||||
* want to report 0777 if the file is a .exe or a directory.
|
||||
|
@ -1607,6 +1607,50 @@ TEST_IMPL(fs_fstat) {
|
||||
}
|
||||
|
||||
|
||||
TEST_IMPL(fs_fstat_st_dev) {
|
||||
uv_fs_t req;
|
||||
uv_fs_t req_link;
|
||||
uv_loop_t* loop = uv_default_loop();
|
||||
char* test_file = "tmp_st_dev";
|
||||
char* symlink_file = "tmp_st_dev_link";
|
||||
|
||||
unlink(test_file);
|
||||
unlink(symlink_file);
|
||||
|
||||
// Create file
|
||||
int r = uv_fs_open(NULL, &req, test_file, UV_FS_O_RDWR | UV_FS_O_CREAT,
|
||||
S_IWUSR | S_IRUSR, NULL);
|
||||
ASSERT_GE(r, 0);
|
||||
ASSERT_GE(req.result, 0);
|
||||
uv_fs_req_cleanup(&req);
|
||||
|
||||
// Create a symlink
|
||||
r = uv_fs_symlink(loop, &req, test_file, symlink_file, 0, NULL);
|
||||
ASSERT_EQ(r, 0);
|
||||
uv_fs_req_cleanup(&req);
|
||||
|
||||
// Call uv_fs_fstat for file
|
||||
r = uv_fs_stat(loop, &req, test_file, NULL);
|
||||
ASSERT_EQ(r, 0);
|
||||
|
||||
// Call uv_fs_fstat for symlink
|
||||
r = uv_fs_stat(loop, &req_link, symlink_file, NULL);
|
||||
ASSERT_EQ(r, 0);
|
||||
|
||||
// Compare st_dev
|
||||
ASSERT_EQ(((uv_stat_t*)req.ptr)->st_dev, ((uv_stat_t*)req_link.ptr)->st_dev);
|
||||
|
||||
// Cleanup
|
||||
uv_fs_req_cleanup(&req);
|
||||
uv_fs_req_cleanup(&req_link);
|
||||
unlink(test_file);
|
||||
unlink(symlink_file);
|
||||
|
||||
MAKE_VALGRIND_HAPPY(loop);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
TEST_IMPL(fs_fstat_stdio) {
|
||||
int fd;
|
||||
int res;
|
||||
|
@ -364,6 +364,7 @@ TEST_DECLARE (fs_mkdtemp)
|
||||
TEST_DECLARE (fs_mkstemp)
|
||||
TEST_DECLARE (fs_fstat)
|
||||
TEST_DECLARE (fs_fstat_stdio)
|
||||
TEST_DECLARE (fs_fstat_st_dev)
|
||||
TEST_DECLARE (fs_access)
|
||||
TEST_DECLARE (fs_chmod)
|
||||
TEST_DECLARE (fs_copyfile)
|
||||
@ -1083,6 +1084,7 @@ TASK_LIST_START
|
||||
TEST_ENTRY (fs_mkstemp)
|
||||
TEST_ENTRY (fs_fstat)
|
||||
TEST_ENTRY (fs_fstat_stdio)
|
||||
TEST_ENTRY (fs_fstat_st_dev)
|
||||
TEST_ENTRY (fs_access)
|
||||
TEST_ENTRY (fs_chmod)
|
||||
TEST_ENTRY (fs_copyfile)
|
||||
|
Loading…
x
Reference in New Issue
Block a user