1225 case '%':
1226 strcpy(q, home);
1227 q += home_len;
1228 break;
1229 case '/':
1230 *q++ = fileSep;
1231 break;
1232 case ':':
1233 *q++ = pathSep;
1234 break;
1235 default:
1236 *q++ = *p;
1237 }
1238 }
1239 *q = '\0';
1240
1241 assert((q - formatted_path) == formatted_path_len, "formatted_path size botched");
1242 return formatted_path;
1243 }
1244
1245 bool os::set_boot_path(char fileSep, char pathSep) {
1246 const char* home = Arguments::get_java_home();
1247 int home_len = (int)strlen(home);
1248
1249 struct stat st;
1250
1251 // modular image if "modules" jimage exists
1252 char* jimage = format_boot_path("%/lib/" MODULES_IMAGE_NAME, home, home_len, fileSep, pathSep);
1253 if (jimage == NULL) return false;
1254 bool has_jimage = (os::stat(jimage, &st) == 0);
1255 if (has_jimage) {
1256 Arguments::set_sysclasspath(jimage, true);
1257 FREE_C_HEAP_ARRAY(char, jimage);
1258 return true;
1259 }
1260 FREE_C_HEAP_ARRAY(char, jimage);
1261
1262 // check if developer build with exploded modules
1263 char* base_classes = format_boot_path("%/modules/" JAVA_BASE_NAME, home, home_len, fileSep, pathSep);
|
1225 case '%':
1226 strcpy(q, home);
1227 q += home_len;
1228 break;
1229 case '/':
1230 *q++ = fileSep;
1231 break;
1232 case ':':
1233 *q++ = pathSep;
1234 break;
1235 default:
1236 *q++ = *p;
1237 }
1238 }
1239 *q = '\0';
1240
1241 assert((q - formatted_path) == formatted_path_len, "formatted_path size botched");
1242 return formatted_path;
1243 }
1244
1245 // This function is a proxy to fopen, it tries to add a non standard flag ('e' or 'N')
1246 // that ensures automatic closing of the file on exec. If it can not find support in
1247 // the underlying c library, it will make an extra system call (fcntl) to ensure automatic
1248 // closing of the file on exec.
1249 FILE* os::fopen(const char* path, const char* mode) {
1250 char modified_mode[20];
1251 assert(strlen(mode) + 1 < sizeof(modified_mode), "mode chars plus one extra must fit in buffer");
1252 sprintf(modified_mode, "%s" LINUX_ONLY("e") BSD_ONLY("e") WINDOWS_ONLY("N"), mode);
1253 FILE* file = ::fopen(path, modified_mode);
1254
1255 #if !(defined LINUX || defined BSD || defined _WINDOWS)
1256 // assume fcntl FD_CLOEXEC support as a backup solution when 'e' or 'N'
1257 // is not supported as mode in fopen
1258 if (file != NULL) {
1259 int fd = fileno(file);
1260 if (fd != -1) {
1261 fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
1262 }
1263 }
1264 #endif
1265
1266 return file;
1267 }
1268
1269 bool os::set_boot_path(char fileSep, char pathSep) {
1270 const char* home = Arguments::get_java_home();
1271 int home_len = (int)strlen(home);
1272
1273 struct stat st;
1274
1275 // modular image if "modules" jimage exists
1276 char* jimage = format_boot_path("%/lib/" MODULES_IMAGE_NAME, home, home_len, fileSep, pathSep);
1277 if (jimage == NULL) return false;
1278 bool has_jimage = (os::stat(jimage, &st) == 0);
1279 if (has_jimage) {
1280 Arguments::set_sysclasspath(jimage, true);
1281 FREE_C_HEAP_ARRAY(char, jimage);
1282 return true;
1283 }
1284 FREE_C_HEAP_ARRAY(char, jimage);
1285
1286 // check if developer build with exploded modules
1287 char* base_classes = format_boot_path("%/modules/" JAVA_BASE_NAME, home, home_len, fileSep, pathSep);
|