Remove unnecessary system calls
authorcoderain <coderain@sdf.org>
Sun, 15 Oct 2017 21:29:15 +0000 (23:29 +0200)
committercoderain <coderain@sdf.org>
Sun, 15 Oct 2017 21:29:15 +0000 (23:29 +0200)
13 files changed:
kernel/include/user.h
kernel/src/acpica/osmlxf.c
kernel/src/drivers/fs/fat.c
kernel/src/object.c
kernel/src/process.c
kernel/src/syscalls.c
kernel/src/thread.c
kernel/src/user.c
library/src/wrappers.c
sdk/process.h
sdk/syscalls.h
sdk/thread.h
sdk/user.h

index 863bbf1364949319746f8129e34023f60068c131..593a95242cc741979661b6328869eb9fc7d6e278 100644 (file)
@@ -36,6 +36,7 @@ typedef struct
     qword_t last_login_attempt;
 } user_t;
 
+dword_t get_current_uid(void);
 bool_t check_privileges(qword_t privilege_mask);
 void user_init(void);
 
index 4828450987e12d15318772ba7f03c85e58af6e38..3b966882213b6bb26d306495736107471ecf670f 100644 (file)
@@ -252,7 +252,7 @@ void AcpiOsStall(UINT32 Microseconds)
 
 ACPI_THREAD_ID AcpiOsGetThreadId(void)
 {
-    return syscall_get_thread_id() + 1;
+    return get_current_thread()->tid + 1;
 }
 
 ACPI_STATUS AcpiOsInstallInterruptHandler(UINT32 InterruptLevel, ACPI_OSD_HANDLER Handler, void *Context)
index 6c5ebba77cddb30cf0834bc2dc85b03b29ea33ea..5163c935d9fb1a3ded73d048072d6dda176e3613 100644 (file)
@@ -651,7 +651,7 @@ static dword_t fatfs_mount(const char *device, const char *mountpoint, dword_t f
     volume->sectors_per_fat = sectors_per_fat;
     volume->total_clusters = total_clusters;
     volume->last_free_cluster = volume->root_dir_cluster + 1;
-    volume->owner_uid = syscall_get_user_id();
+    volume->owner_uid = get_current_uid();
 
     ret = register_mounted_volume(&volume->header);
     if (ret != ERR_SUCCESS) free(volume);
@@ -846,7 +846,7 @@ static dword_t fatfs_open_file(file_instance_t **_instance)
     fatfs_file_t *file = CONTAINER_OF((*_instance)->global, fatfs_file_t, header);
 
     fatfs_volume_t *volume = CONTAINER_OF(file->header.volume, fatfs_volume_t, header);
-    if (syscall_get_user_id() != volume->owner_uid) return ERR_FORBIDDEN;
+    if (get_current_uid() != volume->owner_uid) return ERR_FORBIDDEN;
 
     fatfs_file_instance_t *instance = (fatfs_file_instance_t*)realloc(*_instance, sizeof(fatfs_file_instance_t));
     if (instance == NULL) return ERR_NOMEMORY;
@@ -865,7 +865,7 @@ static dword_t fatfs_close_file(file_instance_t *_instance)
 static dword_t fatfs_delete_file(mounted_volume_t *_volume, const char *path, bool_t purge)
 {
     fatfs_volume_t *volume = CONTAINER_OF(volume, fatfs_volume_t, header);
-    if (syscall_get_user_id() != volume->owner_uid) return ERR_FORBIDDEN;
+    if (get_current_uid() != volume->owner_uid) return ERR_FORBIDDEN;
 
     fatfs_dirent_t dirent;
     dword_t cluster_num;
index fd85a0b56b984c110ae82784f6cb9fab8f1a2910..d025c81d3bf4070cb53e0d7022d32fddf8126325 100644 (file)
@@ -89,7 +89,7 @@ static bool_t access_check(object_t *obj, access_flags_t access_flags)
     if (check_privileges(PRIVILEGE_ACCESS_ALL)) return TRUE;
 
     list_entry_t *ptr;
-    dword_t uid = syscall_get_user_id();
+    dword_t uid = get_current_uid();
 
     for (ptr = obj->acl.next; ptr != &obj->acl; ptr = ptr->next)
     {
index e9edaeb2d2e71c6a8befc9e8a76376503f42496c..215ac97cfcfd770d3e3dce4ade1d92b5b023d0f8 100644 (file)
@@ -123,7 +123,7 @@ sysret_t syscall_open_process(dword_t pid, handle_t *handle)
 
     if (ret == ERR_SUCCESS)
     {
-        if (proc->current_user->uid == syscall_get_user_id() || check_privileges(PRIVILEGE_PROCESS_CONTROL))
+        if (proc->current_user->uid == get_current_uid() || check_privileges(PRIVILEGE_PROCESS_CONTROL))
         {
             ret = open_object(&proc->header, 0, handle);
         }
@@ -464,12 +464,6 @@ sysret_t syscall_terminate(handle_t handle, dword_t exit_code)
     else return terminate_thread_internal(current_thread, exit_code);
 }
 
-sysret_t syscall_get_process_id()
-{
-    process_t *proc = get_current_process();
-    return proc->pid;
-}
-
 sysret_t syscall_query_process(handle_t handle, process_info_t info_type, void *buffer, dword_t size)
 {
     dword_t ret = ERR_SUCCESS;
index 24ebc009d6eb861186347b3e09b8cf7dee43b79e..1caadb54f55252a447f2dab1d605074ab5267c0e 100644 (file)
@@ -54,9 +54,6 @@ const void *service_table[] =
     &syscall_get_exception_info,
     &syscall_get_milliseconds,
     &syscall_get_nanoseconds,
-    &syscall_get_process_id,
-    &syscall_get_thread_id,
-    &syscall_get_user_id,
     &syscall_list_directory,
     &syscall_logon_user,
     &syscall_map_memory_section,
index ca35e6ea206260e80f7d31cc6d5575d34b4c337e..ebf56cc6d8033d6873d54d7f51e85ea162483d08 100644 (file)
@@ -254,11 +254,6 @@ thread_t *get_current_thread()
     return current_thread;
 }
 
-sysret_t syscall_get_thread_id()
-{
-    return current_thread->tid;
-}
-
 void thread_lazy_fpu(void)
 {
     if (last_fpu_thread) fpu_save(last_fpu_thread->state.fpu_state);
@@ -500,7 +495,7 @@ sysret_t syscall_open_thread(dword_t tid, handle_t *handle)
     critical_t critical;
     enter_critical(&critical);
 
-    if (syscall_get_thread_id() == tid)
+    if (current_thread->tid == tid)
     {
         thread = current_thread;
     }
index 6d74dc9075a7ba4f6bf312feb16901ce3948137f..e72987846e14a2639aca95bf9e95faba9502ec7b 100644 (file)
@@ -163,7 +163,7 @@ bool_t check_privileges(qword_t privilege_mask)
     return ((privileges & privilege_mask) == privilege_mask);
 }
 
-sysret_t syscall_get_user_id()
+dword_t get_current_uid(void)
 {
     process_t *proc = get_current_process();
     return proc->current_user->uid;
index d042af73fe01a58589e0bbf9ce1a55a483d78fd4..a9d78e408a022d530fa5110f229a1afc56e7be97 100644 (file)
@@ -129,21 +129,6 @@ sysret_t syscall_get_nanoseconds(void)
     return syscall(SYSCALL_GET_NANOSECONDS);
 }
 
-sysret_t syscall_get_process_id(void)
-{
-    return syscall(SYSCALL_GET_PROCESS_ID);
-}
-
-sysret_t syscall_get_thread_id(void)
-{
-    return syscall(SYSCALL_GET_THREAD_ID);
-}
-
-sysret_t syscall_get_user_id(void)
-{
-    return syscall(SYSCALL_GET_USER_ID);
-}
-
 sysret_t syscall_list_directory(handle_t handle, char *filename, bool_t continue_scan)
 {
     return syscall(SYSCALL_LIST_DIRECTORY, handle, filename, continue_scan);
index 6490ec0aa46d768351d096d5fc404659de1ce6c1..d1fc912c79100402519486ade4d63ac567862da5 100644 (file)
@@ -51,7 +51,6 @@ typedef struct
 sysret_t syscall_open_process(dword_t pid, handle_t *handle);
 sysret_t syscall_create_process(const char *path, dword_t flags, process_params_t *parameters, handle_t *process_handle, handle_t *thread_handle);
 sysret_t syscall_terminate(handle_t handle, dword_t exit_code);
-sysret_t syscall_get_process_id();
 sysret_t syscall_query_process(handle_t handle, process_info_t info_type, void *buffer, dword_t size);
 sysret_t syscall_enum_processes(dword_t *pid_array, dword_t *count);
 sysret_t syscall_wait_process(handle_t handle, dword_t timeout);
index f568e58ffcd1380c92c2661e3788227c571a7386..4b9c680e1526661456c776576f7554dc72abfaaa 100644 (file)
@@ -49,9 +49,6 @@ typedef enum
     SYSCALL_GET_EXCEPTION_INFO,
     SYSCALL_GET_MILLISECONDS,
     SYSCALL_GET_NANOSECONDS,
-    SYSCALL_GET_PROCESS_ID,
-    SYSCALL_GET_THREAD_ID,
-    SYSCALL_GET_USER_ID,
     SYSCALL_LIST_DIRECTORY,
     SYSCALL_LOGON_USER,
     SYSCALL_MAP_MEMORY_SECTION,
index 668f7fa852d9e337e1eccfac81f59d95af59f887..b7b3cb06b2428a53e3d243da0f4c9e0c3d0fe628 100644 (file)
@@ -51,7 +51,6 @@ typedef struct
     byte_t fpu_state[512];
 } thread_state_t;
 
-sysret_t syscall_get_thread_id(void);
 sysret_t syscall_open_thread(dword_t tid, handle_t *handle);
 sysret_t syscall_create_thread(handle_t process, thread_state_t *initial_state, dword_t flags, priority_t priority, handle_t *new_thread);
 sysret_t syscall_terminate_thread(handle_t thread, dword_t return_value);
index 684652674a6c1df21e2ead096af6ba2156720632..64a176e28e87f5c1f915e67bf95912690c61586c 100644 (file)
@@ -99,7 +99,6 @@ typedef enum
 
 sysret_t syscall_create_user(dword_t uid, const char *name, dword_t *password_hash, qword_t privileges);
 sysret_t syscall_delete_user(dword_t uid);
-sysret_t syscall_get_user_id(void);
 sysret_t syscall_set_user_id(dword_t uid);
 sysret_t syscall_revert_user(void);
 sysret_t syscall_logon_user(dword_t uid, const char *password);