Example #1
0
File: set.c Project: jhlxz2003/akb
int
cgiMain()
{
	int act;
	int ret;

	act = check_from();
	switch (act)
	{
	case -1:
		do_error("用户名或密码错误");
		break;
	case 0:
		if (auth_check() < 0)
		{
			do_error("用户名或密码错误");
			return 0;
		}
		show_basic_page();
		break;
	case 1:
		handle_basic();
		break;
	case 2:
		handle_security();
		break;
	case 3:
		ret = what_action();
		if (ret == 0)
			reboot(LINUX_REBOOT_CMD_RESTART);
		else if (ret == 1)
			show_cdev_page();
		break;
	case 4:
		handle_cdev();
		break;
	case 5:
		handle_breq();
		break;
	case 6:
		handle_scene();
		break;
	case 7:
		handle_slnk();
		break;
	case 128:
		reboot(LINUX_REBOOT_CMD_RESTART);
		break;
	default:
		break;
	}

	return 0;
}
Example #2
0
void
umain(int argc, char **argv)
{
	int r;

	static_assert(sizeof(struct BlockInfo) == 64);
	static_assert(BLOCKINFOMAP + (DISKSIZE / BLKSIZE) * sizeof(struct BlockInfo) <= DISKMAP);
	assert(thisenv->env_id == ENVID_BUFCACHE);

	binaryname = "bufcache";
	cprintf("bufcache is running\n");

	// Check that we are able to do I/O

	// If it looks like I/O will definitely fail, then yield first to
	// other runnable, non-idle environments.
	// (This helps previous grading scripts: environment IDs are as
	// expected, but tests still complete quickly.)
	while (!(thisenv->env_tf.tf_eflags & FL_IOPL_MASK)
	       && another_runnable_environment_exists())
		sys_yield();

	outw(0x8A00, 0x8A00);
	cprintf("bufcache can do I/O\n");

	// Find a JOS disk.  Use the second IDE disk (number 1) if available.
	if (ide_probe_disk1())
		ide_set_disk(1);
	else
		ide_set_disk(0);

	// Set up the flush pipe
	if ((r = pipe(p)) < 0)
		panic("Error setting up pipe: %e\n", r);

	// Process incoming requests
	while (1) {
		int32_t breq;
		envid_t envid;

		breq = ipc_recv(&envid, 0, 0);
		handle_flush_queue();
		handle_breq(envid, breq);
	}
}