bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/3] Define and use symbolic names for important processes


From: Justus Winter
Subject: [PATCH 1/3] Define and use symbolic names for important processes
Date: Fri, 26 Jul 2013 16:38:29 +0200

* include/pids.h: New file.
* init/init.c (frob_kernel_process): Use symbolic name for kernel process.
* exec/exec.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 <address@hidden>
+
+   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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]