/*------------------------------------------------------------------------ * app2 - prints PID of current process *------------------------------------------------------------------------ */ process app2() { kprintf("\n The PID for %s is %d",getpname(getpid()), getpid()); resume(create(app3, 1024, 48, "app3", 0, NULL)); sleep(5); kprintf("\n The PID for %s is %d and it's parent is %d",getpname(getpid()), getpid(), getppid()); return OK; }
// Restore the symbol values to their original value and remove any added // symbols. LOCAL void nyx_restore_obarray() { LVAL obvec = getvalue(obarray); int i; // Scan all obarray vectors for (i = 0; i < HSIZE; i++) { LVAL last = NULL; LVAL dcon; // Scan all elements for (dcon = getelement(obvec, i); dcon; dcon = cdr(dcon)) { LVAL dsym = car(dcon); char *name = (char *)getstring(getpname(dsym)); LVAL scon; // Ignore *OBARRAY* since setting it causes the input array to be // truncated. if (strcmp(name, "*OBARRAY*") == 0) { continue; } // Ignore *SCRATCH* since it's allowed to be updated if (strcmp(name, "*SCRATCH*") == 0) { continue; } // Find the symbol in the original obarray. for (scon = getelement(nyx_obarray, hash(name, HSIZE)); scon; scon = cdr(scon)) { LVAL ssym = car(scon); // If found, then set the current symbols value to the original. if (strcmp(name, (char *)getstring(getpname(ssym))) == 0) { setvalue(dsym, nyx_dup_value(getvalue(ssym))); setplist(dsym, nyx_dup_value(getplist(ssym))); setfunction(dsym, nyx_dup_value(getfunction(ssym))); break; } } // If we didn't find the symbol in the original obarray, then it must've // been added and must be removed from the current obarray. if (scon == NULL) { if (last) { rplacd(last, cdr(dcon)); } else { setelement(obvec, i, cdr(dcon)); } } // Must track the last dcon for symbol removal last = dcon; } } }
/* xlgetfname - get a filename */ LVAL xlgetfname(V) { LVAL name; /* get the next argument */ name = xlgetarg(); /* get the filename string */ #ifdef FILETABLE if (streamp(name) && getfile(name) > CONSOLE) /* "Steal" name from file stream */ name = cvstring(filetab[getfile(name)].tname); else #endif if (symbolp(name)) name = getpname(name); else if (!stringp(name)) xlbadtype(name); if (getslength(name) >= FNAMEMAX) xlerror("file name too long", name); /* return the name */ return (name); }
LVAL xsbasekernelsmooth(V) { LVAL x, y, xs, ys, targ; int n, ns, error, ktype; double *dx, *dy, *dxs, *dys, width; n = getfixnum(xlgafixnum()); x = xlgetarg(); y = xlgetarg(); ns = getfixnum(xlgafixnum()); xs = xlgetarg(); ys = xlgetarg(); width = makefloat(xlgetarg()); targ = xlgasymbol(); xllastarg(); dx = getlinalgdvec(0, n, x); dy = null(y) ? NULL : getlinalgdvec(0, n, y); dxs = getlinalgdvec(0, ns, xs); dys = getlinalgdvec(0, ns, ys); switch (getstring(getpname(targ))[0]) { case 'U': ktype = 'U'; break; case 'T': ktype = 'T'; break; case 'G': ktype = 'G'; break; default: ktype = 'B'; break; } error = kernel_smooth(dx, dy, n, width, NULL, NULL, dxs, dys, ns, ktype); return error ? s_true : NIL; }
/* xlenter - enter a symbol into the obarray */ LVAL xlenter(char *name) { LVAL sym,array; int i; /* check for nil */ if (strcmp(name,"NIL") == 0) return (NIL); /* check for symbol already in table */ array = getvalue(obarray); i = hash(name,HSIZE); for (sym = getelement(array,i); sym; sym = cdr(sym)) if (strcmp(name,(char *) getstring(getpname(car(sym)))) == 0) return (car(sym)); /* make a new symbol node and link it into the list */ xlsave1(sym); sym = consd(getelement(array,i)); rplaca(sym,xlmakesym(name)); setelement(array,i,sym); xlpop(); /* return the new symbol */ return (car(sym)); }
/* xlenter - enter a symbol into the obarray */ NODE *xlenter(char *name,int type) { NODE ***oldstk,*sym __HEAPIFY,*array; int i; /* check for nil */ if (strcmp(name,"NIL") == 0) return (NIL); /* check for symbol already in table */ array = getvalue(obarray); i = hash(name,HSIZE); for (sym = getelement(array,i); sym; sym = cdr(sym)) if (strcmp(name,getstring(getpname(car(sym)))) == 0) return (car(sym)); /* make a new symbol node and link it into the list */ oldstk = xlsave1(&sym); sym = consd(getelement(array,i)); rplaca(sym,xlmakesym(name,type)); setelement(array,i,sym); xlstack = oldstk; /* return the new symbol */ return (car(sym)); }
/* xstring - return a string consisting of a single character */ LVAL xstring(void) { LVAL arg; /* get the argument */ arg = xlgetarg(); xllastarg(); /* make sure its not NIL */ if (null(arg)) xlbadtype(arg); /* check the argument type */ switch (ntype(arg)) { case STRING: return (arg); case SYMBOL: return (getpname(arg)); case CHAR: buf[0] = (int)getchcode(arg); buf[1] = '\0'; return (cvstring(buf)); case FIXNUM: buf[0] = getfixnum(arg); buf[1] = '\0'; return (cvstring(buf)); default: xlbadtype(arg); return NIL; /* never happens */ } }
static void sev_send(void *arg, nvlist_t *msg) { if ((errno = sysevent_evc_publish(arg, EC_FM, ESC_FM_ERROR, "com.sun", getpname(), msg, EVCH_SLEEP)) != 0) warn("failed to send event"); }
/* xgensym - generate a symbol */ LVAL xgensym(void) { char sym[STRMAX+11]; /* enough space for prefix and number */ LVAL x; /* get the prefix or number */ if (moreargs()) { x = xlgetarg(); switch (ntype(x)) { case SYMBOL: x = getpname(x); case STRING: strncpy(gsprefix, (char *) getstring(x),STRMAX); gsprefix[STRMAX] = '\0'; break; case FIXNUM: gsnumber = getfixnum(x); break; default: xlerror("bad argument type",x); } } xllastarg(); /* create the pname of the new symbol */ sprintf(sym,"%s%d",gsprefix,gsnumber++); /* make a symbol with this print name */ return (xlmakesym(sym)); }
oidtype read_partial_tuple(bindtype env, oidtype tag, oidtype x, oidtype stream) { // Standard reader int size = 0, fills = 0, j = 0, k = 0; oidtype res, x0; struct ptcell *dres; //Pass 1: compute sizes x0 = x; while (x0 != nil) { if (hd(x) == nil) fills++; size++; x0 = tl(x0); } // Allocate PT res = alloc_partial_tuple(size - fills, fills); dres = dr(res, ptcell); //Pass 2: fill PT with values and blanks x0 = x; while (x0 != nil) { if (symbolp(hd(x0)) && strcmp(getpname(hd(x0)), "*") == 0) { dres->fill[j].pos = k; dres->fill[j].pendingOps = 0; a_setelem(dres->tuple, k, nil, FALSE); j++; } else a_setelem(dres->tuple, k, hd(x0), FALSE); k++; x0 = tl(x0); } return res; }
/* putclosure - output a closure */ LOCAL void putclosure(LVAL fptr, LVAL val) { LVAL name; if (name = getname(val)) sprintf(buf,"#<Closure-%s: #",getstring(getpname(name))); else strcpy(buf,"#<Closure: #"); xlputstr(fptr,buf); sprintf(buf,AFMT,val); xlputstr(fptr,buf); xlputc(fptr,'>'); /* xlputstr(fptr,"\nName: "); xlprint(fptr,getname(val),TRUE); xlputstr(fptr,"\nType: "); xlprint(fptr,gettype(val),TRUE); xlputstr(fptr,"\nLambda: "); xlprint(fptr,getlambda(val),TRUE); xlputstr(fptr,"\nArgs: "); xlprint(fptr,getargs(val),TRUE); xlputstr(fptr,"\nOargs: "); xlprint(fptr,getoargs(val),TRUE); xlputstr(fptr,"\nRest: "); xlprint(fptr,getrest(val),TRUE); xlputstr(fptr,"\nKargs: "); xlprint(fptr,getkargs(val),TRUE); xlputstr(fptr,"\nAargs: "); xlprint(fptr,getaargs(val),TRUE); xlputstr(fptr,"\nBody: "); xlprint(fptr,getbody(val),TRUE); xlputstr(fptr,"\nEnv: "); xlprint(fptr,closure_getenv(val),TRUE); xlputstr(fptr,"\nFenv: "); xlprint(fptr,getfenv(val),TRUE); */ }
/* invert the order by recursion. there will be only one recursion tree * so we can use a static var for managing the last ent */ static void addptree(int *txtpos, char *cmdtxt, int pid, int basepid) { static char l[512] = ""; char *p; if (!pid || pid == basepid) return; addptree(txtpos, cmdtxt, pid2ppid(pid), basepid); p = getpname(pid); if ( strcmp(l, p) ) *txtpos += snprintf(cmdtxt+*txtpos, 4096-*txtpos, "%s%s", *txtpos ? "." : "", getpname(pid)); else *txtpos += snprintf(cmdtxt+*txtpos, 4096-*txtpos, "*"); strcpy(l, p); }
int main(int argc, char const *argv[]) { fprintf(stderr, "te system test:\n"); fprintf(stderr, "......usb state: %d\n", usb_connector_state()); fprintf(stderr, "...........puid: %d\n", getpuid()); fprintf(stderr, "...........paid: %d\n", getpaid()); fprintf(stderr, "...........pdid: %d\n", getpdid()); fprintf(stderr, "..........panme: %s\n", getpname()); while (1); return 0; }
/* xsymname - get the print name of a symbol */ LVAL xsymname(void) { LVAL sym; /* get the symbol */ sym = xlgasymbol(); xllastarg(); /* return the print name */ return (getpname(sym)); }
static int usage(void) { (void) fprintf(stderr, "Usage: %s [-nqv] [-c chan] [file]\n" "\t-c specify alternate channel to use for publication\n" "\t-n compile program but do not inject any events\n" "\t-q enable quiet mode (silence status messages)\n" "\t-v enable verbose output (display event details)\n", getpname()); return (E_USAGE); }
// Make a copy of the original obarray, leaving the original in place LOCAL void nyx_save_obarray() { LVAL newarray; int i; // This provide permanent protection for nyx_obarray as we do not want it // to be garbage-collected. xlprot1(nyx_obarray); nyx_obarray = getvalue(obarray); // Create and set the new vector. This allows us to use xlenter() to // properly add the new symbol. Probably slower than adding directly, // but guarantees proper hashing. newarray = newvector(HSIZE); setvalue(obarray, newarray); // Scan all obarray vectors for (i = 0; i < HSIZE; i++) { LVAL sym; // Scan all elements for (sym = getelement(nyx_obarray, i); sym; sym = cdr(sym)) { LVAL syma = car(sym); char *name = (char *) getstring(getpname(syma)); LVAL nsym = xlenter(name); // Ignore *OBARRAY* since there's no need to copy it if (strcmp(name, "*OBARRAY*") == 0) { continue; } // Ignore *SCRATCH* since it's allowed to be updated if (strcmp(name, "*SCRATCH*") == 0) { continue; } // Duplicate the symbol's values setvalue(nsym, nyx_dup_value(getvalue(syma))); setplist(nsym, nyx_dup_value(getplist(syma))); setfunction(nsym, nyx_dup_value(getfunction(syma))); } } // Swap the obarrays, so that the original is put back into service setvalue(obarray, nyx_obarray); nyx_obarray = newarray; }
int main(int argc, char *argv[]) { int c; size_t i; Buffer *buf; errno = 0; setpname(argv[0]); if (argc < 2) die(2, "usage: %s file", getpname()); if ((c = open(argv[1], O_RDONLY)) == -1) die(1, "failed to open file %s:", argv[1]); if ((buf = makebuf(512)) == NULL) die(1, "allocating buffer failed:"); if (initbuf(buf, c, O_RDONLY) == EOF) die(1, "initializing buffer failed:"); i = 0; while ((c = bgetchar(buf)) != EOF) { if (i == 511 || i == 512 || i == 513) { if (bungetchar(buf) == EOF) { die(1, "bungetchar failed at char %lu", i); break; } if ((c = bgetchar(buf)) == EOF) break; } putc(c, stdout); i++; } if (errno != 0) die(1, "bgetchar failed at char %lu:", i); fprintf(stderr, "reached end of input file %s\n", argv[1]); fprintf(stderr, "%lu bytes read\n", i); bclose(buf); exit(0); }
static int print_usage(FILE *fp, int verbose) { (void) fprintf(fp, "Usage: %s [-dfhlsSt] [-u file] file\n", getpname()); if (verbose) { (void) fprintf(fp, "\t-d dump data object section\n" "\t-f dump function section\n" "\t-h dump file header\n" "\t-l dump label table\n" "\t-s dump string table\n" "\t-S dump statistics\n" "\t-t dump type section\n" "\t-u save uncompressed CTF to a file\n"); } return (E_USAGE); }
/* xhash - compute the hash value of a string or symbol */ LVAL xhash(void) { unsigned char *str; LVAL len,val; int n; /* get the string and the table length */ val = xlgetarg(); len = xlgafixnum(); n = (int)getfixnum(len); xllastarg(); /* get the string */ if (symbolp(val)) str = getstring(getpname(val)); else if (stringp(val)) str = getstring(val); else { xlerror("bad argument type",val); str = NULL; } /* return the hash index */ return (cvfixnum((FIXTYPE)hash((char *) str, n))); }
int main(int argc, char *argv[]) { char c; int i; idtype_t idtype = P_PID; char *idstr = "pid"; char *pool_name = NULL; uint_t flags = 0; int status; (void) getpname(argv[0]); (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); while ((c = getopt(argc, argv, OPTS)) != EOF) { switch (c) { case 'Q': if (flags & (qFLAG | iFLAG | pFLAG)) usage(); flags |= QFLAG; break; case 'e': if (flags & (iFLAG | qFLAG | QFLAG)) usage(); flags |= eFLAG; break; case 'i': for (i = 0; idtypes[i].str != NULL; i++) { if (strcmp(optarg, idtypes[i].str) == 0) { idtype = idtypes[i].idtype; idstr = idtypes[i].str; break; } } if ((flags & (iFLAG | qFLAG | QFLAG)) || idtypes[i].str == NULL) usage(); flags |= iFLAG; break; case 'p': if (flags & (pFLAG | qFLAG | QFLAG)) usage(); flags |= pFLAG; pool_name = optarg; break; case 'q': if (flags & (pFLAG | iFLAG | QFLAG)) usage(); flags |= qFLAG; break; case '?': default: usage(); } } argc -= optind; argv += optind; if (flags & eFLAG && pool_name == NULL) usage(); if (argc < 1 || (flags & (pFLAG | qFLAG | QFLAG)) == 0) usage(); /* * Check to see that the pools facility is enabled */ if (pool_get_status(&status) != PO_SUCCESS) die((ERR_OPEN_DYNAMIC), get_errstr()); if (status == POOL_DISABLED) die((ERR_OPEN_DYNAMIC), strerror(ENOTACTIVE)); if (flags & eFLAG) exec_cmd(pool_name, argv); /*NOTREACHED*/ else process_ids(pool_name, flags, idtype, idstr, argc, argv); return (error); }
int main(int argc, char *argv[]) { const char *pname = getpname(argv[0]); u_longlong_t minf; struct stat st; int c; int dflag = 0; /* for checking in use during -d ops */ int dcmode = DC_CURRENT; /* kernel settings override unless -u */ int modified = 0; /* have we modified the dump config? */ char *minfstr = NULL; /* string value of -m argument */ dumpconf_t dc; /* current configuration */ (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); /* * Take an initial lap through argv hunting for -r root-dir, * so that we can chroot before opening the configuration file. * We also handle -u and any bad options at this point. */ while (optind < argc) { while ((c = getopt(argc, argv, OPTS)) != (int)EOF) { if (c == 'r' && chroot(optarg) == -1) die(gettext("failed to chroot to %s"), optarg); else if (c == 'u') dcmode = DC_OVERRIDE; else if (c == '?') { (void) fprintf(stderr, gettext(USAGE), pname); return (E_USAGE); } } if (optind < argc) { warn(gettext("illegal argument -- %s\n"), argv[optind]); (void) fprintf(stderr, gettext(USAGE), pname); return (E_USAGE); } } if (geteuid() != 0) die(gettext("you must be root to use %s\n"), pname); /* * If no config file exists yet, we're going to create an empty one, * so set the modified flag to force writing out the file. */ if (access(PATH_CONFIG, F_OK) == -1) modified++; /* * Now open and read in the initial values from the config file. * If it doesn't exist, we create an empty file and dc is * initialized with the default values. */ if (dconf_open(&dc, PATH_DEVICE, PATH_CONFIG, dcmode) == -1) return (E_ERROR); /* * Take another lap through argv, processing options and * modifying the dumpconf_t as appropriate. */ for (optind = 1; optind < argc; optind++) { while ((c = getopt(argc, argv, OPTS)) != (int)EOF) { switch (c) { case 'c': if (dconf_str2content(&dc, optarg) == -1) return (E_USAGE); modified++; break; case 'd': if (dconf_str2device(&dc, optarg) == -1) return (E_USAGE); dflag++; modified++; break; case 'm': minfstr = optarg; break; case 'n': dc.dc_enable = DC_OFF; modified++; break; case 's': if (stat(optarg, &st) == -1 || !S_ISDIR(st.st_mode)) { warn(gettext("%s is missing or not a " "directory\n"), optarg); return (E_USAGE); } if (dconf_str2savdir(&dc, optarg) == -1) return (E_USAGE); modified++; break; case 'y': dc.dc_enable = DC_ON; modified++; break; } } } if (minfstr != NULL) { if (minfree_compute(dc.dc_savdir, minfstr, &minf) == -1) return (E_USAGE); if (minfree_write(dc.dc_savdir, minf) == -1) return (E_ERROR); } if (dcmode == DC_OVERRIDE) { /* * In override mode, we try to force an update. If this * fails, we re-load the kernel configuration and write that * out to the file in order to force the file in sync. * * We allow the file to be read-only but print a warning to the * user that indicates it hasn't been updated. */ if (dconf_update(&dc, 0) == -1) (void) dconf_getdev(&dc); if (dc.dc_readonly) warn(gettext("kernel settings updated, but " "%s is read-only\n"), PATH_CONFIG); else if (dconf_write(&dc) == -1) return (E_ERROR); } else if (modified) { /* * If we're modifying the configuration, then try * to update it, and write out the file if successful. */ if (dc.dc_readonly) { warn(gettext("failed to update settings: %s is " "read-only\n"), PATH_CONFIG); return (E_ERROR); } if (dconf_update(&dc, dflag) == -1 || dconf_write(&dc) == -1) return (E_ERROR); } if (dcmode == DC_CURRENT) dconf_print(&dc, stdout); if (dconf_close(&dc) == -1) warn(gettext("failed to close configuration file")); return (E_SUCCESS); }
int main(int argc, char *argv[]) { Symtab *symtab; Symbol *sym; setpname(argv[0]); if (argc > 1) fprintf(stderr, "%s: unused arguments\n", getpname()); if ((symtab = makesymtab(0)) == NULL) die(1, "failed to allocate symbol table:"); if ((sym = storesym(symtab, "foo")) == NULL) die(1, "failed to insert lexem \"foo\":"); sym->symtype = S_IDENT; if ((sym = storesym(symtab, "bar")) == NULL) die(1, "failed to insert lexem \"bar\":"); sym->symtype = S_IDENT; if ((sym = storesym(symtab, "baz")) == NULL) die(1, "failed to insert lexem \"baz\":"); sym->symtype = S_IDENT; if ((sym = findsym(symtab, "foo")) == NULL) die(1, "couldn't find lexem \"foo\":"); if (sym->symtype != S_IDENT) die(1, "symtype of \"foo\" is not S_IDENT"); sym->symtype = S_INTCONST; if ((sym = findsym(symtab, "bar")) == NULL) die(1, "couldn't find lexem \"bar\":"); if (sym->symtype != S_IDENT) die(1, "%s: symtype of \"bar\" is not S_IDENT"); sym->symtype = S_INTCONST; if ((sym = findsym(symtab, "baz")) == NULL) die(1, "couldn't find lexem \"baz\":"); if (sym->symtype != S_IDENT) die(1, "symtype of \"baz\" is not S_IDENT"); sym->symtype = S_INTCONST; if ((sym = findsym(symtab, "foo")) == NULL) die(1, "couldn't find lexem \"foo\":"); if (sym->symtype != S_INTCONST) die(1, "symtype of \"foo\" is not S_INTCONST"); if ((sym = findsym(symtab, "bar")) == NULL) die(1, "couldn't find lexem \"bar\":"); if (sym->symtype != S_INTCONST) die(1, "symtype of \"bar\" is not S_INTCONST"); if ((sym = findsym(symtab, "baz")) == NULL) die(1, "couldn't find lexem \"baz\":"); if (sym->symtype != S_INTCONST) die(1, "symtype of \"baz\" is not S_INTCONST"); freesymtab(symtab); return 0; }
/* xlprint - print an xlisp value */ void xlprint(LVAL fptr, LVAL vptr, int flag) { LVAL nptr,next; int n,i; /* print nil */ if (vptr == NIL) { putsymbol(fptr,"NIL",flag); return; } /* check value type */ switch (ntype(vptr)) { case SUBR: putsubr(fptr,"Subr",vptr); break; case FSUBR: putsubr(fptr,"FSubr",vptr); break; case CONS: xlputc(fptr,'('); for (nptr = vptr; nptr != NIL; nptr = next) { xlprint(fptr,car(nptr),flag); if (next = cdr(nptr)) if (consp(next)) xlputc(fptr,' '); else { xlputstr(fptr," . "); xlprint(fptr,next,flag); break; } } xlputc(fptr,')'); break; case SYMBOL: putsymbol(fptr,(char *) getstring(getpname(vptr)),flag); break; case FIXNUM: putfixnum(fptr,getfixnum(vptr)); break; case FLONUM: putflonum(fptr,getflonum(vptr)); break; case CHAR: putchcode(fptr,getchcode(vptr),flag); break; case STRING: if (flag) putqstring(fptr,vptr); else putstring(fptr,vptr); break; case STREAM: putatm(fptr,"File-Stream",vptr); break; case USTREAM: putatm(fptr,"Unnamed-Stream",vptr); break; case OBJECT: putatm(fptr,"Object",vptr); break; case VECTOR: xlputc(fptr,'#'); xlputc(fptr,'('); for (i = 0, n = getsize(vptr); n-- > 0; ) { xlprint(fptr,getelement(vptr,i++),flag); if (n) xlputc(fptr,' '); } xlputc(fptr,')'); break; case CLOSURE: putclosure(fptr,vptr); break; case EXTERN: if (getdesc(vptr)) { (*(getdesc(vptr)->print_meth))(fptr, getinst(vptr)); } break; case FREE_NODE: putatm(fptr,"Free",vptr); break; default: putatm(fptr,"Foo",vptr); break; } }
int main(int argc, char *argv[]) { char c; pool_conf_t *conf = NULL; const char *static_conf_loc; (void) getpname(argv[0]); (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); while ((c = getopt(argc, argv, "cdensx")) != EOF) { switch (c) { case 'c': /* Create (or modify) system configuration */ Cflag++; break; case 'd': /* Disable the pools facility */ Dflag++; break; case 'e': /* Enable the pools facility */ Eflag++; break; case 'n': /* Don't actually do anything */ Nflag++; break; case 's': /* Update the submitted configuration */ Sflag++; break; case 'x': /* Delete current system configuration */ Xflag++; break; case '?': default: usage(); /*NOTREACHED*/ } } /* * Not all flags can be used at the same time. */ if ((Cflag || Sflag || Dflag || Eflag) && Xflag) usage(); if ((Dflag || Eflag) && (Cflag || Sflag || Xflag)) usage(); if (Dflag && Eflag) usage(); argc -= optind; argv += optind; if (! (Cflag || Sflag)) { if (argc != 0) usage(); } else { if (argc == 0) static_conf_loc = pool_static_location(); else if (argc == 1) static_conf_loc = argv[0]; else usage(); } if (!Nflag && (Cflag + Dflag + Eflag + Xflag != 0) && !priv_ineffect(PRIV_SYS_RES_CONFIG)) die(gettext(ERR_PERMISSIONS)); if (Dflag) { if (pool_set_status(POOL_DISABLED) != PO_SUCCESS) die(gettext(ERR_DISABLE)); } else if (Eflag) { if (pool_set_status(POOL_ENABLED) != PO_SUCCESS) { if (errno == EEXIST) die(gettext(ERR_ENABLE ": System has active processor sets\n")); else die(gettext(ERR_ENABLE)); } } else { if ((conf = pool_conf_alloc()) == NULL) die(gettext(ERR_NOMEM)); if (Cflag + Sflag + Xflag == 0) { /* * No flags means print current system configuration */ config_print(conf); } else if (!Nflag && Xflag) { /* * Destroy active pools configuration and * remove the state file. */ config_destroy(conf); } else { /* * Commit a new configuration. */ if (Cflag) config_commit(conf, static_conf_loc); else { /* * Dump the dynamic state to the * specified location */ if (!Nflag && Sflag) { if (pool_conf_open(conf, pool_dynamic_location(), PO_RDONLY) != PO_SUCCESS) die(gettext(ERR_OPEN_DYNAMIC), get_errstr()); if (pool_conf_export(conf, static_conf_loc, POX_NATIVE) != PO_SUCCESS) die(gettext(ERR_EXPORT_DYNAMIC), static_conf_loc, get_errstr()); (void) pool_conf_close(conf); } } } pool_conf_free(conf); } return (E_PO_SUCCESS); }