< prev index next >

src/os/bsd/vm/perfMemory_bsd.cpp

Print this page
rev 11747 : 8162869: Small fixes for AIX perf memory and attach listener


 864   if (result != -1) {
 865     return fd;
 866   } else {
 867     ::close(fd);
 868     return -1;
 869   }
 870 }
 871 
 872 // open the shared memory file for the given user and vmid. returns
 873 // the file descriptor for the open file or -1 if the file could not
 874 // be opened.
 875 //
 876 static int open_sharedmem_file(const char* filename, int oflags, TRAPS) {
 877 
 878   // open the file
 879   int result;
 880   RESTARTABLE(::open(filename, oflags), result);
 881   if (result == OS_ERR) {
 882     if (errno == ENOENT) {
 883       THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
 884                   "Process not found", OS_ERR);
 885     }
 886     else if (errno == EACCES) {
 887       THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
 888                   "Permission denied", OS_ERR);
 889     }
 890     else {
 891       THROW_MSG_(vmSymbols::java_io_IOException(), os::strerror(errno), OS_ERR);

 892     }
 893   }
 894   int fd = result;
 895 
 896   // check to see if the file is secure
 897   if (!is_file_secure(fd, filename)) {
 898     ::close(fd);
 899     return -1;
 900   }
 901 
 902   return fd;
 903 }
 904 
 905 // create a named shared memory region. returns the address of the
 906 // memory region on success or NULL on failure. A return value of
 907 // NULL will ultimately disable the shared memory feature.
 908 //
 909 // On Solaris and Bsd, the name space for shared memory objects
 910 // is the file system name space.
 911 //
 912 // A monitoring application attaching to a JVM does not need to know
 913 // the file system name of the shared memory object. However, it may
 914 // be convenient for applications to discover the existence of newly
 915 // created and terminating JVMs by watching the file system name space
 916 // for files being created or removed.
 917 //
 918 static char* mmap_create_shared(size_t size) {
 919 
 920   int result;
 921   int fd;
 922   char* mapAddress;
 923 
 924   int vmid = os::current_process_id();
 925 
 926   char* user_name = get_user_name(geteuid());
 927 
 928   if (user_name == NULL)
 929     return NULL;




 864   if (result != -1) {
 865     return fd;
 866   } else {
 867     ::close(fd);
 868     return -1;
 869   }
 870 }
 871 
 872 // open the shared memory file for the given user and vmid. returns
 873 // the file descriptor for the open file or -1 if the file could not
 874 // be opened.
 875 //
 876 static int open_sharedmem_file(const char* filename, int oflags, TRAPS) {
 877 
 878   // open the file
 879   int result;
 880   RESTARTABLE(::open(filename, oflags), result);
 881   if (result == OS_ERR) {
 882     if (errno == ENOENT) {
 883       THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
 884                  "Process not found", OS_ERR);
 885     }
 886     else if (errno == EACCES) {
 887       THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
 888                  "Permission denied", OS_ERR);
 889     }
 890     else {
 891       THROW_MSG_(vmSymbols::java_io_IOException(),
 892                  os::strerror(errno), OS_ERR);
 893     }
 894   }
 895   int fd = result;
 896 
 897   // check to see if the file is secure
 898   if (!is_file_secure(fd, filename)) {
 899     ::close(fd);
 900     return -1;
 901   }
 902 
 903   return fd;
 904 }
 905 
 906 // create a named shared memory region. returns the address of the
 907 // memory region on success or NULL on failure. A return value of
 908 // NULL will ultimately disable the shared memory feature.
 909 //
 910 // On BSD, the name space for shared memory objects
 911 // is the file system name space.
 912 //
 913 // A monitoring application attaching to a JVM does not need to know
 914 // the file system name of the shared memory object. However, it may
 915 // be convenient for applications to discover the existence of newly
 916 // created and terminating JVMs by watching the file system name space
 917 // for files being created or removed.
 918 //
 919 static char* mmap_create_shared(size_t size) {
 920 
 921   int result;
 922   int fd;
 923   char* mapAddress;
 924 
 925   int vmid = os::current_process_id();
 926 
 927   char* user_name = get_user_name(geteuid());
 928 
 929   if (user_name == NULL)
 930     return NULL;


< prev index next >