Implemented rename_thread() and _user_rename_thread() (as pointed out by Jack Burton).
The syscall is not yet connected, and the code has not yet been tested. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7179 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
54327b01b3
commit
d018f3568f
@ -1380,6 +1380,38 @@ find_thread(const char *name)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
rename_thread(thread_id id, const char *name)
|
||||
{
|
||||
status_t status = B_OK;
|
||||
struct thread *thread;
|
||||
|
||||
if (name == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
thread = thread_get_current_thread();
|
||||
if (thread->id == id) {
|
||||
// it's ourself, so we know we aren't in the run queue, and we can manipulate
|
||||
// our structure directly
|
||||
strlcpy(thread->name, name, B_OS_NAME_LENGTH);
|
||||
} else {
|
||||
cpu_status state = disable_interrupts();
|
||||
GRAB_THREAD_LOCK();
|
||||
|
||||
thread = thread_get_thread_struct_locked(id);
|
||||
if (thread) {
|
||||
strlcpy(thread->name, name, B_OS_NAME_LENGTH);
|
||||
} else
|
||||
status = B_BAD_THREAD_ID;
|
||||
|
||||
RELEASE_THREAD_LOCK();
|
||||
restore_interrupts(state);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
set_thread_priority(thread_id id, int32 priority)
|
||||
{
|
||||
@ -1599,6 +1631,20 @@ _user_suspend_thread(thread_id thread)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
_user_rename_thread(thread_id thread, const char *userName)
|
||||
{
|
||||
char name[B_OS_NAME_LENGTH];
|
||||
|
||||
if (!IS_USER_ADDRESS(userName)
|
||||
|| userName == NULL
|
||||
|| user_strlcpy(name, userName, B_OS_NAME_LENGTH) < B_OK)
|
||||
return B_BAD_ADDRESS;
|
||||
|
||||
return rename_thread(thread, name);
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
_user_set_thread_priority(thread_id thread, int32 newPriority)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user