commit-hurd
[Top][All Lists]
Advanced

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

[hurd] 01/01: patches/exec_set_exe.patch: New patch to implement /proc/<


From: Samuel Thibault
Subject: [hurd] 01/01: patches/exec_set_exe.patch: New patch to implement /proc/<pid>/exe
Date: Sun, 08 Jan 2017 16:17:37 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch master
in repository hurd.

commit 7fb464e167c632a62a98272f127c457d7955091f
Author: Samuel Thibault <address@hidden>
Date:   Sun Jan 8 16:16:46 2017 +0000

    patches/exec_set_exe.patch: New patch to implement /proc/<pid>/exe
---
 debian/changelog                  |   6 +
 debian/patches/exec_set_exe.patch | 330 +++++++++++++++++++-------------------
 debian/patches/newRPC.patch       |  26 +++
 debian/patches/series             |   2 +-
 4 files changed, 198 insertions(+), 166 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index d5a3fa9..7c01919 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+hurd (1:0.9.git20170102-2) UNRELEASED; urgency=medium
+
+  * patches/exec_set_exe.patch: New patch to implement /proc/<pid>/exe.
+
+ -- Samuel Thibault <address@hidden>  Sun, 08 Jan 2017 15:39:20 +0000
+
 hurd (1:0.9.git20170102-1) unstable; urgency=medium
 
   * New upstream snapshot.
diff --git a/debian/patches/exec_set_exe.patch 
b/debian/patches/exec_set_exe.patch
index 0bab9dd..0972661 100644
--- a/debian/patches/exec_set_exe.patch
+++ b/debian/patches/exec_set_exe.patch
@@ -1,17 +1,28 @@
-Index: hurd-debian/exec/exec.c
-===================================================================
---- hurd-debian.orig/exec/exec.c
-+++ hurd-debian/exec/exec.c
-@@ -1312,6 +1312,9 @@ do_exec (file_t file,
-       if (e.error)
-       goto out;
- 
-+      if (filename)
-+      proc_set_exe (boot->portarray[INIT_PORT_PROC], filename);
-+
-       set_name (newtask, argv, pid);
-     }
-   else
+Implement /proc/<pid>/exe by adding proc_set/get_exe to the proc server, making
+exec call proc_set_exe, and libps call proc_get_exe. procfs can then just
+retrieve the information to make the "exe" symlink.
+
+* hurd/process.defs (proc_set_exe, proc_get_exe): New RPCs.
+* hurd/process_request.defs: Likewise.
+* hurd/process_reply.defs: Add skips for proc_set_exe and proc_get_exe RPCs.
+* proc/proc.h (struct proc): Add `exe' field.
+* proc/info.c (S_proc_set_exe, S_proc_get_exe): New functions.
+* proc/mgt.c (process_has_exited): Free p->exe.
+* exec/exec.c (do_exec): Call proc_set_exe when a filename is available.
+* libps/ps.h (struct proc_stat): Add `exe_vm_alloced', `exe', and `exe_len'
+field.
+(PSTAT_EXE): New macro.
+(PSTAT_USER_BASE): Change value to make room.
+(proc_stat_exe, proc_stat_exe_len): New macros.
+* libps/procstat.c (proc_stat_set_flags): Handle PSTAT_EXE case by calling
+proc_get_exe.
+* libps/spec.c (ps_get_exe): New function.
+(ps_exe_getter): New structure.
+(ps_fmt_spec): Add "Exe" specification.
+* procfs/process.c (process_file_symlink_make_node, process_file_gc_exe): New
+functions.
+(procfs_dir_entry): Add "exe" entry.
+
 Index: hurd-debian/hurd/process.defs
 ===================================================================
 --- hurd-debian.orig/hurd/process.defs
@@ -30,12 +41,53 @@ Index: hurd-debian/hurd/process.defs
 +routine proc_get_exe (
 +      process: process_t;
 +      which: pid_t;
-+      out path: data_t, dealloc);
++      out path: string_t);
+Index: hurd-debian/hurd/process_request.defs
+===================================================================
+--- hurd-debian.orig/hurd/process_request.defs
++++ hurd-debian/hurd/process_request.defs
+@@ -417,3 +417,6 @@ simpleroutine proc_make_task_namespace_r
+       process: process_t;
+       ureplyport reply: reply_port_t;
+       notify: mach_port_send_t);
++
++skip; /* proc_set_exe  */
++skip; /* proc_get_exe  */
+Index: hurd-debian/hurd/process_reply.defs
+===================================================================
+--- hurd-debian.orig/hurd/process_reply.defs
++++ hurd-debian/hurd/process_reply.defs
+@@ -194,3 +194,5 @@ simpleroutine proc_get_code_reply (
+       end_code: vm_address_t);
+ 
+ skip; /* proc_make_task_namespace  */
++skip; /* proc_set_exe  */
++skip; /* proc_get_exe  */
+Index: hurd-debian/proc/proc.h
+===================================================================
+--- hurd-debian.orig/proc/proc.h
++++ hurd-debian/proc/proc.h
+@@ -68,6 +68,7 @@ struct proc
+   pthread_cond_t p_wakeup;
+ 
+   /* Miscellaneous information */
++  char *exe;                  /* path to binary executable */
+   vm_address_t p_argv, p_envp;
+   vm_address_t start_code;    /* all executable segments are in this range */
+   vm_address_t end_code;
 Index: hurd-debian/proc/info.c
 ===================================================================
 --- hurd-debian.orig/proc/info.c
 +++ hurd-debian/proc/info.c
-@@ -799,3 +799,46 @@ S_proc_getnports (struct proc *callerp,
+@@ -24,6 +24,7 @@
+ #include <sys/mman.h>
+ #include <hurd/hurd_types.h>
+ #include <stdlib.h>
++#include <stdio.h>
+ #include <errno.h>
+ #include <string.h>
+ #include <sys/resource.h>
+@@ -799,3 +800,43 @@ S_proc_getnports (struct proc *callerp,
  
    return err;
  }
@@ -63,8 +115,7 @@ Index: hurd-debian/proc/info.c
 +kern_return_t
 +S_proc_get_exe (struct proc *callerp,
 +              pid_t pid,
-+              char **path,
-+              size_t *pathlen)
++              char *path)
 +{
 +  struct proc *p = pid_find (pid);
 +
@@ -72,111 +123,41 @@ Index: hurd-debian/proc/info.c
 +
 +  if (!p)
 +    return ESRCH;
-+  if (!*pathlen)
-+    return 0;
 +
 +  if (p->exe)
-+    snprintf (*path, *pathlen, "%s", p->exe);
++    snprintf (path, 1024 /* XXX */, "%s", p->exe);
 +  else
-+    **path = 0;
++    path[0] = 0;
 +  return 0;
 +}
 +
-Index: hurd-debian/proc/proc.h
-===================================================================
---- hurd-debian.orig/proc/proc.h
-+++ hurd-debian/proc/proc.h
-@@ -68,6 +68,7 @@ struct proc
-   pthread_cond_t p_wakeup;
- 
-   /* Miscellaneous information */
-+  char *exe;                  /* path to binary executable */
-   vm_address_t p_argv, p_envp;
-   vm_address_t start_code;    /* all executable segments are in this range */
-   vm_address_t end_code;
-Index: hurd-debian/procfs/process.c
+Index: hurd-debian/proc/mgt.c
 ===================================================================
---- hurd-debian.orig/procfs/process.c
-+++ hurd-debian/procfs/process.c
-@@ -95,6 +95,13 @@ static int args_filename_length (const c
- /* Actual content generators */
+--- hurd-debian.orig/proc/mgt.c
++++ hurd-debian/proc/mgt.c
+@@ -770,6 +770,8 @@ process_has_exited (struct proc *p)
  
- static ssize_t
-+process_file_gc_exe (struct proc_stat *ps, char **contents)
-+{
-+  *contents = proc_stat_exe(ps);
-+  return proc_stat_exe_len(ps);
-+}
-+
-+static ssize_t
- process_file_gc_cmdline (struct proc_stat *ps, char **contents)
- {
-   *contents = proc_stat_args(ps);
-@@ -410,6 +417,14 @@ process_file_make_node (void *dir_hook,
-   return np;
- }
+   if (!--p->p_login->l_refcnt)
+     free (p->p_login);
++  free (p->exe);
++  p->exe = NULL;
  
-+static struct node *
-+process_file_symlink_make_node (void *dir_hook, const void *entry_hook)
-+{
-+  struct node *np = process_file_make_node (dir_hook, entry_hook);
-+  if (np) procfs_node_chtype (np, S_IFLNK);
-+  return np;
-+}
-+
- /* Stat needs its own constructor in order to set its mode according to
-    the --stat-mode command-line option.  */
- static struct node *
-@@ -425,6 +440,17 @@ process_stat_make_node (void *dir_hook,
+   ids_rele (p->p_id);
  
- static struct procfs_dir_entry entries[] = {
-   {
-+    .name = "exe",
-+    .hook = & (struct process_file_desc) {
-+      .get_contents = process_file_gc_exe,
-+      .needs = PSTAT_EXE,
-+      .no_cleanup = 1,
-+    },
-+    .ops = {
-+      .make_node = process_file_symlink_make_node,
-+    },
-+  },
-+  {
-     .name = "cmdline",
-     .hook = & (struct process_file_desc) {
-       .get_contents = process_file_gc_cmdline,
-Index: hurd-debian/libps/procstat.c
+Index: hurd-debian/exec/exec.c
 ===================================================================
---- hurd-debian.orig/libps/procstat.c
-+++ hurd-debian/libps/procstat.c
-@@ -956,6 +956,27 @@ proc_stat_set_flags (struct proc_stat *p
-       }
-     }
+--- hurd-debian.orig/exec/exec.c
++++ hurd-debian/exec/exec.c
+@@ -1312,6 +1312,9 @@ do_exec (file_t file,
+       if (e.error)
+       goto out;
  
-+  /* The process's path to binary executable */
-+  if (NEED (PSTAT_EXE, PSTAT_PID))
-+    {
-+      char *buf = malloc (100);
-+      ps->exe_len = 100;
-+      ps->exe = buf;
-+      if (ps->exe)
-+      {
-+        error_t err;
-+        if (err = proc_get_exe (server, ps->pid, &ps->exe, &ps->exe_len))
-+          free (buf);
-+        else
-+          {
-+            have |= PSTAT_EXE;
-+            ps->exe_vm_alloced = (ps->exe != buf);
-+            if (ps->exe_vm_alloced)
-+              free (buf);
-+          }
-+      }
-+    }
++      if (filename)
++      proc_set_exe (boot->portarray[INIT_PORT_PROC], filename);
 +
-   /* The ctty id port; note that this is just a magic cookie;
-      we use it to fetch a port to the actual terminal -- it's not useful for
-      much else.  */
+       set_name (newtask, argv, pid);
+     }
+   else
 Index: hurd-debian/libps/ps.h
 ===================================================================
 --- hurd-debian.orig/libps/ps.h
@@ -225,6 +206,34 @@ Index: hurd-debian/libps/ps.h
  #define proc_stat_has(ps, needs) (((ps)->flags & needs) == needs)
  
  /* True if PS refers to a thread and not a process.  */
+Index: hurd-debian/libps/procstat.c
+===================================================================
+--- hurd-debian.orig/libps/procstat.c
++++ hurd-debian/libps/procstat.c
+@@ -956,6 +956,23 @@ proc_stat_set_flags (struct proc_stat *p
+       }
+     }
+ 
++  /* The process's path to binary executable */
++  if (NEED (PSTAT_EXE, PSTAT_PID))
++    {
++      ps->exe = malloc (sizeof(string_t));
++      if (ps->exe)
++      {
++        if (proc_get_exe (server, ps->pid, ps->exe))
++          free (ps->exe);
++        else
++          {
++            ps->exe_len = strlen(ps->exe);
++            have |= PSTAT_EXE;
++            ps->exe_vm_alloced = 0;
++          }
++      }
++    }
++
+   /* The ctty id port; note that this is just a magic cookie;
+      we use it to fetch a port to the actual terminal -- it's not useful for
+      much else.  */
 Index: hurd-debian/libps/spec.c
 ===================================================================
 --- hurd-debian.orig/libps/spec.c
@@ -253,63 +262,54 @@ Index: hurd-debian/libps/spec.c
    {0}
  };
  
-Index: hurd-debian/exec/Makefile
-===================================================================
---- hurd-debian.orig/exec/Makefile
-+++ hurd-debian/exec/Makefile
-@@ -22,7 +22,7 @@ makemode := server
- 
- SRCS = exec.c main.c hashexec.c hostarch.c
- OBJS = main.o hostarch.o exec.o hashexec.o \
--       execServer.o exec_startupServer.o exec_experimentalServer.o
-+       execServer.o exec_startupServer.o exec_experimentalServer.o 
processUser.o
- 
- target = exec exec.static
- HURDLIBS = trivfs fshelp iohelp ports ihash shouldbeinlibc
-Index: hurd-debian/libps/Makefile
-===================================================================
---- hurd-debian.orig/libps/Makefile
-+++ hurd-debian/libps/Makefile
-@@ -29,7 +29,7 @@ installhdrs = ps.h
- installhdrsubdir = .
- 
- HURDLIBS=ihash shouldbeinlibc
--OBJS = $(SRCS:.c=.o) msgUser.o termUser.o
-+OBJS = $(SRCS:.c=.o) msgUser.o termUser.o processUser.o
- 
- msg-MIGUFLAGS = -D'MSG_IMPORTS=waittime 1000;' -DUSERPREFIX=ps_
- term-MIGUFLAGS = -D'TERM_IMPORTS=waittime 1000;' -DUSERPREFIX=ps_
-Index: hurd-debian/hurd/process_reply.defs
+Index: hurd-debian/procfs/process.c
 ===================================================================
---- hurd-debian.orig/hurd/process_reply.defs
-+++ hurd-debian/hurd/process_reply.defs
-@@ -194,3 +194,5 @@ simpleroutine proc_get_code_reply (
-       end_code: vm_address_t);
+--- hurd-debian.orig/procfs/process.c
++++ hurd-debian/procfs/process.c
+@@ -95,6 +95,13 @@ static int args_filename_length (const c
+ /* Actual content generators */
  
- skip; /* proc_make_task_namespace  */
-+skip; /* proc_set_exe  */
-+skip; /* proc_get_exe  */
-Index: hurd-debian/hurd/process_request.defs
-===================================================================
---- hurd-debian.orig/hurd/process_request.defs
-+++ hurd-debian/hurd/process_request.defs
-@@ -417,3 +417,6 @@ simpleroutine proc_make_task_namespace_r
-       process: process_t;
-       ureplyport reply: reply_port_t;
-       notify: mach_port_send_t);
+ static ssize_t
++process_file_gc_exe (struct proc_stat *ps, char **contents)
++{
++  *contents = proc_stat_exe(ps);
++  return proc_stat_exe_len(ps);
++}
 +
-+skip; /* proc_set_exe  */
-+skip; /* proc_get_exe  */
-Index: hurd-debian/proc/mgt.c
-===================================================================
---- hurd-debian.orig/proc/mgt.c
-+++ hurd-debian/proc/mgt.c
-@@ -770,6 +770,8 @@ process_has_exited (struct proc *p)
- 
-   if (!--p->p_login->l_refcnt)
-     free (p->p_login);
-+  free (p->exe);
-+  p->exe = NULL;
++static ssize_t
+ process_file_gc_cmdline (struct proc_stat *ps, char **contents)
+ {
+   *contents = proc_stat_args(ps);
+@@ -410,6 +417,14 @@ process_file_make_node (void *dir_hook,
+   return np;
+ }
  
-   ids_rele (p->p_id);
++static struct node *
++process_file_symlink_make_node (void *dir_hook, const void *entry_hook)
++{
++  struct node *np = process_file_make_node (dir_hook, entry_hook);
++  if (np) procfs_node_chtype (np, S_IFLNK);
++  return np;
++}
++
+ /* Stat needs its own constructor in order to set its mode according to
+    the --stat-mode command-line option.  */
+ static struct node *
+@@ -425,6 +440,17 @@ process_stat_make_node (void *dir_hook,
  
+ static struct procfs_dir_entry entries[] = {
+   {
++    .name = "exe",
++    .hook = & (struct process_file_desc) {
++      .get_contents = process_file_gc_exe,
++      .needs = PSTAT_EXE,
++      .no_cleanup = 1,
++    },
++    .ops = {
++      .make_node = process_file_symlink_make_node,
++    },
++  },
++  {
+     .name = "cmdline",
+     .hook = & (struct process_file_desc) {
+       .get_contents = process_file_gc_cmdline,
diff --git a/debian/patches/newRPC.patch b/debian/patches/newRPC.patch
index 856a300..eecfc37 100644
--- a/debian/patches/newRPC.patch
+++ b/debian/patches/newRPC.patch
@@ -23,3 +23,29 @@ index 3b8ce58e0..3cb506a27 100644
  
  HURDLIBS:= ihash
  LDLIBS:= -lpthread
+Index: hurd-debian/exec/Makefile
+===================================================================
+--- hurd-debian.orig/exec/Makefile
++++ hurd-debian/exec/Makefile
+@@ -22,7 +22,7 @@ makemode := server
+ 
+ SRCS = exec.c main.c hashexec.c hostarch.c
+ OBJS = main.o hostarch.o exec.o hashexec.o \
+-       execServer.o exec_startupServer.o exec_experimentalServer.o
++       execServer.o exec_startupServer.o exec_experimentalServer.o 
processUser.o
+ 
+ target = exec exec.static
+ HURDLIBS = trivfs fshelp iohelp ports ihash shouldbeinlibc
+Index: hurd-debian/libps/Makefile
+===================================================================
+--- hurd-debian.orig/libps/Makefile
++++ hurd-debian/libps/Makefile
+@@ -29,7 +29,7 @@ installhdrs = ps.h
+ installhdrsubdir = .
+ 
+ HURDLIBS=ihash shouldbeinlibc
+-OBJS = $(SRCS:.c=.o) msgUser.o termUser.o
++OBJS = $(SRCS:.c=.o) msgUser.o termUser.o processUser.o
+ 
+ msg-MIGUFLAGS = -D'MSG_IMPORTS=waittime 1000;' -DUSERPREFIX=ps_
+ term-MIGUFLAGS = -D'TERM_IMPORTS=waittime 1000;' -DUSERPREFIX=ps_
diff --git a/debian/patches/series b/debian/patches/series
index 5c519d2..48b02d0 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -29,4 +29,4 @@ netdde_log.patch
 libports-iterate-refcount.patch
 exec_filename_rpctrace.patch
 procfs
-#exec_set_exe.patch
+exec_set_exe.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

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