[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/4] Implement /proc/cmdline and /proc/mounts as symlinks.
From: |
Jeremie Koenig |
Subject: |
[PATCH 4/4] Implement /proc/cmdline and /proc/mounts as symlinks. |
Date: |
Fri, 13 Aug 2010 19:05:15 +0200 |
* /proc/cmdline -> /proc/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.
* /proc/mounts -> /etc/mtab (push the problem to mount)
Among other things, many parts of d-i 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.
---
procfs_dir.c | 6 ++++++
procfs_nonpid_files.c | 26 ++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/procfs_dir.c b/procfs_dir.c
index f76e6a4..f99f402 100644
--- a/procfs_dir.c
+++ b/procfs_dir.c
@@ -654,6 +654,12 @@ 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;
+
+ if ((err = procfs_create_mounts (dir, &node, timestamp)) != 0)
+ return err;
+
return 0;
}
diff --git a/procfs_nonpid_files.c b/procfs_nonpid_files.c
index 2c1209e..8e88cf3 100644
--- a/procfs_nonpid_files.c
+++ b/procfs_nonpid_files.c
@@ -166,6 +166,32 @@ 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 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
- Re: [PATCH 2/2] Implement some (global) symlinks., (continued)
- Re: [PATCH 1/2] Fix /proc/*/cmdline., olafBuddenhagen, 2010/08/13
- [PATCH 2/4] update_pid_entries(): fix awkwardly indented uninitialized memory leak, Jeremie Koenig, 2010/08/13
- [PATCH 3/4] Set an appropriate st_mode on symlinks., Jeremie Koenig, 2010/08/13
- Re: [PATCH 3/4] Set an appropriate st_mode on symlinks., olafBuddenhagen, 2010/08/15
- Re: [PATCH 3/4] Set an appropriate st_mode on symlinks., Jeremie Koenig, 2010/08/15
- [PATCH 4/4] Implement /proc/cmdline and /proc/mounts as symlinks.,
Jeremie Koenig <=
- Re: [PATCH 4/4] Implement /proc/cmdline and /proc/mounts as symlinks., olafBuddenhagen, 2010/08/15
- Re: [PATCH 1/2] Fix /proc/*/cmdline., olafBuddenhagen, 2010/08/15
Updated procfs series, Jeremie Koenig, 2010/08/16
[PATCH 1/5] Fix /proc/*/cmdline, Jeremie Koenig, 2010/08/16
[PATCH 4/5] Implement /proc/cmdline as a symlinks to 2/cmdline, Jeremie Koenig, 2010/08/16
[PATCH 3/5] Set an appropriate st_mode on symlinks, Jeremie Koenig, 2010/08/16
[PATCH 2/5] update_pid_entries(): fix awkwardly indented uninitialized memory leak, Jeremie Koenig, 2010/08/16
[PATCH 5/5] Implement /proc/mounts as a symlink to /etc/mtab, Jeremie Koenig, 2010/08/16