bool FileMapInfo::FileMapHeader::validate() { if (_version != current_version()) { FileMapInfo::fail_continue("The shared archive file is the wrong version."); return false; } if (_magic != (int)0xf00baba2) { FileMapInfo::fail_continue("The shared archive file has a bad magic number."); return false; } char header_version[JVM_IDENT_MAX]; get_header_version(header_version); if (strncmp(_jvm_ident, header_version, JVM_IDENT_MAX-1) != 0) { if (TraceClassPaths) { tty->print_cr("Expected: %s", header_version); tty->print_cr("Actual: %s", _jvm_ident); } FileMapInfo::fail_continue("The shared archive file was created by a different" " version or build of HotSpot"); return false; } if (_obj_alignment != ObjectAlignmentInBytes) { FileMapInfo::fail_continue("The shared archive file's ObjectAlignmentInBytes of %d" " does not equal the current ObjectAlignmentInBytes of %d.", _obj_alignment, ObjectAlignmentInBytes); return false; } return true; }
bool FileMapInfo::init_from_file(int fd) { size_t sz = _header->data_size(); char* addr = _header->data(); size_t n = os::read(fd, addr, (unsigned int)sz); if (n != sz) { fail_continue("Unable to read the file header."); return false; } if (_header->_version != current_version()) { fail_continue("The shared archive file has the wrong version."); return false; } _file_offset = (long)n; size_t info_size = _header->_paths_misc_info_size; _paths_misc_info = NEW_C_HEAP_ARRAY_RETURN_NULL(char, info_size, mtClass); if (_paths_misc_info == NULL) { fail_continue("Unable to read the file header."); return false; } n = os::read(fd, _paths_misc_info, (unsigned int)info_size); if (n != info_size) { fail_continue("Unable to read the shared path info header."); FREE_C_HEAP_ARRAY(char, _paths_misc_info, mtClass); _paths_misc_info = NULL; return false; } _file_offset += (long)n; return true; }
PLUGIN_EXPORT void PLUGIN_CALL ProcessTick() { if (Updater::version_fetched()) { Version latest_version = Updater::latest_version(); Version current_version(PROJECT_VERSION_STRING); if (current_version < latest_version) { logprintf("New version of CrashDetect is available for download (%s)", latest_version.AsString().c_str()); } } }
bool FileMapInfo::init_from_file(int fd) { size_t n = read(fd, &_header, sizeof(struct FileMapHeader)); if (n != sizeof(struct FileMapHeader)) { fail_continue("Unable to read the file header."); return false; } if (_header._version != current_version()) { fail_continue("The shared archive file has the wrong version."); return false; } _file_offset = (long)n; return true; }
struct protocol_pkt_welcome *make_welcome(const tal_t *ctx, const struct state *state, const struct protocol_net_address *a) { struct protocol_pkt_welcome *w; w = tal_packet(ctx, struct protocol_pkt_welcome, PROTOCOL_PKT_WELCOME); w->version = cpu_to_le32(current_version()); memset(w->moniker, 0, sizeof(w->moniker)); strncpy(w->moniker, "ICBINB! " VERSION, sizeof(w->moniker)); w->uuid = state->uuid; w->you = *a; w->listen_port = cpu_to_le16(state->listen_port); memcpy(w->interests, state->interests, sizeof(w->interests)); /* This is the best block we can tell them about. */ if (state->longest_knowns[0] != genesis_block(state)) tal_packet_append_block(&w, &state->longest_knowns[0]->bi); return w; }
bool FileMapInfo::init_from_file(int fd) { size_t sz = _header->data_size(); char* addr = _header->data(); size_t n = os::read(fd, addr, (unsigned int)sz); if (n != sz) { fail_continue("Unable to read the file header."); return false; } if (_header->_version != current_version()) { fail_continue("The shared archive file has the wrong version."); return false; } _file_offset = (long)n; size_t info_size = _header->_paths_misc_info_size; _paths_misc_info = NEW_C_HEAP_ARRAY_RETURN_NULL(char, info_size, mtClass); if (_paths_misc_info == NULL) { fail_continue("Unable to read the file header."); return false; } n = os::read(fd, _paths_misc_info, (unsigned int)info_size); if (n != info_size) { fail_continue("Unable to read the shared path info header."); FREE_C_HEAP_ARRAY(char, _paths_misc_info); _paths_misc_info = NULL; return false; } size_t len = lseek(fd, 0, SEEK_END); struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[MetaspaceShared::mc]; if (si->_file_offset >= len || len - si->_file_offset < si->_used) { fail_continue("The shared archive file has been truncated."); return false; } _file_offset += (long)n; return true; }
enum protocol_ecode check_welcome(const struct peer *peer, const struct protocol_pkt_welcome *w, const struct protocol_block_header **block_hdr, size_t *block_len) { size_t len = le32_to_cpu(w->len); if (len < sizeof(*w)) return PROTOCOL_ECODE_INVALID_LEN; if (w->type != cpu_to_le32(PROTOCOL_PKT_WELCOME)) return PROTOCOL_ECODE_UNKNOWN_COMMAND; if (w->version != cpu_to_le32(current_version())) return PROTOCOL_ECODE_HIGH_VERSION; /* This is too lenient, but future-proof. */ if (popcount(w->interests, 65536) < 2) return PROTOCOL_ECODE_NO_INTEREST; len -= sizeof(*w); *block_hdr = (const struct protocol_block_header *)(w + 1); *block_len = len; return PROTOCOL_ECODE_NONE; }
/** * 检查jar包是否可共享 */ bool FileMapInfo::validate() { if (_header._version != current_version()) { fail_continue("The shared archive file is the wrong version."); return false; } if (_header._magic != (int)0xf00baba2) { fail_continue("The shared archive file has a bad magic number."); return false; } if (strncmp(_header._jvm_ident, VM_Version::internal_vm_info_string(), JVM_IDENT_MAX-1) != 0) { fail_continue("The shared archive file was created by a different" " version or build of HotSpot."); return false; } // Cannot verify interpreter yet, as it can only be created after the GC // heap has been initialized. if (_header._num_jars >= JVM_SHARED_JARS_MAX) { fail_continue("Too many jar files to share."); return false; } // Build checks on classpath and jar files int num_jars_now = 0; ClassPathEntry *cpe = ClassLoader::classpath_entry(0); for ( ; cpe != NULL; cpe = cpe->next()) { if (cpe->is_jar_file()) { //jar包文件 if (num_jars_now < _header._num_jars) { // Jar file - verify timestamp and file size. struct stat st; const char *path = cpe->name(); if (os::stat(path, &st) != 0) { fail_continue("Unable to open jar file %s.", path); return false; } //jar包已被修改,不能共享 if (_header._jar[num_jars_now]._timestamp != st.st_mtime || _header._jar[num_jars_now]._filesize != st.st_size) { fail_continue("A jar file is not the one used while building" " the shared archive file."); return false; } } ++num_jars_now; } else { // If directories appear in boot classpath, they must be empty to // avoid having to verify each individual class file. const char* name = ((ClassPathDirEntry*)cpe)->name(); if (!os::dir_is_empty(name)) { //类路径 fail_continue("Boot classpath directory %s is not empty.", name); return false; } } } if (num_jars_now < _header._num_jars) { fail_continue("The number of jar files in the boot classpath is" " less than the number the shared archive was created with."); return false; } return true; }