mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:27:45 +00:00
LibFileSystem+Everywhere: Return ByteString from read_link()
This commit is contained in:
parent
cac66aeb53
commit
8d80841e9c
11 changed files with 34 additions and 43 deletions
|
@ -81,9 +81,7 @@ TEST_CASE(test_change_file_location)
|
|||
ftruncate(fd, 0);
|
||||
EXPECT(fchmod(fd, 06755) != -1);
|
||||
|
||||
auto suid_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
|
||||
auto suid_path = suid_path_string.to_byte_string();
|
||||
auto suid_path = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
EXPECT(suid_path.characters());
|
||||
auto new_path = ByteString::formatted("{}.renamed", suid_path);
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ TEST_CASE(unlink_symlink)
|
|||
}
|
||||
|
||||
auto target = TRY_OR_FAIL(FileSystem::read_link("/tmp/linky"sv));
|
||||
EXPECT_EQ(target.bytes_as_string_view(), "/proc/2/foo"sv);
|
||||
EXPECT_EQ(target, "/proc/2/foo"sv);
|
||||
|
||||
rc = unlink("/tmp/linky");
|
||||
EXPECT(rc >= 0);
|
||||
|
|
|
@ -86,8 +86,7 @@ TEST_CASE(test_mkstemp_unique_filename)
|
|||
auto fd = mkstemp(path);
|
||||
EXPECT_NE(fd, -1);
|
||||
|
||||
auto temp_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto temp_path = temp_path_string.to_byte_string();
|
||||
auto temp_path = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
EXPECT(temp_path.characters());
|
||||
|
||||
close(fd);
|
||||
|
@ -105,8 +104,7 @@ TEST_CASE(test_mkstemp_unique_filename)
|
|||
auto fd = mkstemp(path);
|
||||
EXPECT(fd != -1);
|
||||
|
||||
auto path2_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto path2 = path2_string.to_byte_string();
|
||||
auto path2 = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
EXPECT(path2.characters());
|
||||
|
||||
close(fd);
|
||||
|
@ -128,8 +126,7 @@ TEST_CASE(test_mkstemps_unique_filename)
|
|||
auto fd = mkstemps(path, 6);
|
||||
EXPECT_NE(fd, -1);
|
||||
|
||||
auto temp_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto temp_path = temp_path_string.to_byte_string();
|
||||
auto temp_path = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
EXPECT(temp_path.characters());
|
||||
|
||||
close(fd);
|
||||
|
@ -151,8 +148,7 @@ TEST_CASE(test_mkstemps_unique_filename)
|
|||
auto fd = mkstemps(path, 6);
|
||||
EXPECT(fd != -1);
|
||||
|
||||
auto path2_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto path2 = path2_string.to_byte_string();
|
||||
auto path2 = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
EXPECT(path2.characters());
|
||||
|
||||
close(fd);
|
||||
|
|
|
@ -58,8 +58,7 @@ TEST_CASE(test_interp_header_tiny_p_filesz)
|
|||
int nwritten = write(fd, buffer, sizeof(buffer));
|
||||
EXPECT(nwritten);
|
||||
|
||||
auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto elf_path = elf_path_string.to_byte_string();
|
||||
auto elf_path = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
EXPECT(elf_path.characters());
|
||||
|
||||
int rc = execl(elf_path.characters(), "test-elf", nullptr);
|
||||
|
@ -113,8 +112,7 @@ TEST_CASE(test_interp_header_p_filesz_larger_than_p_memsz)
|
|||
int nwritten = write(fd, buffer, sizeof(buffer));
|
||||
EXPECT(nwritten);
|
||||
|
||||
auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto elf_path = elf_path_string.to_byte_string();
|
||||
auto elf_path = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
EXPECT(elf_path.characters());
|
||||
|
||||
int rc = execl(elf_path.characters(), "test-elf", nullptr);
|
||||
|
@ -172,8 +170,7 @@ TEST_CASE(test_interp_header_p_filesz_plus_p_offset_overflow_p_memsz)
|
|||
int nwritten = write(fd, buffer, sizeof(buffer));
|
||||
EXPECT(nwritten);
|
||||
|
||||
auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto elf_path = elf_path_string.to_byte_string();
|
||||
auto elf_path = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
EXPECT(elf_path.characters());
|
||||
|
||||
int rc = execl(elf_path.characters(), "test-elf", nullptr);
|
||||
|
@ -228,8 +225,7 @@ TEST_CASE(test_load_header_p_memsz_zero)
|
|||
int nwritten = write(fd, buffer, sizeof(buffer));
|
||||
EXPECT(nwritten);
|
||||
|
||||
auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto elf_path = elf_path_string.to_byte_string();
|
||||
auto elf_path = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
EXPECT(elf_path.characters());
|
||||
|
||||
int rc = execl(elf_path.characters(), "test-elf", nullptr);
|
||||
|
@ -284,8 +280,7 @@ TEST_CASE(test_load_header_p_memsz_not_equal_to_p_align)
|
|||
int nwritten = write(fd, buffer, sizeof(buffer));
|
||||
EXPECT(nwritten);
|
||||
|
||||
auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto elf_path = elf_path_string.to_byte_string();
|
||||
auto elf_path = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
EXPECT(elf_path.characters());
|
||||
|
||||
int rc = execl(elf_path.characters(), "test-elf", nullptr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue