[PATCH 3/8] debian/patches/procfs/*: New patches for /proc symlinks
Namely, /proc/cmdline -> /proc/2/cmdline;
/proc/mounts -> /etc/mtab.
---
debian/changelog | 3 +
debian/patches/procfs/0001-Fix-proc-cmdline.patch | 47 ++++++++++++++++
...entries-fix-awkwardly-indented-uninitiali.patch | 37 +++++++++++++
...03-Set-an-appropriate-st_mode-on-symlinks.patch | 36 ++++++++++++
...t-proc-cmdline-as-a-symlinks-to-2-cmdline.patch | 57 +++++++++++++++++++
...ment-proc-mounts-as-a-symlink-to-etc-mtab.patch | 58 ++++++++++++++++++++
debian/patches/series | 5 ++
7 files changed, 243 insertions(+), 0 deletions(-)
create mode 100644 debian/patches/procfs/0001-Fix-proc-cmdline.patch
create mode 100644 debian/patches/procfs/0002-update_pid_entries-fix-awkwardly-indented-uninitiali.patch
create mode 100644 debian/patches/procfs/0003-Set-an-appropriate-st_mode-on-symlinks.patch
create mode 100644 debian/patches/procfs/0004-Implement-proc-cmdline-as-a-symlinks-to-2-cmdline.patch
create mode 100644 debian/patches/procfs/0005-Implement-proc-mounts-as-a-symlink-to-etc-mtab.patch
diff --git a/debian/changelog b/debian/changelog
index cf8f8ae..ab17b81 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -93,6 +93,9 @@ hurd (20100802-1) UNRELEASED; urgency=low
upgrades (on initial installs, debootstrap will use the
setup-translators script from the installed hurd package to setup the
devices and servers itself).
+ * debian/patches/procfs/*: New patches (procfs symlinks)
+ - Fix a couple of bugs.
+ - Implement /proc/cmdline and /proc/mounts as symlinks.
-- Samuel Thibault <sthibault@debian.org> Mon, 02 Aug 2010 10:06:06 +0200
diff --git a/debian/patches/procfs/0001-Fix-proc-cmdline.patch b/debian/patches/procfs/0001-Fix-proc-cmdline.patch
new file mode 100644
index 0000000..cf3593d
--- /dev/null
+++ b/debian/patches/procfs/0001-Fix-proc-cmdline.patch
@@ -0,0 +1,47 @@
+From 923c5166f0b10ebbb24f16a76c68f6e91b57caf3 Mon Sep 17 00:00:00 2001
+From: Jeremie Koenig <jk@jk.fr.eu.org>
+Date: Thu, 12 Aug 2010 23:35:21 +0000
+Subject: [PATCH 1/5] Fix /proc/*/cmdline
+
+On Linux, /proc/NNNN/cmdline is a NUL-separated list of arguments.
+We used to truncate after the first one and add some whitespace.
+
+Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org>
+---
+ procfs_pid_files.c | 14 +++++++-------
+ 1 files changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/procfs/procfs_pid_files.c b/procfs_pid_files.c
+index 4686153..9dbe3eb 100644
+--- a/procfs/procfs_pid_files.c
++++ b/procfs/procfs_pid_files.c
+@@ -429,19 +429,19 @@ procfs_read_cmdline_file (struct procfs_dir_entry *dir_entry,
+ error_t err;
+ struct proc_stat *ps;
+ pid_t pid = atoi (dir_entry->dir->node->nn->dir_entry->name);
++
+ err = _proc_stat_create (pid, ps_context, &ps);
++ if (err)
++ return err;
+
+ err = set_field_value (ps, PSTAT_ARGS);
+-
+ if (! err)
+- if (asprintf (&cmdline_data, "%s \n", ps->args) == -1)
+- return errno;
+-
+- memcpy (data, cmdline_data, strlen(cmdline_data));
+- *len = strlen (data);
++ {
++ memcpy (data, ps->args, ps->args_len);
++ *len = ps->args_len;
++ }
+
+ _proc_stat_free (ps);
+- free (cmdline_data);
+ return err;
+ }
+
+--
+1.7.1
+
diff --git a/debian/patches/procfs/0002-update_pid_entries-fix-awkwardly-indented-uninitiali.patch b/debian/patches/procfs/0002-update_pid_entries-fix-awkwardly-indented-uninitiali.patch
new file mode 100644
index 0000000..3aee9be
--- /dev/null
+++ b/debian/patches/procfs/0002-update_pid_entries-fix-awkwardly-indented-uninitiali.patch
@@ -0,0 +1,37 @@
+From c07c41cfd521af5daee0d77c7d77539ae463489d Mon Sep 17 00:00:00 2001
+From: Jeremie Koenig <jk@jk.fr.eu.org>
+Date: Fri, 13 Aug 2010 16:14:50 +0000
+Subject: [PATCH 2/5] update_pid_entries(): fix awkwardly indented uninitialized memory leak
+
+
+Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org>
+---
+ procfs_pid_files.c | 10 ++++------
+ 1 files changed, 4 insertions(+), 6 deletions(-)
+
+diff --git a/procfs/procfs_pid_files.c b/procfs_pid_files.c
+index 9dbe3eb..3008145 100644
+--- a/procfs/procfs_pid_files.c
++++ b/procfs/procfs_pid_files.c
+@@ -46,14 +46,12 @@ update_pid_entries (struct procfs_dir *dir, const char *name,
+ time_t timestamp,
+ const char *symlink_target)
+ {
+- struct procfs_dir_entry *dir_entry;
+- struct stat *stat = (struct stat *) malloc (sizeof (struct stat));
+- stat->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH;
++ struct stat stat;
+
+- dir_entry = update_entries_list (dir, name, stat,
+- timestamp, symlink_target);
++ memset (&stat, 0, sizeof stat);
++ stat->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH;
+
+- return dir_entry;
++ return update_entries_list (dir, name, &stat, timestamp, symlink_target);
+ }
+
+ /* Creates files to store process information for DIR
+--
+1.7.1
+
diff --git a/debian/patches/procfs/0003-Set-an-appropriate-st_mode-on-symlinks.patch b/debian/patches/procfs/0003-Set-an-appropriate-st_mode-on-symlinks.patch
new file mode 100644
index 0000000..c467e9b
--- /dev/null
+++ b/debian/patches/procfs/0003-Set-an-appropriate-st_mode-on-symlinks.patch
@@ -0,0 +1,36 @@
+From 8af9d82dd2bf9299a946df88b3140a7c1743760f Mon Sep 17 00:00:00 2001
+From: Jeremie Koenig <jk@jk.fr.eu.org>
+Date: Fri, 13 Aug 2010 16:16:24 +0000
+Subject: [PATCH 3/5] Set an appropriate st_mode on symlinks
+
+
+Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org>
+---
+ procfs_pid_files.c | 11 ++++++++++-
+ 1 files changed, 10 insertions(+), 1 deletions(-)
+
+diff --git a/procfs/procfs_pid_files.c b/procfs_pid_files.c
+index 3008145..e2ad2fd 100644
+--- a/procfs/procfs_pid_files.c
++++ b/procfs/procfs_pid_files.c
+@@ -49,7 +49,16 @@ update_pid_entries (struct procfs_dir *dir, const char *name,
+ struct stat stat;
+
+ memset (&stat, 0, sizeof stat);
+- stat->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH;
++ if (symlink_target)
++ {
++ stat.st_size = strlen (symlink_target);
++ stat.st_mode = S_IFLNK | 0777;
++ }
++ else
++ {
++ stat.st_size = 0;
++ stat.st_mode = S_IFREG | 0444;
++ }
+
+ return update_entries_list (dir, name, &stat, timestamp, symlink_target);
+ }
+--
+1.7.1
+
diff --git a/debian/patches/procfs/0004-Implement-proc-cmdline-as-a-symlinks-to-2-cmdline.patch b/debian/patches/procfs/0004-Implement-proc-cmdline-as-a-symlinks-to-2-cmdline.patch
new file mode 100644
index 0000000..0fbb528
--- /dev/null
+++ b/debian/patches/procfs/0004-Implement-proc-cmdline-as-a-symlinks-to-2-cmdline.patch
@@ -0,0 +1,57 @@
+From 690dfa7fa7d667d22651fc96ebc0283667ac8ddd Mon Sep 17 00:00:00 2001
+From: Jeremie Koenig <jk@jk.fr.eu.org>
+Date: Sun, 15 Aug 2010 16:09:47 +0000
+Subject: [PATCH 4/5] Implement /proc/cmdline as a symlinks to 2/cmdline
+
+Process 2 is usually gnumach. This is not perfect, as the format of
+/proc/cmdline and /proc/*/cmdline are different on Linux. Namely, the
+latter includes NUL bytes to separate subsequent arguments, while the
+former contains only spaces and a trailing newline.
+
+Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org>
+---
+ procfs_dir.c | 3 +++
+ procfs_nonpid_files.c | 13 +++++++++++++
+ 2 files changed, 16 insertions(+), 0 deletions(-)
+
+diff --git a/procfs/procfs_dir.c b/procfs_dir.c
+index f76e6a4..598b2e3 100644
+--- a/procfs/procfs_dir.c
++++ b/procfs/procfs_dir.c
+@@ -654,6 +654,9 @@ procfs_fill_root_dir(struct procfs_dir *dir, time_t timestamp)
+ if ((err = procfs_create_loadavg (dir, &node, timestamp)) != 0)
+ return err;
+
++ if ((err = procfs_create_cmdline (dir, &node, timestamp)) != 0)
++ return err;
++
+ return 0;
+ }
+
+diff --git a/procfs/procfs_nonpid_files.c b/procfs_nonpid_files.c
+index 2c1209e..2041610 100644
+--- a/procfs/procfs_nonpid_files.c
++++ b/procfs/procfs_nonpid_files.c
+@@ -166,6 +166,19 @@ error_t procfs_create_loadavg (struct procfs_dir *dir,
+ return err;
+ }
+
++error_t procfs_create_cmdline (struct procfs_dir *dir,
++ struct node **node,
++ time_t timestamp)
++{
++ struct procfs_dir_entry *dir_entry;
++ int err;
++
++ dir_entry = update_pid_entries (dir, "cmdline", timestamp, "2/cmdline");
++ err = procfs_create_node (dir_entry, "cmdline", node);
++
++ return err;
++}
++
+ error_t get_uptime (struct timeval *uptime)
+ {
+ struct timeval boot_time, now;
+--
+1.7.1
+
diff --git a/debian/patches/procfs/0005-Implement-proc-mounts-as-a-symlink-to-etc-mtab.patch b/debian/patches/procfs/0005-Implement-proc-mounts-as-a-symlink-to-etc-mtab.patch
new file mode 100644
index 0000000..05923d4
--- /dev/null
+++ b/debian/patches/procfs/0005-Implement-proc-mounts-as-a-symlink-to-etc-mtab.patch
@@ -0,0 +1,58 @@
+From 94ead1954096ee80d7ed84684e186599779eaf8a Mon Sep 17 00:00:00 2001
+From: Jeremie Koenig <jk@jk.fr.eu.org>
+Date: Sun, 15 Aug 2010 16:12:04 +0000
+Subject: [PATCH 5/5] Implement /proc/mounts as a symlink to /etc/mtab
+
+Among other things, many parts of Debian-installer want /proc/mounts.
+Implementing it the right way is non-trivial, though. In the meantime,
+we publish a symlink to /etc/mtab so that the user can fake it in
+whatever way they want. Furthermore I hope to be porting busybox mount
+soon, and use it to manage the mtab in d-i.
+
+Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org>
+---
+ procfs_dir.c | 3 +++
+ procfs_nonpid_files.c | 13 +++++++++++++
+ 2 files changed, 16 insertions(+), 0 deletions(-)
+
+diff --git a/procfs/procfs_dir.c b/procfs_dir.c
+index 598b2e3..f99f402 100644
+--- a/procfs/procfs_dir.c
++++ b/procfs/procfs_dir.c
+@@ -657,6 +657,9 @@ procfs_fill_root_dir(struct procfs_dir *dir, time_t timestamp)
+ if ((err = procfs_create_cmdline (dir, &node, timestamp)) != 0)
+ return err;
+
++ if ((err = procfs_create_mounts (dir, &node, timestamp)) != 0)
++ return err;
++
+ return 0;
+ }
+
+diff --git a/procfs/procfs_nonpid_files.c b/procfs_nonpid_files.c
+index 2041610..e64d7be 100644
+--- a/procfs/procfs_nonpid_files.c
++++ b/procfs/procfs_nonpid_files.c
+@@ -179,6 +179,19 @@ error_t procfs_create_cmdline (struct procfs_dir *dir,
+ return err;
+ }
+
++error_t procfs_create_mounts (struct procfs_dir *dir,
++ struct node **node,
++ time_t timestamp)
++{
++ struct procfs_dir_entry *dir_entry;
++ int err;
++
++ dir_entry = update_pid_entries (dir, "mounts", timestamp, "/etc/mtab");
++ err = procfs_create_node (dir_entry, "mounts", node);
++
++ return err;
++}
++
+ error_t get_uptime (struct timeval *uptime)
+ {
+ struct timeval boot_time, now;
+--
+1.7.1
+
diff --git a/debian/patches/series b/debian/patches/series
index 9d9109f..d0e9c9d 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -25,3 +25,8 @@ libpthread_procfs.patch
makedev_keep_options.patch
makedev_parted_store.patch
console_ignore_bdf_err.patch
+procfs/0001-Fix-proc-cmdline.patch
+procfs/0002-update_pid_entries-fix-awkwardly-indented-uninitiali.patch
+procfs/0003-Set-an-appropriate-st_mode-on-symlinks.patch
+procfs/0004-Implement-proc-cmdline-as-a-symlinks-to-2-cmdline.patch
+procfs/0005-Implement-proc-mounts-as-a-symlink-to-etc-mtab.patch
--
1.7.1
Reply to: