Fix hostname file handling

This commit is contained in:
Kevin Lange 2012-01-30 12:13:11 -06:00
parent 238278c3fc
commit 93df034d2b
2 changed files with 7 additions and 0 deletions

1
.gitignore vendored
View File

@ -9,6 +9,7 @@ initrd/boot
initrd/bin/*
hdd/boot
hdd/bin/*
hdd/etc/hostname
.gdb_history
bootdisk.img
util/toaru-toolchain/*

View File

@ -4,6 +4,9 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <syscall.h>
DEFN_SYSCALL1(sethostname, 31, char *);
@ -21,6 +24,9 @@ void set_hostname() {
} else {
char buf[256];
fgets(buf, 255, _host_file);
if (buf[strlen(buf)-1] == '\n') {
buf[strlen(buf)-1] = '\0';
}
syscall_sethostname(buf);
fclose(_host_file);
}