예제 #1
0
static int ocfs2_validate_gd_parent(struct super_block *sb,
				    struct ocfs2_dinode *di,
				    struct buffer_head *bh,
				    int resize)
{
	unsigned int max_bits;
	struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data;

	if (di->i_blkno != gd->bg_parent_dinode) {
		do_error("Group descriptor #%llu has bad parent pointer (%llu, expected %llu)\n",
			 (unsigned long long)bh->b_blocknr,
			 (unsigned long long)le64_to_cpu(gd->bg_parent_dinode),
			 (unsigned long long)le64_to_cpu(di->i_blkno));
	}

	max_bits = le16_to_cpu(di->id2.i_chain.cl_cpg) * le16_to_cpu(di->id2.i_chain.cl_bpc);
	if (le16_to_cpu(gd->bg_bits) > max_bits) {
		do_error("Group descriptor #%llu has bit count of %u\n",
			 (unsigned long long)bh->b_blocknr,
			 le16_to_cpu(gd->bg_bits));
	}

	/* In resize, we may meet the case bg_chain == cl_next_free_rec. */
	if ((le16_to_cpu(gd->bg_chain) >
	     le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) ||
	    ((le16_to_cpu(gd->bg_chain) ==
	     le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) && !resize)) {
		do_error("Group descriptor #%llu has bad chain %u\n",
			 (unsigned long long)bh->b_blocknr,
			 le16_to_cpu(gd->bg_chain));
	}

	return 0;
}
예제 #2
0
void
init_progress_rpt (void)
{

	/*
	 *  allocate the done vector
	 */

	if ((prog_rpt_done = (__uint64_t *)
		malloc(sizeof(__uint64_t)*glob_agcount)) == NULL ) {
		do_error(_("cannot malloc pointer to done vector\n"));
	}
	bzero(prog_rpt_done, sizeof(__uint64_t)*glob_agcount);

	/*
	 *  Setup comm block, start the thread
	 */

	pthread_mutex_init(&global_msgs.mutex, NULL);
	global_msgs.count = glob_agcount;
	global_msgs.interval = report_interval;
	global_msgs.done   = prog_rpt_done;
	global_msgs.total  = &prog_rpt_total;

	if (pthread_create (&report_thread, NULL,
		progress_rpt_thread, (void *)&global_msgs))
		do_error(_("unable to create progress report thread\n"));

	return;
}
예제 #3
0
파일: ldsvguts.c 프로젝트: usrshare/lincity
void
save_city (char *cname)
{
    char *s, *s2, *s3, *s4;
    int l;

    if ((l = strlen (cname)) < 2)
	return;
    if ((s = (char *) malloc (lc_save_dir_len + l + 16)) == 0)
	malloc_failure ();
    if ((s2 = (char *) malloc (lc_save_dir_len + l + 32)) == 0)
	malloc_failure ();
    if ((s3 = (char *) malloc ((lc_save_dir_len + l) * 2 + 32)) == 0)
	malloc_failure ();
    if ((s4 = (char *) malloc ((lc_save_dir_len + l) * 2 + 32)) == 0)
	malloc_failure ();

    sprintf (s, "%s%c%s", lc_save_dir, PATH_SLASH, cname);
    sprintf (s2, "%s%c%s", lc_save_dir, PATH_SLASH, "tmp-save");
    sprintf (s3, "gzip -f %s", s2);
    sprintf (s4, "mv %s.gz %s", s2, s);

    save_city_raw (s2);
    if (system (s3) != 0)
	do_error ("gzip failed while in save_city");
    if (system (s4) != 0)
	do_error ("mv failed while in save_city");

    free (s);
    free (s2);
    free (s3);
    free (s4);
}
예제 #4
0
파일: vmm.c 프로젝트: ZZJC1306/VMM
/* 将被替换页面的内容写回辅存 */
void do_page_out(Ptr_PageTableItem ptr_pageTabIt)
{
	unsigned int writeNum;
	if (fseek(ptr_auxMem, ptr_pageTabIt->auxAddr, SEEK_SET) < 0)
	{
#ifdef DEBUG
		printf("DEBUG: auxAddr=%u\tftell=%u\n", ptr_pageTabIt, ftell(ptr_auxMem));
#endif
		do_error(ERROR_FILE_SEEK_FAILED);
		exit(1);
	}
	if ((writeNum = fwrite(actMem + ptr_pageTabIt->blockNum * PAGE_SIZE, 
		sizeof(BYTE), PAGE_SIZE, ptr_auxMem)) < PAGE_SIZE)
	{

#ifdef DEBUG
		printf("DEBUG: auxAddr=%u\tftell=%u\n", ptr_pageTabIt->auxAddr, ftell(ptr_auxMem));
		printf("DEBUG: writeNum=%u\n", writeNum);
		printf("DEGUB: feof=%d\tferror=%d\n", feof(ptr_auxMem), ferror(ptr_auxMem));
#endif
		do_error(ERROR_FILE_WRITE_FAILED);
		exit(1);
	}
	printf("写回成功:物理块%u-->>辅存地址%03X\n", ptr_pageTabIt->auxAddr, ptr_pageTabIt->blockNum);

}
예제 #5
0
/* 将辅存内容写入实存 */
void do_page_in(Ptr_PageTableItem ptr_pageTabIt, unsigned int blockNum)
{
	unsigned int readNum;

	//打开辅存文件ptr_auxMem,从文件开头(SEEK_SET)处偏移ptr_pageTabIt->auxAddr(该页表在辅存中的位置)开始读取数据
	if (fseek(ptr_auxMem, ptr_pageTabIt->auxAddr, SEEK_SET) < 0)
	{
#ifdef DEBUG
		printf("DEBUG: auxAddr=%u\tftell=%u\n", ptr_pageTabIt->auxAddr, ftell(ptr_auxMem));
#endif
		do_error(ERROR_FILE_SEEK_FAILED);
		exit(1);
	}

	//从之前打开的ptr_auxMem文件流中读取数据,写入到实存中指定块的位置(actMem + blockNum * PAGE_SIZE)
	//读写字节的大小(sizeof(BYTE))           读写4个字节(PAGE_SIZE)

	//初始化时并没有设置辅存中的数据,所以辅存为空,读取会失败
	if ((readNum = fread(actMem + blockNum * PAGE_SIZE,
		sizeof(BYTE), PAGE_SIZE, ptr_auxMem)) < PAGE_SIZE)
	{
#ifdef DEBUG
		printf("DEBUG: auxAddr=%u\tftell=%u\n", ptr_pageTabIt->auxAddr, ftell(ptr_auxMem));
		printf("DEBUG: blockNum=%u\treadNum=%u\n", blockNum, readNum);
		printf("DEGUB: feof=%d\tferror=%d\n", feof(ptr_auxMem), ferror(ptr_auxMem));
#endif
		do_error(ERROR_FILE_READ_FAILED);
		exit(1);
	}
	printf("调页成功:辅存地址%u-->>物理块%u\n", ptr_pageTabIt->auxAddr, blockNum);

}
예제 #6
0
void do_list_all(int cli_fd, struct be_msg *rmsg)
{
  struct be_group *group = NULL;
  struct be_vc *curr;
  struct be_msg smsg;

  for(group = &group_head; group != NULL; group = group->next) {

    for(curr = group->head; curr != NULL; curr = curr->next) {

      smsg.msgtype = OK; 
      smsg.nas_idx = curr->nas_idx;
      smsg.uid     = curr->uid;
      memcpy(&smsg.pvc, &curr->pvc, sizeof(struct sockaddr_atmpvc));
      memcpy(&smsg.name, group->name, MAX_GROUPNAME_LEN);
      // brcm begin
      smsg.mode = curr->mode;
      // brcm end
      if( send(cli_fd, &smsg, sizeof(smsg), 0) < 0 )
	do_error(LOG_ERR,"do_list_all() couldn't send VC info: %s",strerror(errno));
    }

  }

  if(smsg.msgtype == OK) 
    smsg.msgtype = LIST_END;
  else
    smsg.msgtype = GROUP_NOT_FOUND;

  if( send(cli_fd, &smsg, sizeof(smsg), 0) < 0 )
    do_error(LOG_ERR,"do_list_all() couldn't send LIST_END message: %s",strerror(errno));
}
예제 #7
0
void
write_primary_sb(xfs_sb_t *sbp, int size)
{
	xfs_dsb_t	*buf;

	if (no_modify)
		return;

	buf = memalign(libxfs_device_alignment(), size);
	if (buf == NULL) {
		do_error(_("failed to memalign superblock buffer\n"));
		return;
	}
	memset(buf, 0, size);

	if (lseek64(x.dfd, 0LL, SEEK_SET) != 0LL) {
		free(buf);
		do_error(_("couldn't seek to offset 0 in filesystem\n"));
	}

	
	libxfs_sb_to_disk(buf, sbp, XFS_SB_ALL_BITS);

	if (write(x.dfd, buf, size) != size) {
		free(buf);
		do_error(_("primary superblock write failed!\n"));
	}

	free(buf);
}
예제 #8
0
/* 将被替换页面的内容写回辅存 */
void do_page_out(Ptr_PageTableItem ptr_pageTabIt)
{
	unsigned int writeNum;
	//同上,从辅存中相应页面的地址开始读写
	if (fseek(ptr_auxMem, ptr_pageTabIt->auxAddr, SEEK_SET) < 0)
	{
#ifdef DEBUG
		printf("DEBUG: auxAddr=%u\tftell=%u\n", ptr_pageTabIt, ftell(ptr_auxMem));
#endif
		do_error(ERROR_FILE_SEEK_FAILED);
		exit(1);
	}

	//fwrite()与fread()的区别是,fwrite()执行完之后必须关闭流fclose(),而fread()不关闭会将流移动到上次读写结束的地址
	if ((writeNum = fwrite(actMem + ptr_pageTabIt->blockNum * PAGE_SIZE,
		sizeof(BYTE), PAGE_SIZE, ptr_auxMem)) < PAGE_SIZE)
	{
#ifdef DEBUG
		printf("DEBUG: auxAddr=%u\tftell=%u\n", ptr_pageTabIt->auxAddr, ftell(ptr_auxMem));
		printf("DEBUG: writeNum=%u\n", writeNum);
		printf("DEGUB: feof=%d\tferror=%d\n", feof(ptr_auxMem), ferror(ptr_auxMem));
#endif
		do_error(ERROR_FILE_WRITE_FAILED);
		exit(1);
	}
	printf("写回成功:物理块%u-->>辅存地址%03X\n", ptr_pageTabIt->auxAddr, ptr_pageTabIt->blockNum);

	/********************************************************************************************************/
	//fclose(ptr_auxMem);   main函数里面关闭了
	/********************************************************************************************************/

}
예제 #9
0
void do_list_group(int cli_fd, struct be_msg *rmsg)
{
  struct be_group *group;
  struct be_vc *curr;
  struct be_msg smsg;

  smsg.msgtype = GROUP_NOT_FOUND;

  for(group = &group_head; group != NULL; group = group->next)
    if(!strncmp(rmsg->name,group->name,MAX_GROUPNAME_LEN))
      break;

  if(group) {
    for(curr = group->head; curr != NULL; curr = curr->next) {

      smsg.msgtype =  OK;
      smsg.nas_idx = curr->nas_idx;
      smsg.uid     = curr->uid;
      memcpy(&smsg.pvc, &curr->pvc, sizeof(struct sockaddr_atmpvc));
      memcpy(&smsg.name, &group->name, MAX_GROUPNAME_LEN);
      if( send(cli_fd, &smsg, sizeof(smsg), 0) < 0 )
	do_error(LOG_ERR,"do_list_group() couldn't send OK message: %s",strerror(errno));
    }

    smsg.msgtype = LIST_END;
  }

  if( send(cli_fd, &smsg, sizeof(smsg), 0) < 0 )
    do_error(LOG_ERR,"do_list_group() couldn't send LIST_END message: %s",strerror(errno));
}
예제 #10
0
static int ocfs2_validate_gd_parent(struct super_block *sb,
				    struct ocfs2_dinode *di,
				    struct buffer_head *bh,
				    int clean_error)
{
	unsigned int max_bits;
	struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data;

	if (di->i_blkno != gd->bg_parent_dinode) {
		do_error("Group descriptor #%llu has bad parent "
			 "pointer (%llu, expected %llu)",
			 (unsigned long long)bh->b_blocknr,
			 (unsigned long long)le64_to_cpu(gd->bg_parent_dinode),
			 (unsigned long long)le64_to_cpu(di->i_blkno));
		return -EINVAL;
	}

	max_bits = le16_to_cpu(di->id2.i_chain.cl_cpg) * le16_to_cpu(di->id2.i_chain.cl_bpc);
	if (le16_to_cpu(gd->bg_bits) > max_bits) {
		do_error("Group descriptor #%llu has bit count of %u",
			 (unsigned long long)bh->b_blocknr,
			 le16_to_cpu(gd->bg_bits));
		return -EINVAL;
	}

	if (le16_to_cpu(gd->bg_chain) >=
	    le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) {
		do_error("Group descriptor #%llu has bad chain %u",
			 (unsigned long long)bh->b_blocknr,
			 le16_to_cpu(gd->bg_chain));
		return -EINVAL;
	}

	return 0;
}
예제 #11
0
파일: net.c 프로젝트: johan--/netnuclear
void new_connection(TCPsocket sock) {
   TCPsocket tmp;
   struct socket_node *socket;
   IPaddress *ip;
 
/* accept the connection temporarily */
   tmp = SDLNet_TCP_Accept(sock);
   if (!tmp)
      do_error(SDLNet_GetError());

/* are we full or game already started? */
   if (get_active_players() + 1 > NUM_PLAYERS || current_turn)
      SDLNet_TCP_Close(tmp);
   else {
   /* nope! */
      socket = new_socket(SOCKET_CLIENT);
      socket->sock = tmp;
      if (SDLNet_TCP_AddSocket(sockset, tmp) < 0)
         do_error(SDLNet_GetError());

      ip = SDLNet_TCP_GetPeerAddress(tmp);
      if (!ip)
         do_error(SDLNet_GetError());
      if (SDLNet_ResolveIP(ip))
         strcpy(socket->host, SDLNet_ResolveIP(ip));
      else
         sprintf(socket->host, "Unknown IP");

      join_player(socket);	/*	add player to game	*/
   }
}
예제 #12
0
파일: vmm.c 프로젝트: ZZJC1306/VMM
void do_print_virtual(){
	int i,j,k,readNum,p;
	printf("打印辅存内容:\n");
	BYTE temp[VIRTUAL_MEMORY_SIZE];
	if (fseek(ptr_auxMem, 0, SEEK_SET) < 0)
	{
		do_error(ERROR_FILE_SEEK_FAILED);
		exit(1);
	}
	if ((readNum = fread(temp, 
		sizeof(BYTE), VIRTUAL_MEMORY_SIZE, ptr_auxMem)) < VIRTUAL_MEMORY_SIZE)
	{
		do_error(ERROR_FILE_READ_FAILED);
		exit(1);
	}
	printf("1级页号\t2级页号\t辅存\t内容\t\n");
	for(i=0,k=0;i<ROOT_PAGE_SUM;i++)
	{
		for(p=0;p<CHILD_PAGE_SUM;p++)
		{
			printf("%d\t%d\t%d\t",i,p,k);
			for(j=0;j<PAGE_SIZE;j++){
				printf("%02x ",temp[k++]);
			}
			printf("\n");
		}
	}
}
예제 #13
0
void
incore_ino_init(xfs_mount_t *mp)
{
	int i;
	int agcount = mp->m_sb.sb_agcount;

	if ((inode_tree_ptrs = malloc(agcount *
					sizeof(avltree_desc_t *))) == NULL)
		do_error(_("couldn't malloc inode tree descriptor table\n"));
	if ((inode_uncertain_tree_ptrs = malloc(agcount *
					sizeof(avltree_desc_t *))) == NULL)
		do_error(
		_("couldn't malloc uncertain ino tree descriptor table\n"));

	for (i = 0; i < agcount; i++)  {
		if ((inode_tree_ptrs[i] =
				malloc(sizeof(avltree_desc_t))) == NULL)
			do_error(_("couldn't malloc inode tree descriptor\n"));
		if ((inode_uncertain_tree_ptrs[i] =
				malloc(sizeof(avltree_desc_t))) == NULL)
			do_error(
			_("couldn't malloc uncertain ino tree descriptor\n"));
	}
	for (i = 0; i < agcount; i++)  {
		avl_init_tree(inode_tree_ptrs[i], &avl_ino_tree_ops);
		avl_init_tree(inode_uncertain_tree_ptrs[i], &avl_ino_tree_ops);
	}

	if ((last_rec = malloc(sizeof(ino_tree_node_t *) * agcount)) == NULL)
		do_error(_("couldn't malloc uncertain inode cache area\n"));

	memset(last_rec, 0, sizeof(ino_tree_node_t *) * agcount);

	full_ino_ex_data = 0;
}
예제 #14
0
파일: vmm.c 프로젝트: ZZJC1306/VMM
/* 将辅存内容写入实存 */
void do_page_in(Ptr_PageTableItem ptr_pageTabIt, unsigned int blockNum)
{
	unsigned int readNum;
	if (fseek(ptr_auxMem, ptr_pageTabIt->auxAddr, SEEK_SET) < 0)
	{
#ifdef DEBUG
		printf("DEBUG: auxAddr=%u\tftell=%u\n", ptr_pageTabIt->auxAddr, ftell(ptr_auxMem));
#endif
		do_error(ERROR_FILE_SEEK_FAILED);
		exit(1);
	}
	if ((readNum = fread(actMem + blockNum * PAGE_SIZE, 
		sizeof(BYTE), PAGE_SIZE, ptr_auxMem)) < PAGE_SIZE)
	{

#ifdef DEBUG
		printf("DEBUG: auxAddr=%u\tftell=%u\n", ptr_pageTabIt->auxAddr, ftell(ptr_auxMem));
		printf("DEBUG: blockNum=%u\treadNum=%u\n", blockNum, readNum);
		printf("DEGUB: feof=%d\tferror=%d\n", feof(ptr_auxMem), ferror(ptr_auxMem));
#endif
		do_error(ERROR_FILE_READ_FAILED);
		exit(1);
	}
	printf("调页成功:辅存地址%u-->>物理块%u\n", ptr_pageTabIt->auxAddr, blockNum);
}
예제 #15
0
__uint64_t
print_final_rpt(void)
{
	int i;
	struct tm *tmp;
	time_t now;
	__uint64_t *donep;
	__uint64_t sum;
	msg_block_t 	*msgp = &global_msgs;
	char		msgbuf[DURATION_BUF_SIZE];

	if (!ag_stride)
		return 0;

	if (pthread_mutex_lock(&global_msgs.mutex))
		do_error(_("print_final_rpt: cannot lock progress mutex\n"));

	bzero(&msgbuf, sizeof(msgbuf));

	now = time (NULL);
	tmp = localtime ((const time_t *) &now);

	/*
	*  Sum the work
	*/

	sum = 0;
	donep = msgp->done;
	for (i = 0; i < msgp->count; i++) {
		sum += *donep++;
	}

	if (report_interval) {
		switch(msgp->format->format) {
		case FMT1:
			sprintf (msgbuf, _(*msgp->format->fmt),
				tmp->tm_hour, tmp->tm_min, tmp->tm_sec,
				_(msgp->format->msg), sum,
				*msgp->total, _(*msgp->format->type));
			break;
		case FMT2:
			sprintf (msgbuf, _(*msgp->format->fmt),
				tmp->tm_hour, tmp->tm_min, tmp->tm_sec,
				_(msgp->format->msg), sum,
				_(*msgp->format->type));
			break;
		}
		do_log(_("%s"), msgbuf);
	}

	if (pthread_mutex_unlock(&global_msgs.mutex))
		do_error(_("print_final_rpt: cannot unlock progress mutex\n"));

	return(sum);
}
예제 #16
0
파일: net.c 프로젝트: johan--/netnuclear
void init_net() {
   if (SDLNet_Init() < 0)
      do_error("Failed initializing SDL_net (\"%s\")", SDLNet_GetError());

   sockset = SDLNet_AllocSocketSet(NUM_PLAYERS);
   if (!sockset)
      do_error(SDLNet_GetError());

   online = 0;
   server = 0;
}
예제 #17
0
파일: set.c 프로젝트: 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;
}
예제 #18
0
static int ocfs2_validate_gd_self(struct super_block *sb,
				  struct buffer_head *bh,
				  int resize)
{
	struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data;

	if (!OCFS2_IS_VALID_GROUP_DESC(gd)) {
		do_error("Group descriptor #%llu has bad signature %.*s",
			 (unsigned long long)bh->b_blocknr, 7,
			 gd->bg_signature);
		return -EINVAL;
	}

	if (le64_to_cpu(gd->bg_blkno) != bh->b_blocknr) {
		do_error("Group descriptor #%llu has an invalid bg_blkno "
			 "of %llu",
			 (unsigned long long)bh->b_blocknr,
			 (unsigned long long)le64_to_cpu(gd->bg_blkno));
		return -EINVAL;
	}

	if (le32_to_cpu(gd->bg_generation) != OCFS2_SB(sb)->fs_generation) {
		do_error("Group descriptor #%llu has an invalid "
			 "fs_generation of #%u",
			 (unsigned long long)bh->b_blocknr,
			 le32_to_cpu(gd->bg_generation));
		return -EINVAL;
	}

	if (le16_to_cpu(gd->bg_free_bits_count) > le16_to_cpu(gd->bg_bits)) {
		do_error("Group descriptor #%llu has bit count %u but "
			 "claims that %u are free",
			 (unsigned long long)bh->b_blocknr,
			 le16_to_cpu(gd->bg_bits),
			 le16_to_cpu(gd->bg_free_bits_count));
		return -EINVAL;
	}

	if (le16_to_cpu(gd->bg_bits) > (8 * le16_to_cpu(gd->bg_size))) {
		do_error("Group descriptor #%llu has bit count %u but "
			 "max bitmap bits of %u",
			 (unsigned long long)bh->b_blocknr,
			 le16_to_cpu(gd->bg_bits),
			 8 * le16_to_cpu(gd->bg_size));
		return -EINVAL;
	}

	return 0;
}
예제 #19
0
파일: vmm1.c 프로젝트: AdmiralTony/os-vmm
int do_input_request(){
	int Virtual_Address;
	int Progress;
	char Type;
	unsigned char content;
	printf("请输入合法要求 格式为 “地址 进程号 访问类型 写入数据(仅对写操作有效)\n格式的合法范围为0-255\n进程号的合法范围为0-1\n访问类型为:r(读)、w(写)、x(执行)\n写入数据仅在写时有效\n");
	scanf("%d %d", &Virtual_Address, &Progress);
	getchar();
	scanf("%c %c", &Type, &content);
	//printf("%d %d %c %02X", Virtual_Address, Progress, Type, content);
	if(Virtual_Address < 0 || Virtual_Address > VIRTUAL_MEMORY_SIZE){
		do_error(ERROR_ILLEGAL_INPUT);
		return 0;
	}
	if(Progress < 0 || Progress > VIRTUAL_PROGRESSES){
		do_error(ERROR_ILLEGAL_INPUT);
		return 0;
	}
	if(Type != 'w' && Type != 'r' && Type != 'x'){
		do_error(ERROR_ILLEGAL_INPUT);
		return 0;
	}
	switch(Type){
		case 'w':
			ptr_memAccReq->FromProgress = Progress;
			ptr_memAccReq->virAddr = Virtual_Address;
			ptr_memAccReq->reqType = REQUEST_WRITE;
			ptr_memAccReq->value = content;
			printf("读入请求:\n地址:%u\t类型:写入\t值:%02X\t 所属进程: %u\n", ptr_memAccReq->virAddr, ptr_memAccReq->value, ptr_memAccReq->FromProgress);
			
			break;
		case 'r':
			ptr_memAccReq->FromProgress = Progress;
			ptr_memAccReq->virAddr = Virtual_Address;
			ptr_memAccReq->reqType = REQUEST_READ;
			printf("读入请求:\n地址:%u\t类型:读取\t 所属进程: %u\n", ptr_memAccReq->virAddr, ptr_memAccReq->FromProgress);
			break;
		case 'x':
			ptr_memAccReq->FromProgress = Progress;
			ptr_memAccReq->virAddr = Virtual_Address;
			ptr_memAccReq->reqType = REQUEST_EXECUTE;
			printf("读入请求:\n地址:%u\t类型:执行\t 所属进程: %u\n", ptr_memAccReq->virAddr, ptr_memAccReq->FromProgress);
			break;
		default:
			do_error(ERROR_ILLEGAL_INPUT);
			break;
	}
	return 1;
}
예제 #20
0
파일: vmm.c 프로젝트: AdmiralTony/os-vmm
int main(int argc, char* argv[])
{
	int i;
	char c;
	int flag = 0;
	if (!(ptr_auxMem = fopen(AUXILIARY_MEMORY, "r+")))
	{
		do_error(ERROR_FILE_OPEN_FAILED);
		exit(1);
	}
	do_init();
	do_print_info();
	ptr_memAccReq = (Ptr_MemoryAccessRequest) malloc(sizeof(MemoryAccessRequest));
	/* 在循环中模拟访存请求与处理过程 */
	while (TRUE)
	{
		do_request();
loop:	do_response();
		printf("按Y打印页表,按其他键不打印...\n");
loop1:	if ((c = getchar()) == 'y' || c == 'Y')
			do_print_info();
		while (c != '\n')
			c = getchar();
		if(flag == 1){
			flag = 0;
			goto loop1;
		}
		printf("按X退出程序,按I手动输入请求,按其他键继续...\n");
		if ((c = getchar()) == 'x' || c == 'X')
			break;
		if (c == 'i' || c == 'I'){
			flag = do_input_request();
			if(flag == 1)
				goto loop;
			printf("1111\n");
		}
		while (c != '\n'){
			c = getchar();
		}
		//sleep(5000);
	}

	if (fclose(ptr_auxMem) == EOF)
	{
		do_error(ERROR_FILE_CLOSE_FAILED);
		exit(1);
	}
	return (0);
}
예제 #21
0
파일: error.c 프로젝트: kichik/nsis-1
void error(int code, ...)
{
    va_list ap;
    va_start(ap, code);
    do_error(code, ap);
    va_end(ap);
}
예제 #22
0
파일: lib.c 프로젝트: alexanderkyte/sparse
void warning(struct position pos, const char * fmt, ...)
{
	va_list args;

	if (Wsparse_error) {
		va_start(args, fmt);
		do_error(pos, fmt, args);
		va_end(args);
		return;
	}

	if (!max_warnings) {
		show_info = 0;
		return;
	}

	if (!--max_warnings) {
		show_info = 0;
		fmt = "too many warnings";
	}

	va_start(args, fmt);
	do_warn("warning: ", pos, fmt, args);
	va_end(args);
}
예제 #23
0
/* adds geometry info to linked list.  returns (sometimes new) head of list */
static fs_geo_list_t *
add_geo(fs_geo_list_t *list, fs_geometry_t *geo_p, int index)
{
	fs_geo_list_t	*current = list;

	while (current != NULL)  {
		if (memcmp(geo_p, &current->geo, sizeof(fs_geometry_t)) == 0)  {
			current->refs++;
			return(list);
		}

		current = current->next;
	}

	if ((current = malloc(sizeof(fs_geo_list_t))) == NULL) {
		do_error(_("couldn't malloc geometry structure\n"));
		exit(1);
	}

	current->geo = *geo_p;
	current->refs = 1;
	current->next = list;
	current->index = index;

	return(current);
}
예제 #24
0
파일: lib.c 프로젝트: alexanderkyte/sparse
void sparse_error(struct position pos, const char * fmt, ...)
{
	va_list args;
	va_start(args, fmt);
	do_error(pos, fmt, args);
	va_end(args);
}
예제 #25
0
void ftsh_error( int level, int line, const char *fmt, ... )
{
	va_list args;
	va_start(args,fmt);
	do_error(level,line,fmt,args);
	va_end(args);
}
예제 #26
0
/*
 * Common code for creating inode records for use by trees and lists.
 * called only from add_inodes and add_inodes_uncertain
 *
 * IMPORTANT:  all inodes (inode records) start off as free and
 *		unconfirmed.
 */
