Пример #1
0
void buddy_dump(buddy_ctxt_t *buddy)
{
    int i;
    printf("  <BUDDY BASE=%x MAX=%d ORDER=%d>\n", buddy->base, buddy->index_max, buddy->order);

    for(i = 0; i < buddy->order; i++) {
        int next, index = buddy->free[i];

        if(index != -1) {
            printf("    <ORDER %d>\n", i);
            for(;;) {
                buddy_block_t *block = buddy->all + index;

                if(index < 0 || index >= buddy->index_max) {
                    printf("      <BLOCK *** ERROR index=%d ***>", index);
                } else {
                    addr_t start = buddy->base + (index<< buddy->page_bits);
                    addr_t end   = start + (1UL << (GET_ORDER(block) + buddy->page_bits));

                    printf("      <BLOCK %s A=%x-%x ORDER=%d ME=%d NEXT=%d PREV=%d>\n",
                           IS_FREE(block) ? "free" : "in use",
                           start, end,
                           GET_ORDER(block),
                           index, GET_NEXT(block), GET_PREV(block)
                          );
                }
                next = GET_NEXT(block);
                if(index == next) break;
                index = next;
            }
        }
    }
}
Пример #2
0
static void	print_and_count(t_block *b, size_t *total)
{
	if (getenv("MALLOC_DEBUG"))
	{
		ft_putchar('\t');
		ft_putstr((IS_FREE(b)) ? "[free] " : "[    ] ");
		print_line_memory(b);
		if (!IS_FREE(b))
			*total += b->size;
	}
	else if (!IS_FREE(b))
	{
		print_line_memory(b);
		*total += b->size;
	}
}
Пример #3
0
static int msdos_readdir(struct inode *inode,struct file *filp,
    struct dirent *dirent,int count)
{
	int ino,i,i2,last;
	char c,*walk;
	struct buffer_head *bh;
	struct msdos_dir_entry *de;

