890 }
891 ::close(fd);
892 return -1;
893 }
894
895 return fd;
896 }
897
898 // open the shared memory file for the given user and vmid. returns
899 // the file descriptor for the open file or -1 if the file could not
900 // be opened.
901 //
902 static int open_sharedmem_file(const char* filename, int oflags, TRAPS) {
903
904 // open the file
905 int result;
906 RESTARTABLE(::open(filename, oflags), result);
907 if (result == OS_ERR) {
908 if (errno == ENOENT) {
909 THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
910 "Process not found", OS_ERR);
911 }
912 else if (errno == EACCES) {
913 THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
914 "Permission denied", OS_ERR);
915 }
916 else {
917 THROW_MSG_(vmSymbols::java_io_IOException(), os::strerror(errno), OS_ERR);
918 }
919 }
920 int fd = result;
921
922 // check to see if the file is secure
923 if (!is_file_secure(fd, filename)) {
924 ::close(fd);
925 return -1;
926 }
927
928 return fd;
929 }
930
931 // create a named shared memory region. returns the address of the
932 // memory region on success or NULL on failure. A return value of
933 // NULL will ultimately disable the shared memory feature.
934 //
935 // On Solaris and Linux, the name space for shared memory objects
936 // is the file system name space.
937 //
938 // A monitoring application attaching to a JVM does not need to know
939 // the file system name of the shared memory object. However, it may
940 // be convenient for applications to discover the existence of newly
941 // created and terminating JVMs by watching the file system name space
942 // for files being created or removed.
943 //
944 static char* mmap_create_shared(size_t size) {
945
946 int result;
947 int fd;
948 char* mapAddress;
949
950 int vmid = os::current_process_id();
951
952 char* user_name = get_user_name(geteuid());
953
954 if (user_name == NULL)
955 return NULL;
|
890 }
891 ::close(fd);
892 return -1;
893 }
894
895 return fd;
896 }
897
898 // open the shared memory file for the given user and vmid. returns
899 // the file descriptor for the open file or -1 if the file could not
900 // be opened.
901 //
902 static int open_sharedmem_file(const char* filename, int oflags, TRAPS) {
903
904 // open the file
905 int result;
906 RESTARTABLE(::open(filename, oflags), result);
907 if (result == OS_ERR) {
908 if (errno == ENOENT) {
909 THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
910 "Process not found", OS_ERR);
911 }
912 else if (errno == EACCES) {
913 THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
914 "Permission denied", OS_ERR);
915 }
916 else {
917 THROW_MSG_(vmSymbols::java_io_IOException(),
918 os::strerror(errno), OS_ERR);
919 }
920 }
921 int fd = result;
922
923 // check to see if the file is secure
924 if (!is_file_secure(fd, filename)) {
925 ::close(fd);
926 return -1;
927 }
928
929 return fd;
930 }
931
932 // create a named shared memory region. returns the address of the
933 // memory region on success or NULL on failure. A return value of
934 // NULL will ultimately disable the shared memory feature.
935 //
936 // On Solaris, the name space for shared memory objects
937 // is the file system name space.
938 //
939 // A monitoring application attaching to a JVM does not need to know
940 // the file system name of the shared memory object. However, it may
941 // be convenient for applications to discover the existence of newly
942 // created and terminating JVMs by watching the file system name space
943 // for files being created or removed.
944 //
945 static char* mmap_create_shared(size_t size) {
946
947 int result;
948 int fd;
949 char* mapAddress;
950
951 int vmid = os::current_process_id();
952
953 char* user_name = get_user_name(geteuid());
954
955 if (user_name == NULL)
956 return NULL;
|