static int file_size_match(FF_PKT *ff_pkt, struct conf **confs) { uint64_t sizeleft; uint64_t min_file_size=get_uint64_t(confs[OPT_MIN_FILE_SIZE]); uint64_t max_file_size=get_uint64_t(confs[OPT_MAX_FILE_SIZE]); sizeleft=(uint64_t)ff_pkt->statp.st_size; if(min_file_size && sizeleft<min_file_size) return 0; if(max_file_size && sizeleft>max_file_size) return 0; return 1; }
void Flag::print_as_flag(outputStream* st) { if (is_bool()) { st->print("-XX:%s%s", get_bool() ? "+" : "-", name); } else if (is_intx()) { st->print("-XX:%s=" INTX_FORMAT, name, get_intx()); } else if (is_uintx()) { st->print("-XX:%s=" UINTX_FORMAT, name, get_uintx()); } else if (is_uint64_t()) { st->print("-XX:%s=" UINT64_FORMAT, name, get_uint64_t()); } else if (is_double()) { st->print("-XX:%s=%f", name, get_double()); } else if (is_ccstr()) { st->print("-XX:%s=", name); const char* cp = get_ccstr(); if (cp != NULL) { // Need to turn embedded '\n's back into separate arguments // Not so efficient to print one character at a time, // but the choice is to do the transformation to a buffer // and print that. And this need not be efficient. for (; *cp != '\0'; cp += 1) { switch (*cp) { default: st->print("%c", *cp); break; case '\n': st->print(" -XX:%s=", name); break; } } } } else { ShouldNotReachHere(); } }
void Flag::print_on(outputStream* st, bool withComments) { st->print("%9s %-40s %c= ", type, name, (origin != DEFAULT ? ':' : ' ')); if (is_bool()) st->print("%-16s", get_bool() ? "true" : "false"); if (is_intx()) st->print("%-16ld", get_intx()); if (is_uintx()) st->print("%-16lu", get_uintx()); if (is_uint64_t()) st->print("%-16lu", get_uint64_t()); if (is_double()) st->print("%-16f", get_double()); if (is_ccstr()) { const char* cp = get_ccstr(); if (cp != NULL) { const char* eol; while ((eol = strchr(cp, '\n')) != NULL) { char format_buffer[FORMAT_BUFFER_LEN]; size_t llen = pointer_delta(eol, cp, sizeof(char)); jio_snprintf(format_buffer, FORMAT_BUFFER_LEN, "%%." SIZE_FORMAT "s", llen); st->print(format_buffer, cp); st->cr(); cp = eol+1; st->print("%5s %-35s += ", "", name); } st->print("%-16s", cp); } else st->print("%-16s", ""); } st->print("%-20s", kind); if (withComments) { #ifndef PRODUCT st->print("%s", doc ); #endif } st->cr(); }
double get_double(char* str, char** ss) { uint64_t u = get_uint64_t(str,ss); double* ret_val_ptr = ((double*) &u); double ret_val = *ret_val_ptr; return(ret_val); }
PRAGMA_FORMAT_NONLITERAL_IGNORED_EXTERNAL void Flag::print_on(outputStream* st, bool withComments) { // Don't print notproduct and develop flags in a product build. if (is_constant_in_binary()) { return; } st->print("%9s %-40s %c= ", _type, _name, (!is_default() ? ':' : ' ')); if (is_bool()) { st->print("%-16s", get_bool() ? "true" : "false"); } if (is_intx()) { st->print("%-16ld", get_intx()); } if (is_uintx()) { st->print("%-16lu", get_uintx()); } if (is_uint64_t()) { st->print("%-16lu", get_uint64_t()); } if (is_double()) { st->print("%-16f", get_double()); } if (is_ccstr()) { const char* cp = get_ccstr(); if (cp != NULL) { const char* eol; while ((eol = strchr(cp, '\n')) != NULL) { char format_buffer[FORMAT_BUFFER_LEN]; size_t llen = pointer_delta(eol, cp, sizeof(char)); jio_snprintf(format_buffer, FORMAT_BUFFER_LEN, "%%." SIZE_FORMAT "s", llen); PRAGMA_DIAG_PUSH PRAGMA_FORMAT_NONLITERAL_IGNORED_INTERNAL st->print(format_buffer, cp); PRAGMA_DIAG_POP st->cr(); cp = eol+1; st->print("%5s %-35s += ", "", _name); } st->print("%-16s", cp); } else st->print("%-16s", ""); } st->print("%-20s", " "); print_kind(st); if (withComments) { #ifndef PRODUCT st->print("%s", _doc); #endif } st->cr(); }
static int conf_set_from_global(struct conf **globalc, struct conf **cc) { int i=0; for(i=0; i<OPT_MAX; i++) { if(!(cc[i]->flags & CONF_FLAG_CC_OVERRIDE)) continue; switch(cc[i]->conf_type) { case CT_STRING: set_string(cc[i], get_string(globalc[i])); break; case CT_UINT: set_int(cc[i], get_int(globalc[i])); break; case CT_FLOAT: set_float(cc[i], get_float(globalc[i])); break; case CT_MODE_T: set_mode_t(cc[i], get_mode_t(globalc[i])); break; case CT_SSIZE_T: set_uint64_t(cc[i], get_uint64_t(globalc[i])); break; case CT_E_BURP_MODE: set_e_burp_mode(cc[i], get_e_burp_mode(globalc[i])); break; case CT_E_PROTOCOL: set_e_protocol(cc[i], get_e_protocol(globalc[i])); break; case CT_E_RECOVERY_METHOD: set_e_recovery_method(cc[i], get_e_recovery_method(globalc[i])); break; case CT_E_RSHASH: set_e_rshash(cc[i], get_e_rshash(globalc[i])); break; case CT_STRLIST: // Done later. break; case CT_CNTR: break; // No default so that there are warnings if anything // was missed. } } // If ssl_peer_cn is not set, default it to the client name. if(!get_string(globalc[OPT_SSL_PEER_CN]) && set_string(cc[OPT_SSL_PEER_CN], get_string(cc[OPT_CNAME]))) return -1; return 0; }
void pack_value(char* payload,int wlength,int offset, char* port_value) { char* ptr = payload + (offset*wlength/8); char* ss = NULL; switch(wlength) { case 8: *((uint8_t*)ptr) = get_uint8_t(port_value,&ss); break; case 16: *((uint16_t*)ptr) = get_uint16_t(port_value,&ss); break; case 32: *((uint32_t*)ptr) = get_uint32_t(port_value,&ss); break; case 64: *((uint64_t*)ptr) = get_uint64_t(port_value,&ss); break; default: fprintf(stderr,"Error: unsupported data width %d\n", wlength); return; } }
static void check_default(struct conf **c, enum conf_opt o) { switch(o) { case OPT_BURP_MODE: fail_unless(get_e_burp_mode(c[o])==BURP_MODE_UNSET); break; case OPT_LOCKFILE: case OPT_PIDFILE: case OPT_ADDRESS: case OPT_PORT: case OPT_STATUS_ADDRESS: case OPT_STATUS_PORT: case OPT_SSL_CERT_CA: case OPT_SSL_CERT: case OPT_SSL_KEY: case OPT_SSL_KEY_PASSWORD: case OPT_SSL_PEER_CN: case OPT_SSL_CIPHERS: case OPT_SSL_DHFILE: case OPT_CA_CONF: case OPT_CA_NAME: case OPT_CA_SERVER_NAME: case OPT_CA_BURP_CA: case OPT_CA_CSR_DIR: case OPT_CA_CRL: case OPT_PEER_VERSION: case OPT_CLIENT_LOCKDIR: case OPT_MONITOR_LOGFILE: case OPT_CNAME: case OPT_PASSWORD: case OPT_PASSWD: case OPT_SERVER: case OPT_ENCRYPTION_PASSWORD: case OPT_AUTOUPGRADE_OS: case OPT_AUTOUPGRADE_DIR: case OPT_BACKUP: case OPT_BACKUP2: case OPT_RESTOREPREFIX: case OPT_RESTORE_SPOOL: case OPT_BROWSEFILE: case OPT_BROWSEDIR: case OPT_B_SCRIPT_PRE: case OPT_B_SCRIPT_POST: case OPT_R_SCRIPT_PRE: case OPT_R_SCRIPT_POST: case OPT_B_SCRIPT: case OPT_R_SCRIPT: case OPT_RESTORE_PATH: case OPT_ORIG_CLIENT: case OPT_CONFFILE: case OPT_USER: case OPT_GROUP: case OPT_DIRECTORY: case OPT_TIMESTAMP_FORMAT: case OPT_CLIENTCONFDIR: case OPT_S_SCRIPT_PRE: case OPT_S_SCRIPT_POST: case OPT_MANUAL_DELETE: case OPT_S_SCRIPT: case OPT_TIMER_SCRIPT: case OPT_N_SUCCESS_SCRIPT: case OPT_N_FAILURE_SCRIPT: case OPT_DEDUP_GROUP: case OPT_VSS_DRIVES: case OPT_REGEX: case OPT_RESTORE_CLIENT: fail_unless(get_string(c[o])==NULL); break; case OPT_RATELIMIT: fail_unless(get_float(c[o])==0); break; case OPT_CLIENT_IS_WINDOWS: case OPT_RANDOMISE: case OPT_B_SCRIPT_POST_RUN_ON_FAIL: case OPT_R_SCRIPT_POST_RUN_ON_FAIL: case OPT_SEND_CLIENT_CNTR: case OPT_BREAKPOINT: case OPT_SYSLOG: case OPT_PROGRESS_COUNTER: case OPT_MONITOR_BROWSE_CACHE: case OPT_S_SCRIPT_PRE_NOTIFY: case OPT_S_SCRIPT_POST_RUN_ON_FAIL: case OPT_S_SCRIPT_POST_NOTIFY: case OPT_S_SCRIPT_NOTIFY: case OPT_HARDLINKED_ARCHIVE: case OPT_N_SUCCESS_WARNINGS_ONLY: case OPT_N_SUCCESS_CHANGES_ONLY: case OPT_CROSS_ALL_FILESYSTEMS: case OPT_READ_ALL_FIFOS: case OPT_READ_ALL_BLOCKDEVS: case OPT_SPLIT_VSS: case OPT_STRIP_VSS: case OPT_ATIME: case OPT_SCAN_PROBLEM_RAISES_ERROR: case OPT_OVERWRITE: case OPT_STRIP: case OPT_MESSAGE: case OPT_CA_CRL_CHECK: fail_unless(get_int(c[o])==0); break; case OPT_DAEMON: case OPT_STDOUT: case OPT_FORK: case OPT_ENABLED: case OPT_DIRECTORY_TREE: case OPT_PASSWORD_CHECK: case OPT_LIBRSYNC: case OPT_VERSION_WARN: case OPT_PATH_LENGTH_WARN: case OPT_CLIENT_CAN_DELETE: case OPT_CLIENT_CAN_DIFF: case OPT_CLIENT_CAN_FORCE_BACKUP: case OPT_CLIENT_CAN_LIST: case OPT_CLIENT_CAN_RESTORE: case OPT_CLIENT_CAN_VERIFY: case OPT_SERVER_CAN_RESTORE: case OPT_SERVER_CAN_OVERRIDE_INCLUDES: case OPT_B_SCRIPT_RESERVED_ARGS: case OPT_R_SCRIPT_RESERVED_ARGS: case OPT_GLOB_AFTER_SCRIPT_PRE: case OPT_ACL: case OPT_XATTR: fail_unless(get_int(c[o])==1); break; case OPT_NETWORK_TIMEOUT: fail_unless(get_int(c[o])==60*60*2); break; case OPT_SSL_COMPRESSION: case OPT_MAX_CHILDREN: case OPT_MAX_STATUS_CHILDREN: fail_unless(get_int(c[o])==5); break; case OPT_COMPRESSION: fail_unless(get_int(c[o])==9); break; case OPT_MAX_STORAGE_SUBDIRS: fail_unless(get_int(c[o])==30000); break; case OPT_MAX_HARDLINKS: fail_unless(get_int(c[o])==10000); break; case OPT_UMASK: fail_unless(get_mode_t(c[o])==0022); break; case OPT_STARTDIR: case OPT_B_SCRIPT_PRE_ARG: case OPT_B_SCRIPT_POST_ARG: case OPT_R_SCRIPT_PRE_ARG: case OPT_R_SCRIPT_POST_ARG: case OPT_B_SCRIPT_ARG: case OPT_R_SCRIPT_ARG: case OPT_S_SCRIPT_PRE_ARG: case OPT_S_SCRIPT_POST_ARG: case OPT_S_SCRIPT_ARG: case OPT_TIMER_ARG: case OPT_N_SUCCESS_ARG: case OPT_N_FAILURE_ARG: case OPT_RESTORE_CLIENTS: case OPT_KEEP: case OPT_INCEXCDIR: case OPT_INCLUDE: case OPT_EXCLUDE: case OPT_FSCHGDIR: case OPT_NOBACKUP: case OPT_INCEXT: case OPT_EXCEXT: case OPT_INCREG: case OPT_EXCREG: case OPT_EXCFS: case OPT_EXCOM: case OPT_INCGLOB: case OPT_FIFOS: case OPT_BLOCKDEVS: case OPT_LABEL: fail_unless(get_strlist(c[o])==NULL); break; case OPT_PROTOCOL: fail_unless(get_e_protocol(c[o])==PROTO_AUTO); break; case OPT_HARD_QUOTA: case OPT_SOFT_QUOTA: case OPT_MIN_FILE_SIZE: case OPT_MAX_FILE_SIZE: fail_unless(get_uint64_t(c[o])==0); break; case OPT_WORKING_DIR_RECOVERY_METHOD: fail_unless(get_e_recovery_method(c[o])== RECOVERY_METHOD_DELETE); break; case OPT_RSHASH: fail_unless(get_e_rshash(c[o])==RSHASH_UNSET); break; case OPT_CNTR: fail_unless(get_cntr(c)==NULL); break; case OPT_MAX: break; // No default, so we get compiler warnings if something was // missed. } }
uint32_t get_uint32_t(char* str, char** save_str) { return((uint32_t)(get_uint64_t(str, save_str))); }
uint8_t get_uint8_t(char* str, char** ss) { return((uint8_t)(get_uint64_t(str,ss))); }
int backup_phase1_server_all(struct async *as, struct sdirs *sdirs, struct conf **confs) { int ret=-1; struct sbuf *sb=NULL; char *phase1tmp=NULL; struct asfd *asfd=as->asfd; struct manio *manio=NULL; enum protocol protocol=get_protocol(confs); struct cntr *cntr=get_cntr(confs); logp("Begin phase1 (file system scan)\n"); if(!(phase1tmp=get_tmp_filename(sdirs->phase1data)) || !(manio=manio_open_phase1(phase1tmp, comp_level(get_int(confs[OPT_COMPRESSION])), protocol)) || !(sb=sbuf_alloc(protocol))) goto error; while(1) { sbuf_free_content(sb); switch(sbuf_fill_from_net(sb, asfd, NULL, NULL, cntr)) { case 0: break; case 1: // Last thing the client sends is // 'backupphase2', and it wants an 'ok' reply. if(asfd->write_str(asfd, CMD_GEN, "ok") || send_msg_fzp(manio->fzp, CMD_GEN, "phase1end", strlen("phase1end"))) goto error; goto end; case -1: default: goto error; } if(write_status(CNTR_STATUS_SCANNING, sb->path.buf, cntr) || manio_write_sbuf(manio, sb)) goto error; cntr_add_phase1(cntr, sb->path.cmd, 0); if(sbuf_is_filedata(sb)) { cntr_add_val(cntr, CMD_BYTES_ESTIMATED, (uint64_t)sb->statp.st_size, 0); } } end: if(manio_close(&manio)) { logp("error closing %s in backup_phase1_server\n", phase1tmp); goto error; } if(check_quota(as, cntr, get_uint64_t(confs[OPT_HARD_QUOTA]), get_uint64_t(confs[OPT_SOFT_QUOTA]))) goto error; // Possible rename race condition is of no consequence here, because // the working directory will always get deleted if phase1 is not // complete. if(do_rename(phase1tmp, sdirs->phase1data)) goto error; //cntr_print(p1cntr, cntr, ACTION_BACKUP); logp("End phase1 (file system scan)\n"); ret=0; error: free_w(&phase1tmp); manio_close(&manio); sbuf_free(&sb); return ret; }
void Flag::print_on(outputStream* st, bool withComments, bool printRanges) { // Don't print notproduct and develop flags in a product build. if (is_constant_in_binary()) { return; } if (!printRanges) { st->print("%9s %-40s %c= ", _type, _name, (!is_default() ? ':' : ' ')); if (is_bool()) { st->print("%-16s", get_bool() ? "true" : "false"); } else if (is_int()) { st->print("%-16d", get_int()); } else if (is_uint()) { st->print("%-16u", get_uint()); } else if (is_intx()) { st->print(INTX_FORMAT_W(-16), get_intx()); } else if (is_uintx()) { st->print(UINTX_FORMAT_W(-16), get_uintx()); } else if (is_uint64_t()) { st->print(UINT64_FORMAT_W(-16), get_uint64_t()); } else if (is_size_t()) { st->print(SIZE_FORMAT_W(-16), get_size_t()); } else if (is_double()) { st->print("%-16f", get_double()); } else if (is_ccstr()) { const char* cp = get_ccstr(); if (cp != NULL) { const char* eol; while ((eol = strchr(cp, '\n')) != NULL) { size_t llen = pointer_delta(eol, cp, sizeof(char)); st->print("%.*s", (int)llen, cp); st->cr(); cp = eol+1; st->print("%5s %-35s += ", "", _name); } st->print("%-16s", cp); } else st->print("%-16s", ""); } st->print("%-20s", " "); print_kind(st); #ifndef PRODUCT if (withComments) { st->print("%s", _doc); } #endif st->cr(); } else if (!is_bool() && !is_ccstr()) { if (printRanges) { st->print("%9s %-50s ", _type, _name); CommandLineFlagRangeList::print(_name, st, true); st->print(" %-20s", " "); print_kind(st); #ifndef PRODUCT if (withComments) { st->print("%s", _doc); } #endif st->cr(); } } }