Пример #1
0
/*
 *  walk up the tree building a Unix style path
 */
static void
unixpath(Node *node, String *path)
{
	if(node == node->parent){
		s_append(path, s_to_c(remrootpath));
		return;
	}
	unixpath(node->parent, path);
	if(s_len(path) > 0 && strcmp(s_to_c(path), "/") != 0)
		s_append(path, "/");
	s_append(path, s_to_c(node->remname));
}
Пример #2
0
/*
 *  change to a remote directory.
 */
int
changedir(Node *node)
{
	Node *to;
	String *cdpath;

	to = node;
	if(to == remdir)
		return 0;

	/* build an absolute path */
	switch(os){
	case Tops:
	case VM:
		switch(node->depth){
		case 0:
			remdir = node;
			return 0;
		case 1:
			cdpath = s_clone(node->remname);
			break;
		default:
			return seterr(nosuchfile);
		}
		break;
	case VMS:
		switch(node->depth){
		case 0:
			remdir = node;
			return 0;
		default:
			cdpath = s_new();
			vmspath(node, cdpath);
		}
		break;
	case MVS:
		if(node->depth == 0)
			cdpath = s_clone(remrootpath);
		else{
			cdpath = s_new();
			mvspath(node, cdpath);
		}
		break;
	default:
		if(node->depth == 0)
			cdpath = s_clone(remrootpath);
		else{
			cdpath = s_new();
			unixpath(node, cdpath);
		}
		break;
	}

	uncachedir(remdir, 0);

	/*
	 *  connect, if we need a password (Incomplete)
	 *  act like it worked (best we can do).
	 */
	sendrequest("CWD", s_to_c(cdpath));
	s_free(cdpath);
	switch(getreply(&ctlin, msg, sizeof(msg), 0)){
	case Success:
	case Incomplete:
		remdir = node;
		return 0;
	default:
		return seterr(nosuchfile);
	}
}
Пример #3
0
 Array* unixaddr(STATE, struct sockaddr_un* addr, socklen_t len) {
   Array* ary = Array::create(state, 2);
   ary->set(state, 0, String::create(state, "AF_UNIX"));
   ary->set(state, 1, String::create(state, unixpath(addr, len)));
   return ary;
 }