comparison src/os/linux/vm/perfMemory_linux.cpp @ 1353:a2ea687fdc7c

6938627: Make temporary directory use property java.io.tmpdir when specified Summary: Get java.io.tmpdir property in os::get_temp_directory() and call this instead of harcoding "/tmp". Don't assume trailing file_separator either. Reviewed-by: dholmes, kamg
author coleenp
date Wed, 31 Mar 2010 16:51:18 -0700
parents 98cb887364d3
children c18cbe5936b8
comparison
equal deleted inserted replaced
1330:4a9cc99938e3 1353:a2ea687fdc7c
143 // 143 //
144 static char* get_user_tmp_dir(const char* user) { 144 static char* get_user_tmp_dir(const char* user) {
145 145
146 const char* tmpdir = os::get_temp_directory(); 146 const char* tmpdir = os::get_temp_directory();
147 const char* perfdir = PERFDATA_NAME; 147 const char* perfdir = PERFDATA_NAME;
148 size_t nbytes = strlen(tmpdir) + strlen(perfdir) + strlen(user) + 2; 148 size_t nbytes = strlen(tmpdir) + strlen(perfdir) + strlen(user) + 3;
149 char* dirname = NEW_C_HEAP_ARRAY(char, nbytes); 149 char* dirname = NEW_C_HEAP_ARRAY(char, nbytes);
150 150
151 // construct the path name to user specific tmp directory 151 // construct the path name to user specific tmp directory
152 snprintf(dirname, nbytes, "%s%s_%s", tmpdir, perfdir, user); 152 snprintf(dirname, nbytes, "%s/%s_%s", tmpdir, perfdir, user);
153 153
154 return dirname; 154 return dirname;
155 } 155 }
156 156
157 // convert the given file name into a process id. if the file 157 // convert the given file name into a process id. if the file
329 if (strncmp(dentry->d_name, PERFDATA_NAME, strlen(PERFDATA_NAME)) != 0) { 329 if (strncmp(dentry->d_name, PERFDATA_NAME, strlen(PERFDATA_NAME)) != 0) {
330 continue; 330 continue;
331 } 331 }
332 332
333 char* usrdir_name = NEW_C_HEAP_ARRAY(char, 333 char* usrdir_name = NEW_C_HEAP_ARRAY(char,
334 strlen(tmpdirname) + strlen(dentry->d_name) + 1); 334 strlen(tmpdirname) + strlen(dentry->d_name) + 2);
335 strcpy(usrdir_name, tmpdirname); 335 strcpy(usrdir_name, tmpdirname);
336 strcat(usrdir_name, "/");
336 strcat(usrdir_name, dentry->d_name); 337 strcat(usrdir_name, dentry->d_name);
337 338
338 DIR* subdirp = os::opendir(usrdir_name); 339 DIR* subdirp = os::opendir(usrdir_name);
339 340
340 if (subdirp == NULL) { 341 if (subdirp == NULL) {