int main( int argc, char** argv ) { struct md_HTTP syndicate_http; int test_optind = -1; // set up the test syndicate_functional_test_init( argc, argv, &test_optind, &syndicate_http ); // arguments: getxattr [syndicate options] /path/to/file xattr_name if( test_optind < 0 ) usage( argv[0] ); if( test_optind + 1 >= argc ) usage( argv[0] ); char* path = argv[test_optind]; char* xattr_name = argv[test_optind+1]; // stop Valgrind errors char xattr_value[65536]; for( int i = 0; i <= 65536; i++ ) { xattr_value[i] = 0; } // get state struct syndicate_state* state = syndicate_get_state(); // get the xattr size dbprintf("\n\n\nfs_entry_getxattr( %s, %s )\n\n\n", path, xattr_name ); ssize_t rc = fs_entry_getxattr( state->core, path, xattr_name, xattr_value, 0, SYS_USER, 0 ); if( rc < 0 || rc > 65535 ) { errorf("\n\n\nfs_entry_getxattr( %s, %s ) rc = %zd\n\n\n", path, xattr_name, rc ); syndicate_functional_test_shutdown( &syndicate_http ); exit(1); } dbprintf("\n\n\nfs_entry_getxattr( %s, %s, 0 ) rc = %zd\n\n\n", path, xattr_name, rc ); // get the xattr for real this time rc = fs_entry_getxattr( state->core, path, xattr_name, xattr_value, rc, SYS_USER, 0 ); if( rc < 0 || rc > 65535 ) { errorf("\n\n\nfs_entry_getxattr( %s, %s ) rc = %zd\n\n\n", path, xattr_name, rc ); syndicate_functional_test_shutdown( &syndicate_http ); exit(1); } dbprintf("\n\n\nfs_entry_getxattr( %s, %s ) = '%s'\n\n\n", path, xattr_name, xattr_value ); // shut down the test syndicate_functional_test_shutdown( &syndicate_http ); return 0; }
int main( int argc, char** argv ) { struct md_HTTP syndicate_http; int test_optind = -1; // set up the test syndicate_functional_test_init( argc, argv, &test_optind, &syndicate_http ); // arguments: getxattr [syndicate options] /path/to/file xattr_name if( test_optind < 0 ) usage( argv[0] ); if( test_optind + 2 >= argc ) usage( argv[0] ); char* path = argv[test_optind]; char* xattr_name = argv[test_optind+1]; char* xattr_mode_str = argv[test_optind+2]; char* end = NULL; mode_t xattr_mode = strtol( xattr_mode_str, &end, 8 ); if( end == NULL ) usage( argv[0] ); // get state struct syndicate_state* state = syndicate_get_state(); // get the xattr size dbprintf("\n\n\nfs_entry_chmodxattr( %s, %s, mode=0%o )\n\n\n", path, xattr_name, xattr_mode ); int rc = fs_entry_chmodxattr( state->core, path, xattr_name, xattr_mode ); if( rc < 0 ) { errorf("\n\n\nfs_entry_chmodxattr( %s, %s, mode=0%o ) rc = %d\n\n\n", path, xattr_name, xattr_mode, rc ); syndicate_functional_test_shutdown( &syndicate_http ); exit(1); } errorf("\n\n\nfs_entry_chmodxattr( %s, %s, mode=0%o ) rc = %d\n\n\n", path, xattr_name, xattr_mode, rc ); // shut down the test syndicate_functional_test_shutdown( &syndicate_http ); return 0; }
int main( int argc, char** argv ) { struct md_HTTP syndicate_http; int test_optind = -1; // set up the test syndicate_functional_test_init( argc, argv, &test_optind, &syndicate_http ); // arguments: creat [syndicate options] /path/to/file [data to write] if( test_optind < 0 ) usage( argv[0] ); if( test_optind >= argc ) usage( argv[0] ); char* path = argv[test_optind]; // get state struct syndicate_state* state = syndicate_get_state(); // open the file int rc = 0; SG_debug("\n\n\nfs_entry_open( %s )\n\n\n", path ); struct fs_file_handle* fh = fs_entry_open( state->core, path, SG_SYS_USER, state->core->volume, O_WRONLY, 0755, &rc ); if( fh == NULL || rc != 0 ) { SG_error("\n\n\nfs_entry_open( %s ) rc = %d\n\n\n", path, rc ); exit(1); } else { SG_debug("\n\n\nfs_entry_open( %s ) rc = %d\n\n\n", path, rc ); } // write data for( int i = test_optind + 1; i < argc; i++ ) { // get offset long offset = strtol( argv[i], NULL, 10 ); i++; if( i >= argc ) { // must have [offset size] pairs usage( argv[0] ); } // get data char* buf = argv[i]; size_t size = strlen(buf); // write the data SG_debug("\n\n\nfs_entry_write( %s, %ld, %ld, '%s' )\n\n\n", path, size, offset, buf ); ssize_t nw = fs_entry_write( state->core, fh, buf, size, offset ); if( nw < 0 ) { SG_error("\n\n\nfs_entry_write( %s, %ld, %ld, '%s' ) rc = %d\n\n\n", path, size, offset, buf, nw ); exit(1); } else { SG_debug("\n\n\nfs_entry_write( %s, %ld, %ld, '%s' ) rc = %zd\n\n\n", path, size, offset, buf, nw ); } } // close SG_debug("\n\n\nfs_entry_close( %s )\n\n\n", path ); rc = fs_entry_close( state->core, fh ); if( rc != 0 ) { SG_error("\n\n\nfs_entry_close( %s ) rc = %d\n\n\n", path, rc ); exit(1); } else { SG_debug("\n\n\nfs_entry_close( %s ) rc = %d\n\n\n", path, rc ); } free( fh ); // shut down the test syndicate_functional_test_shutdown( &syndicate_http ); return 0; }
int main( int argc, char** argv ) { struct md_HTTP syndicate_http; int test_optind = -1; // set up the test syndicate_functional_test_init( argc, argv, &test_optind, &syndicate_http ); // arguments: listxattr [syndicate options] /path/to/file if( test_optind < 0 ) usage( argv[0] ); if( test_optind >= argc ) usage( argv[0] ); char* path = argv[test_optind]; char xattr_listing[65536]; memset( xattr_listing, 65536, 0 ); // get state struct syndicate_state* state = syndicate_get_state(); // get the xattr list size dbprintf("\n\n\nfs_entry_listxattr( %s )\n\n\n", path ); ssize_t rc = fs_entry_listxattr( state->core, path, xattr_listing, 0, SYS_USER, 0 ); if( rc < 0 || rc > 65535 ) { errorf("\n\n\nfs_entry_listxattr( %s ) rc = %zd\n\n\n", path, rc ); syndicate_functional_test_shutdown( &syndicate_http ); exit(1); } dbprintf("\n\n\nfs_entry_listxattr( %s, 0 ) rc = %zd\n\n\n", path, rc ); // get the xattr list for real this time memset( xattr_listing, 0, 65536 ); rc = fs_entry_listxattr( state->core, path, xattr_listing, rc, SYS_USER, 0 ); if( rc < 0 || rc > 65535 ) { errorf("\n\n\nfs_entry_listxattr( %s ) rc = %zd\n\n\n", path, rc ); syndicate_functional_test_shutdown( &syndicate_http ); exit(1); } dbprintf("\n\n\nfs_entry_listxattr( %s ) rc = %zd\n", path, rc ); // tokenize and print the xattr listing ssize_t off = 0; while( off < rc ) { printf(" %s\n", xattr_listing + off); off += strlen(xattr_listing + off); off += 1; } printf("\n"); // shut down the test syndicate_functional_test_shutdown( &syndicate_http ); return 0; }