init: Read and launch service files in order using sort()
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
3628464284
commit
d9b7e8edc0
@ -1,6 +1,7 @@
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <luna/PathParser.h>
|
||||
#include <luna/Sort.h>
|
||||
#include <luna/String.h>
|
||||
#include <luna/Vector.h>
|
||||
#include <os/Directory.h>
|
||||
@ -239,6 +240,7 @@ static Result<void> load_services()
|
||||
auto dir = TRY(os::Directory::open("/etc/init"));
|
||||
|
||||
auto services = TRY(dir->list(os::Directory::Filter::ParentAndBase));
|
||||
sort(services.begin(), services.end(), String::compare);
|
||||
|
||||
for (const auto& entry : services)
|
||||
{
|
||||
|
3
initrd/etc/init/00-motd
Normal file
3
initrd/etc/init/00-motd
Normal file
@ -0,0 +1,3 @@
|
||||
Name=motd
|
||||
Command=/bin/cat /etc/motd
|
||||
Wait=true
|
@ -1 +1,2 @@
|
||||
Hello, world!
|
||||
Welcome to the Luna system!
|
||||
Have a look around, you can run 'ls /bin' to list available commands.
|
||||
|
@ -65,6 +65,8 @@ class String
|
||||
static Result<String> from_cstring(const char* str);
|
||||
static Result<String> from_string_view(StringView str);
|
||||
|
||||
static int compare(const String* a, const String* b);
|
||||
|
||||
const char* chars() const
|
||||
{
|
||||
return m_inline ? m_inline_storage : m_string;
|
||||
|
@ -180,3 +180,8 @@ Result<String> String::join(const Vector<String>& vec, StringView delim)
|
||||
|
||||
return sb.string();
|
||||
}
|
||||
|
||||
int String::compare(const String* a, const String* b)
|
||||
{
|
||||
return strcmp(a->chars(), b->chars());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user