< prev index next >

src/os/linux/vm/os_linux.cpp

Print this page




2124   }
2125 
2126   ::close(fd);
2127 
2128   return true;
2129 }
2130 
2131 void os::print_dll_info(outputStream *st) {
2132    st->print_cr("Dynamic libraries:");
2133 
2134    char fname[32];
2135    pid_t pid = os::Linux::gettid();
2136 
2137    jio_snprintf(fname, sizeof(fname), "/proc/%d/maps", pid);
2138 
2139    if (!_print_ascii_file(fname, st)) {
2140      st->print("Can not get library information for pid = %d\n", pid);
2141    }
2142 }
2143 



































2144 void os::print_os_info_brief(outputStream* st) {
2145   os::Linux::print_distro_info(st);
2146 
2147   os::Posix::print_uname_info(st);
2148 
2149   os::Linux::print_libversion_info(st);
2150 
2151 }
2152 
2153 void os::print_os_info(outputStream* st) {
2154   st->print("OS:");
2155 
2156   os::Linux::print_distro_info(st);
2157 
2158   os::Posix::print_uname_info(st);
2159 
2160   // Print warning if unsafe chroot environment detected
2161   if (unsafe_chroot_detected) {
2162     st->print("WARNING!! ");
2163     st->print_cr("%s", unstable_chroot_error);


4008 
4009   for (int j = 0; j < i; ++j) {
4010     if (base[j] != NULL) {
4011       unmap_memory(base[j], size[j]);
4012     }
4013   }
4014 
4015   if (i < max_tries) {
4016     _highest_vm_reserved_address = MAX2(old_highest, (address)requested_addr + bytes);
4017     return requested_addr;
4018   } else {
4019     _highest_vm_reserved_address = old_highest;
4020     return NULL;
4021   }
4022 }
4023 
4024 size_t os::read(int fd, void *buf, unsigned int nBytes) {
4025   return ::read(fd, buf, nBytes);
4026 }
4027 




4028 // TODO-FIXME: reconcile Solaris' os::sleep with the linux variation.
4029 // Solaris uses poll(), linux uses park().
4030 // Poll() is likely a better choice, assuming that Thread.interrupt()
4031 // generates a SIGUSRx signal. Note that SIGUSR1 can interfere with
4032 // SIGSEGV, see 4355769.
4033 
4034 int os::sleep(Thread* thread, jlong millis, bool interruptible) {
4035   assert(thread == Thread::current(),  "thread consistency check");
4036 
4037   ParkEvent * const slp = thread->_SleepEvent ;
4038   slp->reset() ;
4039   OrderAccess::fence() ;
4040 
4041   if (interruptible) {
4042     jlong prevtime = javaTimeNanos();
4043 
4044     for (;;) {
4045       if (os::is_interrupted(thread, true)) {
4046         return OS_INTRPT;
4047       }


5468 }
5469 
5470 bool os::check_heap(bool force) {
5471   return true;
5472 }
5473 
5474 int local_vsnprintf(char* buf, size_t count, const char* format, va_list args) {
5475   return ::vsnprintf(buf, count, format, args);
5476 }
5477 
5478 // Is a (classpath) directory empty?
5479 bool os::dir_is_empty(const char* path) {
5480   DIR *dir = NULL;
5481   struct dirent *ptr;
5482 
5483   dir = opendir(path);
5484   if (dir == NULL) return true;
5485 
5486   /* Scan the directory */
5487   bool result = true;
5488   char buf[sizeof(struct dirent) + MAX_PATH];
5489   while (result && (ptr = ::readdir(dir)) != NULL) {
5490     if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
5491       result = false;
5492     }
5493   }
5494   closedir(dir);
5495   return result;
5496 }
5497 
5498 // This code originates from JDK's sysOpen and open64_w
5499 // from src/solaris/hpi/src/system_md.c
5500 
5501 #ifndef O_DELETE
5502 #define O_DELETE 0x10000
5503 #endif
5504 
5505 // Open a file. Unlink the file immediately after open returns
5506 // if the specified oflag has the O_DELETE flag set.
5507 // O_DELETE is used only in j2se/src/share/native/java/util/zip/ZipFile.c
5508 
5509 int os::open(const char *path, int oflag, int mode) {




2124   }
2125 
2126   ::close(fd);
2127 
2128   return true;
2129 }
2130 
2131 void os::print_dll_info(outputStream *st) {
2132    st->print_cr("Dynamic libraries:");
2133 
2134    char fname[32];
2135    pid_t pid = os::Linux::gettid();
2136 
2137    jio_snprintf(fname, sizeof(fname), "/proc/%d/maps", pid);
2138 
2139    if (!_print_ascii_file(fname, st)) {
2140      st->print("Can not get library information for pid = %d\n", pid);
2141    }
2142 }
2143 
2144 int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *param) {
2145   FILE *procmapsFile = NULL;
2146 
2147   // Open the procfs maps file for the current process
2148   if ((procmapsFile = fopen("/proc/self/maps", "r")) != NULL) {
2149     // Allocate PATH_MAX for file name plus a reasonable size for other fields.
2150     char line[PATH_MAX + 100];
2151 
2152     // Read line by line from 'file'
2153     while (fgets(line, sizeof(line), procmapsFile) != NULL) {
2154       u8 base, top, offset, inode;
2155       char permissions[5];
2156       char device[6];
2157       char name[PATH_MAX + 1];
2158 
2159       // Parse fields from line
2160       sscanf(line, UINT64_FORMAT_X "-" UINT64_FORMAT_X " %4s " UINT64_FORMAT_X " %5s " INT64_FORMAT " %s",
2161              &base, &top, permissions, &offset, device, &inode, name);
2162 
2163       // Filter by device id '00:00' so that we only get file system mapped files.
2164       if (strcmp(device, "00:00") != 0) {
2165 
2166         // Call callback with the fields of interest
2167         if(callback(name, (address)base, (address)top, param)) {
2168           // Oops abort, callback aborted
2169           fclose(procmapsFile);
2170           return 1;
2171         }
2172       }
2173     }
2174     fclose(procmapsFile);
2175   }
2176   return 0;
2177 }
2178 
2179 void os::print_os_info_brief(outputStream* st) {
2180   os::Linux::print_distro_info(st);
2181 
2182   os::Posix::print_uname_info(st);
2183 
2184   os::Linux::print_libversion_info(st);
2185 
2186 }
2187 
2188 void os::print_os_info(outputStream* st) {
2189   st->print("OS:");
2190 
2191   os::Linux::print_distro_info(st);
2192 
2193   os::Posix::print_uname_info(st);
2194 
2195   // Print warning if unsafe chroot environment detected
2196   if (unsafe_chroot_detected) {
2197     st->print("WARNING!! ");
2198     st->print_cr("%s", unstable_chroot_error);


4043 
4044   for (int j = 0; j < i; ++j) {
4045     if (base[j] != NULL) {
4046       unmap_memory(base[j], size[j]);
4047     }
4048   }
4049 
4050   if (i < max_tries) {
4051     _highest_vm_reserved_address = MAX2(old_highest, (address)requested_addr + bytes);
4052     return requested_addr;
4053   } else {
4054     _highest_vm_reserved_address = old_highest;
4055     return NULL;
4056   }
4057 }
4058 
4059 size_t os::read(int fd, void *buf, unsigned int nBytes) {
4060   return ::read(fd, buf, nBytes);
4061 }
4062 
4063 size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
4064   return ::pread(fd, buf, nBytes, offset);
4065 }
4066 
4067 // TODO-FIXME: reconcile Solaris' os::sleep with the linux variation.
4068 // Solaris uses poll(), linux uses park().
4069 // Poll() is likely a better choice, assuming that Thread.interrupt()
4070 // generates a SIGUSRx signal. Note that SIGUSR1 can interfere with
4071 // SIGSEGV, see 4355769.
4072 
4073 int os::sleep(Thread* thread, jlong millis, bool interruptible) {
4074   assert(thread == Thread::current(),  "thread consistency check");
4075 
4076   ParkEvent * const slp = thread->_SleepEvent ;
4077   slp->reset() ;
4078   OrderAccess::fence() ;
4079 
4080   if (interruptible) {
4081     jlong prevtime = javaTimeNanos();
4082 
4083     for (;;) {
4084       if (os::is_interrupted(thread, true)) {
4085         return OS_INTRPT;
4086       }


5507 }
5508 
5509 bool os::check_heap(bool force) {
5510   return true;
5511 }
5512 
5513 int local_vsnprintf(char* buf, size_t count, const char* format, va_list args) {
5514   return ::vsnprintf(buf, count, format, args);
5515 }
5516 
5517 // Is a (classpath) directory empty?
5518 bool os::dir_is_empty(const char* path) {
5519   DIR *dir = NULL;
5520   struct dirent *ptr;
5521 
5522   dir = opendir(path);
5523   if (dir == NULL) return true;
5524 
5525   /* Scan the directory */
5526   bool result = true;
5527   while (result && (ptr = readdir(dir)) != NULL) {

5528     if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
5529       result = false;
5530     }
5531   }
5532   closedir(dir);
5533   return result;
5534 }
5535 
5536 // This code originates from JDK's sysOpen and open64_w
5537 // from src/solaris/hpi/src/system_md.c
5538 
5539 #ifndef O_DELETE
5540 #define O_DELETE 0x10000
5541 #endif
5542 
5543 // Open a file. Unlink the file immediately after open returns
5544 // if the specified oflag has the O_DELETE flag set.
5545 // O_DELETE is used only in j2se/src/share/native/java/util/zip/ZipFile.c
5546 
5547 int os::open(const char *path, int oflag, int mode) {


< prev index next >