summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2016-02-05 22:29:07 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2016-02-05 22:29:07 +0000
commita07632cea359a68576961f7b45238a6a37a82945 (patch)
treef6110f8da57fe92116207eadde881e24ed6d190b
parent14fafe1c7dc8e0d2718591f3a06a84ec0d32c9b5 (diff)
downloadillumos-joyent-a07632cea359a68576961f7b45238a6a37a82945.tar.gz
OS-5149 /proc/self/mountinfo should be clean like /proc/mounts
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
-rw-r--r--usr/src/uts/common/brand/lx/procfs/lx_prvnops.c75
1 files changed, 49 insertions, 26 deletions
diff --git a/usr/src/uts/common/brand/lx/procfs/lx_prvnops.c b/usr/src/uts/common/brand/lx/procfs/lx_prvnops.c
index a2dad381be..2911a182df 100644
--- a/usr/src/uts/common/brand/lx/procfs/lx_prvnops.c
+++ b/usr/src/uts/common/brand/lx/procfs/lx_prvnops.c
@@ -1531,6 +1531,37 @@ lxpr_read_pid_maps(lxpr_node_t *lxpnp, lxpr_uiobuf_t *uiobuf)
}
/*
+ * Make mount entry look more like Linux. Non-zero return to skip it.
+ */
+static int
+lxpr_clean_mntent(char **mntpt, char **fstype, char **resource)
+{
+ if (strcmp(*mntpt, "/var/ld") == 0 ||
+ strcmp(*fstype, "objfs") == 0 ||
+ strcmp(*fstype, "mntfs") == 0 ||
+ strcmp(*fstype, "ctfs") == 0 ||
+ strncmp(*mntpt, "/native/", 8) == 0) {
+ return (1);
+ }
+
+ if (strcmp(*fstype, "tmpfs") == 0) {
+ *resource = "tmpfs";
+ } else if (strcmp(*fstype, "lx_proc") == 0) {
+ *resource = *fstype = "proc";
+ } else if (strcmp(*fstype, "lx_sysfs") == 0) {
+ *resource = *fstype = "sysfs";
+ } else if (strcmp(*fstype, "lx_devfs") == 0) {
+ *resource = *fstype = "devtmpfs";
+ } else if (strcmp(*fstype, "lx_cgroup") == 0) {
+ *resource = *fstype = "cgroup";
+ } else if (strcmp(*fstype, "lxautofs") == 0) {
+ *fstype = "autofs";
+ }
+
+ return (0);
+}
+
+/*
* lxpr_read_pid_mountinfo(): information about process mount points. e.g.:
* 14 19 0:13 / /sys rw,nosuid,nodev,noexec,relatime - sysfs sysfs rw
* mntid parid devnums root mntpnt mntopts - fstype mntsrc superopts
@@ -1637,13 +1668,14 @@ nextfs:
printp = print_head;
while (printp != NULL) {
struct print_data *printp_next;
- const char *resource;
+ char *resource;
char *mntpt;
+ char *fstype;
struct vnode *vp;
int error;
mntpt = (char *)refstr_value(printp->vfs_mntpt);
- resource = refstr_value(printp->vfs_resource);
+ resource = (char *)refstr_value(printp->vfs_resource);
if (mntpt != NULL && mntpt[0] != '\0')
mntpt = ZONE_PATH_TRANSLATE(mntpt, zone);
@@ -1670,6 +1702,12 @@ nextfs:
resource = "none";
}
+ /* Make things look more like Linux. */
+ fstype = vfssw[printp->vfs_fstype].vsw_name;
+ if (lxpr_clean_mntent(&mntpt, &fstype, &resource) != 0) {
+ goto nextp;
+ }
+
/*
* XXX parent ID is not tracked correctly here. Currently we
* always assume the parent ID is the root ID.
@@ -1680,7 +1718,7 @@ nextfs:
major(printp->vfs_dev), minor(printp->vfs_dev),
mntpt,
printp->vfs_flag & VFS_RDONLY ? "ro" : "rw",
- vfssw[printp->vfs_fstype].vsw_name,
+ fstype,
resource,
printp->vfs_flag & VFS_RDONLY ? "ro" : "rw");
@@ -1693,6 +1731,10 @@ nextp:
mnt_id++;
}
+
+ /* Add a single dummy entry for /native */
+ lxpr_uiobuf_printf(uiobuf, "%d %d 0:1 / /native ro - zfs /native ro\n",
+ mnt_id, root_id);
}
/*
@@ -3490,14 +3532,14 @@ nextfs:
printp = print_head;
while (printp != NULL) {
struct print_data *printp_next;
- const char *resource;
+ char *resource;
char *fstype;
char *mntpt;
struct vnode *vp;
int error;
mntpt = (char *)refstr_value(printp->vfs_mntpt);
- resource = refstr_value(printp->vfs_resource);
+ resource = (char *)refstr_value(printp->vfs_resource);
if (mntpt != NULL && mntpt[0] != '\0')
mntpt = ZONE_PATH_TRANSLATE(mntpt, zone);
@@ -3525,31 +3567,12 @@ nextfs:
resource = "-";
}
- /* Make things look more like Linux */
+ /* Make things look more like Linux. */
fstype = vfssw[printp->vfs_fstype].vsw_name;
-
- if (strcmp(mntpt, "/var/ld") == 0 ||
- strcmp(fstype, "objfs") == 0 ||
- strcmp(fstype, "mntfs") == 0 ||
- strcmp(fstype, "ctfs") == 0 ||
- strncmp(mntpt, "/native/", 8) == 0) {
+ if (lxpr_clean_mntent(&mntpt, &fstype, &resource) != 0) {
goto nextp;
}
- if (strcmp(fstype, "tmpfs") == 0) {
- resource = "tmpfs";
- } else if (strcmp(fstype, "lx_proc") == 0) {
- resource = fstype = "proc";
- } else if (strcmp(fstype, "lx_sysfs") == 0) {
- resource = fstype = "sysfs";
- } else if (strcmp(fstype, "lx_devfs") == 0) {
- resource = fstype = "devtmpfs";
- } else if (strcmp(fstype, "lx_cgroup") == 0) {
- resource = fstype = "cgroup";
- } else if (strcmp(fstype, "lxautofs") == 0) {
- fstype = "autofs";
- }
-
lxpr_uiobuf_printf(uiobuf,
"%s %s %s %s 0 0\n", resource, mntpt, fstype,
printp->vfs_flag & VFS_RDONLY ? "ro" : "rw");