hotspot/src/os/bsd/vm/os_bsd.cpp
changeset 14471 f3a6b82e25cf
parent 14286 ec9e76cd402f
child 14626 0cf4eccf130f
child 14583 d70ee55535f4
equal deleted inserted replaced
14383:f31aacbd0f36 14471:f3a6b82e25cf
  1196     return false;
  1196     return false;
  1197   }
  1197   }
  1198   return os::stat(filename, &statbuf) == 0;
  1198   return os::stat(filename, &statbuf) == 0;
  1199 }
  1199 }
  1200 
  1200 
  1201 void os::dll_build_name(char* buffer, size_t buflen,
  1201 bool os::dll_build_name(char* buffer, size_t buflen,
  1202                         const char* pname, const char* fname) {
  1202                         const char* pname, const char* fname) {
       
  1203   bool retval = false;
  1203   // Copied from libhpi
  1204   // Copied from libhpi
  1204   const size_t pnamelen = pname ? strlen(pname) : 0;
  1205   const size_t pnamelen = pname ? strlen(pname) : 0;
  1205 
  1206 
  1206   // Quietly truncate on buffer overflow.  Should be an error.
  1207   // Return error on buffer overflow.
  1207   if (pnamelen + strlen(fname) + strlen(JNI_LIB_PREFIX) + strlen(JNI_LIB_SUFFIX) + 2 > buflen) {
  1208   if (pnamelen + strlen(fname) + strlen(JNI_LIB_PREFIX) + strlen(JNI_LIB_SUFFIX) + 2 > buflen) {
  1208       *buffer = '\0';
  1209     return retval;
  1209       return;
       
  1210   }
  1210   }
  1211 
  1211 
  1212   if (pnamelen == 0) {
  1212   if (pnamelen == 0) {
  1213     snprintf(buffer, buflen, JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX, fname);
  1213     snprintf(buffer, buflen, JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX, fname);
       
  1214     retval = true;
  1214   } else if (strchr(pname, *os::path_separator()) != NULL) {
  1215   } else if (strchr(pname, *os::path_separator()) != NULL) {
  1215     int n;
  1216     int n;
  1216     char** pelements = split_path(pname, &n);
  1217     char** pelements = split_path(pname, &n);
  1217     for (int i = 0 ; i < n ; i++) {
  1218     for (int i = 0 ; i < n ; i++) {
  1218       // Really shouldn't be NULL, but check can't hurt
  1219       // Really shouldn't be NULL, but check can't hurt
  1220         continue; // skip the empty path values
  1221         continue; // skip the empty path values
  1221       }
  1222       }
  1222       snprintf(buffer, buflen, "%s/" JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX,
  1223       snprintf(buffer, buflen, "%s/" JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX,
  1223           pelements[i], fname);
  1224           pelements[i], fname);
  1224       if (file_exists(buffer)) {
  1225       if (file_exists(buffer)) {
       
  1226         retval = true;
  1225         break;
  1227         break;
  1226       }
  1228       }
  1227     }
  1229     }
  1228     // release the storage
  1230     // release the storage
  1229     for (int i = 0 ; i < n ; i++) {
  1231     for (int i = 0 ; i < n ; i++) {
  1234     if (pelements != NULL) {
  1236     if (pelements != NULL) {
  1235       FREE_C_HEAP_ARRAY(char*, pelements, mtInternal);
  1237       FREE_C_HEAP_ARRAY(char*, pelements, mtInternal);
  1236     }
  1238     }
  1237   } else {
  1239   } else {
  1238     snprintf(buffer, buflen, "%s/" JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX, pname, fname);
  1240     snprintf(buffer, buflen, "%s/" JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX, pname, fname);
  1239   }
  1241     retval = true;
       
  1242   }
       
  1243   return retval;
  1240 }
  1244 }
  1241 
  1245 
  1242 const char* os::get_current_directory(char *buf, int buflen) {
  1246 const char* os::get_current_directory(char *buf, int buflen) {
  1243   return getcwd(buf, buflen);
  1247   return getcwd(buf, buflen);
  1244 }
  1248 }