示例#1
0
/* process group descriptors */
static int process_group_desc(
		struct bio *bio, 
		struct xen_vbd *vbd, 
		struct label *label
) {
	struct ext3_group_desc *desc;
	struct ljx_ext3_superblock *lsb = vbd->superblock;
	struct label *tlabel;
	unsigned int num_groups;
	int i, ret;
	void *buf;

	num_groups = label->nr_sec * SECTOR_SIZE / sizeof(struct ext3_group_desc);
	num_groups = lsb->groups_count;
	buf = kzalloc(num_groups * sizeof(struct ext3_group_desc), GFP_KERNEL);
	if ((ret = copy_block(bio, buf, 0, num_groups * sizeof(struct ext3_group_desc))))
		return ret;

	JPRINTK("scanning %u groups", num_groups);
	for (i = 0; i < num_groups; i++) {
		desc = (struct ext3_group_desc *) (buf + i * sizeof(struct ext3_group_desc));
		tlabel = insert_label(
				&vbd->label_list,
				le32_to_cpu(desc->bg_inode_table) * lsb->block_size,
				lsb->inodes_per_group * lsb->inode_size / SECTOR_SIZE,
				INODE_BLOCK);
		tlabel->processor = &process_inode_block;
		JPRINTK("group %u desc:", i);
		JPRINTK("\tblock_bitmap: %u, inode_bitmap: %u, used_dirs: %u",
				le32_to_cpu(desc->bg_block_bitmap),
				(unsigned int) le32_to_cpu(desc->bg_inode_bitmap),
				(unsigned int) le32_to_cpu(desc->bg_used_dirs_count));
	}

	kfree(buf);

	return 0;
}
示例#2
0
static object *insert_ltable(char *column, char *limit, line_item *v, int type)
{
   short		 global = masm_level;
   char			*s;
   object		*o = NULL;
   paragraph		*p, *q;

   line_item		 vnew;
   value		*vlbase;

   int			 x, size;
   int			 base_displacement = 0;

   #ifdef STRUCTURE_DEPTH
   object		*adhesionp
			= (active_x) ? active_instance[active_x - 1]
                                     : NULL;

   int			 adhesion_level = -1;
   int			 b4 = type;
   #endif

   if (type == UNDEFINED) global = 0;
   else
   {
      load_name(column, limit);
      if (label_highest_byte == 0) return NULL;

      #ifdef SYNONYMS
      if (*label_margin == '(') load_qualifier(label_margin, limit);
      #endif

      s = label_margin;

      while (*s++ == '*') global--;
   }


   #ifdef STRUCTURE_DEPTH

   if ((adhesionp) && (global == adhesionp->l.passflag)
   &&  (type) && (type ^ SET) && (type ^ BLANK))
   {
      o = findlabel_in_node();
      adhesion_level = adhesionp->l.r.l.xref;
      if (adhesion_level < 0) adhesion_level = 0;
      global = adhesion_level;
      if (uselector['B'-'A'])
      printf("[L%x:A%x:G%x:V%x:P%X]%s:%s\n",
              masm_level, adhesion_level, global, type,
              adhesionp->l.passflag,
              adhesionp->l.name, name);
   }

   else
   {
      if (global > 0)
      {
         o = retrieve_dynamic_label();

         if (o)
         {
            if (o->l.r.l.xref ^ global) o = NULL;
         }
      }
      else
      {
         #ifdef HASH
         o = hash_locate(0);
         #else
         o = retrieve_label();
         #endif
      }
   }

   #else

   if (global > 0)
   {
      o = retrieve_dynamic_label();

      if (o)
      {
         if (o->l.r.l.xref ^ global) o = NULL;
      }
   }
   else
   {
      #ifdef HASH
      o = hash_locate(0);
      #else
      o = retrieve_label();
      #endif
   }

   #endif

   if ((type == LOCATION) || (type == BLANK))
   {
      if (x = actual->flags & 129)
      {
         vnew = *v;
         v = &vnew;

         if (x & 128)
         {
            if (type == LOCATION) type = EQUF;
            v->b[RADIX/8-5] = actual->rbase;
            base_displacement = 1;
         }

         if (x == 1)
         {
            vlbase = (value *) actual->runbank;
            operand_add(v, &vlbase->value);
         }
      }
   }

