/** Change the size of a file */ int atmos_truncate(const char *path, off_t newsize) { int retstat = 0; char fpath[PATH_MAX]; log_msg("\natmos_truncate(path=\"%s\", newsize=%lld)\n", path, newsize); atmos_fullpath(fpath, path); if(newsize == 0) { ws_result result; //update_ns(ATMOS_DATA->c, fpath, NULL,NULL, NULL, NULL, &result); delete_ns(ATMOS_DATA->c, fpath,&result); log_msg("%s\t\n", result.response_body); if(204 == result.return_code ) { ws_result wsr; retstat = 0; create_ns(ATMOS_DATA->c, fpath, NULL, NULL, NULL, &wsr); result_deinit(&wsr); } else { retstat = -1; } result_deinit(&result); } //retstat = truncate(fpath, newsize); if (retstat < 0) atmos_error("atmos_truncate truncate"); return retstat; }
// The parameters here are a little bit confusing, but do correspond // to the symlink() system call. The 'path' is where the link points, // while the 'link' is the link itself. So we need to leave the path // unaltered, but insert the link into the mounted directory. int atmos_symlink(const char *path, const char *link) { int retstat = 0; ws_result wsr; char fpath[PATH_MAX]; sprintf(fpath, "%s%s",ATMOS_DATA->rootdir,link); log_msg("\natmos_symlink(path=\"%s\", link=\"%s\")\n", path, link); create_ns(ATMOS_DATA->c, fpath, NULL, NULL, NULL, &wsr); log_msg("%s\t\n", wsr.response_body); //FIXME also needs metadata symlink=true if(201 == wsr.return_code ) { postdata *pd = malloc(sizeof(postdata)); memset(pd, 0, sizeof(postdata)); retstat = 0; result_deinit(&wsr); strcpy(pd->data, link); pd->body_size = strlen(link); update_ns(ATMOS_DATA->c, fpath, NULL, NULL, pd,NULL, &wsr); if (200 == wsr.return_code) { retstat = 0; } else { retstat = -1; } result_deinit(&wsr); } else { retstat = -1; } return retstat; }
// shouldn't that comment be "if" there is no.... ? //set special ness in user meta??? //FIXME int atmos_mknod(const char *path, mode_t mode, dev_t dev) { int retstat = 0; log_msg("\natmos_mknod(path=\"%s\", mode=0%3o, dev=%lld)\n", path, mode, dev); ws_result wsr; struct fuse_context * fc; char fpath[PATH_MAX]; sprintf(fpath, "%s%s",ATMOS_DATA->rootdir, path); fc = fuse_get_context(); log_msg("\natmos_mknod(path=\"%s\", mode=0%3o)\n", path, mode); create_ns(ATMOS_DATA->c, fpath, NULL, NULL, NULL, &wsr); log_msg("atmos_mknod %s\t\n", wsr.response_body); if(201 == wsr.return_code ) { retstat = 0; } else { retstat = -1; } result_deinit(&wsr); return retstat; }
static int enter_or_create_ns(const char *statedir, const char *name) { int fd; pid_t pid = read_pid(statedir); if (pid <= 0 || kill(pid, 0)) { fd = create_ns(statedir, name); } else { /* Prevent destroy/join races by connecting first */ fd = connect_to_watcher(statedir); if (fd < 0) fd = create_ns(statedir, name); else enter_all(pid); } return fd; }
int main() { if(SERVER){ create_ns("namespace001"); printf("Namespace created, configuring interfaces:\n"); system("ip link add veth0 type veth peer name veth1"); system("ip a s"); create_sctp_sock(); while(1){ sleep(20); } } }
int main(int argc, char *argv[]) { int i; int fuse_stat; struct atmos_state *atmos_data; ws_result wsr; static int opt_binary= 0; //setup memcaceh atmos_data = calloc(sizeof(struct atmos_state), 1); atmos_data->attr_cache = memcached_create(NULL); memcached_server_st *servers= memcached_servers_parse("localhost"); memcached_server_push(atmos_data->attr_cache, servers); memcached_server_list_free(servers); memcached_behavior_set(atmos_data->attr_cache, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, (uint64_t)opt_binary); if (atmos_data == NULL) { perror("main calloc"); abort(); } atmos_data->logfile = log_open(); // libfuse is able to do most of the command line parsing; all I // need to do is to extract the rootdir; this will be the first // non-option passed in. I'm using the GNU non-standard extension // and having realpath malloc the space for the path // the string. for (i = 1; (i < argc) && (argv[i][0] == '-'); i++); if (i == argc) atmos_usage(); atmos_data->rootdir = "/FUSETEST"; for (; i < argc; i++) argv[i] = argv[i+1]; argc--; static const char *user_id = "mail"; static const char *key = "w7mxRvPlDYUkA4J6uTuItfUS1u4="; static const char *endpoint = "10.241.38.90"; //*/ /* static const char *user_id = "0e069767430c4d37997853b058eb0af8/EMC007A49DEEA84C837E"; static const char *key ="YlVdJFb03nYtXZk0lk0KjQplVcI="; static const char *endpoint ="accesspoint.emccis.com";//*/ atmos_data->c = init_ws(user_id, key, endpoint); create_ns(atmos_data->c, "/FUSETEST/",NULL, NULL, NULL, &wsr); fprintf(stderr, "atmos setup to receive fuse %d\n", wsr.return_code); result_deinit(&wsr); fprintf(stderr, "about to call fuse_main\n"); fuse_stat = fuse_main(argc, argv, &atmos_oper, atmos_data); fprintf(stderr, "fuse_main returned %d\n", fuse_stat); return fuse_stat; }