init: Add a Message of the Day
This commit is contained in:
parent
bd4c587409
commit
b69fbd46bf
@ -1,8 +1,35 @@
|
|||||||
|
#include <errno.h>
|
||||||
#include <luna.h>
|
#include <luna.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
void show_motd()
|
||||||
|
{
|
||||||
|
FILE* fp = fopen("/etc/motd", "r");
|
||||||
|
if (!fp)
|
||||||
|
{
|
||||||
|
if (errno != ENOENT) { perror("fopen"); }
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char buf[4096];
|
||||||
|
size_t nread = fread(buf, sizeof(buf) - 1, 1, fp);
|
||||||
|
if (ferror(fp))
|
||||||
|
{
|
||||||
|
perror("fread");
|
||||||
|
fclose(fp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
buf[nread] = 0;
|
||||||
|
|
||||||
|
puts(buf);
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
putchar('\n');
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
if (getpid() != 1)
|
if (getpid() != 1)
|
||||||
@ -11,7 +38,7 @@ int main()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Welcome to Luna!\n\n");
|
show_motd();
|
||||||
|
|
||||||
msleep(200);
|
msleep(200);
|
||||||
|
|
||||||
|
3
initrd/etc/motd
Normal file
3
initrd/etc/motd
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Welcome to Luna!
|
||||||
|
|
||||||
|
Tip of the day: Type 'help' to get started!
|
Loading…
Reference in New Issue
Block a user