comparison src/os/solaris/vm/os_solaris.cpp @ 691:956304450e80

6819213: revive sun.boot.library.path Summary: Support multiplex and mutable sun.boot.library.path Reviewed-by: acorn, dcubed, xlu
author phh
date Wed, 01 Apr 2009 16:38:01 -0400
parents 6bdd6923ba16
children 665be97e8704
comparison
equal deleted inserted replaced
690:d142f1feeed5 691:956304450e80
1825 1825
1826 const char* os::dll_file_extension() { return ".so"; } 1826 const char* os::dll_file_extension() { return ".so"; }
1827 1827
1828 const char* os::get_temp_directory() { return "/tmp/"; } 1828 const char* os::get_temp_directory() { return "/tmp/"; }
1829 1829
1830 void os::dll_build_name( 1830 static bool file_exists(const char* filename) {
1831 char* buffer, size_t buflen, const char* pname, const char* fname) { 1831 struct stat statbuf;
1832 // copied from libhpi 1832 if (filename == NULL || strlen(filename) == 0) {
1833 return false;
1834 }
1835 return os::stat(filename, &statbuf) == 0;
1836 }
1837
1838 void os::dll_build_name(char* buffer, size_t buflen,
1839 const char* pname, const char* fname) {
1840 // Copied from libhpi
1833 const size_t pnamelen = pname ? strlen(pname) : 0; 1841 const size_t pnamelen = pname ? strlen(pname) : 0;
1834 1842
1835 /* Quietly truncate on buffer overflow. Should be an error. */ 1843 // Quietly truncate on buffer overflow. Should be an error.
1836 if (pnamelen + strlen(fname) + 10 > (size_t) buflen) { 1844 if (pnamelen + strlen(fname) + 10 > (size_t) buflen) {
1837 *buffer = '\0'; 1845 *buffer = '\0';
1838 return; 1846 return;
1839 } 1847 }
1840 1848
1841 if (pnamelen == 0) { 1849 if (pnamelen == 0) {
1842 sprintf(buffer, "lib%s.so", fname); 1850 snprintf(buffer, buflen, "lib%s.so", fname);
1851 } else if (strchr(pname, *os::path_separator()) != NULL) {
1852 int n;
1853 char** pelements = split_path(pname, &n);
1854 for (int i = 0 ; i < n ; i++) {
1855 // really shouldn't be NULL but what the heck, check can't hurt
1856 if (pelements[i] == NULL || strlen(pelements[i]) == 0) {
1857 continue; // skip the empty path values
1858 }
1859 snprintf(buffer, buflen, "%s/lib%s.so", pelements[i], fname);
1860 if (file_exists(buffer)) {
1861 break;
1862 }
1863 }
1864 // release the storage
1865 for (int i = 0 ; i < n ; i++) {
1866 if (pelements[i] != NULL) {
1867 FREE_C_HEAP_ARRAY(char, pelements[i]);
1868 }
1869 }
1870 if (pelements != NULL) {
1871 FREE_C_HEAP_ARRAY(char*, pelements);
1872 }
1843 } else { 1873 } else {
1844 sprintf(buffer, "%s/lib%s.so", pname, fname); 1874 snprintf(buffer, buflen, "%s/lib%s.so", pname, fname);
1845 } 1875 }
1846 } 1876 }
1847 1877
1848 const char* os::get_current_directory(char *buf, int buflen) { 1878 const char* os::get_current_directory(char *buf, int buflen) {
1849 return getcwd(buf, buflen); 1879 return getcwd(buf, buflen);