diff options
author | Keith M Wesolowski <wesolows@foobazco.org> | 2013-08-21 23:54:45 +0000 |
---|---|---|
committer | Keith M Wesolowski <wesolows@foobazco.org> | 2013-08-21 23:54:45 +0000 |
commit | 84a6527d59b307f3925d3dbac3728fd0d1db4706 (patch) | |
tree | 0f87ef159a57043733b2ad0f861e14d22d635942 /usr/src/lib/libproc/common/Pexecname.c | |
parent | 7d7a5b1f6447ad858fd291d2b95da27e7c690325 (diff) | |
parent | 2a12f85ad140e332791b4bad1208a734c3f26bf3 (diff) | |
download | illumos-joyent-release-20130822.tar.gz |
[illumos-gate merge]20130822release-20130822
commit 2a12f85ad140e332791b4bad1208a734c3f26bf3
3946 ::gcore
commit 840b2722e5294ae44aa3af6189002f521d7c50e0
3915 Add adjuncts support to the build (fix lint)
commit afffa6e9b45cbe9b33943e26568d8ac69b899252
4062 libscf: memory leaks in scf_simple_app_props_get()
commit 2fbdf8dbf01ec1c85fcd3827cdf9e9f5f46c4c8a
4061 libzfs: memory leak in iter_dependents_cb()
commit 713d6c208802cfbb806329ec0d154b641b80c355
4047 panic from dbuf_free_range() from dmu_free_object() while doing zfs receive
Diffstat (limited to 'usr/src/lib/libproc/common/Pexecname.c')
-rw-r--r-- | usr/src/lib/libproc/common/Pexecname.c | 66 |
1 files changed, 5 insertions, 61 deletions
diff --git a/usr/src/lib/libproc/common/Pexecname.c b/usr/src/lib/libproc/common/Pexecname.c index 82b4219560..8af0416e10 100644 --- a/usr/src/lib/libproc/common/Pexecname.c +++ b/usr/src/lib/libproc/common/Pexecname.c @@ -22,6 +22,9 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright (c) 2013 by Delphix. All rights reserved. + */ #define __EXTENSIONS__ #include <string.h> @@ -236,23 +239,7 @@ found: } /* - * Callback function for Pfindexec(). We return a match if we can stat the - * suggested pathname and confirm its device and inode number match our - * previous information about the /proc/<pid>/object/a.out file. - */ -static int -stat_exec(const char *path, struct stat64 *stp) -{ - struct stat64 st; - - return (stat64(path, &st) == 0 && S_ISREG(st.st_mode) && - stp->st_dev == st.st_dev && stp->st_ino == st.st_ino); -} - -/* - * Return the full pathname for the executable file. If the process handle is - * a core file, we've already tried our best to get the executable name. - * Otherwise, we make an attempt using Pfindexec(). + * Return the full pathname for the executable file. */ char * Pexecname(struct ps_prochandle *P, char *buf, size_t buflen) @@ -262,48 +249,5 @@ Pexecname(struct ps_prochandle *P, char *buf, size_t buflen) return (buf); } - if (P->state != PS_DEAD && P->state != PS_IDLE) { - char exec_name[PATH_MAX]; - char cwd[PATH_MAX]; - char proc_cwd[64]; - struct stat64 st; - int ret; - - /* - * Try to get the path information first. - */ - (void) snprintf(exec_name, sizeof (exec_name), - "%s/%d/path/a.out", procfs_path, (int)P->pid); - if ((ret = readlink(exec_name, buf, buflen - 1)) > 0) { - buf[ret] = '\0'; - (void) Pfindobj(P, buf, buf, buflen); - return (buf); - } - - /* - * Stat the executable file so we can compare Pfindexec's - * suggestions to the actual device and inode number. - */ - (void) snprintf(exec_name, sizeof (exec_name), - "%s/%d/object/a.out", procfs_path, (int)P->pid); - - if (stat64(exec_name, &st) != 0 || !S_ISREG(st.st_mode)) - return (NULL); - - /* - * Attempt to figure out the current working directory of the - * target process. This only works if the target process has - * not changed its current directory since it was exec'd. - */ - (void) snprintf(proc_cwd, sizeof (proc_cwd), - "%s/%d/path/cwd", procfs_path, (int)P->pid); - - if ((ret = readlink(proc_cwd, cwd, PATH_MAX - 1)) > 0) - cwd[ret] = '\0'; - - (void) Pfindexec(P, ret > 0 ? cwd : NULL, - (int (*)(const char *, void *))stat_exec, &st); - } - - return (NULL); + return (P->ops.pop_execname(P, buf, buflen, P->data)); } |