522 // open the directory and check if the file for the given vmid exists. |
522 // open the directory and check if the file for the given vmid exists. |
523 // The file with the expected name and the latest creation date is used |
523 // The file with the expected name and the latest creation date is used |
524 // to determine the user name for the process id. |
524 // to determine the user name for the process id. |
525 // |
525 // |
526 struct dirent* dentry; |
526 struct dirent* dentry; |
527 char* tdbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(tmpdirname), mtInternal); |
|
528 errno = 0; |
527 errno = 0; |
529 while ((dentry = os::readdir(tmpdirp, (struct dirent *)tdbuf)) != NULL) { |
528 while ((dentry = os::readdir(tmpdirp)) != NULL) { |
530 |
529 |
531 // check if the directory entry is a hsperfdata file |
530 // check if the directory entry is a hsperfdata file |
532 if (strncmp(dentry->d_name, PERFDATA_NAME, strlen(PERFDATA_NAME)) != 0) { |
531 if (strncmp(dentry->d_name, PERFDATA_NAME, strlen(PERFDATA_NAME)) != 0) { |
533 continue; |
532 continue; |
534 } |
533 } |
558 os::closedir(subdirp); |
557 os::closedir(subdirp); |
559 continue; |
558 continue; |
560 } |
559 } |
561 |
560 |
562 struct dirent* udentry; |
561 struct dirent* udentry; |
563 char* udbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(usrdir_name), mtInternal); |
|
564 errno = 0; |
562 errno = 0; |
565 while ((udentry = os::readdir(subdirp, (struct dirent *)udbuf)) != NULL) { |
563 while ((udentry = os::readdir(subdirp)) != NULL) { |
566 |
564 |
567 if (filename_to_pid(udentry->d_name) == vmid) { |
565 if (filename_to_pid(udentry->d_name) == vmid) { |
568 struct stat statbuf; |
566 struct stat statbuf; |
569 int result; |
567 int result; |
570 |
568 |
604 |
602 |
605 FREE_C_HEAP_ARRAY(char, filename, mtInternal); |
603 FREE_C_HEAP_ARRAY(char, filename, mtInternal); |
606 } |
604 } |
607 } |
605 } |
608 os::closedir(subdirp); |
606 os::closedir(subdirp); |
609 FREE_C_HEAP_ARRAY(char, udbuf, mtInternal); |
|
610 FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal); |
607 FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal); |
611 } |
608 } |
612 os::closedir(tmpdirp); |
609 os::closedir(tmpdirp); |
613 FREE_C_HEAP_ARRAY(char, tdbuf, mtInternal); |
|
614 |
610 |
615 return(oldest_user); |
611 return(oldest_user); |
616 } |
612 } |
617 |
613 |
618 // return the name of the user that owns the JVM indicated by the given vmid. |
614 // return the name of the user that owns the JVM indicated by the given vmid. |
735 // remove or create new files in this directory. The behavior of this |
731 // remove or create new files in this directory. The behavior of this |
736 // loop under these conditions is dependent upon the implementation of |
732 // loop under these conditions is dependent upon the implementation of |
737 // opendir/readdir. |
733 // opendir/readdir. |
738 // |
734 // |
739 struct dirent* entry; |
735 struct dirent* entry; |
740 char* dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(dirname), mtInternal); |
|
741 |
|
742 errno = 0; |
736 errno = 0; |
743 while ((entry = os::readdir(dirp, (struct dirent *)dbuf)) != NULL) { |
737 while ((entry = os::readdir(dirp)) != NULL) { |
744 |
738 |
745 pid_t pid = filename_to_pid(entry->d_name); |
739 pid_t pid = filename_to_pid(entry->d_name); |
746 |
740 |
747 if (pid == 0) { |
741 if (pid == 0) { |
748 |
742 |
778 } |
772 } |
779 |
773 |
780 // close the directory and reset the current working directory |
774 // close the directory and reset the current working directory |
781 close_directory_secure_cwd(dirp, saved_cwd_fd); |
775 close_directory_secure_cwd(dirp, saved_cwd_fd); |
782 |
776 |
783 FREE_C_HEAP_ARRAY(char, dbuf, mtInternal); |
|
784 } |
777 } |
785 |
778 |
786 // make the user specific temporary directory. Returns true if |
779 // make the user specific temporary directory. Returns true if |
787 // the directory exists and is secure upon return. Returns false |
780 // the directory exists and is secure upon return. Returns false |
788 // if the directory exists but is either a symlink, is otherwise |
781 // if the directory exists but is either a symlink, is otherwise |