Compare commits

..

No commits in common. "6e3f176457ef90d6a5f869a6d8eaac4980cd11a1" and "a3a287f5ca998e563a57108a176fc18667b12c76" have entirely different histories.

6 changed files with 0 additions and 73 deletions

View File

@ -101,9 +101,6 @@ namespace Kernel
BAN::ErrorOr<long> sys_create(const char*, mode_t);
BAN::ErrorOr<long> sys_create_dir(const char*, mode_t);
BAN::ErrorOr<long> sys_unlink(const char*);
BAN::ErrorOr<long> readlink_impl(BAN::StringView absolute_path, char* buffer, size_t bufsize);
BAN::ErrorOr<long> sys_readlink(const char* path, char* buffer, size_t bufsize);
BAN::ErrorOr<long> sys_readlinkat(int fd, const char* path, char* buffer, size_t bufsize);
BAN::ErrorOr<long> sys_chmod(const char*, mode_t);

View File

@ -782,47 +782,6 @@ namespace Kernel
return 0;
}
BAN::ErrorOr<long> Process::readlink_impl(BAN::StringView absolute_path, char* buffer, size_t bufsize)
{
auto inode = TRY(VirtualFileSystem::get().file_from_absolute_path(m_credentials, absolute_path, O_NOFOLLOW | O_RDONLY)).inode;
// FIXME: no allocation needed
auto link_target = TRY(inode->link_target());
size_t byte_count = BAN::Math::min<size_t>(link_target.size(), bufsize);
memcpy(buffer, link_target.data(), byte_count);
return byte_count;
}
BAN::ErrorOr<long> Process::sys_readlink(const char* path, char* buffer, size_t bufsize)
{
LockGuard _(m_lock);
validate_string_access(path);
validate_pointer_access(buffer, bufsize);
auto absolute_path = TRY(absolute_path_of(path));
return readlink_impl(absolute_path.sv(), buffer, bufsize);
}
BAN::ErrorOr<long> Process::sys_readlinkat(int fd, const char* path, char* buffer, size_t bufsize)
{
LockGuard _(m_lock);
validate_string_access(path);
validate_pointer_access(buffer, bufsize);
// FIXME: handle O_SEARCH in fd
auto parent_path = TRY(m_open_file_descriptors.path_of(fd));
BAN::String absolute_path;
TRY(absolute_path.append(parent_path));
TRY(absolute_path.push_back('/'));
TRY(absolute_path.append(path));
return readlink_impl(absolute_path.sv(), buffer, bufsize);
}
BAN::ErrorOr<long> Process::sys_chmod(const char* path, mode_t mode)
{
if (mode & S_IFMASK)

View File

@ -211,12 +211,6 @@ namespace Kernel
case SYS_UNLINK:
ret = Process::current().sys_unlink((const char*)arg1);
break;
case SYS_READLINK:
ret = Process::current().sys_readlink((const char*)arg1, (char*)arg2, (size_t)arg3);
break;
case SYS_READLINKAT:
ret = Process::current().sys_readlinkat((int)arg1, (const char*)arg2, (char*)arg3, (size_t)arg4);
break;
default:
dwarnln("Unknown syscall {}", syscall);
break;

View File

@ -59,8 +59,6 @@ __BEGIN_DECLS
#define SYS_CREATE 56 // creat, mkfifo
#define SYS_CREATE_DIR 57 // mkdir
#define SYS_UNLINK 58
#define SYS_READLINK 59
#define SYS_READLINKAT 60
__END_DECLS

View File

@ -78,16 +78,6 @@ ssize_t write(int fildes, const void* buf, size_t nbyte)
return syscall(SYS_WRITE, fildes, buf, nbyte);
}
ssize_t readlink(const char* __restrict path, char* __restrict buf, size_t bufsize)
{
return syscall(SYS_READLINK, path, buf, bufsize);
}
ssize_t readlinkat(int fd, const char* __restrict path, char* __restrict buf, size_t bufsize)
{
return syscall(SYS_READLINKAT, fd, path, buf, bufsize);
}
int dup(int fildes)
{
return syscall(SYS_DUP, fildes);

View File

@ -74,18 +74,7 @@ void list_directory(const char* path)
}
if (list)
{
printf("%s %4d %4d %6d %s%s\e[m", mode_string(st.st_mode), st.st_uid, st.st_gid, st.st_size, color_string(st.st_mode), dirent->d_name);
if (S_ISLNK(st.st_mode))
{
char link_buffer[128];
ssize_t ret = readlinkat(dirfd(dirp), dirent->d_name, link_buffer, sizeof(link_buffer));
if (ret >= 0)
printf(" -> %.*s", ret, link_buffer);
else
perror("readlink");
}
}
else
printf("%s%s\e[m", color_string(st.st_mode), dirent->d_name);