mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:27:45 +00:00
Add sys$uname() and a /bin/uname utility.
This commit is contained in:
parent
384e2f24d4
commit
1c45b28da6
15 changed files with 129 additions and 10 deletions
|
@ -7,6 +7,7 @@ OBJS = \
|
|||
dirent.o \
|
||||
stdlib.o \
|
||||
time.o \
|
||||
utsname.o \
|
||||
entry.o
|
||||
|
||||
LIBRARY = LibC.a
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "stdio.h"
|
||||
#include "stdarg.h"
|
||||
#include "types.h"
|
||||
#include "string.h"
|
||||
#include "errno.h"
|
||||
#include <Kernel/Syscall.h>
|
||||
|
||||
#define ALWAYS_INLINE __attribute__ ((always_inline))
|
||||
|
@ -169,5 +171,10 @@ int sprintf(char* buffer, const char* fmt, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void perror(const char* s)
|
||||
{
|
||||
printf("%s: %s\n", s, strerror(errno));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ extern "C" {
|
|||
int printf(const char* fmt, ...);
|
||||
int sprintf(char* buffer, const char* fmt, ...);
|
||||
int putchar(int ch);
|
||||
void perror(const char*);
|
||||
|
||||
}
|
||||
|
||||
|
|
14
LibC/utsname.cpp
Normal file
14
LibC/utsname.cpp
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include "utsname.h"
|
||||
#include "errno.h"
|
||||
#include <Kernel/Syscall.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
int uname(struct utsname* buf)
|
||||
{
|
||||
int rc = Syscall::invoke(Syscall::PosixUname, (dword)buf);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
17
LibC/utsname.h
Normal file
17
LibC/utsname.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#define UTSNAME_ENTRY_LEN 65
|
||||
|
||||
extern "C" {
|
||||
|
||||
struct utsname {
|
||||
char sysname[UTSNAME_ENTRY_LEN];
|
||||
char nodename[UTSNAME_ENTRY_LEN];
|
||||
char release[UTSNAME_ENTRY_LEN];
|
||||
char version[UTSNAME_ENTRY_LEN];
|
||||
char machine[UTSNAME_ENTRY_LEN];
|
||||
};
|
||||
|
||||
int uname(struct utsname*);
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue