Kernel+LibC: Add get_process_name() syscall
It does exactly what it sounds like: int get_process_name(char* buffer, int buffer_size);
This commit is contained in:
parent
d64e698bf1
commit
6ad3efe067
Notes:
sideshowbarker
2024-07-19 12:40:20 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/6ad3efe0671
6 changed files with 29 additions and 1 deletions
|
@ -2859,3 +2859,19 @@ int Process::sys$set_process_icon(int icon_id)
|
|||
m_icon_id = icon_id;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$get_process_name(char* buffer, int buffer_size)
|
||||
{
|
||||
if (buffer_size <= 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (!validate_write(buffer, buffer_size))
|
||||
return -EFAULT;
|
||||
|
||||
if (m_name.length() >= buffer_size)
|
||||
return -ENAMETOOLONG;
|
||||
|
||||
strncpy(buffer, m_name.characters(), buffer_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -108,6 +108,7 @@ public:
|
|||
void die();
|
||||
void finalize();
|
||||
|
||||
int sys$get_process_name(char* buffer, int buffer_size);
|
||||
int sys$watch_file(const char* path, int path_length);
|
||||
int sys$dbgputch(u8);
|
||||
int sys$dbgputstr(const u8*, int length);
|
||||
|
|
|
@ -307,6 +307,8 @@ static u32 handle(RegisterDump& regs, u32 function, u32 arg1, u32 arg2, u32 arg3
|
|||
return current->process().sys$set_process_icon((int)arg1);
|
||||
case Syscall::SC_mprotect:
|
||||
return current->process().sys$mprotect((void*)arg1, (size_t)arg2, (int)arg3);
|
||||
case Syscall::SC_get_process_name:
|
||||
return current->process().sys$get_process_name((char*)arg1, (int)arg2);
|
||||
default:
|
||||
kprintf("<%u> int0x82: Unknown function %u requested {%x, %x, %x}\n", current->process().pid(), function, arg1, arg2, arg3);
|
||||
return -ENOSYS;
|
||||
|
|
|
@ -123,7 +123,8 @@ struct timeval;
|
|||
__ENUMERATE_SYSCALL(watch_file) \
|
||||
__ENUMERATE_SYSCALL(share_buffer_globally) \
|
||||
__ENUMERATE_SYSCALL(set_process_icon) \
|
||||
__ENUMERATE_SYSCALL(mprotect)
|
||||
__ENUMERATE_SYSCALL(mprotect) \
|
||||
__ENUMERATE_SYSCALL(get_process_name)
|
||||
|
||||
namespace Syscall {
|
||||
|
||||
|
|
|
@ -561,4 +561,11 @@ void dump_backtrace()
|
|||
{
|
||||
syscall(SC_dump_backtrace);
|
||||
}
|
||||
|
||||
int get_process_name(char* buffer, int buffer_size)
|
||||
{
|
||||
int rc = syscall(SC_get_process_name, buffer, buffer_size);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ __BEGIN_DECLS
|
|||
|
||||
extern char** environ;
|
||||
|
||||
int get_process_name(char* buffer, int buffer_size);
|
||||
void dump_backtrace();
|
||||
int fsync(int fd);
|
||||
void sysbeep();
|
||||
|
|
Loading…
Add table
Reference in a new issue