mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-05-28 15:34:31 +00:00
feat(kernel/syscalls): implement uname syscall
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
parent
fc43512c75
commit
9f393754f6
@ -624,6 +624,14 @@ typedef struct FramebufferScreenInfo
|
|||||||
*/
|
*/
|
||||||
#define FBIOGET_SCREEN_INFO 0xf0
|
#define FBIOGET_SCREEN_INFO 0xf0
|
||||||
|
|
||||||
|
struct kutsname
|
||||||
|
{
|
||||||
|
char sysname[65];
|
||||||
|
char release[65];
|
||||||
|
char version[65];
|
||||||
|
char machine[65];
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief List of syscalls
|
* @brief List of syscalls
|
||||||
*
|
*
|
||||||
@ -1601,6 +1609,22 @@ typedef enum
|
|||||||
* - #EACCES if permission is denied
|
* - #EACCES if permission is denied
|
||||||
*/
|
*/
|
||||||
SYS_RENAME,
|
SYS_RENAME,
|
||||||
|
/**
|
||||||
|
* @brief Get unix name information
|
||||||
|
*
|
||||||
|
* @code
|
||||||
|
* int uname(struct kutsname *buf);
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @details Retrieves information about the operating system.
|
||||||
|
*
|
||||||
|
* @param buf Pointer to `kutsname` structure to store information
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - #EOK on success
|
||||||
|
* - #EFAULT if `buf` is outside accessible address space
|
||||||
|
*/
|
||||||
|
SYS_UNAME,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Max number of syscalls
|
* @brief Max number of syscalls
|
||||||
@ -1782,4 +1806,7 @@ typedef enum
|
|||||||
/** @copydoc SYS_RENAME */
|
/** @copydoc SYS_RENAME */
|
||||||
#define call_rename(oldpath, newpath) syscall2(SYS_RENAME, (scarg)oldpath, (scarg)newpath)
|
#define call_rename(oldpath, newpath) syscall2(SYS_RENAME, (scarg)oldpath, (scarg)newpath)
|
||||||
|
|
||||||
|
/** @copydoc SYS_UNAME */
|
||||||
|
#define call_uname(buf) syscall1(SYS_UNAME, (scarg)buf)
|
||||||
|
|
||||||
#endif // !__FENNIX_API_SYSCALLS_LIST_H__
|
#endif // !__FENNIX_API_SYSCALLS_LIST_H__
|
||||||
|
2
Kernel/.vscode/preinclude.h
vendored
2
Kernel/.vscode/preinclude.h
vendored
@ -9,6 +9,6 @@
|
|||||||
#define __kernel__ 1
|
#define __kernel__ 1
|
||||||
#define KERNEL_NAME "Fennix"
|
#define KERNEL_NAME "Fennix"
|
||||||
#define KERNEL_ARCH "amd64"
|
#define KERNEL_ARCH "amd64"
|
||||||
#define KERNEL_VERSION "1.0"
|
#define KERNEL_VERSION "1.0.0"
|
||||||
#define GIT_COMMIT "0000000000000000000000000000000000000000"
|
#define GIT_COMMIT "0000000000000000000000000000000000000000"
|
||||||
#define GIT_COMMIT_SHORT "0000000"
|
#define GIT_COMMIT_SHORT "0000000"
|
||||||
|
@ -624,6 +624,14 @@ typedef struct FramebufferScreenInfo
|
|||||||
*/
|
*/
|
||||||
#define FBIOGET_SCREEN_INFO 0xf0
|
#define FBIOGET_SCREEN_INFO 0xf0
|
||||||
|
|
||||||
|
struct kutsname
|
||||||
|
{
|
||||||
|
char sysname[65];
|
||||||
|
char release[65];
|
||||||
|
char version[65];
|
||||||
|
char machine[65];
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief List of syscalls
|
* @brief List of syscalls
|
||||||
*
|
*
|
||||||
@ -1601,6 +1609,22 @@ typedef enum
|
|||||||
* - #EACCES if permission is denied
|
* - #EACCES if permission is denied
|
||||||
*/
|
*/
|
||||||
SYS_RENAME,
|
SYS_RENAME,
|
||||||
|
/**
|
||||||
|
* @brief Get unix name information
|
||||||
|
*
|
||||||
|
* @code
|
||||||
|
* int uname(struct kutsname *buf);
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @details Retrieves information about the operating system.
|
||||||
|
*
|
||||||
|
* @param buf Pointer to `kutsname` structure to store information
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - #EOK on success
|
||||||
|
* - #EFAULT if `buf` is outside accessible address space
|
||||||
|
*/
|
||||||
|
SYS_UNAME,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Max number of syscalls
|
* @brief Max number of syscalls
|
||||||
@ -1782,4 +1806,7 @@ typedef enum
|
|||||||
/** @copydoc SYS_RENAME */
|
/** @copydoc SYS_RENAME */
|
||||||
#define call_rename(oldpath, newpath) syscall2(SYS_RENAME, (scarg)oldpath, (scarg)newpath)
|
#define call_rename(oldpath, newpath) syscall2(SYS_RENAME, (scarg)oldpath, (scarg)newpath)
|
||||||
|
|
||||||
|
/** @copydoc SYS_UNAME */
|
||||||
|
#define call_uname(buf) syscall1(SYS_UNAME, (scarg)buf)
|
||||||
|
|
||||||
#endif // !__FENNIX_API_SYSCALLS_LIST_H__
|
#endif // !__FENNIX_API_SYSCALLS_LIST_H__
|
||||||
|
@ -212,6 +212,54 @@ static int sys_rmdir(SysFrm *Frame, const char *path) { return -ENOSYS; }
|
|||||||
static int sys_unlink(SysFrm *Frame, const char *pathname) { return -ENOSYS; }
|
static int sys_unlink(SysFrm *Frame, const char *pathname) { return -ENOSYS; }
|
||||||
static int sys_rename(SysFrm *Frame, const char *oldpath, const char *newpath) { return -ENOSYS; }
|
static int sys_rename(SysFrm *Frame, const char *oldpath, const char *newpath) { return -ENOSYS; }
|
||||||
|
|
||||||
|
static int sys_uname(SysFrm *Frame, struct kutsname *buf)
|
||||||
|
{
|
||||||
|
PCB *pcb = thisProcess;
|
||||||
|
Memory::VirtualMemoryArea *vma = pcb->vma;
|
||||||
|
|
||||||
|
struct kutsname *pBuf = vma->UserCheckAndGetAddress(buf, sizeof(struct kutsname));
|
||||||
|
if (pBuf == nullptr)
|
||||||
|
return -EFAULT;
|
||||||
|
|
||||||
|
strncpy(pBuf->sysname, KERNEL_NAME, sizeof(pBuf->sysname));
|
||||||
|
|
||||||
|
char release[sizeof(pBuf->release)];
|
||||||
|
sprintf(release, "%s", KERNEL_VERSION);
|
||||||
|
strncpy(pBuf->release, release, sizeof(pBuf->release));
|
||||||
|
|
||||||
|
char version[sizeof(pBuf->version)];
|
||||||
|
|
||||||
|
bool isDebug = false;
|
||||||
|
#ifdef DEBUG
|
||||||
|
isDebug = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
sprintf(version, "FNX-v%s-%s %s %s %s %s",
|
||||||
|
KERNEL_VERSION, GIT_COMMIT_SHORT,
|
||||||
|
isDebug ? "DEBUG" : "RELEASE",
|
||||||
|
__DATE__, __TIME__, __VERSION__);
|
||||||
|
strncpy(pBuf->version, version, sizeof(pBuf->version));
|
||||||
|
|
||||||
|
#if defined(__amd64__)
|
||||||
|
const char *osarch = "x86_64";
|
||||||
|
#elif defined(__i386__)
|
||||||
|
const char *osarch = "i386";
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
const char *osarch = "aarch64";
|
||||||
|
#elif defined(__arm__)
|
||||||
|
const char *osarch = "arm";
|
||||||
|
#else
|
||||||
|
const char *osarch = "unknown";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
strncpy(pBuf->machine, osarch, sizeof(pBuf->machine));
|
||||||
|
|
||||||
|
debug("%s %s %s %s", pBuf->sysname, pBuf->release,
|
||||||
|
pBuf->version, pBuf->machine);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static SyscallData scTbl[SYS_MAX] = {};
|
static SyscallData scTbl[SYS_MAX] = {};
|
||||||
__constructor void __init_native_syscalls(void)
|
__constructor void __init_native_syscalls(void)
|
||||||
{
|
{
|
||||||
@ -281,6 +329,7 @@ __constructor void __init_native_syscalls(void)
|
|||||||
scTbl[SYS_RMDIR] = {"SYS_RMDIR", (void *)sys_rmdir};
|
scTbl[SYS_RMDIR] = {"SYS_RMDIR", (void *)sys_rmdir};
|
||||||
scTbl[SYS_UNLINK] = {"SYS_UNLINK", (void *)sys_unlink};
|
scTbl[SYS_UNLINK] = {"SYS_UNLINK", (void *)sys_unlink};
|
||||||
scTbl[SYS_RENAME] = {"SYS_RENAME", (void *)sys_rename};
|
scTbl[SYS_RENAME] = {"SYS_RENAME", (void *)sys_rename};
|
||||||
|
scTbl[SYS_UNAME] = {"SYS_UNAME", (void *)sys_uname};
|
||||||
}
|
}
|
||||||
|
|
||||||
uintptr_t HandleNativeSyscalls(SysFrm *Frame)
|
uintptr_t HandleNativeSyscalls(SysFrm *Frame)
|
||||||
|
@ -624,6 +624,14 @@ typedef struct FramebufferScreenInfo
|
|||||||
*/
|
*/
|
||||||
#define FBIOGET_SCREEN_INFO 0xf0
|
#define FBIOGET_SCREEN_INFO 0xf0
|
||||||
|
|
||||||
|
struct kutsname
|
||||||
|
{
|
||||||
|
char sysname[65];
|
||||||
|
char release[65];
|
||||||
|
char version[65];
|
||||||
|
char machine[65];
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief List of syscalls
|
* @brief List of syscalls
|
||||||
*
|
*
|
||||||
@ -1601,6 +1609,22 @@ typedef enum
|
|||||||
* - #EACCES if permission is denied
|
* - #EACCES if permission is denied
|
||||||
*/
|
*/
|
||||||
SYS_RENAME,
|
SYS_RENAME,
|
||||||
|
/**
|
||||||
|
* @brief Get unix name information
|
||||||
|
*
|
||||||
|
* @code
|
||||||
|
* int uname(struct kutsname *buf);
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @details Retrieves information about the operating system.
|
||||||
|
*
|
||||||
|
* @param buf Pointer to `kutsname` structure to store information
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - #EOK on success
|
||||||
|
* - #EFAULT if `buf` is outside accessible address space
|
||||||
|
*/
|
||||||
|
SYS_UNAME,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Max number of syscalls
|
* @brief Max number of syscalls
|
||||||
@ -1782,4 +1806,7 @@ typedef enum
|
|||||||
/** @copydoc SYS_RENAME */
|
/** @copydoc SYS_RENAME */
|
||||||
#define call_rename(oldpath, newpath) syscall2(SYS_RENAME, (scarg)oldpath, (scarg)newpath)
|
#define call_rename(oldpath, newpath) syscall2(SYS_RENAME, (scarg)oldpath, (scarg)newpath)
|
||||||
|
|
||||||
|
/** @copydoc SYS_UNAME */
|
||||||
|
#define call_uname(buf) syscall1(SYS_UNAME, (scarg)buf)
|
||||||
|
|
||||||
#endif // !__FENNIX_API_SYSCALLS_LIST_H__
|
#endif // !__FENNIX_API_SYSCALLS_LIST_H__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user