- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Trying to use pstat_getpathname when running f...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2009 04:14 PM
06-23-2009 04:14 PM
Any suggestions would be appreciated! I already looked at three previous threads that come up when I searched for getpathname and it seems this function is not always guaranteed to work depending on what is in the cache.
struct pst_vm_status vmstat;
struct pst_filedetails psfdetails;
char name[1024];
int pid = getpid();
if ((pstat_getprocvm(&vmstat, sizeof(vmstat), pid, 1)) < 0)
return eSysFailure;
if ((pstat_getfiledetails(&psfdetails, sizeof(psfdetails),
&(vmstat.pst_fid))) < 0)
return eSysFailure;
if ((pstat_getpathname(name, sizeof(name), &(vmstat.pst_fid))) <0)
return eSysFailure;
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2009 07:35 PM
06-23-2009 07:35 PM
Solutionhttp://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1278175
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1280356
Any reason you don't use the tried and true argv[0] solution?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2009 06:03 AM
06-24-2009 06:03 AM
Re: Trying to use pstat_getpathname when running from DVD
The code you put in the other thread is probably not an obvious option. NOTE: I did not write this program - I am simply trying to help figure out the fix.
I built the program you provided and it appears what I want is the contents of "argv[0]" - is that right? I am pretty rusty with my C programming skills!
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2009 09:12 PM
06-24-2009 09:12 PM
Re: Trying to use pstat_getpathname when running from DVD
My statement was about using my argv hand waving instead of newfangled pstat_getpathname(2).
>The code you put in the other thread is probably not an obvious option.
Not obvious in that you can't figure it out, or won't work for you?
>I want is the contents of "argv[0]" - is that right?
It gets the contents of argv[0] and $PATH.
What it doesn't show is how to check argv[0] and then append getcwd(2) or the $PATH components until stat(2) finds an executable.
Something like this:
#include
#include
#include
#include
#include
#include
#include
#include
#if defined(__LP64__) || defined(__ia64)
#define ARGVS __argv
#else
extern char **__argv_value;
#define ARGVS __argv_value
#endif
int main() {
struct stat stat_buf;
char buf[MAXPATHLEN], buf2[MAXPATHLEN];
int i, found;
char *patht, *p;
const char *path = getenv("PATH");
printf("PATH=%s\n", path);
/* Now look at argv[0] and PATH */
if (ARGVS[0][0] == '/') {
printf("Path to executable: %s\n", ARGVS[0]);
return 0;
}
if (!getcwd(buf, sizeof(buf))) {
fprintf(stderr, "Can't get CWD: %s\n", strerror(errno));
return 1;
}
if (ARGVS[0][0] == '.') {
/* Assume it fits */
strcat(buf, "/");
strcat(buf, ARGVS[0]);
printf("Path to executable: %s\n", buf);
return 0;
}
found = 0;
patht = strdup(path);
p = strtok(patht, ":");
while (p) {
if (p[0] == '\0' || strcmp(p, ".") == 0) {
strcpy(buf2, buf);
} else
strcpy(buf2, p);
strcat(buf2, "/");
strcat(buf2, ARGVS[0]);
if (stat(buf2, &stat_buf) == 0 && !(stat_buf.st_mode & S_IFDIR) &&
access(buf2, X_OK) == 0) {
found = 1;
break;
}
p = strtok(NULL, ":");
}
free(patht);
if (found)
printf("Path to executable: %s\n", buf2);
else
printf("Can't find executable path for: %s\n", ARGVS[0]);
return 0;
}
- Tags:
- threads corrupted
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2009 10:08 AM
06-25-2009 10:08 AM
Re: Trying to use pstat_getpathname when running from DVD
I said your solution was not obvious based on my own perspective which is limited since I am not actively writing code and have only done a little C programming.
I have no idea why the program was written as it exists. I am only being asked to help in identifying a solution to the problem.
I opened a case with HP once I had a test program using our technique. It turns out there is a defect in 11.31 that has caused the code to no longer function as expected. So HP will be correcting that problem.
I am going to try the revised code you sent. I'll let you know if that works for a DVD, but it may be several days since I have to build it and write it to a DVD.
Thank you so much for the input.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2009 10:34 AM
06-25-2009 10:34 AM
Re: Trying to use pstat_getpathname when running from DVD
Your input is appreciated!
I guess I should post the HP fix here once I get more information from them?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2009 11:42 AM
06-25-2009 11:42 AM
Re: Trying to use pstat_getpathname when running from DVD
Did you mean if you use a relative path? If I have "." in PATH, I get the right result. If I execute ./a.out (or any other relative path) I do get: $PWD/./a.out
If you don't like that, you can call realpath(3).
>I guess I should post the HP fix here once I get more information from them?
Sure, you can list the patch ID.