void test_url_ipv4_no_port() { dcap_url * url = dc_getURL("dcap://1.2.3.4/path/to/file"); CU_ASSERT_PTR_NOT_NULL(url); CU_ASSERT_EQUAL(url->type, URL_DCAP); CU_ASSERT_STRING_EQUAL(url->host, "1.2.3.4"); CU_ASSERT_STRING_EQUAL(url->file, "path/to/file"); CU_ASSERT_EQUAL(url->port, DEFAULT_DOOR_PORT); }
void test_url_ipv6_no_port() { dcap_url * url = dc_getURL("dcap://[fe80::21c:c0ff:fea0:caf4]/path/to/file"); CU_ASSERT_PTR_NOT_NULL(url); CU_ASSERT_EQUAL(url->type, URL_DCAP); CU_ASSERT_STRING_EQUAL(url->host, "fe80::21c:c0ff:fea0:caf4"); CU_ASSERT_STRING_EQUAL(url->file, "path/to/file"); CU_ASSERT_EQUAL(url->port, 22125); }
void test_url_ipv4() { dcap_url * url = dc_getURL("dcap://1.2.3.4:22127/path/to/file"); CU_ASSERT_PTR_NOT_NULL(url); CU_ASSERT_EQUAL(url->type, URL_DCAP); CU_ASSERT_STRING_EQUAL(url->host, "1.2.3.4"); CU_ASSERT_STRING_EQUAL(url->file, "path/to/file"); CU_ASSERT_EQUAL(url->port, 22127); }
void test_url_no_port() { dcap_url * url = dc_getURL("dcap://door.site.org/path/to/file"); CU_ASSERT_PTR_NOT_NULL(url); CU_ASSERT_EQUAL(url->type, URL_DCAP); CU_ASSERT_STRING_EQUAL(url->host, "door.site.org"); CU_ASSERT_STRING_EQUAL(url->file, "path/to/file"); CU_ASSERT_EQUAL(url->port, DEFAULT_DOOR_PORT); }
void test_url() { dcap_url * url = dc_getURL("dcap://door.site.org:22127/path/to/file"); CU_ASSERT_PTR_NOT_NULL(url); CU_ASSERT_EQUAL(url->type, URL_DCAP); CU_ASSERT_STRING_EQUAL(url->host, "door.site.org"); CU_ASSERT_STRING_EQUAL(url->file, "path/to/file"); CU_ASSERT_EQUAL(url->port, 22127); }
int dc_chown( const char *path, uid_t uid, gid_t gid) { dcap_url *url; struct vsp_node *node; int rc; url = (dcap_url *)dc_getURL(path); if( url == NULL ) { dc_debug(DC_INFO, "Using system native chown for %s.", path); return system_chown(path, uid, gid); } node = new_vsp_node( path ); if( node == NULL ) { free(url->file); free(url->host); if( url->prefix != NULL ) free(url->prefix); free(url); return 1; } node->url = url; if (url->type == URL_PNFS) { node->pnfsId = (char *)strdup(url->file); }else{ node->pnfsId = (char *)strdup(path); } node->asciiCommand = DCAP_CMD_CHOWN; node->uid = uid; node->gid = gid; rc = cache_open(node); /* node cleanup procedure */ node_unplug( node ); deleteQueue(node->queueID); node_destroy(node); return rc; }
int dc_acl(const char *path, int cmd, int nentries, void *aclbufp) { dcap_url *url; struct vsp_node *node; int rc; url = (dcap_url *)dc_getURL(path); if( url == NULL ) { dc_debug(DC_INFO, "Using system native chown for %s.", path); return system_acl(path, cmd, nentries, aclbufp); } else { free(url->file); free(url->host); if( url->prefix != NULL ) { free(url->prefix); } free(url); } return dc_acl_dummy(cmd); }
int dc_lstat64(const char *path, struct stat64 *buf) #endif { dcap_url *url; struct vsp_node *node; #ifdef WIN32 struct _stati64 *s; #else struct stat64 *s; #endif int rc; int old_errno; #ifdef DC_CALL_TRACE showTraceBack(); #endif /* nothing wrong ... yet */ dc_errno = DEOK; url = (dcap_url *)dc_getURL(path); /* let system to do the work where it's possible */ if(url == NULL) { dc_debug(DC_INFO, "Using system native lstat64 for %s.", path); rc = system_lstat64(path, buf); /* isPnfs overwrite errno */ old_errno = errno; if( (buf->st_size != 1) || !isPnfs(path) ) { errno = old_errno; return rc; } } node = new_vsp_node(path); if (node == NULL) { dc_debug(DC_ERROR, "dc_stat: Failed to create new node."); free(url->file); free(url->host); free(url); return -1; } node->url = url; if (url == NULL ) { getPnfsID(node); }else{ if (url->type == URL_PNFS) { node->pnfsId = (char *)strdup(url->file); }else{ node->pnfsId = (char *)strdup(path); } } node->asciiCommand = DCAP_CMD_LSTAT; rc = cache_open(node); if(node->ipc != NULL) { #ifdef WIN32 s = (struct _stati64*)node->ipc; memcpy(buf, s, sizeof(struct _stati64) ); #else s = (struct stat64*)node->ipc; memcpy(buf, s, sizeof(struct stat64) ); #endif free(node->ipc); node->ipc = NULL; } /* node cleanup procedure */ node_unplug( node ); deleteQueue(node->queueID); node_destroy(node); if( rc != 0 ) { errno = ENOENT; } return rc; }
void test_bad_formated() { dcap_url * url = dc_getURL("dcap://[fe80::21c:c0ff:fea0:caf4/path/to/file"); CU_ASSERT_PTR_NULL(url); }
void test_not_a_url() { dcap_url * url = dc_getURL("/path/to/file"); CU_ASSERT_PTR_NULL(url); }