void gdbFindCB(Widget w, XtPointer client_data, XtPointer call_data) { SourceView::SearchDirection direction = (SourceView::SearchDirection) (long) client_data; assert(direction == SourceView::forward || direction == SourceView::backward); if (direction != last_find_direction) { last_find_direction = direction; update_options(); } XmPushButtonCallbackStruct *cbs = (XmPushButtonCallbackStruct *)call_data; // LessTif 0.79 sometimes returns NULL in cbs->event. Handle this. Time tm; if (cbs->event != 0) tm = time(cbs->event); else tm = XtLastTimestampProcessed(XtDisplay(w)); string key = source_arg->get_string(); source_view->find(key, direction, app_data.find_words_only, app_data.find_case_sensitive, tm); source_arg->set_string(key); }
void SetStartupTipsCB(Widget, XtPointer, XtPointer call_data) { XmToggleButtonCallbackStruct *info = (XmToggleButtonCallbackStruct *)call_data; app_data.startup_tips = info->set; update_options(); }
void GLWindow::paintGL() { static unsigned int fps_time_ms = 0, fps_ticks = 0; static unsigned long last_time = 0L; unsigned long current_time = 0; current_time = get_current_time_ms(); frame_time_ms = current_time - last_time; update_options(); render_update(frame_time_ms / 1000.0); render_draw(); fps_ticks++; last_time = current_time; fps_time_ms += frame_time_ms; if(fps_time_ms >= 1000) { current_fps = fps_ticks; fps_ticks = 0; fps_time_ms = 0; } }
int main(int argc, char *argv[]) { const char *mntfromname, **vfslist, *vfstype; struct fstab *fs; struct statfs *mntbuf; int all, ch, i, init_flags, late, failok, mntsize, rval, have_fstab, ro; int onlylate; char *cp, *ep, *options; all = init_flags = late = onlylate = 0; ro = 0; options = NULL; vfslist = NULL; vfstype = "ufs"; while ((ch = getopt(argc, argv, "adF:fLlno:prt:uvw")) != -1) switch (ch) { case 'a': all = 1; break; case 'd': debug = 1; break; case 'F': setfstab(optarg); break; case 'f': init_flags |= MNT_FORCE; break; case 'L': onlylate = 1; late = 1; break; case 'l': late = 1; break; case 'n': /* For compatibility with the Linux version of mount. */ break; case 'o': if (*optarg) { options = catopt(options, optarg); if (specified_ro(optarg)) ro = 1; } break; case 'p': fstab_style = 1; verbose = 1; break; case 'r': options = catopt(options, "ro"); ro = 1; break; case 't': if (vfslist != NULL) errx(1, "only one -t option may be specified"); vfslist = makevfslist(optarg); vfstype = optarg; break; case 'u': init_flags |= MNT_UPDATE; break; case 'v': verbose = 1; break; case 'w': options = catopt(options, "noro"); break; case '?': default: usage(); /* NOTREACHED */ } argc -= optind; argv += optind; #define BADTYPE(type) \ (strcmp(type, FSTAB_RO) && \ strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ)) if ((init_flags & MNT_UPDATE) && (ro == 0)) options = catopt(options, "noro"); rval = 0; switch (argc) { case 0: if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) err(1, "getmntinfo"); if (all) { while ((fs = getfsent()) != NULL) { if (BADTYPE(fs->fs_type)) continue; if (checkvfsname(fs->fs_vfstype, vfslist)) continue; if (hasopt(fs->fs_mntops, "noauto")) continue; if (!hasopt(fs->fs_mntops, "late") && onlylate) continue; if (hasopt(fs->fs_mntops, "late") && !late) continue; if (hasopt(fs->fs_mntops, "failok")) failok = 1; else failok = 0; if (!(init_flags & MNT_UPDATE) && ismounted(fs, mntbuf, mntsize)) continue; options = update_options(options, fs->fs_mntops, mntbuf->f_flags); if (mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file, init_flags, options, fs->fs_mntops) && !failok) rval = 1; } } else if (fstab_style) { for (i = 0; i < mntsize; i++) { if (checkvfsname(mntbuf[i].f_fstypename, vfslist)) continue; putfsent(&mntbuf[i]); } } else { for (i = 0; i < mntsize; i++) { if (checkvfsname(mntbuf[i].f_fstypename, vfslist)) continue; if (!verbose && (mntbuf[i].f_flags & MNT_IGNORE) != 0) continue; prmount(&mntbuf[i]); } } exit(rval); case 1: if (vfslist != NULL) usage(); rmslashes(*argv, *argv); if (init_flags & MNT_UPDATE) { mntfromname = NULL; have_fstab = 0; if ((mntbuf = getmntpt(*argv)) == NULL) errx(1, "not currently mounted %s", *argv); /* * Only get the mntflags from fstab if both mntpoint * and mntspec are identical. Also handle the special * case where just '/' is mounted and 'spec' is not * identical with the one from fstab ('/dev' is missing * in the spec-string at boot-time). */ if ((fs = getfsfile(mntbuf->f_mntonname)) != NULL) { if (strcmp(fs->fs_spec, mntbuf->f_mntfromname) == 0 && strcmp(fs->fs_file, mntbuf->f_mntonname) == 0) { have_fstab = 1; mntfromname = mntbuf->f_mntfromname; } else if (argv[0][0] == '/' && argv[0][1] == '\0') { fs = getfsfile("/"); have_fstab = 1; mntfromname = fs->fs_spec; } } if (have_fstab) { options = update_options(options, fs->fs_mntops, mntbuf->f_flags); } else { mntfromname = mntbuf->f_mntfromname; options = update_options(options, NULL, mntbuf->f_flags); } rval = mountfs(mntbuf->f_fstypename, mntfromname, mntbuf->f_mntonname, init_flags, options, 0); break; } if ((fs = getfsfile(*argv)) == NULL && (fs = getfsspec(*argv)) == NULL) errx(1, "%s: unknown special file or file system", *argv); if (BADTYPE(fs->fs_type)) errx(1, "%s has unknown file system type", *argv); rval = mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file, init_flags, options, fs->fs_mntops); break; case 2: /* * If -t flag has not been specified, the path cannot be * found, spec contains either a ':' or a '@', then assume * that an NFS file system is being specified ala Sun. * Check if the hostname contains only allowed characters * to reduce false positives. IPv6 addresses containing * ':' will be correctly parsed only if the separator is '@'. * The definition of a valid hostname is taken from RFC 1034. */ if (vfslist == NULL && ((ep = strchr(argv[0], '@')) != NULL || (ep = strchr(argv[0], ':')) != NULL)) { if (*ep == '@') { cp = ep + 1; ep = cp + strlen(cp); } else cp = argv[0]; while (cp != ep) { if (!isdigit(*cp) && !isalpha(*cp) && *cp != '.' && *cp != '-' && *cp != ':') break; cp++; } if (cp == ep) vfstype = "nfs"; } rval = mountfs(vfstype, argv[0], argv[1], init_flags, options, NULL); break; default: usage(); /* NOTREACHED */ } /* * If the mount was successfully, and done by root, tell mountd the * good news. */ if (rval == 0 && getuid() == 0) restart_mountd(); exit(rval); }
int main(int argc, char **argv) { const char *mntfromname, **vfslist, *vfstype; struct fstab *fs; struct statfs *mntbuf; FILE *mountdfp; pid_t pid; int all, ch, i, init_flags, mntsize, rval, have_fstab; char *options; all = init_flags = 0; options = NULL; vfslist = NULL; vfstype = "ufs"; while ((ch = getopt(argc, argv, "adF:fo:prwt:uv")) != -1) { switch (ch) { case 'a': all = 1; break; case 'd': debug = 1; break; case 'F': setfstab(optarg); break; case 'f': init_flags |= MNT_FORCE; break; case 'o': if (*optarg) options = catopt(options, optarg); break; case 'p': fstab_style = 1; verbose = 1; break; case 'r': options = catopt(options, "ro"); break; case 't': if (vfslist != NULL) errx(1, "only one -t option may be specified"); vfslist = makevfslist(optarg); vfstype = optarg; break; case 'u': init_flags |= MNT_UPDATE; break; case 'v': verbose = 1; break; case 'w': options = catopt(options, "noro"); break; case '?': default: usage(); /* NOTREACHED */ } } argc -= optind; argv += optind; #define BADTYPE(type) \ (strcmp(type, FSTAB_RO) && \ strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ)) rval = 0; switch (argc) { case 0: if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) err(1, "getmntinfo"); if (all) { while ((fs = getfsent()) != NULL) { if (BADTYPE(fs->fs_type)) continue; if (checkvfsname(fs->fs_vfstype, vfslist)) continue; if (hasopt(fs->fs_mntops, "noauto")) continue; if (!(init_flags & MNT_UPDATE) && ismounted(fs, mntbuf, mntsize)) continue; options = update_options(options, fs->fs_mntops, mntbuf->f_flags); if (mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file, init_flags, options, fs->fs_mntops)) rval = 1; } } else if (fstab_style) { for (i = 0; i < mntsize; i++) { if (checkvfsname(mntbuf[i].f_fstypename, vfslist)) continue; putfsent(&mntbuf[i]); } } else { for (i = 0; i < mntsize; i++) { if (checkvfsname(mntbuf[i].f_fstypename, vfslist)) continue; prmount(&mntbuf[i]); } } exit(rval); case 1: if (vfslist != NULL) usage(); rmslashes(*argv, *argv); if (init_flags & MNT_UPDATE) { mntfromname = NULL; have_fstab = 0; if ((mntbuf = getmntpt(*argv)) == NULL) errx(1, "not currently mounted %s", *argv); /* * Only get the mntflags from fstab if both mntpoint * and mntspec are identical. Also handle the special * case where just '/' is mounted and 'spec' is not * identical with the one from fstab ('/dev' is missing * in the spec-string at boot-time). */ if ((fs = getfsfile(mntbuf->f_mntonname)) != NULL) { if (strcmp(fs->fs_spec, mntbuf->f_mntfromname) == 0 && strcmp(fs->fs_file, mntbuf->f_mntonname) == 0) { have_fstab = 1; mntfromname = mntbuf->f_mntfromname; } else if (argv[0][0] == '/' && argv[0][1] == '\0') { fs = getfsfile("/"); have_fstab = 1; mntfromname = fs->fs_spec; } } if (have_fstab) { options = update_options(options, fs->fs_mntops, mntbuf->f_flags); } else { mntfromname = mntbuf->f_mntfromname; options = update_options(options, NULL, mntbuf->f_flags); } rval = mountfs(mntbuf->f_fstypename, mntfromname, mntbuf->f_mntonname, init_flags, options, 0); break; } if ((fs = getfsfile(*argv)) == NULL && (fs = getfsspec(*argv)) == NULL) errx(1, "%s: unknown special file or file system", *argv); if (BADTYPE(fs->fs_type)) errx(1, "%s has unknown file system type", *argv); rval = mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file, init_flags, options, fs->fs_mntops); break; case 2: /* * If -t flag has not been specified, the path cannot be * found. * * If the spec is not a file and contains a ':' then assume * NFS. * * If the spec is a cdev attempt to extract the fstype from * the label. * * When all else fails ufs is assumed. */ if (vfslist == NULL) { if (strpbrk(argv[0], ":") != NULL && access(argv[0], 0) == -1) { vfstype = "nfs"; } else { checkdisklabel(argv[0], &vfstype); } } rval = mountfs(vfstype, getdevpath(argv[0], 0), argv[1], init_flags, options, NULL); break; default: usage(); /* NOTREACHED */ } /* * If the mount was successfully, and done by root, tell mountd the * good news. Pid checks are probably unnecessary, but don't hurt. */ if (rval == 0 && getuid() == 0 && (mountdfp = fopen(_PATH_MOUNTDPID, "r")) != NULL) { if (fscanf(mountdfp, "%d", &pid) == 1 && pid > 0 && kill(pid, SIGHUP) == -1 && errno != ESRCH) err(1, "signal mountd"); fclose(mountdfp); } exit(rval); }
STATIC int test_mod(test_pars_t *tp, pdu_t *pdu, iscsi_pdu_kind_t kind, int rxtx, int err) { mod_desc_t *mod; uint32_t mpoff, off; int i, rc = 0, s; tp->pdu_count[kind][rxtx]++; tp->pdu_count[ANY_PDU][rxtx]++; do { if ((mod = TAILQ_FIRST(&tp->mods)) == NULL) { return check_loss(tp, rxtx); } if (mod->pars.which_pdu != ANY_PDU && mod->pars.which_pdu != kind) { return check_loss(tp, rxtx); } mpoff = mod->pars.pdu_offset; switch (mod->pars.which_offset) { case ABSOLUTE_ANY: off = tp->pdu_count[ANY_PDU][CNT_TX] + tp->pdu_count[ANY_PDU][CNT_RX]; break; case RELATIVE_ANY: off = (tp->pdu_count[ANY_PDU][CNT_TX] + tp->pdu_count[ANY_PDU][CNT_RX]) - (tp->pdu_last[ANY_PDU][CNT_TX] + tp->pdu_last[ANY_PDU][CNT_RX]); break; case ABSOLUTE_PDUKIND: off = tp->pdu_count[kind][rxtx]; break; case RELATIVE_PDUKIND: off = tp->pdu_count[kind][rxtx] - tp->pdu_last[kind][rxtx]; break; case ABSOLUTE_TX: if (rxtx != CNT_TX) return check_loss(tp, rxtx); off = tp->pdu_count[ANY_PDU][CNT_TX]; break; case RELATIVE_TX: if (rxtx != CNT_TX) return check_loss(tp, rxtx); off = tp->pdu_count[ANY_PDU][CNT_TX] - tp->pdu_last[ANY_PDU][CNT_TX]; break; case ABSOLUTE_RX: if (rxtx != CNT_RX) return check_loss(tp, rxtx); off = tp->pdu_count[ANY_PDU][CNT_RX]; break; case RELATIVE_RX: if (rxtx != CNT_RX) return check_loss(tp, rxtx); off = tp->pdu_count[ANY_PDU][CNT_RX] - tp->pdu_last[ANY_PDU][CNT_RX]; break; default: /* bad offset - skip this entry */ mpoff = off = 0; break; } DEB(1, ("test_mod: kind=%d, rxtx=%d, pdukind=%d, mpoff=%d, " "whichoff=%d, off=%d\n", kind, rxtx, mod->pars.which_pdu, mpoff, mod->pars.which_offset, off)); if (!off || (mpoff != 0 && mpoff < off)) { /* This might happen in some cases. Just discard the modification. */ s = splbio(); TAILQ_REMOVE(&tp->mods, mod, link); splx(s); update_options(tp, mod); if (mod->pars.options & ISCSITEST_OPT_WAIT_FOR_COMPLETION) { mod->pars.status = ISCSI_STATUS_TEST_MODIFICATION_SKIPPED; wakeup(mod); } free(mod, M_TEMP); } } while (mpoff && mpoff < off); if (mpoff > off) return check_loss(tp, rxtx); DEB(1, ("test_mod: opt=%x, pdu_ptr=%x, num_mods=%d\n", mod->pars.options, (int) mod->pdu_ptr, mod->pars.num_pdu_mods)); if (mod->pdu_ptr) test_get(pdu, mod, err); if (mod->pars.options & ISCSITEST_OPT_DISCARD_PDU) rc = 1; else if (check_loss(tp, rxtx)) rc = 1; else if (mod->pars.num_pdu_mods) { if (!(mod->pars.options & ISCSITEST_OPT_MOD_PERMANENT)) { /* * Note: if the PDU is later resent, the unmodified one will be * used as resend_pdu restores the original io vector. */ pdu->mod_pdu = pdu->pdu; pdu->io_vec[0].iov_base = &pdu->mod_pdu; } for (i = 0; i < mod->pars.num_pdu_mods; i++) { mod_pdu(pdu, &mod->mods[i]); } } if (rxtx == CNT_TX) { if (mod->pars.options & ISCSITEST_OPT_NO_RESPONSE_PDU) { ccb_t *ccb = pdu->owner; DEB(1, ("test_mod: No response expected, completing CCB %x\n", (int)ccb)); if (ccb != NULL && (ccb->disp == CCBDISP_WAIT || ccb->disp == CCBDISP_SCSIPI)) { /* simulate timeout */ wake_ccb(ccb, ISCSI_STATUS_TIMEOUT); } } if ((mod->pars.options & ISCSITEST_SFLAG_UPDATE_FIELDS) && mod->pars.num_pdu_mods) { connection_t *conn = pdu->connection; if (conn->HeaderDigest && !(mod->pars.options & ISCSITEST_SFLAG_NO_HEADER_DIGEST)) pdu->pdu.HeaderDigest = gen_digest(&pdu->pdu, BHS_SIZE); if (pdu->uio.uio_iovcnt > 1 && conn->DataDigest && !(mod->pars.options & ISCSITEST_SFLAG_NO_DATA_DIGEST)) pdu->data_digest = gen_digest_2( pdu->io_vec[1].iov_base, pdu->io_vec[1].iov_len, pdu->io_vec[2].iov_base, pdu->io_vec[2].iov_len); } } s = splbio(); TAILQ_REMOVE(&tp->mods, mod, link); update_options(tp, mod); /* we've modified a PDU - copy current count into last count */ memcpy(tp->pdu_last, tp->pdu_count, sizeof(tp->pdu_last)); splx(s); if (mod->pars.options & ISCSITEST_OPT_WAIT_FOR_COMPLETION) { wakeup(mod); } if (mod->pars.options & ISCSITEST_KILL_CONNECTION) { kill_connection(tp->connection, ISCSI_STATUS_TEST_CONNECTION_CLOSED, NO_LOGOUT, TRUE); } free(mod, M_TEMP); return rc; }