int main(int argc, char **argv) { // initialize the SNFS API layer if (snfs_init(CLIENT_SOCK,SERVER_SOCK) < 0) { printf("[test] unable to initialize SNFS API.\n"); return -1; } else { printf("[test] SNFS API initialized.\n"); } // invoke the 'create' service to create file 'f1' in root dir snfs_fhandle_t file_fh; if (snfs_create(ROOT_FHANDLE,"f1",&file_fh) != STAT_OK) { printf("[test] error creating a file in server.\n"); return -1; } printf("[test] file created with file handle %d.\n",file_fh); /* * do the 'write' */ // build a string of 'A' chars char data[DATA_SIZE]; for (int i = 0; i < DATA_SIZE-1; data[i] = 'A', i++); data[DATA_SIZE-1] = '\0'; // invoke the 'write' service to write to file 'f1' unsigned fsize; if (snfs_write(file_fh,0,DATA_SIZE,data,&fsize) != STAT_OK) { printf("[test] error writing to file.\n"); return -1; } // test if all data was written if (fsize != DATA_SIZE) { printf("[test] error: sizes differ %d!=%d.\n",fsize,DATA_SIZE); return -1; } //copying "f1" to "f2" if (snfs_copy(ROOT_FHANDLE,"f1",ROOT_FHANDLE,"f2",&file_fh) != STAT_OK) { printf("[test] error copying a file.\n"); return -1; } printf("[test] copy successful to a file with file handle %d.\n",file_fh); printf("[test] PASSED.\n"); return 0; }
int my_init_lib() { char CLIENT_SOCK[] = "/tmp/clientXXXXXX"; if(mkstemp(CLIENT_SOCK) < 0) { printf("[my_init_lib] Unable to create client socket.\n"); return -1; } if(snfs_init(CLIENT_SOCK, SERVER_SOCK) < 0) { printf("[my_init_lib] Unable to initialize SNFS API.\n"); return -1; } Open_files_list = queue_create(); Lib_initted = 1; return 0; }
int main(int argc, char **argv) { // initialize the SNFS API layer if (snfs_init(CLIENT_SOCK,SERVER_SOCK) < 0) { printf("[test] unable to initialize SNFS API.\n"); return -1; } else { printf("[test] SNFS API initialized.\n"); } // invoke the 'create' service to create file 'f1' in root dir snfs_fhandle_t file_fh; snfs_fhandle_t fh; snfs_fhandle_t fh2; if (snfs_mkdir(ROOT_FHANDLE,"dir1",&fh) != STAT_OK) { printf("[test] error creating a dir in server.\n"); return -1; } if (snfs_create(fh,"f1",&file_fh) != STAT_OK) { printf("[test] error creating a file in server.\n"); return -1; } if (snfs_create(fh, "d2", &fh2) != STAT_OK) { printf("[test] error creating dir2 in server\n"); return -1; } printf("[test] file created with file handle %d.\n",file_fh); //removing file "f1" from root firectory if (snfs_remove(ROOT_FHANDLE, "dir1", &fh) != STAT_OK) { printf("[test] error deleting file in server.\n"); return -1; } printf("[test] file was successfully deleted.\n"); printf("[test] PASSED.\n"); return 0; }
int main(int argc, char **argv) { // initialize the SNFS API layer if (snfs_init(CLIENT_SOCK,SERVER_SOCK) < 0) { printf("[test] unable to initialize SNFS API.\n"); return -1; } else { printf("[test] SNFS API initialized.\n"); } snfs_fhandle_t file_fh; // invoke the 'create' service to create file 'f1' in root dir if (snfs_create(ROOT_FHANDLE,"f1",&file_fh) != STAT_OK) { printf("[test] error creating a file in server.\n"); return -1; } printf("[test] file created with file handle %d.\n",file_fh); /* * do the 'write' fo file "f1" */ // build a string of 'A' chars char data[DATA_SIZE]; for (int i = 0; i < DATA_SIZE-1; data[i] = 'A', i++); data[DATA_SIZE-1] = '\0'; // invoke the 'write' service to write to file 'f1' unsigned fsize; if (snfs_write(file_fh,0,DATA_SIZE,data,&fsize) != STAT_OK) { printf("[test] error writing to file.\n"); return -1; } //Dumping Cache of Blocks's entries on server side if (snfs_dumpcache() != STAT_OK) { printf("[test] error dumping the entries of the cache of blocks .\n"); return -1; } printf("\n[test] Cache of blocks's dumping is successfull if block 11 is the only one cached.\n \n(Please check check dumping list on the server terminal).\n\n"); return 0; }
int main(int argc, char **argv) { sthread_t threads[NUM_TC]; sthread_t prodthr; int i; available_reqs = 0; // initialize sthread lib sthread_init(); //initialize filesystem snfs_init(argc, argv); // initialize SNFS layer struct sockaddr_un servaddr; // initialize communications srv_init_socket(&servaddr); // initialize monitor mon = sthread_monitor_init(); // create thread_consumer threads for(i = 0; i < NUM_TC; i++) { threads[i] = sthread_create(thread_consumer, (void*) NULL,1); if (threads[i] == NULL) { printf("Error while creating threads. Terminating...\n"); exit(-1); } } // create producer thread prodthr = sthread_create(thread_producer, (void*) NULL,1); sthread_join(prodthr, (void**)NULL); for(i = 0; i < NUM_TC; i++) sthread_join(threads[i], (void **)NULL); return 0; }
void copy_job(nfs_job_t *src, nfs_job_t *dest) { if (dest->poly == NULL) { dest->poly = (mpz_polys_t *)malloc(sizeof(mpz_polys_t)); mpz_polys_init(dest->poly); } copy_mpz_polys_t(src->poly, dest->poly); dest->rlim = src->rlim; dest->alim = src->alim; dest->lpbr = src->lpbr; dest->lpba = src->lpba; dest->mfbr = src->mfbr; dest->mfba = src->mfba; dest->rlambda = src->rlambda; dest->alambda = src->alambda; dest->qrange = src->qrange; strcpy(dest->sievername, src->sievername); dest->startq = src->startq; dest->min_rels = src->min_rels; dest->current_rels = src->current_rels; dest->poly_time = src->poly_time; dest->last_leading_coeff = src->last_leading_coeff; dest->use_max_rels = src->use_max_rels; if (src->snfs != NULL) { if (dest->snfs == NULL) { dest->snfs = (snfs_t *)malloc(sizeof(snfs_t)); snfs_init(dest->snfs); } snfs_copy_poly(src->snfs, dest->snfs); } return; }
int main(int argc, char **argv) { // initialize the SNFS API layer if (snfs_init(CLIENT_SOCK,SERVER_SOCK) < 0) { printf("[test] unable to initialize SNFS API.\n"); return -1; } else { printf("[test] SNFS API initialized.\n"); } snfs_fhandle_t file_fh1; snfs_fhandle_t file_fh2; // invoke the 'create' service to create file 'f1' in root dir if (snfs_create(ROOT_FHANDLE,"f1",&file_fh1) != STAT_OK) { printf("[test] error creating a file in server.\n"); return -1; } printf("[test] file created with file handle %d.\n",file_fh1); /* * do the 'write' fo file "f1" */ // build a string of 'A' chars char data[DATA_SIZE]; for (int i = 0; i < DATA_SIZE-1; data[i] = 'A', i++); data[DATA_SIZE-1] = '\0'; // invoke the 'write' service to write to file 'f1' unsigned fsize; if (snfs_write(file_fh1,0,DATA_SIZE,data,&fsize) != STAT_OK) { printf("[test] error writing to file.\n"); return -1; } // invoke the 'create' service to create file 'f2' in root dir if (snfs_create(ROOT_FHANDLE,"f2",&file_fh2) != STAT_OK) { printf("[test] error creating a file in server.\n"); return -1; } printf("[test] file created with file handle %d.\n",file_fh2); /* * do the 'write' fo file "f2" */ // build a string of 'B' chars for (int i = 0; i < DATA_SIZE-1; data[i] = 'B', i++); data[DATA_SIZE-1] = '\0'; // invoke the 'write' service to write to file 'f2' if (snfs_write(file_fh2,0,DATA_SIZE,data,&fsize) != STAT_OK) { printf("[test] error writing to file.\n"); return -1; } // test if all data was written if (fsize != DATA_SIZE) { printf("[test] error: sizes differ %d!=%d.\n",fsize,DATA_SIZE); return -1; } //Dumping FS diskusage if (snfs_diskusage() != STAT_OK) { printf("[test] error dumping occupied data blocks.\n"); return -1; } printf("\n[test] File system data blocks usage was successfully dumped only if occupied blocks are: \n - the first one (the 11th) storing file 'f1' data and \n - the second one (the 12th) storing file 'f2' data\n \n(Please check diskusage dumping on the server terminal).\n\n"); return 0; }