[prev in list] [next in list] [prev in thread] [next in thread] 

List:       hurd-bug
Subject:    [PATCH 1/3] kern: implement task_set_name
From:       Justus Winter <4winter () informatik ! uni-hamburg ! de>
Date:       2014-02-04 10:01:52
Message-ID: 1391508112-4970-1-git-send-email-4winter () informatik ! uni-hamburg ! de
[Download RAW message or body]

task_set_name sets the name of a task.  This is a debugging aid.  The
name will be used in error messages printed by the kernel.

* kern/task.c (task_set_name): New function.
* kern/task.h (task_set_name): New declaration.
---
 kern/task.c | 17 +++++++++++++++++
 kern/task.h |  4 ++++
 2 files changed, 21 insertions(+)

diff --git a/kern/task.c b/kern/task.c
index 0b5a6f7..66eb25c 100644
--- a/kern/task.c
+++ b/kern/task.c
@@ -37,6 +37,7 @@
 #include <mach/vm_param.h>
 #include <mach/task_info.h>
 #include <mach/task_special_ports.h>
+#include <mach_debug/mach_debug_types.h>
 #include <ipc/ipc_space.h>
 #include <ipc/ipc_types.h>
 #include <kern/debug.h>
@@ -1071,6 +1072,22 @@ task_priority(
 }
 
 /*
+ *	task_set_name
+ *
+ *	Set the name of task TASK to NAME.  This is a debugging aid.
+ *	NAME will be used in error messages printed by the kernel.
+ */
+kern_return_t
+task_set_name(
+	task_t			task,
+	kernel_debug_name_t	name)
+{
+	strncpy(task->name, name, sizeof task->name - 1);
+	task->name[sizeof task->name - 1] = '\0';
+	return KERN_SUCCESS;
+}
+
+/*
  *	task_collect_scan:
  *
  *	Attempt to free resources owned by tasks.
diff --git a/kern/task.h b/kern/task.h
index 7ae10cd..3c10dc0 100644
--- a/kern/task.h
+++ b/kern/task.h
@@ -39,6 +39,7 @@
 #include <mach/time_value.h>
 #include <mach/mach_param.h>
 #include <mach/task_info.h>
+#include <mach_debug/mach_debug_types.h>
 #include <kern/kern_types.h>
 #include <kern/lock.h>
 #include <kern/queue.h>
@@ -169,6 +170,9 @@ extern kern_return_t	task_assign(
 extern kern_return_t	task_assign_default(
 	task_t		task,
 	boolean_t	assign_threads);
+extern kern_return_t	task_set_name(
+	task_t			task,
+	kernel_debug_name_t	name);
 extern void consider_task_collect(void);
 
 /*
-- 
1.8.5.2


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic