From e330a99f7a334fd34a93cdf0649714640c55b39e Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Thu, 21 Nov 2019 10:31:43 +0000 Subject: [PATCH 1/2] Revert "glocalfileinfo: Only return file mode, not type, as UNIX_MODE attribute" This reverts commit bfdc5fc4fc84ef8518d2d1a328c8482cf5a38e98. This changes the semantics of G_FILE_ATTRIBUTE_ID_UNIX_MODE, and we've already found one user of the previous semantics (ostree). Closes #1934 --- gio/glocalfileinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c index 5ba7691a6..52455672a 100644 --- a/gio/glocalfileinfo.c +++ b/gio/glocalfileinfo.c @@ -987,7 +987,7 @@ set_info_from_stat (GFileInfo *info, /* Mostly pointless on Windows. * Still, it allows for S_ISREG/S_ISDIR and IWRITE (read-only) checks. */ - _g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_UNIX_MODE, statbuf->st_mode & ~S_IFMT); + _g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_UNIX_MODE, statbuf->st_mode); #if defined (HAVE_STRUCT_STAT_ST_BLKSIZE) _g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_UNIX_BLOCK_SIZE, statbuf->st_blksize); #endif From 0c88825a75f88abb64b151aed6fbb880ad0f3675 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Thu, 21 Nov 2019 10:33:43 +0000 Subject: [PATCH 2/2] test_copy_preserve_mode: Adjust for the previous revert Now we're returning the file type again, we need to mask it out to compare with the mode. We can also check that the statbuf said the file is a regular file. Related: #1934 --- gio/tests/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gio/tests/file.c b/gio/tests/file.c index 33dc50aa6..8d3aafa63 100644 --- a/gio/tests/file.c +++ b/gio/tests/file.c @@ -929,7 +929,8 @@ test_copy_preserve_mode (void) dest_mode = g_file_info_get_attribute_uint32 (dest_info, G_FILE_ATTRIBUTE_UNIX_MODE); - g_assert_cmpint (dest_mode, ==, vectors[i].expected_destination_mode); + g_assert_cmpint (dest_mode & ~S_IFMT, ==, vectors[i].expected_destination_mode); + g_assert_cmpint (dest_mode & S_IFMT, ==, S_IFREG); (void) g_file_delete (tmpfile, NULL, NULL); (void) g_file_delete (dest_tmpfile, NULL, NULL);