/*================================================================ * eat_dir - recursively install directory *===============================================================*/ void eat_dir(ino_t parent) { /* Read prototype lines and set up directory. Recurse if need be. */ char *token[MAX_TOKENS], *p; char line[LINE_LEN]; int mode, usrid, grpid, maj, min, f; ino_t n; zone_t z; size_t size; while (1) { get_line(line, token); p = token[0]; if (*p == '$') return; p = token[1]; mode = mode_con(p); usrid = atoi(token[2]); grpid = atoi(token[3]); n = alloc_inode(mode, usrid, grpid); /* Enter name in directory and update directory's size. */ enter_dir(parent, token[0], n); incr_size(parent, sizeof(struct direct)); /* Check to see if file is directory or special. */ incr_link(n); if (*p == 'd') { /* This is a directory. */ z = alloc_zone(); /* zone for new directory */ add_zone(n, z, 2 * sizeof(struct direct), current_time); enter_dir(n, ".", n); enter_dir(n, "..", parent); incr_link(parent); incr_link(n); eat_dir(n); } else if (*p == 'b' || *p == 'c') { /* Special file. */ maj = atoi(token[4]); min = atoi(token[5]); size = 0; if (token[6]) size = atoi(token[6]); size = block_size * size; add_zone(n, (zone_t) (makedev(maj,min)), size, current_time); } else if (*p == 's') { enter_symlink(n, token[4]); } else { /* Regular file. Go read it. */ if ((f = open(token[4], O_RDONLY)) < 0) { fprintf(stderr, "%s: Can't open %s: %s\n", progname, token[4], strerror(errno)); } else { eat_file(n, f); } } } }
/*================================================================ * rootdir - install the root directory *===============================================================*/ void rootdir(ino_t inode) { zone_t z; z = alloc_zone(); add_zone(inode, z, 2 * sizeof(struct direct), current_time); enter_dir(inode, ".", inode); enter_dir(inode, "..", inode); incr_link(inode); incr_link(inode); }
void scene_view::mousePressEvent(QMouseEvent *event) { auto btns = event->buttons(); const bool mouse_left = btns.testFlag(Qt::LeftButton); if (m_mode == mode_add && mouse_left && !m_selected_add.id.empty()) { m_objects.push_back(m_selected_add); m_objects.back().name = new_name("object", m_objects); update_objects_tree(); } if (m_mode == mode_zone && mouse_left) { add_zone(m_zone_add); m_zones.back().name = new_name("zone", m_zones); update_objects_tree(); } if (m_mode == mode_path && mouse_left) { auto p0 = nya_math::vec4(m_cursor_pos, m_selected_add.y); const auto &sel_paths = m_selection["paths"]; if (sel_paths.empty()) { path p; p.name = new_name("path", m_paths); p.points.push_back(p0); m_paths.push_back(p); update_objects_tree(); set_selection("paths", m_paths.size() - 1); } else { int idx = *sel_paths.rbegin(); if (idx < (int)m_paths.size()) { m_paths[idx].points.push_back(p0); set_selection("paths", idx); } } } m_mouse_x = event->localPos().x(); m_mouse_y = event->localPos().y(); update(); }
void create() { do_setup++; ::create(); do_setup--; set_light(80); set_climate("Aw"); add_zone("plain"); switch((string)WEATHER->query_season()) { case "spring": add_item("flower", ({"long", "Some pretty flowers.", "get", ({this_object(), "do_get_flower"}), "pick", ({this_object(), "do_get_flower"}), "smell", "The flowers smell wonderful." }));
void enter_symlink(ino_t inode, char *lnk) { zone_t z; size_t len; char *buf; buf = alloc_block(); z = alloc_zone(); len = strlen(lnk); if (len >= block_size) pexit("symlink too long, max length is %u", (unsigned)block_size - 1); strcpy(buf, lnk); put_block((z << zone_shift), buf); add_zone(inode, z, len, current_time); free(buf); }
/* Zonesize >= blocksize */ void eat_file(ino_t inode, int f) { int ct = 0, i, j; zone_t z = 0; char *buf; time_t timeval; buf = alloc_block(); do { for (i = 0, j = 0; i < zone_per_block; i++, j += ct) { memset(buf, 0, block_size); if ((ct = read(f, buf, block_size)) > 0) { if (i == 0) z = alloc_zone(); put_block((z << zone_shift) + i, buf); } } timeval = (dflag ? current_time : file_time(f)); if (ct) add_zone(inode, z, (size_t) j, timeval); } while (ct == block_size); close(f); free(buf); }
int main(int argc, char **argv) { DIR *procdir; char *p; char *sortk = "cpu"; /* default sort key */ int opt; int timeout; struct pollfd pollset; char key; (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); Progname(argv[0]); lwpid_init(); fd_init(Setrlimit()); while ((opt = getopt(argc, argv, "vcmaRLtu:U:n:p:C:P:s:S:j:k:TJz:Z")) != (int)EOF) { switch (opt) { case 'R': opts.o_outpmode |= OPT_REALTIME; break; case 'c': opts.o_outpmode &= ~OPT_TERMCAP; opts.o_outpmode &= ~OPT_FULLSCREEN; break; case 'm': case 'v': opts.o_outpmode &= ~OPT_PSINFO; opts.o_outpmode |= OPT_MSACCT; break; case 't': opts.o_outpmode &= ~OPT_PSINFO; opts.o_outpmode |= OPT_USERS; break; case 'a': opts.o_outpmode |= OPT_SPLIT | OPT_USERS; break; case 'T': opts.o_outpmode |= OPT_SPLIT | OPT_TASKS; break; case 'J': opts.o_outpmode |= OPT_SPLIT | OPT_PROJECTS; break; case 'n': if ((p = strtok(optarg, ",")) == NULL) Die(gettext("invalid argument for -n\n")); opts.o_ntop = Atoi(p); if (p = strtok(NULL, ",")) opts.o_nbottom = Atoi(p); opts.o_outpmode &= ~OPT_FULLSCREEN; break; case 's': opts.o_sortorder = -1; sortk = optarg; break; case 'S': opts.o_sortorder = 1; sortk = optarg; break; case 'u': if ((p = strtok(optarg, ", ")) == NULL) Die(gettext("invalid argument for -u\n")); add_uid(&euid_tbl, p); while (p = strtok(NULL, ", ")) add_uid(&euid_tbl, p); break; case 'U': if ((p = strtok(optarg, ", ")) == NULL) Die(gettext("invalid argument for -U\n")); add_uid(&ruid_tbl, p); while (p = strtok(NULL, ", ")) add_uid(&ruid_tbl, p); break; case 'p': fill_table(&pid_tbl, optarg, 'p'); break; case 'C': fill_set_table(optarg); opts.o_outpmode |= OPT_PSETS; break; case 'P': fill_table(&cpu_tbl, optarg, 'P'); break; case 'k': fill_table(&tsk_tbl, optarg, 'k'); break; case 'j': fill_prj_table(optarg); break; case 'L': opts.o_outpmode |= OPT_LWPS; break; case 'z': if ((p = strtok(optarg, ", ")) == NULL) Die(gettext("invalid argument for -z\n")); add_zone(&zone_tbl, p); while (p = strtok(NULL, ", ")) add_zone(&zone_tbl, p); break; case 'Z': opts.o_outpmode |= OPT_SPLIT | OPT_ZONES; break; default: Usage(); } } (void) atexit(Exit); if ((opts.o_outpmode & OPT_USERS) && !(opts.o_outpmode & OPT_SPLIT)) opts.o_nbottom = opts.o_ntop; if (opts.o_ntop == 0 || opts.o_nbottom == 0) Die(gettext("invalid argument for -n\n")); if (!(opts.o_outpmode & OPT_SPLIT) && (opts.o_outpmode & OPT_USERS) && ((opts.o_outpmode & (OPT_PSINFO | OPT_MSACCT)))) Die(gettext("-t option cannot be used with -v or -m\n")); if ((opts.o_outpmode & OPT_SPLIT) && (opts.o_outpmode && OPT_USERS) && !((opts.o_outpmode & (OPT_PSINFO | OPT_MSACCT)))) Die(gettext("-t option cannot be used with " "-a, -J, -T or -Z\n")); if ((opts.o_outpmode & OPT_USERS) && (opts.o_outpmode & (OPT_TASKS | OPT_PROJECTS | OPT_ZONES))) Die(gettext("-a option cannot be used with " "-t, -J, -T or -Z\n")); if (((opts.o_outpmode & OPT_TASKS) && (opts.o_outpmode & (OPT_PROJECTS|OPT_ZONES))) || ((opts.o_outpmode & OPT_PROJECTS) && (opts.o_outpmode & (OPT_TASKS|OPT_ZONES)))) { Die(gettext("-J, -T and -Z options are mutually exclusive\n")); } if (argc > optind) opts.o_interval = Atoi(argv[optind++]); if (argc > optind) opts.o_count = Atoi(argv[optind++]); if (opts.o_count == 0) Die(gettext("invalid counter value\n")); if (argc > optind) Usage(); if (opts.o_outpmode & OPT_REALTIME) Priocntl("RT"); if (isatty(STDOUT_FILENO) == 1 && isatty(STDIN_FILENO)) opts.o_outpmode |= OPT_TTY; /* interactive */ if (!(opts.o_outpmode & OPT_TTY)) { opts.o_outpmode &= ~OPT_TERMCAP; /* no termcap for pipes */ opts.o_outpmode &= ~OPT_FULLSCREEN; } if (opts.o_outpmode & OPT_TERMCAP) ldtermcap(); /* can turn OPT_TERMCAP off */ if (opts.o_outpmode & OPT_TERMCAP) (void) setsize(); list_alloc(&lwps, opts.o_ntop); list_alloc(&users, opts.o_nbottom); list_alloc(&tasks, opts.o_nbottom); list_alloc(&projects, opts.o_nbottom); list_alloc(&zones, opts.o_nbottom); list_setkeyfunc(sortk, &opts, &lwps, LT_LWPS); list_setkeyfunc(NULL, &opts, &users, LT_USERS); list_setkeyfunc(NULL, &opts, &tasks, LT_TASKS); list_setkeyfunc(NULL, &opts, &projects, LT_PROJECTS); list_setkeyfunc(NULL, &opts, &zones, LT_ZONES); if (opts.o_outpmode & OPT_TERMCAP) curses_on(); if ((procdir = opendir("/proc")) == NULL) Die(gettext("cannot open /proc directory\n")); if (opts.o_outpmode & OPT_TTY) { (void) printf(gettext("Please wait...\r")); (void) fflush(stdout); } set_signals(); pollset.fd = STDIN_FILENO; pollset.events = POLLIN; timeout = opts.o_interval * MILLISEC; /* * main program loop */ do { if (sigterm == 1) break; if (sigtstp == 1) { curses_off(); (void) signal(SIGTSTP, SIG_DFL); (void) kill(0, SIGTSTP); /* * prstat stops here until it receives SIGCONT signal. */ sigtstp = 0; (void) signal(SIGTSTP, sig_handler); curses_on(); print_movecur = FALSE; if (opts.o_outpmode & OPT_FULLSCREEN) sigwinch = 1; } if (sigwinch == 1) { if (setsize() == 1) { list_free(&lwps); list_free(&users); list_free(&tasks); list_free(&projects); list_free(&zones); list_alloc(&lwps, opts.o_ntop); list_alloc(&users, opts.o_nbottom); list_alloc(&tasks, opts.o_nbottom); list_alloc(&projects, opts.o_nbottom); list_alloc(&zones, opts.o_nbottom); } sigwinch = 0; (void) signal(SIGWINCH, sig_handler); } prstat_scandir(procdir); list_refresh(&lwps); if (print_movecur) (void) putp(movecur); print_movecur = TRUE; if ((opts.o_outpmode & OPT_PSINFO) || (opts.o_outpmode & OPT_MSACCT)) { list_sort(&lwps); list_print(&lwps); } if (opts.o_outpmode & OPT_USERS) { list_sort(&users); list_print(&users); list_clear(&users); } if (opts.o_outpmode & OPT_TASKS) { list_sort(&tasks); list_print(&tasks); list_clear(&tasks); } if (opts.o_outpmode & OPT_PROJECTS) { list_sort(&projects); list_print(&projects); list_clear(&projects); } if (opts.o_outpmode & OPT_ZONES) { list_sort(&zones); list_print(&zones); list_clear(&zones); } if (opts.o_count == 1) break; /* * If poll() returns -1 and sets errno to EINTR here because * the process received a signal, it is Ok to abort this * timeout and loop around because we check the signals at the * top of the loop. */ if (opts.o_outpmode & OPT_TTY) { if (poll(&pollset, (nfds_t)1, timeout) > 0) { if (read(STDIN_FILENO, &key, 1) == 1) { if (tolower(key) == 'q') break; } } } else { (void) sleep(opts.o_interval); } } while (opts.o_count == (-1) || --opts.o_count); if (opts.o_outpmode & OPT_TTY) (void) putchar('\r'); return (0); }
IC35L080AVVA07::IC35L080AVVA07() { std::cout << "Creating IBM 120GXP IC35L080AVVA07" << std::endl; nsurfaces = 4; bytes_per_sector = 512; cmd_ovh = 0.0002; // in s seek_time = 0.0082; // in s rot_latency = 0.00417; // in s head_switch_time = 0.0015; // in s cyl_switch_time = 0.002; // in s revolution_time = 0.0083; // in s interface_speed = 100000000; // in byte/s int first_sect = 0; int last_cyl = 0; add_zone(last_cyl, 1938, 928, first_sect); add_zone(last_cyl, 3756, 921, first_sect); add_zone(last_cyl, 5564, 896, first_sect); add_zone(last_cyl, 7687, 896, first_sect); add_zone(last_cyl, 9526, 888, first_sect); add_zone(last_cyl, 11334, 883, first_sect); add_zone(last_cyl, 13331, 864, first_sect); add_zone(last_cyl, 15128, 850, first_sect); add_zone(last_cyl, 16925, 840, first_sect); add_zone(last_cyl, 18922, 822, first_sect); add_zone(last_cyl, 20709, 806, first_sect); add_zone(last_cyl, 22601, 792, first_sect); add_zone(last_cyl, 24138, 787, first_sect); add_zone(last_cyl, 26024, 768, first_sect); add_zone(last_cyl, 27652, 752, first_sect); add_zone(last_cyl, 29501, 740, first_sect); add_zone(last_cyl, 31234, 725, first_sect); add_zone(last_cyl, 33009, 698, first_sect); add_zone(last_cyl, 34784, 691, first_sect); add_zone(last_cyl, 36609, 672, first_sect); add_zone(last_cyl, 38374, 648, first_sect); add_zone(last_cyl, 40139, 630, first_sect); add_zone(last_cyl, 41904, 614, first_sect); add_zone(last_cyl, 43519, 595, first_sect); add_zone(last_cyl, 45250, 576, first_sect); add_zone(last_cyl, 47004, 552, first_sect); add_zone(last_cyl, 48758, 533, first_sect); add_zone(last_cyl, 50491, 512, first_sect); add_zone(last_cyl, 52256, 493, first_sect); add_zone(last_cyl, 54010, 471, first_sect); add_zone(last_cyl, 55571, 448, first_sect); #if 0 set<Zone, ZoneCmp>::iterator it = zones.begin(); int i = 0; for ( ; it != zones.end(); it++, i++) { //const int block_size = 128*3*1024* 4; // one cylinder std::cout << "Zone " << i << " first sector: " << (*it).first_sector; std::cout << " sectors: " << (*it).sectors << " sustained rate: "; std::cout << (*it).sustained_data_rate / 1024 / 1024 << " MiB/s" << std::endl; } std::cout << "Last sector : " << first_sect << std::endl; std::cout << "Approx. capacity: " << (first_sect / 1024 / 1024) * bytes_per_sector << " MiB" << std::endl; #endif std::cout << "Transfer 16 MiB from zone 0 : " << get_delay(0, 16 * 1024 * 1024) << " s" << std::endl; std::cout << "Transfer 16 MiB from zone 30: " << get_delay(file::offset_type(158204036) * file::offset_type(bytes_per_sector), 16 * 1024 * 1024) << " s" << std::endl; }