コード例 #1
0
ファイル: DHT.hpp プロジェクト: HPCProjectsTry/grappa
    void lookup ( K key, CF f ) {
      uint64_t index = computeIndex( key );
      GlobalAddress< Cell > target = base + index; 

      // FIXME: remove 'this' capture when using gcc4.8, this is just a bug in 4.7
      //TODO optimization where only need to do remotePrivateTask instead of call_async
      //if you are going to do more suspending ops (comms) inside the loop
      Grappa::spawnRemote<GCE>( target.core(), [key, target, f, this]() {
        Entry e;
        if (lookup_local( key, target.pointer(), &e)) {
          f(e.value);
        }
      });
    }
コード例 #2
0
ファイル: DHT.hpp プロジェクト: HPCProjectsTry/grappa
    bool lookup ( K key, V * val ) {          
      uint64_t index = computeIndex( key );
      GlobalAddress< Cell > target = base + index; 

      // FIXME: remove 'this' capture when using gcc4.8, this is just a bug in 4.7
      lookup_result result = Grappa::delegate::call( target.core(), [key,target,this]() {

        DHT_TYPE(lookup_result) lr;

        Entry e;
        if (lookup_local( key, target.pointer(), &e)) {
          lr.valid = true;
          lr.result = e.value;
        }

        return lr;
      });

      *val = result.result;
      return result.valid;
    } 
コード例 #3
0
ファイル: lex.c プロジェクト: knicos/Cadence-Eden
static int
id_token(void)
{
    extern symptr lookup(char *, int);
    extern symptr install(char *, int, int, int, Int);
    extern int  local_declare(char *);
    extern int  lookup_local(char *);
    int         i;
    symptr      sp;
    char        *tempyytext;
    char	*tempagentname;
    char	aname[80];
	int context;
	void *tempoid;

	context = basecontext;
    tempagentname = agentName;

    while (isalnum(nextc) || nextc == '_') {
      input();
    }

	end_text1();

    /* printf("yytext %s", yytext); */
    if ((i = keyword_token(yytext))) {	/* keyword ? */
      if (i==EVAL) inEVAL = 1;
      end_text();
      return i;		/* return the lexeme */
    }

	if (nextc == ':') {
		if (peek() == ':') {
			strcpy(aname, yytext);
			tempagentname = aname;
			input();
			input();
			end_text();
			clear_text();
	
			while (isalnum(nextc) || nextc == '_') {
				input();
			}
	
			end_text1();
		}
	
	}


    if (inauto || inpara) {	/* declaring local variables ? */
        end_text();
	yylval.narg = local_declare(yytext);
	return LOCAL;
    } else {			/* in statements */
	if ((i = lookup_local(yytext))) {	/* local variable ? */
            end_text();
	    if (i < 0) {	/* it is an argument */
		yylval.narg = -i;
		return ARG;
	    } else {		/* it is a local variable */
		yylval.narg = i;
		return LOCAL;
	    }
	} else {
	    if (builtin_ft_check(yytext) == 0) {
	      /* Don't append (pre or post) an agent name if: 1) if a
                 built-in function, 2) if we're in the general context
                 (no >> syntax etc used), 3) the definitions are from
                 a Scout window definition, 4) similarly, if the
                 definitions are from a Donald 'within' definition, 5)
                 if the name already has a ~ prefix [Ash, with
                 Patrick] */
	      /* printf("yytext1 = %s %s %i %i %i\n", yytext, agentName,
		 appAgentName, append_agentName, append_NoAgentName); */
	       if (*tempagentname != 0 && appAgentName > 0 && append_agentName > 0
	           && append_NoAgentName > 0) {
		   /*tempyytext = yytext;
		   new_yytext[0] = '\0';
                   if (yytext[0] == '_' && inPrefix) {
                     strcat(new_yytext, "_");
                     tempyytext++;
                   }
		   if (inPrefix) strcat(new_yytext, agentName);
		      else  strcat(new_yytext, tempyytext);
		   strcat(new_yytext, "_"); *//* New double underbar for DOSTE context [Nick] */
		   /*if (inPrefix) strcat(new_yytext, tempyytext);
		      else  strcat(new_yytext, agentName);
          	   strcpy(yytext, new_yytext);
          	   yyleng = strlen(yytext);*/
 		   /*   printf("agentName = %s \n", agentName);  */
		   /* printf("yytext = %s \n", yytext); */

			/* Make a context from agent name [Nick] */
			context = doste_context(tempagentname);
	       }

		
	    }
	    end_text();

	    /* must be global [Ash] */
 	    if ((sp = lookup(yytext, context)) == 0)  {
	      /* doesn't already exist [Ash] */
	      sp = install(yytext,context, VAR, UNDEF, 0);
	      /* printf("new_yytext = %s", yytext);  */
            }
#ifdef DISTRIB
            if (!strcmp(sp->name, "higherPriority")) setHighPrior=1;
#endif /* DISTRIB */
	    yylval.sym = sp;
	    return sp->stype;
	}
    }
}
コード例 #4
0
// search inode by use imap (step1: flag 1 = only directory ; step2: flag 0 = only file)
static void search_imap_inode(char* des_dir, __u32 t_after, __u32 t_before, int flag)
{
struct ext2_group_desc 			*gdp;
struct 	ext2_inode_large 		*inode;
//struct dir_list_head_t 			*dir = NULL;
struct ring_buf* 			i_list = NULL;
r_item*					item = NULL;
int  					zero_flag, retval, load, x ,i ;
char 					*pathname = NULL;
char					*i_pathname = NULL;
char 					*buf= NULL;
unsigned char				*tmp_buf = NULL;
__u32 					blocksize, inodesize, inode_max, inode_per_group, block_count;
__u32 					inode_per_block , inode_block_group, group;
blk_t 					block_nr;
__u32   				c_time, d_time, mode;
ext2_ino_t 				first_block_inode_nr , inode_nr;


pathname = malloc(26);
blocksize = current_fs->blocksize;
inodesize = current_fs->super->s_inode_size;
inode_max = current_fs->super->s_inodes_count;
inode_per_group = current_fs->super->s_inodes_per_group;
buf = malloc(blocksize);
if (! (flag & 0x01) ){
	tmp_buf = malloc (12 * blocksize);
	if (!tmp_buf)
		goto errout;
	cookie = magic_open(MAGIC_MIME | MAGIC_NO_CHECK_COMPRESS | MAGIC_NO_CHECK_ELF | MAGIC_CONTINUE);
	if ((! cookie) ||  magic_load(cookie, NULL)){
		fprintf(stderr,"ERROR: can't find libmagic\n");
		goto errout;
	}
}

inode_per_block = blocksize / inodesize;
inode_block_group = inode_per_group / inode_per_block;

for (group = 0 ; group < current_fs->group_desc_count ; group++){
#ifdef EXT2_FLAG_64BITS
	gdp = ext2fs_group_desc(current_fs, current_fs->group_desc, group);
#else
	gdp = &current_fs->group_desc[group];
#endif
	zero_flag = 0;

	if (!(flag & 0x02)){ //skip this in disaster mode
		// NEXT GROUP IF INODE NOT INIT
		if (gdp->bg_flags & (EXT2_BG_INODE_UNINIT)) continue;
	
		// SET ZERO-FLAG IF FREE INODES == INODE/GROUP for fast ext3 
		if (gdp->bg_free_inodes_count == inode_per_group) zero_flag = 1;
	}

//FIXME for struct ext4_group_desc 48/64BIT	
	for (block_nr = gdp->bg_inode_table , block_count = 0 ;
			 block_nr < (gdp->bg_inode_table + inode_block_group); block_nr++, block_count++) {
		
		if (!(flag & 0x02)){ //skip this in disaster mode
			// break if the first block only zero inode
			if ((block_count ==1) && (zero_flag == (inode_per_block + 1))) break;
		}

//FIXME  inode_max ????	
		first_block_inode_nr = (group * inode_per_group) + (block_count * inode_per_block) + 1;
		load = 0;
		for (i = 0; i<inode_per_block;i++){
			if ( ! ext2fs_test_block_bitmap(imap,first_block_inode_nr + i)){
				load++;
				break;
			}
		}

		if (load){		 
			retval = read_block ( current_fs , &block_nr , buf);
			if (retval) return;

			for (inode_nr = first_block_inode_nr ,x = 0; x < inode_per_block ; inode_nr++ , x++){

				if ( ! ext2fs_test_block_bitmap(imap,inode_nr)){
	
					inode = (struct ext2_inode_large*) (buf + (x*inodesize));
					c_time = ext2fs_le32_to_cpu(inode->i_ctime);
					mode = ext2fs_le32_to_cpu(inode->i_mode);
					if ( ! ( flag & 0x02)) { 
						//no check this inode in disaster mode
 						if ((! c_time ) && (!(inode->i_mode & LINUX_S_IFMT)) ) {
							if(zero_flag) zero_flag++ ;
						continue;
						}
	
						d_time = ext2fs_le32_to_cpu(inode->i_dtime);
						if ( (! d_time) || d_time <= t_after){
							ext2fs_mark_generic_bitmap(imap,inode_nr);
						continue;
						}
					}
// 1. magical step 
					if (LINUX_S_ISDIR(mode) && ( flag & 0x01) && (pathname)){ 
						sprintf(pathname,"<%lu>",(long unsigned int)inode_nr);

	
						struct dir_list_head_t * dir = NULL;
						if (flag & 0x02){
							//disaster mode 
							//only search for undeleted entry 
							dir = get_dir3(NULL,0, inode_nr , "MAGIC-1",pathname, t_after,t_before, 0);
							if (dir) {
								lookup_local(des_dir, dir,t_after,t_before, RECOV_ALL | LOST_DIR_SEARCH );
								clear_dir_list(dir);
							}
						}
						else{   //search for all 
							dir = get_dir3(NULL,0, inode_nr , "MAGIC-1",pathname, t_after,t_before, DELETED_OPT);
							if (dir) {
								lookup_local(des_dir,dir,t_after,t_before,DELETED_OPT|RECOV_ALL|LOST_DIR_SEARCH);
								clear_dir_list(dir);
							}
						}

						
					}

// 2. magical step
					if (! (flag & 0x01) ){
						i_list = get_j_inode_list(current_fs->super, inode_nr);
						item = get_undel_inode(i_list,t_after,t_before);
						ext2fs_mark_generic_bitmap(imap,inode_nr);

						if (item) {
							if (! LINUX_S_ISDIR(item->inode->i_mode) ) {
								i_pathname = identify_filename(i_pathname, tmp_buf,
										(struct ext2_inode*)item->inode, inode_nr);
								sprintf(pathname,"<%lu>",(long unsigned int)inode_nr);
								recover_file(des_dir,"MAGIC-2", ((i_pathname)?i_pathname : pathname),
									     (struct ext2_inode*)item->inode, inode_nr, 0);
								if(i_pathname){
									free(i_pathname);
									i_pathname = NULL;
								}
							}
						}
						if (i_list) ring_del(i_list);
					}	
				}
			}
		}
	}
}
errout:
	if (pathname)
		 free(pathname);

	if(buf) {
		free(buf);
		buf = NULL;
	}

	if (tmp_buf){
		free(tmp_buf);
		tmp_buf = NULL;
	}
	if (cookie){
		magic_close(cookie);
		cookie = 0;
	}
return;
}