Skip to content

Commit c1bbf2e

Browse files
committed
Fix Dir.home("doesnotexist") on ZFS on Ubuntu 20.10
1 parent f18b9df commit c1bbf2e

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/main/c/truffleposix/truffleposix.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,14 @@ char* truffleposix_get_user_home(const char *name) {
211211
return NULL;
212212
}
213213
goto retry;
214-
} else if (ret != 0) {
214+
} else if (ret == EINTR) {
215+
goto retry;
216+
} else if (ret == EIO || ret == EMFILE || ret == ENFILE) {
215217
free(buffer);
216218
errno = ret;
217219
return NULL;
218-
} else {
219-
/* ret == 0 && result == NULL means not found */
220+
} else { // result == NULL, which means not found
221+
// ret should be 0 in that case according to the man page, but it doesn't seem to always hold
220222
free(buffer);
221223
return strdup("");
222224
}

src/main/ruby/truffleruby/core/truffle/file_operations.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def self.expand_path(path, dir, expand_tilde)
4242
length = Primitive.find_string(path, '/', 1) || path.bytesize
4343
name = path.byteslice 1, length - 1
4444

45-
if ptr = Truffle::POSIX.truffleposix_get_user_home(name) and !ptr.null?
45+
ptr = Truffle::POSIX.truffleposix_get_user_home(name)
46+
if !ptr.null?
4647
dir = ptr.read_string
4748
ptr.free
4849
raise ArgumentError, "user #{name} does not exist" if dir.empty?

0 commit comments

Comments
 (0)