Compare commits

...

2 Commits

Author SHA1 Message Date
bd4c587409 sh: Try to execute programs in /bin if they are not found 2022-10-20 19:12:17 +02:00
a06e1c5a21 VFS: Remove warning when file is not found
That is a common ocurrence.
2022-10-20 19:11:50 +02:00
2 changed files with 14 additions and 6 deletions

View File

@ -1,3 +1,4 @@
#include <errno.h>
#include <luna.h>
#include <stdio.h>
#include <stdlib.h>
@ -104,7 +105,18 @@ void command_execute(command* cmd)
}
if (child == 0)
{
execv(cmd->buffer, NULL);
if (cmd->buffer[0] != '/' && access(cmd->buffer, F_OK) < 0) // FIXME: Race condition.
{
if (errno == ENOENT)
{ // Try in /bin
char* buf = malloc(cmd->size + 6);
strlcpy(buf, "/bin/", 6);
strncat(buf, cmd->buffer, cmd->size);
execv(buf, NULL);
}
}
else
execv(cmd->buffer, NULL);
perror(cmd->buffer);
exit(127);
}

View File

@ -104,11 +104,7 @@ VFS::Node* VFS::resolve_path(const char* filename, Node* root)
return 0;
}
Node* child = current_node->find_func(current_node, buffer);
if (!child)
{
kwarnln("Current node did not find our target node");
return 0;
}
if (!child) { return 0; }
if (child->flags & VFS_MOUNTPOINT)
{
if (!child->link)