int add_getdir(const char *fname, function_to_call_t *fun) { if (fname) { //printf("fname: %s\n", fname); struct request *req = get_req(); req->buf = (char *)MALLOC(sizeof(struct dirent) * max_array_size); req->size = sizeof(struct dirent) * max_array_size; req->fun = fun; req->type = agetdir; strcpy(req->path, fname); return aio_getdir(req); }else error("permission denied\n"); return 1; }
int add_getdir(const char *fname, function_to_call_t *fun) { if (fname) { aiob *aio= get_aiob(); memset(aio, 0, sizeof(aiob)); //printf("fname: %s\n", fname); int fd = open(fname, O_RDONLY); aio->aio_fildes = fd; aio->aio_buf = (char *)MALLOC(sizeof(struct dirent) * max_array_size); aio->aio_nbytes = sizeof(struct dirent) * max_array_size; struct request *req = get_req(); req->aio = aio; req->fun = fun; req->type = agetdir; add_req(req); return aio_getdir(aio); }else error("permission denied\n"); return 1; }