int GIGAmkdir(const char *path, mode_t mode) { logMessage(LOG_TRACE, __func__, " ==> mkdir(path=[%s], mode=[0%3o])", path, mode); int ret = 0; char fpath[MAX_LEN] = {0}; char dir[MAX_LEN] = {0}; char file[MAX_LEN] = {0}; int dir_id = 0; switch (giga_options_t.backend_type) { case BACKEND_LOCAL_FS: get_full_path(fpath, path); ret = local_mkdir(fpath, mode); ret = FUSE_ERROR(ret); break; case BACKEND_RPC_LEVELDB: parse_path_components(path, dir, file); ret = rpc_mkdir(dir_id, path, mode); ret = FUSE_ERROR(ret); break; default: break; } return ret; }
void my_mkdir_r(char *path,int index) { int i, len; char str[512]; char fullname[512]; char *temp; DEBUG("****************my_mkdir_r*******************\n"); DEBUG("%s\n", path); memset(str,0,sizeof(str)); temp = strstr(path, smb_config.multrule[index]->mount_path); len = strlen(smb_config.multrule[index]->mount_path); strcpy(str, temp + len); //strncpy(str,path,512); len = strlen(str); for(i = 0; i < len; i++) { if(str[i] == '/' && i != 0) { str[i] = '\0'; memset(fullname, 0, sizeof(fullname)); sprintf(fullname, "%s%s", smb_config.multrule[index]->mount_path, str); if(access(fullname, F_OK) != 0) { DEBUG("%s\n", fullname); local_mkdir(fullname); } str[i] = '/'; } } memset(fullname, 0, sizeof(fullname)); sprintf(fullname, "%s%s", smb_config.multrule[index]->mount_path, str); if(len > 0 && access(fullname, F_OK) != 0) { DEBUG("%s\n", fullname); local_mkdir(fullname); } }
int write_notify_file(char *path, int signal_num) { FILE *fp; char fullname[64]; memset(fullname,0,sizeof(fullname)); local_mkdir("/tmp/notify"); local_mkdir("/tmp/notify/usb"); sprintf(fullname, "%s/sambaclient", path); fp = fopen(fullname, "w"); if(NULL == fp) { printf("open notify %s file fail\n", fullname); return -1; } fprintf(fp, "%d", signal_num); fclose(fp); return 0; }
bool_t giga_rpc_mkdir_1_svc(giga_dir_id dir_id, giga_pathname path, mode_t mode, giga_result_t *rpc_reply, struct svc_req *rqstp) { (void)rqstp; assert(rpc_reply); assert(path); logMessage(LOG_TRACE, __func__, "==> RPC_mkdir_recv(path=%s,mode=0%3o)", path, mode); bzero(rpc_reply, sizeof(giga_result_t)); struct giga_directory *dir = cache_fetch(&dir_id); if (dir == NULL) { rpc_reply->errnum = -EIO; logMessage(LOG_DEBUG, __func__, "Dir (id=%d) not in cache!", dir_id); return true; } // (1): get the giga index/partition for operation int index = giga_get_index_for_file(&dir->mapping, (const char*)path); int server = giga_get_server_for_index(&dir->mapping, index); // (2): is this the correct server? NO --> (errnum=-EAGAIN) and return if (server != giga_options_t.serverID) { rpc_reply->errnum = -EAGAIN; memcpy(&(rpc_reply->giga_result_t_u.bitmap), &dir->mapping, sizeof(dir->mapping)); logMessage(LOG_TRACE, __func__, "req for server-%d reached server-%d.", server, giga_options_t.serverID); return true; } char path_name[MAX_LEN]; switch (giga_options_t.backend_type) { case BACKEND_RPC_LOCALFS: snprintf(path_name, sizeof(path_name), "%s/%s", giga_options_t.mountpoint, path); rpc_reply->errnum = local_mkdir(path_name, mode); break; case BACKEND_RPC_LEVELDB: // create object in the underlying file system snprintf(path_name, sizeof(path_name), "%s/%s", giga_options_t.mountpoint, path); rpc_reply->errnum = local_mkdir(path_name, mode); // create object entry (metadata) in levelDB object_id += 1; rpc_reply->errnum = leveldb_create(ldb_mds, dir_id, index, OBJ_DIR, object_id, path, path_name); break; default: break; } logMessage(LOG_TRACE, __func__, "RPC_mkdir_reply(status=%d)", rpc_reply->errnum); return true; }