[llvm] r297945 - [Support] Add support for getting file system permissions on Windows and implement sys::fs::set/getPermissions to work with them

Dimitry Andric via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 15 14:56:31 PDT 2017


On 16 Mar 2017, at 12:22, James Henderson via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> Author: jhenderson
> Date: Thu Mar 16 06:22:09 2017
> New Revision: 297945
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=297945&view=rev
> Log:
> [Support] Add support for getting file system permissions on Windows and implement sys::fs::set/getPermissions to work with them
> 
> This change adds support for functions to set and get file permissions, in a similar manner to the C++17 permissions() function in <filesystem>. The setter uses chmod on Unix systems and SetFileAttributes on Windows, setting the permissions as passed in. The getter simply uses the existing status() function.

Hi James,

I'm not completely sure, but this commit appears to cause the following test failures on FreeBSD:

FAIL: LLVM-Unit :: Support/SupportTests/FileSystemTest.permissions (1896 of 30938)
******************** TEST 'LLVM-Unit :: Support/SupportTests/FileSystemTest.permissions' FAILED ********************
Note: Google Test filter = FileSystemTest.permissions
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from FileSystemTest
[ RUN      ] FileSystemTest.permissions
/share/dim/src/llvm/trunk/unittests/Support/Path.cpp:1518: Failure
      Expected: fs::setPermissions(TempPath, fs::sticky_bit)
      Which is: generic:79
To be equal to: NoError
      Which is: system:0
/share/dim/src/llvm/trunk/unittests/Support/Path.cpp:1519: Failure
Value of: CheckPermissions(fs::sticky_bit)
  Actual: false
Expected: true
/share/dim/src/llvm/trunk/unittests/Support/Path.cpp:1524: Failure
      Expected: fs::setPermissions(TempPath, fs::set_uid_on_exe | fs::set_gid_on_exe | fs::sticky_bit)
      Which is: generic:79
To be equal to: NoError
      Which is: system:0
/share/dim/src/llvm/trunk/unittests/Support/Path.cpp:1526: Failure
Value of: CheckPermissions(fs::set_uid_on_exe | fs::set_gid_on_exe | fs::sticky_bit)
  Actual: false
Expected: true
/share/dim/src/llvm/trunk/unittests/Support/Path.cpp:1531: Failure
      Expected: fs::setPermissions(TempPath, fs::all_read | fs::set_uid_on_exe | fs::set_gid_on_exe | fs::sticky_bit)
      Which is: generic:79
To be equal to: NoError
      Which is: system:0
/share/dim/src/llvm/trunk/unittests/Support/Path.cpp:1533: Failure
Value of: CheckPermissions(fs::all_read | fs::set_uid_on_exe | fs::set_gid_on_exe | fs::sticky_bit)
  Actual: false
Expected: true
/share/dim/src/llvm/trunk/unittests/Support/Path.cpp:1535: Failure
      Expected: fs::setPermissions(TempPath, fs::all_perms)
      Which is: generic:79
To be equal to: NoError
      Which is: system:0
/share/dim/src/llvm/trunk/unittests/Support/Path.cpp:1536: Failure
Value of: CheckPermissions(fs::all_perms)
  Actual: false
Expected: true
[  FAILED  ] FileSystemTest.permissions (1 ms)
[----------] 1 test from FileSystemTest (1 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (2 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] FileSystemTest.permissions

 1 FAILED TEST
Test Directory: /home/dim/tmp/lit_tmp_yuZqzY/file-system-test-fd2cdc


So specifically, the following ones:

> +  EXPECT_EQ(fs::setPermissions(TempPath, fs::sticky_bit), NoError);
> +  EXPECT_TRUE(CheckPermissions(fs::sticky_bit));
> +
> +  EXPECT_EQ(fs::setPermissions(TempPath, fs::set_uid_on_exe |
> +                                             fs::set_gid_on_exe |
> +                                             fs::sticky_bit),
> +            NoError);
> +  EXPECT_TRUE(CheckPermissions(fs::set_uid_on_exe | fs::set_gid_on_exe |
> +                               fs::sticky_bit));
> +
> +  EXPECT_EQ(fs::setPermissions(TempPath, fs::all_read | fs::set_uid_on_exe |
> +                                             fs::set_gid_on_exe |
> +                                             fs::sticky_bit),
> +            NoError);
> +  EXPECT_TRUE(CheckPermissions(fs::all_read | fs::set_uid_on_exe |
> +                               fs::set_gid_on_exe | fs::sticky_bit));
> +
> +  EXPECT_EQ(fs::setPermissions(TempPath, fs::all_perms), NoError);
> +  EXPECT_TRUE(CheckPermissions(fs::all_perms));

As far as I can see, the value for fs::sticky_bit is OK, since it's the same on Linux on FreeBSD, but why all these tests are getting errno 79 (EFTYPE, which is "Inappropriate file type or format"), is not completely clear to me.

Ed, do you have any idea?

-Dimitry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170415/a30de051/attachment.sig>


More information about the llvm-commits mailing list