mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-05-28 15:34:31 +00:00
fix(userspace/libc): implement uname()
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
parent
9f393754f6
commit
cbc6238d9d
@ -20,19 +20,37 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fennix/syscalls.h>
|
||||||
|
|
||||||
export int uname(struct utsname *name)
|
export int uname(struct utsname *name)
|
||||||
{
|
{
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
|
{
|
||||||
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct kutsname kname;
|
||||||
|
int result = call_uname(&kname);
|
||||||
|
if (result == 0)
|
||||||
|
{
|
||||||
|
strcpy(name->sysname, kname.sysname);
|
||||||
|
strcpy(name->release, kname.release);
|
||||||
|
strcpy(name->version, kname.version);
|
||||||
|
strcpy(name->machine, kname.machine);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errno = result;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (gethostname(name->nodename, sizeof(name->nodename)) != 0)
|
if (gethostname(name->nodename, sizeof(name->nodename)) != 0)
|
||||||
|
{
|
||||||
|
errno = EIO;
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
strcpy(name->sysname, "Fennix");
|
|
||||||
strcpy(name->release, "1.0.0");
|
|
||||||
strcpy(name->version, "Fennix Version 1.0.0");
|
|
||||||
strcpy(name->machine, "x86_64");
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user