[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 02/17] Define and use symbolic names for important processes
From: |
Justus Winter |
Subject: |
[PATCH 02/17] Define and use symbolic names for important processes |
Date: |
Thu, 15 Aug 2013 09:37:52 +0200 |
* include/pids.h: New file.
* init/init.c (frob_kernel_process): Use symbolic name for kernel process.
* exec/main.c (S_exec_init): Use symbolic name for startup process.
* libdiskfs/boot-start.c (diskfs_S_fsys_init): Likewise.
* libdiskfs/init-startup.c (_diskfs_init_completed): Likewise.
* pfinet/main.c (arrange_shutdown_notification): Likewise.
* proc/mgt.c (create_startup_proc): Likewise.
* proc/main.c (main): Use symbolic name for proc process.
---
exec/main.c | 3 ++-
include/pids.h | 29 +++++++++++++++++++++++++++++
init/init.c | 3 ++-
libdiskfs/boot-start.c | 3 ++-
libdiskfs/init-startup.c | 3 ++-
pfinet/main.c | 3 ++-
proc/main.c | 3 ++-
proc/mgt.c | 3 ++-
8 files changed, 43 insertions(+), 7 deletions(-)
create mode 100644 include/pids.h
diff --git a/exec/main.c b/exec/main.c
index efad85a..d5d6882 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -25,6 +25,7 @@
#include <hurd/startup.h>
#include <argp.h>
#include <version.h>
+#include <pids.h>
const char *argp_program_version = STANDARD_HURD_VERSION (exec);
@@ -246,7 +247,7 @@ S_exec_init (struct trivfs_protid *protid,
proc_register_version (procserver, host_priv, "exec", "", HURD_VERSION);
- err = proc_getmsgport (procserver, 1, &startup);
+ err = proc_getmsgport (procserver, HURD_PID_STARTUP, &startup);
assert_perror (err);
mach_port_deallocate (mach_task_self (), procserver);
diff --git a/include/pids.h b/include/pids.h
new file mode 100644
index 0000000..485916b
--- /dev/null
+++ b/include/pids.h
@@ -0,0 +1,29 @@
+/* List of special processes.
+
+ Copyright (C) 2013 Free Software Foundation
+ Written by Justus Winter <4winter@informatik.uni-hamburg.de>
+
+ This file is part of the GNU Hurd.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#ifndef _HURD_PROCESSES_H
+#define _HURD_PROCESSES_H
+
+#define HURD_PID_PROC 0
+#define HURD_PID_STARTUP 1
+#define HURD_PID_KERNEL 2
+
+#endif /* _HURD_PROCESSES_H */
diff --git a/init/init.c b/init/init.c
index 930408e..05fce78 100644
--- a/init/init.c
+++ b/init/init.c
@@ -49,6 +49,7 @@
#include <maptime.h>
#include <version.h>
#include <argp.h>
+#include <pids.h>
#include "startup_notify_U.h"
#include "startup_reply_U.h"
@@ -770,7 +771,7 @@ frob_kernel_process (void)
task_t task;
process_t proc, kbs;
- err = proc_pid2task (procserver, 2, &task);
+ err = proc_pid2task (procserver, HURD_PID_KERNEL, &task);
if (err)
{
error (0, err, "cannot get kernel task port");
diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c
index b62d5f3..6d9a773 100644
--- a/libdiskfs/boot-start.c
+++ b/libdiskfs/boot-start.c
@@ -33,6 +33,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA
02139, USA. */
#include <string.h>
#include <argz.h>
#include <error.h>
+#include <pids.h>
#include "fsys_S.h"
#include "fsys_reply_U.h"
@@ -606,7 +607,7 @@ diskfs_S_fsys_init (mach_port_t port,
proc_register_version (procserver, host, diskfs_server_name, "",
diskfs_server_version);
- err = proc_getmsgport (procserver, 1, &startup);
+ err = proc_getmsgport (procserver, HURD_PID_STARTUP, &startup);
if (!err)
{
startup_essential_task (startup, mach_task_self (), MACH_PORT_NULL,
diff --git a/libdiskfs/init-startup.c b/libdiskfs/init-startup.c
index 2c0814f..ff1622f 100644
--- a/libdiskfs/init-startup.c
+++ b/libdiskfs/init-startup.c
@@ -26,6 +26,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA
02139, USA. */
#include <error.h>
#include <hurd/fsys.h>
#include <hurd/startup.h>
+#include <pids.h>
char *_diskfs_chroot_directory;
@@ -190,7 +191,7 @@ _diskfs_init_completed ()
if (err)
goto errout;
- err = proc_getmsgport (proc, 1, &init);
+ err = proc_getmsgport (proc, HURD_PID_STARTUP, &init);
mach_port_deallocate (mach_task_self (), proc);
if (err)
goto errout;
diff --git a/pfinet/main.c b/pfinet/main.c
index 01b324d..c952719 100644
--- a/pfinet/main.c
+++ b/pfinet/main.c
@@ -28,6 +28,7 @@
#include <string.h>
#include <fcntl.h>
#include <version.h>
+#include <pids.h>
/* Include Hurd's errno.h file, but don't include glue-include/hurd/errno.h,
since it #undef's the errno macro. */
@@ -153,7 +154,7 @@ arrange_shutdown_notification ()
if (!procserver)
return;
- err = proc_getmsgport (procserver, 1, &initport);
+ err = proc_getmsgport (procserver, HURD_PID_STARTUP, &initport);
mach_port_deallocate (mach_task_self (), procserver);
if (err)
return;
diff --git a/proc/main.c b/proc/main.c
index 494169e..73abbc0 100644
--- a/proc/main.c
+++ b/proc/main.c
@@ -28,6 +28,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA
02139, USA. */
#include <argp.h>
#include <error.h>
#include <version.h>
+#include <pids.h>
#include "proc.h"
@@ -87,7 +88,7 @@ main (int argc, char **argv, char **envp)
self_proc = allocate_proc (mach_task_self ());
assert (self_proc);
- complete_proc (self_proc, 0);
+ complete_proc (self_proc, HURD_PID_PROC);
startup_port = ports_get_send_right (startup_proc);
err = startup_procinit (boot, startup_port, &startup_proc->p_task,
diff --git a/proc/mgt.c b/proc/mgt.c
index 7af9c1a..1a881d0 100644
--- a/proc/mgt.c
+++ b/proc/mgt.c
@@ -32,6 +32,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA
02139, USA. */
#include <sys/resource.h>
#include <hurd/auth.h>
#include <assert.h>
+#include <pids.h>
#include "proc.h"
#include "process_S.h"
@@ -582,7 +583,7 @@ create_startup_proc (void)
p = allocate_proc (MACH_PORT_NULL);
assert (p);
- p->p_pid = 1;
+ p->p_pid = HURD_PID_STARTUP;
p->p_parent = p;
p->p_sib = 0;
--
1.7.10.4
- [PATCH 15/16] exec: keep track of the range where executable segments are mapped, (continued)
Make sysvinit pid 1, fix killall5 (2), Justus Winter, 2013/08/15
- [PATCH 01/17] hurd: add missing routines in process_reply.defs, Justus Winter, 2013/08/15
- [PATCH 02/17] Define and use symbolic names for important processes,
Justus Winter <=
- [PATCH 04/17] daemons: fix setsid(2) in console-run, Justus Winter, 2013/08/15
- [PATCH 05/17] proc: make the function check_owner available, Justus Winter, 2013/08/15
- [PATCH 03/17] Add proc_set_init_task, make runsystem pid 1, Justus Winter, 2013/08/15
[PATCH 06/17] proc: add proc_mark_important server code, Justus Winter, 2013/08/15
[PATCH 07/17] hurd: add proc_mark_important, Justus Winter, 2013/08/15
[PATCH 08/17] init: Mark all of inits children and init itself as important, Justus Winter, 2013/08/15
[PATCH 09/17] libdiskfs: register libdiskfs-based translators as important, Justus Winter, 2013/08/15