Changeset 63554 in vbox for trunk/src/VBox/Runtime/r3/netbsd/rtProcInitExePath-netbsd.cpp
- Timestamp:
- Aug 16, 2016 1:09:11 PM (8 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/netbsd/rtProcInitExePath-netbsd.cpp
r63550 r63554 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - rtProcInitName, FreeBSD.3 * IPRT - rtProcInitName, NetBSD. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2006-201 6Oracle Corporation7 * Copyright (C) 2006-2010 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 47 47 DECLHIDDEN(int) rtProcInitExePath(char *pszPath, size_t cchPath) 48 48 { 49 #ifdef KERN_PROC_PATHNAME50 int aiName[4];51 aiName[0] = CTL_KERN;52 aiName[1] = KERN_PROC;53 aiName[2] = KERN_PROC_PATHNAME; /* This was introduced in FreeBSD 6.0, thus the #ifdef above. */54 aiName[3] = -1; /* Shorthand for the current process. */55 56 size_t cchExePath = cchPath;57 if (sysctl(aiName, RT_ELEMENTS(aiName), pszPath, &cchExePath, NULL, 0) == 0)58 {59 const char *pszTmp;60 int rc = rtPathFromNative(&pszTmp, pszPath, NULL);61 AssertMsgRCReturn(rc, ("rc=%Rrc pszPath=\"%s\"\nhex: %.*Rhxs\n", rc, pszPath, cchExePath, pszPath), rc);62 if (pszTmp != pszPath)63 {64 rc = RTStrCopy(pszPath, cchPath, pszTmp);65 rtPathFreeIprt(pszTmp, pszPath);66 }67 return rc;68 }69 70 int rc = RTErrConvertFromErrno(errno);71 AssertMsgFailed(("rc=%Rrc errno=%d cchExePath=%d\n", rc, errno, cchExePath));72 return rc;73 74 #else75 76 49 /* 77 50 * Read the /proc/curproc/file link, convert to native and return it. 78 51 */ 79 int cchLink = readlink("/proc/curproc/ file", pszPath, cchPath - 1);52 int cchLink = readlink("/proc/curproc/exe", pszPath, cchPath - 1); 80 53 if (cchLink > 0 && (size_t)cchLink <= cchPath - 1) 81 54 { … … 83 56 84 57 char const *pszTmp; 85 int rc = rtPathFromNative(&pszTmp, pszPath );58 int rc = rtPathFromNative(&pszTmp, pszPath, NULL); 86 59 AssertMsgRCReturn(rc, ("rc=%Rrc pszLink=\"%s\"\nhex: %.*Rhxs\n", rc, pszPath, cchLink, pszPath), rc); 87 60 if (pszTmp != pszPath) 88 61 { 89 62 rc = RTStrCopy(pszPath, cchPath, pszTmp); 90 rtPathFreeIprt(pszTmp );63 rtPathFreeIprt(pszTmp, pszPath); 91 64 } 92 65 return rc; … … 125 98 AssertMsgFailed(("rc=%Rrc err=%d cchLink=%d hExe=%p\n", rc, err, cchLink, hExe)); 126 99 return rc; 127 #endif128 100 } 129
Note:
See TracChangeset
for help on using the changeset viewer.