Changeset 36465 in vbox
- Timestamp:
- Mar 29, 2011 4:22:33 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/solaris/coredumper-solaris.cpp
r36210 r36465 53 53 # include <sys/systeminfo.h> 54 54 # include <sys/mman.h> 55 # include <sys/types.h> 56 # include <sys/stat.h> 57 # include <fcntl.h> 55 58 # include <ucontext.h> 56 59 #endif /* RT_OS_SOLARIS */ … … 212 215 { 213 216 uint64_t cb = 0; 214 RTFILE hFile;215 i nt rc = RTFileOpen(&hFile, pszPath, RTFILE_O_OPEN | RTFILE_O_READ);216 if (RT_SUCCESS(rc))217 {217 int fd = open(pszPath, O_RDONLY); 218 if (fd >= 0) 219 { 220 RTFILE hFile = fd; 218 221 RTFileGetSize(hFile, &cb); 219 222 RTFileClose(hFile); 220 223 } 221 224 else 222 CORELOGRELSYS((CORELOG_NAME "GetFileSize failed to open %s rc=%Rrc\n", pszPath, rc));225 CORELOGRELSYS((CORELOG_NAME "GetFileSize: failed to open %s rc=%Rrc\n", pszPath, RTErrConvertFromErrno(fd))); 223 226 return cb < ~(size_t)0 ? (size_t)cb : ~(size_t)0; 224 227 } … … 350 353 * @param pcb Where to store size of the buffer. 351 354 * 352 * @return IPRT status code. 355 * @return IPRT status code. If the proc file is 0 bytes, VINF_SUCCESS is 356 * returned with pointed to values of @c ppv, @c pcb set to NULL and 0 357 * respectively. 353 358 */ 354 359 static int ProcReadFileInto(PVBOXCORE pVBoxCore, const char *pszProcFileName, void **ppv, size_t *pcb) … … 358 363 char szPath[PATH_MAX]; 359 364 RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/%s", (int)pVBoxCore->VBoxProc.Process, pszProcFileName); 360 RTFILE hFile; 361 int rc = RTFileOpen(&hFile, szPath, RTFILE_O_OPEN | RTFILE_O_READ); 362 if (RT_SUCCESS(rc)) 363 { 365 int rc = VINF_SUCCESS; 366 int fd = open(szPath, O_RDONLY); 367 if (fd >= 0) 368 { 369 RTFILE hFile = fd; 364 370 uint64_t u64Size; 365 371 RTFileGetSize(hFile, &u64Size); … … 377 383 *pcb = 0; 378 384 *ppv = NULL; 385 rc = VINF_SUCCESS; 379 386 } 380 387 RTFileClose(hFile); 381 388 } 382 389 else 390 { 391 rc = RTErrConvertFromErrno(fd); 383 392 CORELOGRELSYS((CORELOG_NAME "ProcReadFileInto: failed to open %s. rc=%Rrc\n", szPath, rc)); 393 } 384 394 return rc; 385 395 } … … 399 409 PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc; 400 410 char szPath[PATH_MAX]; 401 RTFILE hFile;411 int rc = VINF_SUCCESS; 402 412 403 413 RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/psinfo", (int)pVBoxProc->Process); 404 int rc = RTFileOpen(&hFile, szPath, RTFILE_O_OPEN | RTFILE_O_READ); 405 if (RT_SUCCESS(rc)) 406 { 414 int fd = open(szPath, O_RDONLY); 415 if (fd >= 0) 416 { 417 RTFILE hFile = fd; 407 418 size_t cbProcInfo = sizeof(psinfo_t); 408 419 rc = ReadFileNoIntr(hFile, &pVBoxProc->ProcInfo, cbProcInfo); 409 } 410 411 RTFileClose(hFile); 420 RTFileClose(hFile); 421 } 422 else 423 { 424 rc = RTErrConvertFromErrno(fd); 425 CORELOGRELSYS((CORELOG_NAME "ProcReadInfo: failed to open %s. rc=%Rrc\n", szPath, rc)); 426 } 427 412 428 return rc; 413 429 } … … 428 444 429 445 char szPath[PATH_MAX]; 430 RTFILE hFile;446 int rc = VINF_SUCCESS; 431 447 432 448 RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/status", (int)pVBoxProc->Process); 433 int rc = RTFileOpen(&hFile, szPath, RTFILE_O_OPEN | RTFILE_O_READ); 434 if (RT_SUCCESS(rc)) 435 { 449 int fd = open(szPath, O_RDONLY); 450 if (fd >= 0) 451 { 452 RTFILE hFile = fd; 436 453 size_t cbRead; 437 454 size_t cbProcStatus = sizeof(pstatus_t); 438 455 AssertCompile(sizeof(pstatus_t) == sizeof(pVBoxProc->ProcStatus)); 439 456 rc = ReadFileNoIntr(hFile, &pVBoxProc->ProcStatus, cbProcStatus); 440 } 441 RTFileClose(hFile); 457 RTFileClose(hFile); 458 } 459 else 460 { 461 rc = RTErrConvertFromErrno(fd); 462 CORELOGRELSYS((CORELOG_NAME "ProcReadStatus: failed to open %s. rc=%Rrc\n", szPath, rc)); 463 } 442 464 return rc; 443 465 } … … 518 540 PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc; 519 541 char szPath[PATH_MAX]; 520 RTFILE hFile = NIL_RTFILE;542 int rc = VINF_SUCCESS; 521 543 RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/auxv", (int)pVBoxProc->Process); 522 int rc = RTFileOpen(&hFile, szPath, RTFILE_O_OPEN | RTFILE_O_READ); 523 if (RT_FAILURE(rc)) 524 { 525 CORELOGRELSYS((CORELOG_NAME "ProcReadAuxVecs: RTFileOpen %s failed rc=%Rrc\n", szPath, rc)); 544 int fd = open(szPath, O_RDONLY); 545 if (fd < 0) 546 { 547 rc = RTErrConvertFromErrno(fd); 548 CORELOGRELSYS((CORELOG_NAME "ProcReadAuxVecs: failed to open %s rc=%Rrc\n", szPath, rc)); 526 549 return rc; 527 550 } 528 551 552 RTFILE hFile = fd; 529 553 uint64_t u64Size; 530 554 RTFileGetSize(hFile, &u64Size); … … 568 592 } 569 593 else 594 { 570 595 CORELOGRELSYS((CORELOG_NAME "ProcReadAuxVecs: aux file too small %u, expecting %u or more\n", cbAuxFile, sizeof(auxv_t))); 596 rc = VERR_READ_ERROR; 597 } 571 598 572 599 RTFileClose(hFile); … … 608 635 PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc; 609 636 char szPath[PATH_MAX]; 610 RTFILE hFile = NIL_RTFILE;637 int rc = VINF_SUCCESS; 611 638 RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/map", (int)pVBoxProc->Process); 612 int rc = RTFileOpen(&hFile, szPath, RTFILE_O_OPEN | RTFILE_O_READ); 613 if (RT_FAILURE(rc)) 639 int fd = open(szPath, O_RDONLY); 640 if (fd < 0) 641 { 642 rc = RTErrConvertFromErrno(fd); 643 CORELOGRELSYS((CORELOG_NAME "ProcReadMappings: failed to open %s. rc=%Rrc\n", szPath, rc)); 614 644 return rc; 615 645 } 646 647 RTFILE hFile = fd; 616 648 RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/as", (int)pVBoxProc->Process); 617 rc = RTFileOpen(&pVBoxProc->hAs, szPath, RTFILE_O_OPEN | RTFILE_O_READ); 618 if (RT_SUCCESS(rc)) 619 { 649 fd = open(szPath, O_RDONLY); 650 if (fd >= 0) 651 { 652 pVBoxProc->hAs = fd; 653 620 654 /* 621 655 * Allocate and read all the prmap_t objects from proc. … … 1147 1181 RTStrPrintf(szLpsInfoPath, sizeof(szLpsInfoPath), "/proc/%d/lpsinfo", (int)pVBoxProc->Process); 1148 1182 1149 RTFILE hFile = NIL_RTFILE; 1150 int rc = RTFileOpen(&hFile, szLpsInfoPath, RTFILE_O_READ); 1151 if (RT_SUCCESS(rc)) 1152 { 1183 int rc = VINF_SUCCESS; 1184 int fd = open(szLpsInfoPath, O_RDONLY); 1185 if (fd >= 0) 1186 { 1187 RTFILE hFile = fd; 1153 1188 uint64_t u64Size; 1154 1189 RTFileGetSize(hFile, &u64Size); … … 1177 1212 RTFileClose(hFile); 1178 1213 } 1214 else 1215 rc = RTErrConvertFromErrno(rc); 1179 1216 1180 1217 return rc; … … 1752 1789 * @param pfnWriter Pointer to the writer function to override default writer (NULL uses default). 1753 1790 * 1754 * @remarks Resumes all suspended threads, unless it's an invalid core. 1791 * @remarks Resumes all suspended threads, unless it's an invalid core. This 1792 * function must be called only -after- rtCoreDumperCreateCore(). 1755 1793 * @return VBox status. 1756 1794 */ … … 1767 1805 PVBOXPROCESS pVBoxProc = &pVBoxCore->VBoxProc; 1768 1806 char szPath[PATH_MAX]; 1807 int rc = VINF_SUCCESS; 1769 1808 1770 1809 /* … … 1772 1811 */ 1773 1812 RTStrPrintf(szPath, sizeof(szPath), "/proc/%d/as", (int)pVBoxProc->Process); 1774 int rc = RTFileOpen(&pVBoxProc->hAs, szPath, RTFILE_O_OPEN | RTFILE_O_READ); 1775 if (RT_FAILURE(rc)) 1776 { 1813 int fd = open(szPath, O_RDONLY); 1814 if (fd < 0) 1815 { 1816 rc = RTErrConvertFromErrno(fd); 1777 1817 CORELOGRELSYS((CORELOG_NAME "WriteCore: Failed to open address space, %s. rc=%Rrc\n", szPath, rc)); 1778 1818 goto WriteCoreDone; 1779 1819 } 1780 1820 1821 pVBoxProc->hAs = fd; 1822 1781 1823 /* 1782 1824 * Create the core file. 1783 1825 */ 1784 rc = RTFileOpen(&pVBoxCore->hCoreFile, pVBoxCore->szCorePath,1785 RTFILE_O_OPEN_CREATE | RTFILE_O_TRUNCATE | RTFILE_O_READWRITE | RTFILE_O_DENY_ALL);1786 if (RT_FAILURE(rc))1787 {1826 fd = open(pVBoxCore->szCorePath, O_CREAT | O_TRUNC | O_RDWR, S_IRUSR); 1827 if (fd < 0) 1828 { 1829 rc = RTErrConvertFromErrno(fd); 1788 1830 CORELOGRELSYS((CORELOG_NAME "WriteCore: failed to open %s. rc=%Rrc\n", pVBoxCore->szCorePath, rc)); 1789 1831 goto WriteCoreDone; 1790 1832 } 1833 1834 pVBoxCore->hCoreFile = fd; 1791 1835 1792 1836 pVBoxCore->offWrite = 0; … … 1904 1948 1905 1949 WriteCoreDone: 1906 if (pVBoxCore->hCoreFile != NIL_RTFILE) 1950 if (pVBoxCore->hCoreFile != NIL_RTFILE) /* Initialized in rtCoreDumperCreateCore() */ 1907 1951 { 1908 1952 RTFileClose(pVBoxCore->hCoreFile); … … 1910 1954 } 1911 1955 1912 if (pVBoxProc->hAs != NIL_RTFILE) 1956 if (pVBoxProc->hAs != NIL_RTFILE) /* Initialized in rtCoreDumperCreateCore() */ 1913 1957 { 1914 1958 RTFileClose(pVBoxProc->hAs);
Note:
See TracChangeset
for help on using the changeset viewer.