   if (o)
   {
      if (type == BLANK) return o;

      x = o->l.valued;

      if (x == BLANK)
      {
         o->l.valued = type;
         o->l.value = *v;
         return o;
      }

      /*************************************

	$blank does not alter any label
	which already exists

      *************************************/
 
      #ifdef RECORD
      if (type == RECORD)
      {
         if ((branch_record == 0) && (record_nest == 0)) base_displacement = 1;
         type = EQUF;

         if (actual->flags & 128)
         {
            vnew = *v;
            v = &vnew;
            v->b[RADIX/8-5] = actual->rbase;
         }
      }
      #endif

      if (x)
      {
         if (type ^ x)
         {
            if ((pass) && ((type == LOCATION) || (base_displacement)))
            {
               if ((x == EQU) || (x == SET) || (x == EQUF))
               return o;
            }

            flagp(o->l.name, "may not be retyped");
            return o;
         }
      }

      if (type == FORM) return o;

      if (type == SET)
      {
      }
      else
      {
         if (background_pass)
         {
            if       (type == LOCATION) checkwave(v, o, actual->flags);
            else if (base_displacement) checkwaveb(v, o); 
         }
         else
         {
            #ifdef BINARY
            if (o->l.valued == UNDEFINED) o->l.valued = type;
            else
            #endif
            {
               flagp1p(o->l.name, "may not be restated");
               return o;
            }
         }
      }
   }
   else
   {
      #ifdef EQUAZE
      if ((type == EQU) || (type == SET)) type = BLANK;
      #endif

      size = sizeof(label) + label_length - PARAGRAPH;

      if (global > 0)
      {
         flotsam -= size;

         if (flotsam < 0)
         {
            flag_either_pass("too many dynamic labels", "abandon");
            exit(0);
         }

         o = floatop;
         floatop = (object *) ((char *) floatop + size);
         o->l.along = NULL;
         floatop->i = 0;
      }
      else
      {
         o = lr;

         if (remainder < size) o = buy_ltable();

         remainder -= size;

         lr = (object *) ((char *) lr + size);
      }

      lr->i = 0;

      p = (paragraph *) o->l.name;
      q = (paragraph *)      name;
      x = label_length >> 2;

      while (x--) *p++ = *q++;

      o->l.r.i = 0;
      o->l.r.l.xref = global;

      #ifdef HASH
      o->l.hashlink = NULL;
      #endif

      #ifdef BINARY
      o->l.link = NULL;
      #endif

      o->l.down = NULL;
      o->l.along = NULL;
      o->h.type = LABEL;
      o->h.length = size;
      o->l.passflag = 0;

      o->l.valued = type;

      if (type == SET) o->l.value = zero_o;

      if (global > 0)
      {
      }
      else
      {
         #ifdef STRUCTURE_DEPTH
         if ((active_x) && (global == adhesion_level)
         &&  (b4) && (b4 ^ SET) && (b4 ^ BLANK)) inslabel(o);
         else
         #endif
         {
            #ifdef HASH

            hash_in(o);

            #endif
 
            if ((list) || (o->l.valued  == UNDEFINED))
            {
               insert_label(o);
            }
         }
      }
   }

   if (type == SET) 
   {
   }
   else o->l.value = *v;

   o->l.passflag = masm_level;

   if ((uselector['L'-'A']) && (masm_level))
   {
      printf("[%x<-%x:%x:%s:%d:%s]\n", masm_level, global, type,
              file_label[depth]->l.name, ll[depth], o->l.name);
   }

   if ((type == LOCATION) || (type == BLANK))
   {
      o->l.r.l.rel = counter_of_reference | 128;

      if (actual->relocatable) o->l.r.l.y |= 1;
      else                     o->l.r.l.y &= 254;
   }

   if (base_displacement) o->l.r.l.rel = counter_of_reference | 128;

   return o; 
}
示例#3
0
/**
 * Based on fs/ext3/super.c:1630. Can't use bread, however. 
 */
