diff --git a/src/os/solaris/sigar_os.h b/src/os/solaris/sigar_os.h index f806f4bf..338ce8cc 100644 --- a/src/os/solaris/sigar_os.h +++ b/src/os/solaris/sigar_os.h @@ -166,6 +166,8 @@ typedef void (*proc_free_func_t)(void *); typedef void (*proc_objname_func_t)(void *, uintptr_t, const char *, size_t); +typedef char * (*proc_dirname_func_t)(const char *, char *, size_t); + struct sigar_t { SIGAR_T_BASE; @@ -213,6 +215,7 @@ struct sigar_t { proc_grab_func_t pgrab; proc_free_func_t pfree; proc_objname_func_t pobjname; + proc_dirname_func_t pdirname; }; #define kSTAT_uint(v, type) \ diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index ae07f30e..80f856e3 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -431,10 +431,12 @@ static int sigar_init_libproc(sigar_t *sigar) sigar->pgrab = (proc_grab_func_t)dlsym(sigar->plib, "Pgrab"); sigar->pfree = (proc_free_func_t)dlsym(sigar->plib, "Pfree"); sigar->pobjname = (proc_objname_func_t)dlsym(sigar->plib, "Pobjname"); + sigar->pdirname = (proc_dirname_func_t)dlsym(sigar->plib, "proc_dirname"); CHECK_PSYM(pgrab); CHECK_PSYM(pfree); CHECK_PSYM(pobjname); + CHECK_PSYM(pdirname); return SIGAR_OK; } @@ -697,7 +699,28 @@ int sigar_proc_fd_get(sigar_t *sigar, sigar_pid_t pid, int sigar_proc_exe_get(sigar_t *sigar, sigar_pid_t pid, sigar_proc_exe_t *procexe) { - return SIGAR_ENOTIMPL; + int status; + char buffer[BUFSIZ]; + + if ((status = sigar_init_libproc(sigar)) != SIGAR_OK) { + return status; + } + + procexe->name[0] = '\0'; /*XXX*/ + + (void)SIGAR_PROC_FILENAME(buffer, pid, "/cwd"); + + if (!sigar->pdirname(buffer, procexe->cwd, sizeof(procexe->cwd))) { + procexe->cwd[0] = '\0'; + } + + (void)SIGAR_PROC_FILENAME(buffer, pid, "/root"); + + if (!(sigar->pdirname(buffer, procexe->root, sizeof(procexe->root)))) { + procexe->root[0] = '\0'; + } + + return SIGAR_OK; } /* from libproc.h, not included w/ solaris distro */