/*FUNCTION*/ DIR *hook_opendir(pExecuteObject pEo, char *pszDirectoryName, tDIR *pDirectory ){ /*noverbatim CUT*/ return file_opendir(pszDirectoryName,pDirectory); }
static void file_opendir_func() { int file_fd = 0; int file_context = 0; __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(); /* check context & fd unitl get to Max request id */ for(int i = 0; i < 256; i++) { file_context = i; int status = file_opendir("Test", opendir_callback, &file_context); __fio->output_buffer->head = i; __fio->output_buffer->tail = i + 1; /* FIORequest that put in to output_buffer of __fio */ FIORequest* output_buffer = malloc(sizeof(FIORequest)); output_buffer->type = FILE_T_OPENDIR; output_buffer->context = &file_context; output_buffer->id = (__fio->request_id - 1) % FIO_MAX_REQUEST_ID; output_buffer->fd = file_fd = i; __fio->output_buffer->array[i] = output_buffer; assert_int_equal(FIO_OK, status); 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; }
int main(int argc, char** argv) { printf("Thread %d booting\n", thread_id()); if(thread_id() == 0) { time_init(); event_init(); ginit(argc, argv); } thread_barrior(); init(argc, argv); thread_barrior(); /* Start of User Code Area */ int fd; file_init(); file_opendir("/", open_cb, &fd); if(thread_id() == 0) { while(1) { event_loop(); } } /* End of User Code Area */ thread_barrior(); destroy(); thread_barrior(); if(thread_id() == 0) { gdestroy(argc, argv); } return 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; }
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; }