Пример #1
0
int _CreateFile(char* path,u32 perm,int mode)
{   
	/* 1) create cache file
	 * 2) create data_center file
	 * 3) init_file
	 * 4) open cache file with 'mode' 
	 * */
	int fd;
	char dst_path[MAX_PATH];
	get_cache_path(path,dst_path);
	if((fd = creat(dst_path,perm)) == -1){
		perror("create cache file");
		return fd;
	}
	close(fd);
	get_data_path(path,dst_path);
	if((fd = creat(dst_path,perm)) == -1){
		perror("create data center file");
		return fd;
	}
	close(fd);
	/* init file */
	if(init_file(path) != 0){
		fprintf(stderr,"init_file fail!\n");
		return -1;
	}
	fd = open(dst_path,mode);
	return fd;
}
Пример #2
0
void load_lib(char *filename) {
     void (*init_module)();
     char lib_full_path[PATH_MAX];
     get_cache_path(filename, lib_full_path);
     printf("lib_tools.c:load_lib() - Full path to load is %s, loading:\n",lib_full_path);
     void* handle=dlopen(lib_full_path,RTLD_NOW|RTLD_GLOBAL);
     if(handle==NULL) {
        printf("lib_tools.c:load_lib() - dlopen() error: %s\n",dlerror());
     }
#ifdef __linux
     init_module = dlsym(handle,"init_module");
     init_module();
#endif   
}
Пример #3
0
int _OpenFile(char* path,int mode)
{
	/* 1) open cache first,if ok,return opened fd 
	 * 2) if cache file open fail,open dtc file instead*/
	int fd;
	char dst_path[MAX_PATH];
	get_cache_path(path,dst_path);
	if((fd = open(dst_path,mode)) == -1){
		/* open dtc file */
		perror("Open cache_file");
		get_data_path(path,dst_path);
		if((fd = open(dst_path,mode)) == -1){
			perror("Open dtc_file");
		}
	}
	return fd;
}
Пример #4
0
int _Remove(char* path)
{
	/* 1) remove cache file 
	 * 2) remove dtc file 
	 * 3) remove md */
	int rt = 0;
	char dst_path[MAX_PATH];
	get_cache_path(path,dst_path);
	if((rt = remove(dst_path)) != 0){
		perror("Remove cache file");
		goto ret;
	}
	get_data_path(path,dst_path);
	if((rt = remove(dst_path)) != 0){
		perror("Remove data center file");
		goto ret;
	}
	if(de_init_file(path) != 0){
		rt = 1;
	}
ret:
	return rt;
}