int pvremove(struct cmd_context *cmd, int argc, char **argv) { int i; unsigned force_count; unsigned prompt; struct dm_list pv_names; if (!argc) { log_error("Please enter a physical volume path"); return EINVALID_CMD_LINE; } force_count = arg_count(cmd, force_ARG); prompt = arg_count(cmd, yes_ARG); dm_list_init(&pv_names); /* Needed to change the set of orphan PVs. */ if (!lockd_gl(cmd, "ex", 0)) return_ECMD_FAILED; for (i = 0; i < argc; i++) { dm_unescape_colons_and_at_signs(argv[i], NULL, NULL); if (!str_list_add(cmd->mem, &pv_names, argv[i])) return_ECMD_FAILED; } if (!pvremove_many(cmd, &pv_names, force_count, prompt)) return_ECMD_FAILED; return ECMD_PROCESSED; }
/* * Normal snapshot or thinly-provisioned snapshot? */ static int _determine_snapshot_type(struct volume_group *vg, struct lvcreate_params *lp) { struct lv_list *lvl; if (!(lvl = find_lv_in_vg(vg, lp->origin))) { log_error("Snapshot origin LV %s not found in Volume group %s.", lp->origin, vg->name); return 0; } if (!arg_count(vg->cmd, extents_ARG) && !arg_count(vg->cmd, size_ARG)) { if (!lv_is_thin_volume(lvl->lv)) { log_error("Please specify either size or extents with snapshots."); return 0; } lp->thin = 1; if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin"))) return_0; lp->pool = first_seg(lvl->lv)->pool_lv->name; } return 1; }
int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv) { const char *vg_name = NULL; if (argc == 1) { vg_name = skip_dev_dir(cmd, argv[0], NULL); if (!validate_name(vg_name)) { log_error("Volume group name \"%s\" is invalid", vg_name); return ECMD_FAILED; } } else if (!(arg_count(cmd, list_ARG) && arg_count(cmd, file_ARG))) { log_error("Please specify a *single* volume group to restore."); return ECMD_FAILED; } /* * FIXME: overloading the -l arg for now to display a * list of archive files for a particular vg */ if (arg_count(cmd, list_ARG)) { if (!(arg_count(cmd,file_ARG) ? archive_display_file(cmd, arg_str_value(cmd, file_ARG, "")) : archive_display(cmd, vg_name))) { stack; return ECMD_FAILED; } return ECMD_PROCESSED; } if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) { log_error("Unable to lock volume group %s", vg_name); return ECMD_FAILED; } if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) { log_error("Unable to lock orphans"); unlock_vg(cmd, vg_name); return ECMD_FAILED; } cmd->handles_unknown_segments = 1; if (!(arg_count(cmd, file_ARG) ? backup_restore_from_file(cmd, vg_name, arg_str_value(cmd, file_ARG, "")) : backup_restore(cmd, vg_name))) { unlock_vg(cmd, VG_ORPHANS); unlock_vg(cmd, vg_name); log_error("Restore failed."); return ECMD_FAILED; } log_print("Restored volume group %s", vg_name); unlock_vg(cmd, VG_ORPHANS); unlock_vg(cmd, vg_name); return ECMD_PROCESSED; }
/* * Decide whether it is "safe" to wipe the labels on this device. * 0 indicates we may not. */ static int pvremove_check(struct cmd_context *cmd, const char *name) { struct physical_volume *pv; /* is the partition type set correctly ? */ if ((arg_count(cmd, force_ARG) < 1) && !is_lvm_partition(name)) { log_error("%s: Not LVM partition type: use -f to override", name); return 0; } /* Is there a pv here already? */ /* If not, this is an error unless you used -f. */ if (!(pv = pv_read(cmd, name, NULL, NULL, 1))) { if (arg_count(cmd, force_ARG)) return 1; log_error("Physical Volume %s not found", name); return 0; } /* orphan ? */ if (is_orphan(pv)) return 1; /* Allow partial & exported VGs to be destroyed. */ /* we must have -ff to overwrite a non orphan */ if (arg_count(cmd, force_ARG) < 2) { log_error("Can't pvremove physical volume \"%s\" of " "volume group \"%s\" without -ff", name, pv_vg_name(pv)); return 0; } /* prompt */ if (!arg_count(cmd, yes_ARG) && yes_no_prompt(_really_wipe, name, pv_vg_name(pv)) == 'n') { log_print("%s: physical volume label not removed", name); return 0; } if (arg_count(cmd, force_ARG)) { log_warn("WARNING: Wiping physical volume label from " "%s%s%s%s", name, !is_orphan(pv) ? " of volume group \"" : "", !is_orphan(pv) ? pv_vg_name(pv) : "", !is_orphan(pv) ? "\"" : ""); } return 1; }
int vgexport(struct cmd_context *cmd, int argc, char **argv) { if (!argc && !arg_count(cmd, all_ARG)) { log_error("Please supply volume groups or use -a for all."); return ECMD_FAILED; } if (argc && arg_count(cmd, all_ARG)) { log_error("No arguments permitted when using -a for all."); return ECMD_FAILED; } return process_each_vg(cmd, argc, argv, LCK_VG_WRITE, 1, NULL, &vgexport_single); }
static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv, void *handle) // __attribute((unused))) { struct lvinfo info; int lv_total = 0; uint64_t lv_capacity_total = 0; int inkernel, snap_active = 1; struct lv_segment *snap_seg = NULL; float snap_percent; /* fused, fsize; */ const char *active_str, *snapshot_str; if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv)) return ECMD_PROCESSED; inkernel = lv_info(cmd, lv, &info, 1) && info.exists; if (lv_is_origin(lv)) { list_iterate_items_gen(snap_seg, struct lv_segment, &lv->snapshot_segs, origin_list) { if (inkernel && (snap_active = lv_snapshot_percent(snap_seg->cow, &snap_percent))) if (snap_percent < 0 || snap_percent >= 100) snap_active = 0; } snap_seg = NULL; } else if (lv_is_cow(lv)) {
static int _lvdisplay_single(struct cmd_context *cmd, struct logical_volume *lv, void *handle) { if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv)) return ECMD_PROCESSED; if (arg_count(cmd, colon_ARG)) lvdisplay_colons(lv); else { lvdisplay_full(cmd, lv, handle); if (arg_count(cmd, maps_ARG)) lvdisplay_segments(lv); } return ECMD_PROCESSED; }
oop slotsMap::copy_add_argument_slot(slotsOop obj, stringOop name, slotType type, oop contents, oop anno, bool mustAllocate) { assert_smi(contents, "arg data must be position"); if (!name->is_unary()) return ErrorCodes::vmString_prim_error(ARGUMENTCOUNTERROR); slotDesc* old = find_slot(name); slotsOop result; if (old == NULL) result= obj; else if (old->is_arg_slot()) { // No need to remove and reinsert because order is the same. // Only the annotation might be really different. // The index will be off by one (assumes that added slot is new) assert(smiOop(contents)->value() == smiOop(old->data)->value() + 1, "arg index wrong"); return change_slot(obj, old, type, old->data, anno, mustAllocate); } else { result= (slotsOop)copy_remove_slot(obj, name, mustAllocate); if (oop(result) == failedAllocationOop || result->is_mark()) return result; assert(result->is_slots(), "just checking"); } assert(smiOop(contents)->value() == arg_count(), "arg index wrong"); return ((slotsMap*)result->map())->copy_add_new_slot(result, name, type, contents, anno, mustAllocate); }
static void b_shift(char **av) { int shift = (av[1] == NULL ? 1 : a2u(av[1])); List *s, *dollarzero; if (av[1] != NULL && av[2] != NULL) { arg_count("shift"); return; } if (shift < 0) { badnum(av[1]); return; } s = varlookup("*")->n; dollarzero = varlookup("0"); while (s != NULL && shift != 0) { s = s->n; --shift; } if (s == NULL && shift != 0) { fprint(2, "cannot shift\n"); set(FALSE); } else { varassign("*", append(dollarzero, s), FALSE); set(TRUE); } }
static void b_break(char **av) { if (av[1] != NULL) { arg_count("break"); return; } rc_raise(eBreak); }
arg_parse(char *str, arg_info *entry) #endif { int length = 0; if (arg_count (*entry) == P_ONE_ARG) { char **store = (char **) arg_result_ptr (*entry); length = put_one_arg (arg_result_type (*entry), str, store, arg_prefix (*entry), arg_string (*entry)); } /* if (arg_count == P_ONE_ARG) */ else { /* Must be a table of arguments */ char **store = (char **) arg_result_ptr (*entry); if (store) { while (*store) store++; length = put_one_arg(arg_result_type (*entry), str, store++, arg_prefix (*entry), arg_string (*entry)); *store = (char *) NULL; } /* if (store) */ } /* else */ return length; } /* arg_parse */
std::string SCAN_Name::arg(size_t i) const { if(i >= arg_count()) throw std::range_error("SCAN_Name::arg " + std::to_string(i) + " out of range for '" + as_string() + "'"); return args[i]; }
std::string SCAN_Name::all_arguments() const { std::string out; if(arg_count()) { out += '('; for(size_t i = 0; i != arg_count(); ++i) { out += arg(i); if(i != arg_count() - 1) out += ','; } out += ')'; } return out; }
void src_cpp_line( const char *line, int length ) { arg_List args; char *tmp = alloca( length + 1 ); int lineno; strncpy( tmp, line, length ); tmp [ length ] = '\0'; args = arg_argify( tmp, 0 ); if ((lineno = atoi( arg_get( args, 1 ) )) > 0) --lineno; else lineno = 1; src_new_line( lineno ); /* FIXME! This is debugging cruft to be removed. */ if (arg_count( args ) == 2) { PRINTF(MAA_SRC,( "lineno %s\n", arg_get( args, 1 ) )); } else { PRINTF(MAA_SRC,( "lineno %s in %s\n", arg_get( args, 1 ), arg_get( args, 2 ) )); src_new_file( arg_get( args, 2 ) ); } arg_destroy( args ); }
static int _lvsegs_single(struct cmd_context *cmd, struct logical_volume *lv, void *handle) { if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv)) return ECMD_PROCESSED; return process_each_segment_in_lv(cmd, lv, handle, _segs_single); }
static void b_newpgrp(char **av) { if (av[1] != NULL) { arg_count("newpgrp"); return; } setpgid(rc_pid, rc_pid); /* XXX check return value */ tcsetpgrp(2, rc_pid); /* XXX check return value */ }
void get(){ empty_queues(); GtkTextBuffer *b = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_rem)); GtkTextBuffer *s = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_step)); GtkTextIter start_i, end; gtk_text_buffer_get_start_iter (b, &start_i); gtk_text_buffer_get_end_iter (b, &end); gchar *c = gtk_text_buffer_get_text(b, &start_i, &end, FALSE); int i; for(i = strlen(c) - 1; c[i] == '\n' || c[i] == '\0' ; i++) c[i] = '\0'; int n = arg_count(c, '\n'); alloc_m(n); char **line; line = (char **)malloc(sizeof(char *)*(n + 1)); splitter(c, line, "\n"); for(i = 0; i < n; i++){ char **num; num = (char **)malloc(sizeof(char *)*(n + 2)); int nm = splitter(line[i], num, ","); if(nm < n + 1){ gtk_entry_set_text(GTK_ENTRY(entry_out), "INPUT ERROR : metrix error"); gtk_text_buffer_set_text(s, "", -1); return; } int j; for(j = 0; j < n + 1; j++) if(validate(num[j])) m[i][j] = atof(num[j]); else{ free(num); free(line); free(c); gtk_entry_set_text(GTK_ENTRY(entry_out), "INPUT ERROR : invalide characters"); gtk_text_buffer_set_text(s, "", -1); return; } free(num); } free(line); int flag = solve(n + 1, n); if(!flag) gtk_entry_set_text(GTK_ENTRY(entry_out), "INPUT ERROR!"); else set_output(n); if(start != NULL) { curnt = start; gtk_text_buffer_set_text(s, curnt -> s, -1); }else gtk_text_buffer_set_text(s, "", -1); }
static int _read_size_params(struct lvcreate_params *lp, struct lvcreate_cmdline_params *lcp, struct cmd_context *cmd) { if (arg_count(cmd, extents_ARG) + arg_count(cmd, size_ARG) != 1) { log_error("Please specify either size or extents (not both)"); return 0; } if (arg_count(cmd, extents_ARG)) { if (arg_sign_value(cmd, extents_ARG, 0) == SIGN_MINUS) { log_error("Negative number of extents is invalid"); return 0; } lp->extents = arg_uint_value(cmd, extents_ARG, 0); lcp->percent = arg_percent_value(cmd, extents_ARG, PERCENT_NONE); } /* Size returned in kilobyte units; held in sectors */ if (arg_count(cmd, size_ARG)) { if (arg_sign_value(cmd, size_ARG, 0) == SIGN_MINUS) { log_error("Negative size is invalid"); return 0; } lcp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0)); lcp->percent = PERCENT_NONE; } /* Size returned in kilobyte units; held in sectors */ if (arg_count(cmd, virtualsize_ARG)) { if (arg_sign_value(cmd, virtualsize_ARG, 0) == SIGN_MINUS) { log_error("Negative virtual origin size is invalid"); return 0; } lp->voriginsize = arg_uint64_value(cmd, virtualsize_ARG, UINT64_C(0)); if (!lp->voriginsize) { log_error("Virtual origin size may not be zero"); return 0; } } return 1; }
static int _get_vsn(struct cmd_context *cmd, uint16_t *version_int) { const char *vsn; unsigned int major, minor, patchlevel; if (arg_count(cmd, atversion_ARG)) vsn = arg_str_value(cmd, atversion_ARG, NULL); else if (arg_count(cmd, sinceversion_ARG)) vsn = arg_str_value(cmd, sinceversion_ARG, NULL); else vsn = LVM_VERSION; if (sscanf(vsn, "%u.%u.%u", &major, &minor, &patchlevel) != 3) { log_error("Incorrect version format."); return 0; } *version_int = vsn(major, minor, patchlevel); return 1; }
int pvs(struct cmd_context *cmd, int argc, char **argv) { report_type_t type; if (arg_count(cmd, segments_ARG)) type = PVSEGS; else type = PVS; return _report(cmd, argc, argv, type); }
static int _lvs_single(struct cmd_context *cmd, struct logical_volume *lv, void *handle) { if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv)) return ECMD_PROCESSED; if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL)) return ECMD_FAILED; return ECMD_PROCESSED; }
std::string SCAN_Name::algo_name_and_args() const { std::string out; out = algo_name(); if(arg_count()) { out += '('; for(size_t i = 0; i != arg_count(); ++i) { out += arg(i); if(i != arg_count() - 1) out += ','; } out += ')'; } return out; }
static void b_cd(char **av) { if (*++av == NULL) { List *s2 = varlookup("home"); *av = (s2 == NULL) ? "/" : s2->w; } else if (av[1] != NULL) { arg_count("cd"); return; } if (isabsolute(*av) || streq(*av, ".") || streq(*av, "..")) { /* absolute pathname? */ if (chdir(*av) < 0) { set(FALSE); uerror(*av); } else { update_cwd_var(); set(TRUE); } } else { char *path = NULL; size_t pathlen = 0; List nil; List *s = varlookup("cdpath"); if (s == NULL) { s = &nil; nil.w = ""; nil.n = NULL; } do { if (s != &nil && *s->w != '\0') { const size_t t = strlen(*av) + strlen(s->w) + 2; if (t > pathlen) path = nnew_arr(char, pathlen = t); strcpy(path, s->w); if (!streq(s->w, "/")) /* "//" is special to POSIX */ strcat(path, "/"); strcat(path, *av); } else { pathlen = 0; path = *av; } if (chdir(path) >= 0) { update_cwd_var(); set(TRUE); if (interactive && *s->w != '\0' && !streq(s->w, ".")) fprint(1, "%s\n", path); return; } s = s->n; } while (s != NULL); fprint(2, "couldn't cd to %s\n", *av); set(FALSE); }
int pvremove(struct cmd_context *cmd, int argc, char **argv) { int i, r; int ret = ECMD_PROCESSED; if (!argc) { log_error("Please enter a physical volume path"); return EINVALID_CMD_LINE; } if (arg_count(cmd, yes_ARG) && !arg_count(cmd, force_ARG)) { log_error("Option y can only be given with option f"); return EINVALID_CMD_LINE; } for (i = 0; i < argc; i++) { r = pvremove_single(cmd, argv[i], NULL); if (r > ret) ret = r; } return ret; }
init_store(arg_info *table, int entries) #endif { int index; for (index = 0; index < entries; index++) if (arg_count (table[index]) == P_INFINITE_ARGS) { char **place = (char **) arg_result_ptr (table[index]); if (place) *place = (char *) NULL; } /* if arg_count == P_INFINITE_ARGS */ } /* init_store */
void sendDesc::print() { if (isPrimCall()) { PrimDesc *pd= getPrimDescOfFirstInstruction(jump_addr(), true); lprintf("primitive: %s\n", pd->name()); return; } printIndent(); printLookupType(raw_lookupType()); LookupType l= lookupType(); if (isPerformLookupType(l)) { lprintf(": argc: %ld", arg_count()); } else { lprintf(": selector: "); selector()->print_real_oop(); } if (l & DelegateeStaticBit) { lprintf(": delegatee: "); delegatee()->print_real_oop(); } Indent++; printIndent(); lprintf("addr: %#lx", jump_addr()); if (Memory->code->contains(jump_addr())) { lprintf(" (nmethod %#lx)", nmethod::findNMethod(jump_addr())); } lprintf("; mask: "); printMask(mask()); lprintf("\n"); printIndent(); lprintf("dependency: "); dependency()->print(); lprintf("\n"); if (pic()) { printIndent(); lprintf("PIC: p ((CacheStub*)%#lx)->print()\n", pic()); } if (countStub()) { printIndent(); lprintf("count stub: p ((CountStub*)%#lx)->print()\n", countStub()); } Indent --; }
static void b_umask(char **av) { int i; if (*++av == NULL) { set(TRUE); i = umask(0); umask(i); fprint(1, "0%o\n", i); } else if (av[1] == NULL) { i = o2u(*av); if ((unsigned int) i > 0777) { fprint(2, "bad umask\n"); set(FALSE); } else { umask(i); set(TRUE); } } else { arg_count("umask"); return; } }
static void b_wait(char **av) { int status; pid_t pid; if (av[1] == NULL) { waitforall(); return; } if (av[2] != NULL) { arg_count("wait"); return; } if ((pid = a2u(av[1])) < 0) { badnum(av[1]); return; } if (rc_wait4(pid, &status, FALSE) > 0) setstatus(pid, status); else set(FALSE); sigchk(); }
arg_verify(char **argv, arg_info *table, int entries) #endif { int i; char *this_program = ""; if (argv) this_program = argv[0]; for (i = 0; i < entries; i++) { arg_info *arg = &table[i]; /* Check the argument flags */ if (arg_flags (*arg) & ~(P_CASE_INSENSITIVE | P_REQUIRED_PREFIX)) { fprintf (stderr, "%s [arg_verify]: too many ", this_program); fprintf (stderr, "flags in entry %d: '%x' (hex)\n", i, arg_flags (*arg)); } /* if */ /* Check the argument count */ { int count = arg_count (*arg); if (count != P_NO_ARGS && count != P_ONE_ARG && count != P_INFINITE_ARGS) { fprintf (stderr, "%s [arg_verify]: invalid ", this_program); fprintf (stderr, "argument count in entry %d: '%d'\n", i, count); } /* if count != P_NO_ARGS ... */ /* Check the result field; want to be able to store results */ else if (arg_result_ptr (*arg) == (int *) NULL) { fprintf (stderr, "%s [arg_verify]: ", this_program); fprintf (stderr, "no argument storage given for "); fprintf (stderr, "entry %d\n", i); } /* if arg_result_ptr */ } /* Check the argument type */ { int type = arg_result_type (*arg); if (type < P_STRING || type > P_DOUBLE) fprintf(stderr, "%s [arg_verify]: bad arg type in entry %d: '%d'\n", this_program, i, type); } /* Check table size */ { int size = arg_table_size (*arg); if (arg_count (*arg) == P_INFINITE_ARGS && size < 1) { fprintf (stderr, "%s [arg_verify]: bad ", this_program); fprintf (stderr, "table size in entry %d: '%d'\n", i, size); } /* if (arg_count == P_INFINITE_ARGS && size < 1) */ } } /* for i = 0 */ return TRUE; } /* arg_verify */
parse_args(int argc, char **argv, arg_info *table, int entries, char **others, int other_count) #endif { boolean result; if (argv) this_program = argv[0]; /* Check the validity of the table and its parameters */ result = arg_verify (argv, table, entries); /* Initialize the storage values */ init_store (table, entries); if (result) { boolean use_prefix = TRUE; char *argv0; argc--; argv0 = *++argv; while (argc) { int index, length; index = match_table (*argv, table, entries, use_prefix, &length); if (index < 0) { /* The argument doesn't match anything in the table */ if (others) { if (*argv > argv0) *--*argv = '-'; /* complain at invalid flag */ if (other_count > 0) { *others++ = *argv; other_count--; } else { fprintf (stderr, "%s: too many parameters: ", this_program); fprintf (stderr, "'%s' ignored\n", *argv); } /* else */ } /* if (others) */ argv0 = *++argv; argc--; } else { /* A match was found */ if (length >= strlen (*argv)) { argc--; argv0 = *++argv; use_prefix = TRUE; } else { (*argv) += length; use_prefix = FALSE; } /* else */ /* Parse any necessary arguments */ if (arg_count (table[index]) != P_NO_ARGS) { /* Now length will be used to store the number of parsed characters */ length = arg_parse(*argv, &table[index]); if (*argv == NULL) argc = 0; else if (length >= strlen (*argv)) { argc--; argv0 = *++argv; use_prefix = TRUE; } else { (*argv) += length; use_prefix = FALSE; } /* else */ } /* if (argv_count != P_NO_ARGS) */ else *arg_result_ptr(table[index]) = arg_table_size(table[index]); } /* else */ } /* while (argc) */ } /* if (result) */ return result; } /* parse_args */