extern int ljx_ext3_fill_super(
		struct xen_vbd *vbd,
		struct ext3_super_block *sb, 
		int silent
) {
	struct ljx_ext3_superblock *lsb;
	struct ljx_ext3_superblock **pp_lsb; 
	struct label *label;
	unsigned int blocksize, db_count, i, block, groups_left;

	lsb = kzalloc(sizeof(struct ljx_ext3_superblock), GFP_KERNEL);
	if (! lsb)
		return -ENOMEM;
	pp_lsb = &vbd->superblock;
	*pp_lsb = lsb;

	/* compute blocksize
	minsize = bdev_logical_block_size(vbd->bdev);
	size = EXT3_MIN_BLOCK_SIZE;
	if (size < minsize)
		size = minsize;
	*/
	blocksize = vbd->bdev->bd_block_size;

	lsb->inodes_count      =  le32_to_cpu(sb->s_inodes_count);
	lsb->blocks_count      =  le32_to_cpu(sb->s_blocks_count);
	lsb->inode_size        =  le32_to_cpu(sb->s_inode_size);
	lsb->first_data_block  =  le32_to_cpu(sb->s_first_data_block);
	lsb->log_block_size    =  le32_to_cpu(sb->s_log_block_size);
	lsb->log_frag_size     =  le32_to_cpu(sb->s_log_frag_size);
	lsb->blocks_per_group  =  le32_to_cpu(sb->s_blocks_per_group);
	lsb->frags_per_group   =  le32_to_cpu(sb->s_frags_per_group);
	lsb->inodes_per_group  =  le32_to_cpu(sb->s_inodes_per_group);
	lsb->first_inode       =  le32_to_cpu(sb->s_first_ino);
	lsb->journal_inum      =  le32_to_cpu(sb->s_journal_inum);
	lsb->inodes_per_block  =  blocksize / le32_to_cpu(sb->s_inode_size);
	lsb->desc_per_block    =  blocksize / sizeof(struct ext3_group_desc);
	lsb->groups_count      =  ((le32_to_cpu(sb->s_blocks_count) -
			       le32_to_cpu(sb->s_first_data_block) - 1)
				       / lsb->blocks_per_group) + 1;
	lsb->first_meta_bg     =  le32_to_cpu(sb->s_first_meta_bg);
	lsb->feature_incompat  =  le32_to_cpu(sb->s_feature_incompat);
	lsb->feature_ro_compat  =  le32_to_cpu(sb->s_feature_ro_compat);
	lsb->block_size		=  EXT3_MIN_BLOCK_SIZE << lsb->log_block_size;

	db_count = DIV_ROUND_UP(lsb->groups_count, lsb->desc_per_block);
	lsb->group_desc = kzalloc(db_count * sizeof(struct ljx_ext3_group_desc *),
			GFP_KERNEL);
	if (lsb->group_desc == NULL)
		return -ENOMEM;
	lsb->group_desc = kzalloc(db_count * sizeof(*lsb->group_desc), GFP_KERNEL);
	groups_left = lsb->groups_count;
	for (i = 0; i < db_count; i++) {
		block = descriptor_loc(lsb, i);
		lsb->group_desc[i].init = false;
		lsb->group_desc[i].location = block;
		JPRINTK("group desc at %u", block);
		label = insert_label(
				&vbd->label_list, 
				block, 
				8,
				GROUP_DESC
		);
		label->processor = &process_group_desc;
	}
	JPRINTK("Total number of groups: %u", lsb->groups_count);
	print_label_list(&vbd->label_list);

	return 0;
}
示例#4
0
文件: parse.c 项目: elboza/WiCE
void read_file(char *filename,struct Process **pproc)
{
	FILE *fp;
	char *endfile,line[MAXSTR],*p,save_token[MAXSTR];
	int label_bool=0,line_count=0,num_code=0,n_args;
	struct instruction_node *new_instr;
	struct Process *proc;
	struct expr_node *new_expr;
	proc=(struct Process*)malloc(sizeof(struct Process));
	if(proc==NULL) die("errore nell'allocare struct Process");
	proc->pt=NULL;
	proc->pc=NULL;
	proc->prev=NULL;
	proc->next=NULL;
	proc->processID=get_processID();
	fp=fopen(filename,"r");
	if(fp==NULL) die("error opening file");
	proc->pc=(struct process_construct*)malloc(sizeof(struct process_construct));
	if(proc->pc==NULL) die("errore nell'allocare process_construct");
	proc->pc->first=NULL;
	proc->pc->last=NULL;
	proc->pc->len=0;
	proc->pc->org[0]='\0';
	proc->pc->vt_first=NULL;
	proc->pc->vt_last=NULL;
	while((endfile=fgets(line,MAXSTR,fp))!=NULL)
	{
		line_count++;
		p=&line[0];
		if(*p==';') continue;
		p=skip_space(p);
		if(*p=='\n') continue;
		p=get_token(p);
		p=skip_space(p);
		if((strcmp(my_token,"org"))==0) 
		{
			p=get_word(p);strncpy(proc->pc->org,my_token,MAXSTR);
			if(*p!='\n') {sprintf(save_token,"parse error at line %d. not an end line after the org argument",line_count);die(save_token);}
			continue;
		}
		if((strcmp(my_token,"end"))==0) 
		{
			p=skip_space(p);
			if(*p!='\n') {sprintf(save_token,"parse error after 'end' at line %d.",line_count);die(save_token);}
			break;
		}
		if((strcmp(my_token,"assert"))==0) 
		{
			take_assert(p);
			new_expr=(struct expr_node*)malloc(sizeof(struct expr_node));
			if(new_expr==NULL)
			{printf("at line %d, ",line_count);die("error allocating new_expr");}
			p=skip_space(p);
			p=get_b_arg(&new_expr,p,line_count);
			insert_in_vt(ASSERT_STR,new_expr,line_count,proc);
			continue;
		}
		if(*p==':') 
		{
			insert_label(my_token,num_code,line_count,proc);p=skip_space(++p);
			if(*p=='\n') continue;
			p=get_token(p);
		}
		n_args=is_instr(my_token,line_count);
		if(n_args!=-1) 
		{
			new_instr=(struct instruction_node*)malloc(sizeof(struct instruction_node));
			if(new_instr==NULL) {printf("at line %d , ",line_count);die("error allocating new_instr");}
			strncpy(new_instr->instr,my_token,MAXSTR);
			new_instr->num_node=num_code++;
			new_instr->line_count=line_count;
			new_instr->prev=NULL;
			new_instr->next=NULL;
			new_instr->code=NULL;
			new_instr->left=NULL;
			new_instr->right=NULL;
			new_instr->laddr[0]='#';new_instr->laddr[1]='\0';
			new_instr->raddr[0]='#';new_instr->raddr[1]='\0';
			strcpy(new_instr->modifier,"NULL");
			if(*p=='.'){
				p=get_word(++p);is_modifier(my_token,line_count);
				strncpy(new_instr->modifier,my_token,MAXMOD);
			}
			p=skip_space(p);
			if(n_args>0)
			{
				p=get_addr_mode(p); //$ by default. the result is in my_token
				new_instr->laddr[0]=my_token[0];
				new_instr->laddr[1]='\0';
				//p=get_token(p);
				//new_instr->left=(struct expr_node*)malloc(sizeof(struct expr_node));
				//if(new_instr->left==NULL){
				//printf("at line %d , ",line_count);die("error alocating left expr");}
				p=get_arg(&new_instr->left,p,line_count);
				p=skip_space(p);
				if(n_args>1)
				{
					if(*p!=',')
					{printf("at line %d , ",line_count);die("a comma expected (,)");}
					p=skip_space(++p);
					p=get_addr_mode(p); //$ by default. the result is in my_token
					new_instr->raddr[0]=my_token[0];
					new_instr->raddr[1]='\0';
					//p=get_token(p);
					//new_instr->right=(struct expr_node*)malloc(sizeof(struct expr_node));
					//if(new_instr->right==NULL){
					//printf("at line %d , ",line_count);die("error allocating right expr");}
					p=get_arg(&new_instr->right,p,line_count);
					p=skip_space(p);
				}
			}
			if(*p!='\n')
			{printf("at line %d , ",line_count);die("not an ending line after command");}
			//add the node
			add_node(new_instr,proc);
			continue;
		}
		strncpy(save_token,my_token,MAXSTR);
		p=get_token(p);
		if((strcmp(my_token,"equ"))==0) 
		{
			new_expr=(struct expr_node*)malloc(sizeof(struct expr_node));
			if(new_expr==NULL)
			{printf("at line %d, ",line_count);die("error allocating new_expr");}
			p=skip_space(p);
			p=get_arg(&new_expr,p,line_count);
			insert_in_vt(save_token,new_expr,line_count,proc);
			continue;
		}
	}
	fclose(fp);
	proc->pc->len=num_code;
	add_proc(proc);
	*pproc=proc;
}