Ejemplo n.º 1
0
/*FUNCTION*/
struct dirent *hook_readdir(pExecuteObject pEo,
                            DIR *pDirectory
  ){
/*noverbatim
CUT*/
  return file_readdir(pDirectory);
  }
Ejemplo n.º 2
0
void open_cb(int fd, void* context) {
	*(int*)context = fd;
	if(fd >= 0) {
		Dirent* dirent = malloc(sizeof(Dirent));
		file_readdir(fd, dirent, dio_cb, context);

	} else {
		printf("fd : %d\n", fd);
	}
}
Ejemplo n.º 3
0
int32_t readdir(int32_t fd, dirent_t *dirp) {

    /* fd must be a valid open descriptor: */
    if (fd < 0 || fd >= FD_MAX || curproc->file[fd] == NULL)
        return EBADF;

    /* do the read: */
    return -file_readdir(curproc->file[fd], dirp);

}
Ejemplo n.º 4
0
static void file_readdir_func() {
	int file_fd = 0;
	int file_context = 0;

	int size = 1024;

	__malloc_pool = malloc(0x40000);
	init_memory_pool(0x40000, __malloc_pool, 0);

	__fio = fio_create(__malloc_pool);

	timer_init("Intel(R) Core(TM) i5-4670 CPU @ 3.40GHz");
	event_init();
	file_init();

	Dirent* buffer = malloc(sizeof(Dirent));

	for(int i = 0; i < 256; i++) {
		file_context = file_fd = i;
		
		sprintf(buffer->name, "Read Test %d", file_fd);
		int status = file_readdir(file_fd, buffer, readdir_callback, &file_context);

		__fio->output_buffer->head = i;
		__fio->output_buffer->tail = i + 1;
		
		FIORequest* output_buffer = malloc(sizeof(FIORequest));
		output_buffer->type = FILE_T_READDIR;
		output_buffer->context = &file_context;
		output_buffer->fd = file_fd;
		output_buffer->id = (__fio->request_id - 1) % FIO_MAX_REQUEST_ID;

		output_buffer->op.file_io.buffer = buffer;
		output_buffer->op.file_io.size = size;
		
		__fio->output_buffer->array[i] = output_buffer;

		assert_int_equal(status, FIO_OK);

		event_loop();
	}

	fifo_destroy(__fio->input_buffer);
	fifo_destroy(__fio->output_buffer);
	__free(__fio, __malloc_pool);
	
	destroy_memory_pool(__malloc_pool);	
	free(__malloc_pool);
	__malloc_pool = NULL;
}
Ejemplo n.º 5
0
struct file *
file_create_caseinsensitive(char *name)
{
    char dirname[strlen(name)+1];
    char *filename;
    char *p;
    void *d;
    struct file *ret;

    ret=file_create(name);
    if (ret)
        return ret;

    strcpy(dirname, name);
    p=dirname+strlen(name);
    while (p > dirname) {
        if (*p == '/')
            break;
        p--;
    }
    *p=0;
    d=file_opendir(dirname);
    if (d) {
        *p++='/';
        while ((filename=file_readdir(d))) {
            if (!strcasecmp(filename, p)) {
                strcpy(p, filename);
                ret=file_create(dirname);
                if (ret)
                    break;
            }
        }
        file_closedir(d);
    }
    return ret;
}
Ejemplo n.º 6
0
Archivo: file.c Proyecto: albertz/navit
struct file *
file_create_caseinsensitive(char *name, struct attr **options)
{
	char *dirname=g_alloca(sizeof(char)*(strlen(name)+1));
	char *filename;
	char *p;
	void *d;
	struct file *ret;

	ret=file_create(name, options);
	if (ret)
		return ret;

	strcpy(dirname, name);
	p=dirname+strlen(name);
	while (p > dirname) {
		if (*p == '/')
			break;
		p--;
	}
	*p=0;
	d=file_opendir(dirname);
	if (d) {
		*p++='/';
		while ((filename=file_readdir(d))) {
			if (!g_strcasecmp(filename, p)) {
				strcpy(p, filename);
				ret=file_create(dirname, options);
				if (ret)
					break;
			}
		}
		file_closedir(d);
	}
	return ret;
}
Ejemplo n.º 7
0
//
//void read_cb(void* buffer, size_t size, void* context) {
//	int total_size = *(int*)context;
//	total_size += size;
//	*(int*)context = total_size;
//	if(total_size == read_size) {
//		after = time_us();
//		printf("time : %lu\n", after - before);
//		printf("size : %dK\n", total_size / 1024);
//		printf("size : %dM\n", total_size / 1024 / 1024);
//		printf("size : %dG\n", total_size / 1024 / 1024 / 1024);
//		return;
//	} else {
////		printf("size : %dK\n", total_size / 1024);
////		printf("size : %dM\n", total_size / 1024 / 1024);
////		printf("size : %dG\n", total_size / 1024 / 1024 / 1024);
//		file_write(read_fd, buffer, read_size - total_size, read_cb, context);
//	}
//}
//
//void open_cb(int fd, void* context) {
//	if(fd >= 0) {
//		buffer = malloc(1800240);
//		if(!buffer) {
//			printf("malloc error\n"); 
//			return;
//		}
//		memset(buffer, 0x22, 1700240);
//		before = time_us();
//		read_size = 4096*256*512;
//		read_fd = fd;
//		file_write(fd, buffer, read_size, read_cb, context);
//	}
//}
void dio_cb(Dirent* dir, void* context) {
	if(*dir->name) {
		printf("name : %s\n", dir->name);
		file_readdir(*(int*)context, dir, dio_cb, context);
	}
}
Ejemplo n.º 8
0
int main(int argc, char **argv)
{
    if(argc == 1)
    {
        usage();
        exit(1);
    }
    while((cret = getopt(argc,argv,"bwetvf:s:l:u: ")) != EOF) {
        switch(cret) {
        case 'f':	/* Force factor */
            x=atoi(optarg);
            if(x < 0)
                x=1;
            break;
        case 's':	/* Size of files */
            sz=atoi(optarg);
            if(optarg[strlen(optarg)-1]=='k' ||
                    optarg[strlen(optarg)-1]=='K') {
                sz = (1024 * atoi(optarg));
            }
            if(optarg[strlen(optarg)-1]=='m' ||
                    optarg[strlen(optarg)-1]=='M') {
                sz = (1024 * 1024 * atoi(optarg));
            }
            if(sz < 0)
                sz=1;
            break;
        case 'l':	/* lower force value */
            lower=atoi(optarg);
            range=1;
            if(lower < 0)
                lower=1;
            break;
        case 'v':	/* version */
            splash();
            exit(0);
            break;
        case 'u':	/* upper force value */
            upper=atoi(optarg);
            range=1;
            if(upper < 0)
                upper=1;
            break;
        case 't':	/* verbose */
            verbose=1;
            break;
        case 'e':	/* Excel */
            excel=1;
            break;
        case 'b':	/* Best */
            best=1;
            break;
        case 'w':	/* Worst */
            worst=1;
            break;
        }
    }
    mbuffer=(char *)malloc(sz);
    memset(mbuffer,'a',sz);
    if(!excel)
        printf("\nFileop:  File size is %d,  Output is in Ops/sec. (A=Avg, B=Best, W=Worst)\n",sz);
    if(!verbose)
    {
#ifdef Windows
        printf(" .     %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %12s\n",
               "mkdir","rmdir","create","read","write","close","stat",
               "access","chmod","readdir","delete"," Total_files");
#else

        printf(" .     %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %12s\n",
               "mkdir","rmdir","create","read","write","close","stat",
               "access","chmod","readdir","link  ","unlink","delete",
               " Total_files");
#endif
    }
    if(x==0)
        x=1;
    if(range==0)
        lower=upper=x;
    for(i=lower; i<=upper; i++)
    {
        clear_stats();
        x=i;
        /*
         * Dir Create test
         */
        dir_create(x);

        if(verbose)
        {
            printf("mkdir:   Dirs = %9lld ",stats[_STAT_DIR_CREATE].counter);
            printf("Total Time = %12.9f seconds\n", stats[_STAT_DIR_CREATE].total_time);
            printf("         Avg mkdir(s)/sec     = %12.2f (%12.9f seconds/op)\n",
                   stats[_STAT_DIR_CREATE].counter/stats[_STAT_DIR_CREATE].total_time,
                   stats[_STAT_DIR_CREATE].total_time/stats[_STAT_DIR_CREATE].counter);
            printf("         Best mkdir(s)/sec    = %12.2f (%12.9f seconds/op)\n",1/stats[_STAT_DIR_CREATE].best,stats[_STAT_DIR_CREATE].best);
            printf("         Worst mkdir(s)/sec   = %12.2f (%12.9f seconds/op)\n\n",1/stats[_STAT_DIR_CREATE].worst,stats[_STAT_DIR_CREATE].worst);
        }
        /*
         * Dir delete test
         */
        dir_delete(x);

        if(verbose)
        {
            printf("rmdir:   Dirs = %9lld ",stats[_STAT_DIR_DELETE].counter);
            printf("Total Time = %12.9f seconds\n",stats[_STAT_DIR_DELETE].total_time);
            printf("         Avg rmdir(s)/sec     = %12.2f (%12.9f seconds/op)\n",
                   stats[_STAT_DIR_DELETE].counter/stats[_STAT_DIR_DELETE].total_time,
                   stats[_STAT_DIR_DELETE].total_time/stats[_STAT_DIR_DELETE].counter);
            printf("         Best rmdir(s)/sec    = %12.2f (%12.9f seconds/op)\n",1/stats[_STAT_DIR_DELETE].best,stats[_STAT_DIR_DELETE].best);
            printf("         Worst rmdir(s)/sec   = %12.2f (%12.9f seconds/op)\n\n",1/stats[_STAT_DIR_DELETE].worst,stats[_STAT_DIR_DELETE].worst);
        }

        /*
         * Create test
         */
        file_create(x);
        if(verbose)
        {
            printf("create:  Files = %9lld ",stats[_STAT_CREATE].counter);
            printf("Total Time = %12.9f seconds\n", stats[_STAT_CREATE].total_time);
            printf("         Avg create(s)/sec    = %12.2f (%12.9f seconds/op)\n",
                   stats[_STAT_CREATE].counter/stats[_STAT_CREATE].total_time,
                   stats[_STAT_CREATE].total_time/stats[_STAT_CREATE].counter);
            printf("         Best create(s)/sec   = %12.2f (%12.9f seconds/op)\n",
                   1/stats[_STAT_CREATE].best,stats[_STAT_CREATE].best);
            printf("         Worst create(s)/sec  = %12.2f (%12.9f seconds/op)\n\n",
                   1/stats[_STAT_CREATE].worst,stats[_STAT_CREATE].worst);
            printf("write:   Files = %9lld ",stats[_STAT_WRITE].counter);
            printf("Total Time = %12.9f seconds\n", stats[_STAT_WRITE].total_time);
            printf("         Avg write(s)/sec     = %12.2f (%12.9f seconds/op)\n",
                   stats[_STAT_WRITE].counter/stats[_STAT_WRITE].total_time,
                   stats[_STAT_WRITE].total_time/stats[_STAT_WRITE].counter);
            printf("         Best write(s)/sec    = %12.2f (%12.9f seconds/op)\n",
                   1/stats[_STAT_WRITE].best,stats[_STAT_WRITE].best);
            printf("         Worst write(s)/sec   = %12.2f (%12.9f seconds/op)\n\n",
                   1/stats[_STAT_WRITE].worst,stats[_STAT_WRITE].worst);
            printf("close:   Files = %9lld ",stats[_STAT_CLOSE].counter);
            printf("Total Time = %12.9f seconds\n", stats[_STAT_CLOSE].total_time);
            printf("         Avg close(s)/sec     = %12.2f (%12.9f seconds/op)\n",
                   stats[_STAT_CLOSE].counter/stats[_STAT_CLOSE].total_time,
                   stats[_STAT_CLOSE].total_time/stats[_STAT_CLOSE].counter);
            printf("         Best close(s)/sec    = %12.2f (%12.9f seconds/op)\n",
                   1/stats[_STAT_CLOSE].best,stats[_STAT_CLOSE].best);
            printf("         Worst close(s)/sec   = %12.2f (%12.9f seconds/op)\n\n",
                   1/stats[_STAT_CLOSE].worst,stats[_STAT_CLOSE].worst);
        }

        /*
         * Stat test
         */
        file_stat(x);

        if(verbose)
        {
            printf("stat:    Files = %9lld ",stats[_STAT_STAT].counter);
            printf("Total Time = %12.9f seconds\n", stats[_STAT_STAT].total_time);
            printf("         Avg stat(s)/sec      = %12.2f (%12.9f seconds/op)\n",
                   stats[_STAT_STAT].counter/stats[_STAT_STAT].total_time,
                   stats[_STAT_STAT].total_time/stats[_STAT_STAT].counter);
            printf("         Best stat(s)/sec     = %12.2f (%12.9f seconds/op)\n",
                   1/stats[_STAT_STAT].best,stats[_STAT_STAT].best);
            printf("         Worst stat(s)/sec    = %12.2f (%12.9f seconds/op)\n\n",
                   1/stats[_STAT_STAT].worst,stats[_STAT_STAT].worst);
        }
        /*
         * Read test
         */
        file_read(x);

        if(verbose)
        {
            printf("read:    Files = %9lld ",stats[_STAT_READ].counter);
            printf("Total Time = %12.9f seconds\n", stats[_STAT_READ].total_time);
            printf("         Avg read(s)/sec      = %12.2f (%12.9f seconds/op)\n",
                   stats[_STAT_READ].counter/stats[_STAT_READ].total_time,
                   stats[_STAT_READ].total_time/stats[_STAT_READ].counter);
            printf("         Best read(s)/sec     = %12.2f (%12.9f seconds/op)\n",
                   1/stats[_STAT_READ].best,stats[_STAT_READ].best);
            printf("         Worst read(s)/sec    = %12.2f (%12.9f seconds/op)\n\n",
                   1/stats[_STAT_READ].worst,stats[_STAT_READ].worst);
        }

        /*
         * Access test
         */
        file_access(x);
        if(verbose)
        {
            printf("access:  Files = %9lld ",stats[_STAT_ACCESS].counter);
            printf("Total Time = %12.9f seconds\n", stats[_STAT_ACCESS].total_time);
            printf("         Avg access(s)/sec    = %12.2f (%12.9f seconds/op)\n",
                   stats[_STAT_ACCESS].counter/stats[_STAT_ACCESS].total_time,
                   stats[_STAT_ACCESS].total_time/stats[_STAT_ACCESS].counter);
            printf("         Best access(s)/sec   = %12.2f (%12.9f seconds/op)\n",
                   1/stats[_STAT_ACCESS].best,stats[_STAT_ACCESS].best);
            printf("         Worst access(s)/sec  = %12.2f (%12.9f seconds/op)\n\n",
                   1/stats[_STAT_ACCESS].worst,stats[_STAT_ACCESS].worst);
        }
        /*
         * Chmod test
         */
        file_chmod(x);

        if(verbose)
        {
            printf("chmod:   Files = %9lld ",stats[_STAT_CHMOD].counter);
            printf("Total Time = %12.9f seconds\n", stats[_STAT_CHMOD].total_time);
            printf("         Avg chmod(s)/sec     = %12.2f (%12.9f seconds/op)\n",
                   stats[_STAT_CHMOD].counter/stats[_STAT_CHMOD].total_time,
                   stats[_STAT_CHMOD].total_time/stats[_STAT_CHMOD].counter);
            printf("         Best chmod(s)/sec    = %12.2f (%12.9f seconds/op)\n",
                   1/stats[_STAT_CHMOD].best,stats[_STAT_CHMOD].best);
            printf("         Worst chmod(s)/sec   = %12.2f (%12.9f seconds/op)\n\n",
                   1/stats[_STAT_CHMOD].worst,stats[_STAT_CHMOD].worst);
        }
        /*
         * readdir test
         */
        file_readdir(x);

        if(verbose)
        {
            printf("readdir: Files = %9lld ",stats[_STAT_READDIR].counter);
            printf("Total Time = %12.9f seconds\n", stats[_STAT_READDIR].total_time);
            printf("         Avg readdir(s)/sec   = %12.2f (%12.9f seconds/op)\n",
                   stats[_STAT_READDIR].counter/stats[_STAT_READDIR].total_time,
                   stats[_STAT_READDIR].total_time/stats[_STAT_READDIR].counter);
            printf("         Best readdir(s)/sec  = %12.2f (%12.9f seconds/op)\n",
                   1/stats[_STAT_READDIR].best,stats[_STAT_READDIR].best);
            printf("         Worst readdir(s)/sec = %12.2f (%12.9f seconds/op)\n\n",
                   1/stats[_STAT_READDIR].worst,stats[_STAT_READDIR].worst);
        }
#if !defined(Windows)
        /*
         * link test
         */
        file_link(x);
        if(verbose)
        {
            printf("link:    Files = %9lld ",stats[_STAT_LINK].counter);
            printf("Total Time = %12.9f seconds\n",stats[_STAT_LINK].total_time);
            printf("         Avg link(s)/sec      = %12.2f (%12.9f seconds/op)\n",
                   stats[_STAT_LINK].counter/stats[_STAT_LINK].total_time,
                   stats[_STAT_LINK].total_time/stats[_STAT_LINK].counter);
            printf("         Best link(s)/sec     = %12.2f (%12.9f seconds/op)\n",
                   1/stats[_STAT_LINK].best,stats[_STAT_LINK].best);
            printf("         Worst link(s)/sec    = %12.2f (%12.9f seconds/op)\n\n",
                   1/stats[_STAT_LINK].worst,stats[_STAT_LINK].worst);
        }
        /*
         * unlink test
         */
        file_unlink(x);
        if(verbose)
        {
            printf("unlink:  Files = %9lld ",stats[_STAT_UNLINK].counter);
            printf("Total Time = %12.9f seconds\n", stats[_STAT_UNLINK].total_time);
            printf("         Avg unlink(s)/sec    = %12.2f (%12.9f seconds/op)\n",
                   stats[_STAT_UNLINK].counter/stats[_STAT_UNLINK].total_time,
                   stats[_STAT_UNLINK].total_time/stats[_STAT_UNLINK].counter);
            printf("         Best unlink(s)/sec   = %12.2f (%12.9f seconds/op)\n",
                   1/stats[_STAT_UNLINK].best,stats[_STAT_UNLINK].best);
            printf("         Worst unlink(s)/sec  = %12.2f (%12.9f seconds/op)\n\n",
                   1/stats[_STAT_UNLINK].worst,stats[_STAT_UNLINK].worst);
        }
#endif
        /*
         * Delete test
         */
        file_delete(x);
        if(verbose)
        {
            printf("delete:  Files = %9lld ",stats[_STAT_DELETE].counter);
            printf("Total Time = %12.9f seconds\n", stats[_STAT_DELETE].total_time);
            printf("         Avg delete(s)/sec    = %12.2f (%12.9f seconds/op)\n",
                   stats[_STAT_DELETE].counter/stats[_STAT_DELETE].total_time,
                   stats[_STAT_DELETE].total_time/stats[_STAT_DELETE].counter);
            printf("         Best delete(s)/sec   = %12.2f (%12.9f seconds/op)\n",
                   1/stats[_STAT_DELETE].best,stats[_STAT_DELETE].best);
            printf("         Worst delete(s)/sec  = %12.2f (%12.9f seconds/op)\n\n",
                   1/stats[_STAT_DELETE].worst,stats[_STAT_DELETE].worst);
        }
        if(!verbose)
        {
            printf("%c %4d %6.0f ",'A',x,stats[_STAT_DIR_CREATE].counter/stats[_STAT_DIR_CREATE].total_time);
            printf("%6.0f ",stats[_STAT_DIR_DELETE].counter/stats[_STAT_DIR_DELETE].total_time);
            printf("%6.0f ",stats[_STAT_CREATE].counter/stats[_STAT_CREATE].total_time);
            printf("%6.0f ",stats[_STAT_READ].counter/stats[_STAT_READ].total_time);
            printf("%6.0f ",stats[_STAT_WRITE].counter/stats[_STAT_WRITE].total_time);
            printf("%6.0f ",stats[_STAT_CLOSE].counter/stats[_STAT_CLOSE].total_time);
            printf("%6.0f ",stats[_STAT_STAT].counter/stats[_STAT_STAT].total_time);
            printf("%6.0f ",stats[_STAT_ACCESS].counter/stats[_STAT_ACCESS].total_time);
            printf("%6.0f ",stats[_STAT_CHMOD].counter/stats[_STAT_CHMOD].total_time);
            printf("%6.0f ",stats[_STAT_READDIR].counter/stats[_STAT_READDIR].total_time);
#ifndef Windows
            printf("%6.0f ",stats[_STAT_LINK].counter/stats[_STAT_LINK].total_time);
            printf("%6.0f ",stats[_STAT_UNLINK].counter/stats[_STAT_UNLINK].total_time);
#endif
            printf("%6.0f ",stats[_STAT_DELETE].counter/stats[_STAT_DELETE].total_time);
            printf("%12d ",x*x*x);
            printf("\n");
            fflush(stdout);

            if(best)
            {
                printf("%c %4d %6.0f ",'B',x, 1/stats[_STAT_DIR_CREATE].best);
                printf("%6.0f ",1/stats[_STAT_DIR_DELETE].best);
                printf("%6.0f ",1/stats[_STAT_CREATE].best);
                printf("%6.0f ",1/stats[_STAT_READ].best);
                printf("%6.0f ",1/stats[_STAT_WRITE].best);
                printf("%6.0f ",1/stats[_STAT_CLOSE].best);
                printf("%6.0f ",1/stats[_STAT_STAT].best);
                printf("%6.0f ",1/stats[_STAT_ACCESS].best);
                printf("%6.0f ",1/stats[_STAT_CHMOD].best);
                printf("%6.0f ",1/stats[_STAT_READDIR].best);
#ifndef Windows
                printf("%6.0f ",1/stats[_STAT_LINK].best);
                printf("%6.0f ",1/stats[_STAT_UNLINK].best);
#endif
                printf("%6.0f ",1/stats[_STAT_DELETE].best);
                printf("%12d ",x*x*x);
                printf("\n");
                fflush(stdout);
            }
            if(worst)
            {
                printf("%c %4d %6.0f ",'W',x, 1/stats[_STAT_DIR_CREATE].worst);
                printf("%6.0f ",1/stats[_STAT_DIR_DELETE].worst);
                printf("%6.0f ",1/stats[_STAT_CREATE].worst);
                printf("%6.0f ",1/stats[_STAT_READ].worst);
                printf("%6.0f ",1/stats[_STAT_WRITE].worst);
                printf("%6.0f ",1/stats[_STAT_CLOSE].worst);
                printf("%6.0f ",1/stats[_STAT_STAT].worst);
                printf("%6.0f ",1/stats[_STAT_ACCESS].worst);
                printf("%6.0f ",1/stats[_STAT_CHMOD].worst);
                printf("%6.0f ",1/stats[_STAT_READDIR].worst);
#ifndef Windows
                printf("%6.0f ",1/stats[_STAT_LINK].worst);
                printf("%6.0f ",1/stats[_STAT_UNLINK].worst);
#endif
                printf("%6.0f ",1/stats[_STAT_DELETE].worst);
                printf("%12d ",x*x*x);
                printf("\n");
                fflush(stdout);
            }
        }
    }
    return(0);
}