summaryrefslogtreecommitdiff
path: root/lib/fileutils.rb
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-01-23 15:33:42 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-01-24 10:49:35 +0900
commita19228f878d955eaf2cce086bcf53f46fdf894b9 (patch)
treef63a4e6081f855b42b386774271bf1f767f5d043 /lib/fileutils.rb
parent50925b64099df2021f7cdf652f7e807808cb1482 (diff)
brace the fact that lchmod(2) can EOPNOTSUPP
Musl libc has this function as a tiny wrapper of fchmodat(3posix). On the other hand Linux kernel does not support changing modes of a symlink. The operation always fails with EOPNOTSUPP. This fchmodat behaviour is defined in POSIX. We have to take care of such exceptions.
Diffstat (limited to 'lib/fileutils.rb')
-rw-r--r--lib/fileutils.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index a7ad65ae5e..04788e26ca 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -1345,6 +1345,7 @@ module FileUtils
else
File.chmod mode, path()
end
+ rescue Errno::EOPNOTSUPP
end
def chown(uid, gid)
@@ -1439,7 +1440,7 @@ module FileUtils
if st.symlink?
begin
File.lchmod mode, path
- rescue NotImplementedError
+ rescue NotImplementedError, Errno::EOPNOTSUPP
end
else
File.chmod mode, path