diff options
Diffstat (limited to 'usr/src/lib/libproc/common/proc_arg.c')
-rw-r--r-- | usr/src/lib/libproc/common/proc_arg.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/usr/src/lib/libproc/common/proc_arg.c b/usr/src/lib/libproc/common/proc_arg.c index 2a79b016c2..c25a89b944 100644 --- a/usr/src/lib/libproc/common/proc_arg.c +++ b/usr/src/lib/libproc/common/proc_arg.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -39,21 +38,22 @@ #include <errno.h> #include <dirent.h> -#include "libproc.h" +#include "Pcontrol.h" static int open_psinfo(const char *arg, int *perr) { /* - * Allocate enough space for "/proc/" + arg + "/psinfo" + * Allocate enough space for procfs_path + arg + "/psinfo" */ - char *path = alloca(strlen(arg) + 14); + char *path = alloca(strlen(arg) + strlen(procfs_path) + 9); struct stat64 st; int fd; if (strchr(arg, '/') == NULL) { - (void) strcpy(path, "/proc/"); + (void) strcpy(path, procfs_path); + (void) strcat(path, "/"); (void) strcat(path, arg); } else (void) strcpy(path, arg); @@ -430,7 +430,7 @@ proc_walk(proc_walk_f *func, void *arg, int flag) DIR *procdir; struct dirent *dirent; char *errptr; - char pidstr[80]; + char pidstr[PATH_MAX]; psinfo_t psinfo; lwpsinfo_t *lwpsinfo; prheader_t prheader; @@ -445,7 +445,7 @@ proc_walk(proc_walk_f *func, void *arg, int flag) errno = EINVAL; return (-1); } - if ((procdir = opendir("/proc")) == NULL) + if ((procdir = opendir(procfs_path)) == NULL) return (-1); while (dirent = readdir(procdir)) { if (dirent->d_name[0] == '.') /* skip . and .. */ @@ -455,7 +455,7 @@ proc_walk(proc_walk_f *func, void *arg, int flag) continue; /* PR_WALK_PROC case */ (void) snprintf(pidstr, sizeof (pidstr), - "/proc/%ld/psinfo", pid); + "%s/%ld/psinfo", procfs_path, pid); fd = open(pidstr, O_RDONLY); if (fd < 0) continue; @@ -471,7 +471,7 @@ proc_walk(proc_walk_f *func, void *arg, int flag) } /* PR_WALK_LWP case */ (void) snprintf(pidstr, sizeof (pidstr), - "/proc/%ld/lpsinfo", pid); + "%s/%ld/lpsinfo", procfs_path, pid); fd = open(pidstr, O_RDONLY); if (fd < 0) continue; |