static struct ino_tree_node *
alloc_ino_node(
	struct xfs_mount	*mp,
	xfs_agino_t		starting_ino)
{
	struct ino_tree_node 	*irec;

	irec = malloc(sizeof(*irec));
	if (!irec)
		do_error(_("inode map malloc failed\n"));

	irec->avl_node.avl_nextino = NULL;
	irec->avl_node.avl_forw = NULL;
	irec->avl_node.avl_back = NULL;

	irec->ino_startnum = starting_ino;
	irec->ino_confirmed = 0;
	irec->ino_isa_dir = 0;
	irec->ir_free = (xfs_inofree_t) - 1;
	irec->ir_sparse = 0;
	irec->ino_un.ex_data = NULL;
	irec->nlink_size = sizeof(__uint8_t);
	irec->disk_nlinks.un8 = alloc_nlink_array(irec->nlink_size);
	irec->ftypes = alloc_ftypes_array(mp);
	return irec;
}
예제 #27
0
파일: error.cpp 프로젝트: Distrotech/groff
void warning(const char *format, 
	     const errarg &arg1,
	     const errarg &arg2,
	     const errarg &arg3)
{
  do_error(WARNING, format, arg1, arg2, arg3);
}
예제 #28
0
파일: error.cpp 프로젝트: Distrotech/groff
void error(const char *format, 
	   const errarg &arg1,
	   const errarg &arg2,
	   const errarg &arg3)
{
  do_error(ERROR, format, arg1, arg2, arg3);
}
예제 #29
0
파일: error.cpp 프로젝트: Distrotech/groff
void fatal(const char *format, 
	   const errarg &arg1,
	   const errarg &arg2,
	   const errarg &arg3)
{
  do_error(FATAL, format, arg1, arg2, arg3);
}
예제 #30
0
void
alloc_ex_data(ino_tree_node_t *irec)
{
	parent_list_t 	*ptbl;

	ptbl = irec->ino_un.plist;
	irec->ino_un.ex_data  = (ino_ex_data_t *)calloc(1, sizeof(ino_ex_data_t));
	if (irec->ino_un.ex_data == NULL)
		do_error(_("could not malloc inode extra data\n"));

	irec->ino_un.ex_data->parents = ptbl;

	switch (irec->nlink_size) {
	case sizeof(__uint8_t):
		irec->ino_un.ex_data->counted_nlinks.un8 =
			alloc_nlink_array(irec->nlink_size);
		break;
	case sizeof(__uint16_t):
		irec->ino_un.ex_data->counted_nlinks.un16 =
			alloc_nlink_array(irec->nlink_size);
		break;
	case sizeof(__uint32_t):
		irec->ino_un.ex_data->counted_nlinks.un32 =
			alloc_nlink_array(irec->nlink_size);
		break;
	default:
		ASSERT(0);
	}
}