Compare commits
68 Commits
d10fceda0a
...
44f2a4e97e
Author | SHA1 | Date | |
---|---|---|---|
44f2a4e97e | |||
db9b9c53e9 | |||
a5217a1401 | |||
86e6e7aea5 | |||
3efa9e267a | |||
62673876fb | |||
ca2fb9e442 | |||
e743c83fe0 | |||
38d0a42eac | |||
1e5a762620 | |||
491e46cfcb | |||
3009920c0e | |||
bfbe166679 | |||
73e3c271ff | |||
e3a6877962 | |||
526af76d51 | |||
c6a67d9361 | |||
610e3c9c80 | |||
b55287e0a1 | |||
ec50a03f1b | |||
c233c9b98e | |||
570b9464c6 | |||
c45c153773 | |||
0d3983432e | |||
6efd55dce8 | |||
63c8f4131f | |||
03dc260ba9 | |||
cfabd62687 | |||
4c91191b4e | |||
a281a35806 | |||
c835979f9f | |||
4da16c1eaa | |||
e6ef86e620 | |||
2e50829d0a | |||
676b95af04 | |||
6b47a8c732 | |||
8346adf87f | |||
897ef6f91d | |||
290f391ea9 | |||
708b408861 | |||
d8ae676faa | |||
88961e1cc3 | |||
8f61062b72 | |||
9a47d84313 | |||
593e37a0f4 | |||
2134a55a3a | |||
a04759aa0e | |||
ec5fad5b21 | |||
6656e2164a | |||
d4ca297a68 | |||
84a7a8855a | |||
861c4454e7 | |||
1302e3dc12 | |||
37c3003ec9 | |||
4bed2d15f0 | |||
626eb7a977 | |||
787db55888 | |||
cdc01f6772 | |||
f3e73b241e | |||
505551e349 | |||
e1a7e93f52 | |||
0e75cc3feb | |||
0f95a3637d | |||
221fa360b3 | |||
fd8d8b4f34 | |||
5a13dd4dae | |||
2abb43d709 | |||
70a232cfcd |
@ -49,6 +49,7 @@ Result<u64> ScriptLoader::load(AddressSpace* space)
|
||||
Result<Vector<String>> ScriptLoader::cmdline(const String& path, Vector<String> args)
|
||||
{
|
||||
Vector<String> new_args;
|
||||
TRY(new_args.try_reserve(m_interpreter_cmdline.size() + args.size() + 1));
|
||||
for (auto& arg : m_interpreter_cmdline) { TRY(new_args.try_append(move(arg))); }
|
||||
auto arg = TRY(path.clone());
|
||||
TRY(new_args.try_append(move(arg)));
|
||||
|
@ -18,10 +18,12 @@ Result<u64> sys_poll(Registers*, SyscallArgs args)
|
||||
|
||||
if (!MemoryManager::copy_from_user(fds, kfds, nfds * sizeof(pollfd))) return err(EFAULT);
|
||||
|
||||
Vector<SharedPtr<VFS::Inode>> inodes;
|
||||
auto* current = Scheduler::current();
|
||||
TRY(check_pledge(current, Promise::p_stdio));
|
||||
|
||||
Vector<SharedPtr<VFS::Inode>> inodes;
|
||||
TRY(inodes.try_reserve(nfds));
|
||||
|
||||
for (nfds_t i = 0; i < nfds; i++)
|
||||
{
|
||||
int fd = kfds[i].fd;
|
||||
|
@ -88,6 +88,7 @@ Result<u64> ThreadImage::push_mem_on_stack(const u8* mem, usize size)
|
||||
Result<u64> ThreadImage::push_string_vector_on_stack(const Vector<String>& vec)
|
||||
{
|
||||
Vector<u64> user_vec;
|
||||
TRY(user_vec.try_reserve(vec.size() + 1));
|
||||
for (const auto& item : vec)
|
||||
{
|
||||
// Copy each individual string and retrieve a userspace pointer to said copy
|
||||
|
@ -62,7 +62,7 @@ template <typename T> class Vector
|
||||
|
||||
Result<void> try_append(T&& item)
|
||||
{
|
||||
if (m_capacity == m_size) TRY(resize(m_capacity + 8));
|
||||
if (m_capacity == m_size) TRY(resize(m_capacity ? m_capacity * 2 : 8));
|
||||
|
||||
new (&m_data[m_size]) T(move(item));
|
||||
|
||||
@ -252,6 +252,8 @@ template <typename T> class Vector
|
||||
|
||||
Result<void> resize(usize new_capacity)
|
||||
{
|
||||
if (new_capacity < m_capacity) return {};
|
||||
|
||||
const usize new_byte_capacity = new_capacity * sizeof(T);
|
||||
|
||||
void* const ptr = TRY(realloc_impl(m_data, new_byte_capacity));
|
||||
|
@ -26,6 +26,7 @@ namespace os
|
||||
Result<void> Process::exec(StringView path, Slice<String> args, bool search_in_path)
|
||||
{
|
||||
Vector<const char*> argv;
|
||||
TRY(argv.try_reserve(args.size() + 1));
|
||||
for (const auto& arg : args) { TRY(argv.try_append(arg.chars())); }
|
||||
TRY(argv.try_append(nullptr));
|
||||
|
||||
@ -39,6 +40,7 @@ namespace os
|
||||
Result<void> Process::exec(StringView path, Slice<StringView> args, bool search_in_path)
|
||||
{
|
||||
Vector<const char*> argv;
|
||||
TRY(argv.try_reserve(args.size() + 1));
|
||||
for (const auto& arg : args) { TRY(argv.try_append(arg.chars())); }
|
||||
TRY(argv.try_append(nullptr));
|
||||
|
||||
@ -52,10 +54,12 @@ namespace os
|
||||
Result<void> Process::exec(StringView path, Slice<String> args, Slice<String> env, bool search_in_path)
|
||||
{
|
||||
Vector<const char*> argv;
|
||||
TRY(argv.try_reserve(args.size() + 1));
|
||||
for (const auto& arg : args) { TRY(argv.try_append(arg.chars())); }
|
||||
TRY(argv.try_append(nullptr));
|
||||
|
||||
Vector<const char*> envp;
|
||||
TRY(envp.try_reserve(env.size() + 1));
|
||||
for (const auto& arg : env) { TRY(envp.try_append(arg.chars())); }
|
||||
TRY(envp.try_append(nullptr));
|
||||
|
||||
@ -83,6 +87,7 @@ namespace os
|
||||
Result<pid_t> Process::spawn(StringView path, Slice<String> args, bool search_in_path)
|
||||
{
|
||||
Vector<const char*> argv;
|
||||
TRY(argv.try_reserve(args.size() + 1));
|
||||
for (const auto& arg : args) { TRY(argv.try_append(arg.chars())); }
|
||||
TRY(argv.try_append(nullptr));
|
||||
|
||||
@ -92,6 +97,7 @@ namespace os
|
||||
Result<pid_t> Process::spawn(StringView path, Slice<StringView> args, bool search_in_path)
|
||||
{
|
||||
Vector<const char*> argv;
|
||||
TRY(argv.try_reserve(args.size() + 1));
|
||||
for (const auto& arg : args) { TRY(argv.try_append(arg.chars())); }
|
||||
TRY(argv.try_append(nullptr));
|
||||
|
||||
@ -101,10 +107,12 @@ namespace os
|
||||
Result<pid_t> Process::spawn(StringView path, Slice<String> args, Slice<String> env, bool search_in_path)
|
||||
{
|
||||
Vector<const char*> argv;
|
||||
TRY(argv.try_reserve(args.size() + 1));
|
||||
for (const auto& arg : args) { TRY(argv.try_append(arg.chars())); }
|
||||
TRY(argv.try_append(nullptr));
|
||||
|
||||
Vector<const char*> envp;
|
||||
TRY(envp.try_reserve(env.size() + 1));
|
||||
for (const auto& arg : env) { TRY(envp.try_append(arg.chars())); }
|
||||
TRY(envp.try_append(nullptr));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user