	if (!inode || !S_ISDIR(inode->i_mode)) return -EBADF;
	if (inode->i_ino == MSDOS_ROOT_INO) {
/* Fake . and .. for the root directory. */
		if (filp->f_pos == 2) filp->f_pos = 0;
		else if (filp->f_pos < 2) {
				walk = filp->f_pos++ ? ".." : ".";
				for (i = 0; *walk; walk++)
					put_fs_byte(*walk,dirent->d_name+i++);
				put_fs_long(MSDOS_ROOT_INO,&dirent->d_ino);
				put_fs_byte(0,dirent->d_name+i);
				put_fs_word(i,&dirent->d_reclen);
				return i;
			}
	}
	if (filp->f_pos & (sizeof(struct msdos_dir_entry)-1)) return -ENOENT;
	bh = NULL;
	while ((ino = msdos_get_entry(inode,&filp->f_pos,&bh,&de)) > -1) {
		if (!IS_FREE(de->name) && !(de->attr & ATTR_VOLUME)) {
			for (i = last = 0; i < 8; i++) {
				if (!(c = de->name[i])) break;
				if (c >= 'A' && c <= 'Z') c += 32;
				if (c != ' ') last = i+1;
				put_fs_byte(c,i+dirent->d_name);
			}
			i = last;
			put_fs_byte('.',i+dirent->d_name);
			i++;
			for (i2 = 0; i2 < 3; i2++) {
				if (!(c = de->ext[i2])) break;
				if (c >= 'A' && c <= 'Z') c += 32;
				if (c != ' ') last = i+1;
				put_fs_byte(c,i+dirent->d_name);
				i++;
			}
			if ((i = last) != 0) {
				if (!strcmp(de->name,MSDOS_DOT))
					ino = inode->i_ino;
				else if (!strcmp(de->name,MSDOS_DOTDOT))
						ino = msdos_parent_ino(inode,0);
				put_fs_long(ino,&dirent->d_ino);
				put_fs_byte(0,i+dirent->d_name);
				put_fs_word(i,&dirent->d_reclen);
				brelse(bh);
				return i;
			}
		}
	}
	if (bh) brelse(bh);
	return 0;
}
Пример #4
0
static int ehandler_dir(dentry_t * entry)
{
    if (IS_FREE(entry))
        return 0;
    if (ATTR_DIRECTORY(entry) || ATTR_ARCHIVE(entry))
    {
        puts(entry->name);
        ENTER();
    }
    return 0;
}
Пример #5
0
static int ehandler_cd(dentry_t * entry)
{
    if (IS_FREE(entry))
        return 0;
    if (ATTR_DIRECTORY(entry) || ATTR_ARCHIVE(entry))
        if (strncmp(entry->name, buffer+3, strlen(buffer+3)) == 0)
        {
            cd = *entry;
            return 1;
        }
    return 0;
}
Пример #6
0
static int ehandler_cat(dentry_t * entry)
{
    if (IS_FREE(entry))
        return 0;
    if (ATTR_DIRECTORY(entry) || ATTR_ARCHIVE(entry))
        if (strncmp(entry->name, buffer+4, strlen(buffer+4)) == 0)
        {
            fs_file_read(entry, shandler_cat);
            ENTER();
            return 1;
        }
    return 0;
}
Пример #7
0
BS_IO_RETURN_t 
simpleOSD_lun_open(char *path,           /*IN*/
                       int oflag,            /*IN*/
                       uint64_t *size,       /*OUT*/
                       uint32_t *blksize,    /*OUT*/
                       int *lun_index){      /*OUT*/
    BS_IO_RETURN_t ret = BS_IO_SUCCESS;

    int next_free_lun=0;
    int is_free=FALSE;

    for(next_free_lun=0;next_free_lun<NB_MAX_LUN && 
            (p_simpleOSD_lun_list[next_free_lun]);next_free_lun++){		
        if((IS_FREE(p_simpleOSD_lun_list[next_free_lun])))
            break;
    }
    if(next_free_lun>=NB_MAX_LUN){
        ret=BS_IO_ERROR;
        BLOCKFRONT_LOG(LOG_CRITICAL,"\n Reached max LUN limit:%d",NB_MAX_LUN);
        goto end;
    }
    if(!(p_simpleOSD_lun_list[next_free_lun]))	
        p_simpleOSD_lun_list[next_free_lun]=GET_MEMORY(sizeof(osd_lun_t));
    USE_LUN(p_simpleOSD_lun_list[next_free_lun]);

    osd_lun_t *p_curr_lun=(osd_lun_t*)VAL_POINTER(p_simpleOSD_lun_list[next_free_lun]);
    /*Need to modify path name as <dc_path>/dev_blockdev_name and separate 
      block_dev_name from absolute path*/
    
    strncpy(p_curr_lun->lun_vol,path,MAXNAMESIZE);
    p_curr_lun->lun_index=next_free_lun;
    p_curr_lun->io_flag=oflag;

    
	snprintf(p_curr_lun->datacache_info.lun_dc_path,MAXPATHSIZE,"/%s/%s/",
				global_blk_frontend_parameters.dc_path,p_curr_lun->lun_vol);
	
    /*Update Lun from MDS or conf file based on device name */
    if(ret=simpleOSD_get_lun_info(p_curr_lun)){
        ret=BS_IO_ERROR;
        goto end;
    }
	
    *size=p_curr_lun->lun_capacity;
    *blksize=p_curr_lun->block_size;
    *lun_index=next_free_lun;
end:
    return ret;
}
Пример #8
0
t_block			*find_block(t_block **last, size_t size, int type_zone)
{
	t_block	*b;
	size_t	align_size;

	b = g_base[type_zone];
	align_size = ALIGN4(size);
	while (b && (!IS_FREE(b) || align_size > b->size + b->rest))
	{
		*last = b;
		b = b->next;
	}
	if (!b)
		MALLOC_DEBUG("/!\\ No block found");
	else
		MALLOC_DEBUG("New block found");
	return (b);
}