Пример #1
0
/* We are single threaded now, hence it's ok to use strtok() */
static int
do_ls(struct AffReader_s *r, const char *name, const char *kp)
{
//    char *pp = xstrdup(kp);
//    char *p = pp;
    struct AffNode_s *root = aff_reader_root(r);
    struct AffNode_s *node;
    struct arg arg;
    
    node = lookup_path(r, root, kp);
    if (NULL == node) {
        fprintf(stderr, "lhpc-aff: %s[%s]: cannot read node\n", name, kp);
        return 0;   // FIXME print error and proceed
    }
//    for (node = root, p = strtok(p, "/"); p; p = strtok(NULL, "/")) {
//	node = aff_reader_chdir(r, node, p);
//	if (node == 0) {
//	    fprintf(stderr, "lhpc-aff: error accesing %s:%s at %s\n",
//		    name, kp, p);
//	    free(pp);
//	    return 0;   // FIXME print error and proceed
//	}
//    }
//    free(pp);
    arg.r = r;
    arg.fname = name;
    arg.kpath = kp;
    arg.root = root;
    do_node(node, &arg);
    return (aff_reader_errstr(r) != 0);
}
Пример #2
0
static void
make_path( sliceable_switch *sliceable_switch, uint64_t in_datapath_id, uint16_t in_port, uint16_t in_vid,
           uint64_t out_datapath_id, uint16_t out_port, uint16_t out_vid, const buffer *packet ) {
  dlist_element *hops = resolve_path( sliceable_switch->pathresolver, in_datapath_id, in_port, out_datapath_id, out_port );
  if ( hops == NULL ) {
    warn( "No available path found ( %#" PRIx64 ":%u -> %#" PRIx64 ":%u ).",
          in_datapath_id, in_port, out_datapath_id, out_port );
    discard_packet_in( in_datapath_id, in_port, packet );
    return;
  }

  // check if the packet is ARP or not
  if ( sliceable_switch->handle_arp_with_packetout && packet_type_arp( packet ) ) {
    // send packet out for tail switch
    free_hop_list( hops );
    output_packet( packet, out_datapath_id, out_port, out_vid );
    return;
  }

  const uint32_t wildcards = 0;
  struct ofp_match match;
  set_match_from_packet( &match, in_port, wildcards, packet );

  if ( lookup_path( in_datapath_id, match, PRIORITY ) != NULL ) {
    warn( "Duplicated path found." );
    output_packet( packet, out_datapath_id, out_port, out_vid );
    return;
  }

  const uint16_t hard_timeout = 0;
  path *p = create_path( match, PRIORITY, sliceable_switch->idle_timeout, hard_timeout );
  assert( p != NULL );
  for ( dlist_element *e = get_first_element( hops ); e != NULL; e = e->next ) {
    pathresolver_hop *rh = e->data;
    hop *h = create_hop( rh->dpid, rh->in_port_no, rh->out_port_no, NULL );
    assert( h != NULL );
    append_hop_to_path( p, h );
  } // for(;;)

  dlist_element *e = get_last_element( hops );
  pathresolver_hop *last_hop = e->data;
  packet_out_params *params = xmalloc( sizeof( struct packet_out_params ) );
  params->packet = duplicate_buffer( packet );
  params->out_datapath_id = last_hop->dpid;
  params->out_port_no = last_hop->out_port_no;
  params->out_vid = out_vid;

  bool ret = setup_path( p, handle_setup, params, NULL, NULL );
  if ( ret != true ) {
    error( "Failed to set up path." );
    output_packet( packet, out_datapath_id, out_port, out_vid );
    free_buffer( params->packet );
    xfree( params );
  }

  delete_path( p );

  // free them
  free_hop_list( hops );
}
Пример #3
0
/*
 * 'path' is '/' + canonical path, or a relative path.  It is not the
 * same as a canonical path.
 */
char *
gfs_realpath_canonical(const char *path, char **abspathp)
{
	struct node *n, *p;
	char *e, *abspath;
	int l, len;

	e = gfs_refreshdir();
	if (e != NULL) 
		return (e);
	e = lookup_path(path, -1, GFARM_INODE_LOOKUP, &n);
	if (e != NULL)
		return (e);
	len = 0;
	for (p = n; p != root; p = p->parent) {
		if (p != n)
			++len; /* for '/' */
		len += strlen(p->name);
	}
	abspath = malloc(len + 1);
	if (abspath == NULL)
		return (GFARM_ERR_NO_MEMORY);
	abspath[len] = '\0';
	for (p = n; p != root; p = p->parent) {
		if (p != n)
			abspath[--len] = '/';
		l = strlen(p->name);
		len -= l;
		memcpy(abspath + len, p->name, l);
	}
	*abspathp = abspath;
	return (NULL);
}
Пример #4
0
int FuseWrapper::getattr_fn(const char* path, struct stat* stbuf) {
  std::unique_lock<std::mutex> lk(list_mutex);
  FuseClient* client = lookup_path(path);
  if (client == nullptr)
    return -1;
  else
    return client->getattr(path, stbuf);
}
Пример #5
0
int FuseWrapper::open_fn(const char* path, fuse_file_info* fi) {
  std::unique_lock<std::mutex> lk(list_mutex);
  FuseClient* client = lookup_path(path);
  if (client == nullptr)
    return -1;
  else
    return client->open(path, fi);
}
Пример #6
0
int FuseWrapper::read_fn(const char* path, char* buf, size_t size, off_t offset,
            fuse_file_info* fi) {
  std::unique_lock<std::mutex> lk(list_mutex);
  FuseClient* client = lookup_path(path);
  if (client == nullptr)
    return -1;
  else
    return client->read(path, buf, size, offset, fi);
}
Пример #7
0
static int myth_getattr(const char *path, struct stat *stbuf)
{
	struct path_info info;
	int i;

	debug("%s(): path '%s'\n", __FUNCTION__, path);

	if (strcmp(path, README_PATH) == 0) {
		return readme_getattr(path, stbuf);
	}

	memset(&info, 0, sizeof(info));
	if (lookup_path(path, &info) < 0) {
		return -ENOENT;
	}

        memset(stbuf, 0, sizeof(struct stat));
        if (info.host == NULL) {
                stbuf->st_mode = S_IFDIR | 0555;
                stbuf->st_nlink = 2;
		return 0;
	}

	if (info.dir == NULL) {
                stbuf->st_mode = S_IFDIR | 0555;
                stbuf->st_nlink = 2;
		return 0;
	}

	i = 0;
	while (dircb[i].name) {
		if (strcmp(info.dir, dircb[i].name) == 0) {
			break;
		}
		i++;
	}
	if (dircb[i].name == NULL) {
		return -ENOENT;
	}

	if (info.file == NULL) {
                stbuf->st_mode = S_IFDIR | 0555;
                stbuf->st_nlink = 2;
		return 0;
	}

	i = 0;
	while (dircb[i].name) {
		if (strcmp(info.dir, dircb[i].name) == 0) {
			return dircb[i].getattr(&info, stbuf);
		}
		i++;
	}

	return -ENOENT;
}
Пример #8
0
static int lookup_triplets(const char *const *triplets, const char *name)
{
	int i;
	char buf[PATH_MAX];

	for (i = 0; triplets[i] != NULL; i++) {
		scnprintf(buf, sizeof(buf), "%s%s", triplets[i], name);
		if (lookup_path(buf))
			return i;
	}
	return -1;
}
Пример #9
0
static int myth_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
			off_t offset, struct fuse_file_info *fi)
{
	struct path_info info;
	int i;

	debug("%s(): path '%s'\n", __FUNCTION__, path);

	memset(&info, 0, sizeof(info));
	if (lookup_path(path, &info) < 0) {
		return -ENOENT;
	}

	if (info.host == NULL) {
		for (i=0; i<MAX_CONN; i++) {
			if (conn[i].host) {
				filler(buf, conn[i].host, NULL, 0);
			}
		}

		goto finish;
	}

	if (info.dir == NULL) {
		i = 0;
		while (dircb[i].name) {
			filler(buf, dircb[i].name, NULL, 0);
			i++;
		}
		goto finish;
	}

	i = 0;
	while (dircb[i].name) {
		if (strcmp(info.dir, dircb[i].name) == 0) {
			dircb[i].readdir(&info, buf, filler, offset, fi);
			goto finish;
		}
		i++;
	}

	return -ENOENT;

finish:
	filler(buf, ".", NULL, 0);
	filler(buf, "..", NULL, 0);

	if (strcmp(path, "/") == 0) {
		filler(buf, "README", NULL, 0);
	}

	return 0;
}
Пример #10
0
static int myth_open(const char *path, struct fuse_file_info *fi)
{
	int i, f;
	struct path_info info;

	debug("%s(): path '%s'\n", __FUNCTION__, path);

	if (strcmp(path, README_PATH) == 0) {
		return readme_open(path, fi);
	}

	memset(&info, 0, sizeof(info));
	if (lookup_path(path, &info) < 0) {
		return -ENOENT;
	}

	if (info.file == NULL) {
		return -ENOENT;
	}

	pthread_mutex_lock(&mutex);

	for (f=0; f<MAX_FILES; f++) {
		if (!files[f].used) {
			break;
		}
	}
	if (f == MAX_FILES) {
		pthread_mutex_unlock(&mutex);
		return -ENFILE;
	}

	files[f].used = 1;

	pthread_mutex_unlock(&mutex);

	fi->fh = -1;

	i = 0;
	while (dircb[i].name) {
		if (strcmp(info.dir, dircb[i].name) == 0) {
			if (dircb[i].open == NULL) {
				return -ENOENT;
			}
			dircb[i].open(f, &info, fi);
			return 0;
		}
		i++;
	}

	return -ENOENT;
}
Пример #11
0
   /* 
    * run the program
    */
int main()
{
      // holds the directories in the path
   char path_dirs[ MAX_PATHS ][ MAX_PATH_LEN ];
      
   int num_dirs = parse_path( path_dirs );
   
   char line[ LINE_LEN ];
   command_t cmd;

      // get input
   print_prompt();
   read_cmd( line );
   parse_cmd( line, &cmd );

      // until we get a line that starts with exit or quit
   while( !cmd.argv[0] || 
          ( strcmp( cmd.argv[0], "quit" ) && 
            strcmp( cmd.argv[0], "exit" ) ) )
   {
      if( cmd.argv[0] )
         cmd.name = lookup_path( cmd.argv, path_dirs, num_dirs );

      if( cmd.name && cmd.argc > 0 )
      {
            // create the child
         pid_t child_pid = fork();
         if( child_pid < 0 )
            perror( "fork" );
         else if( child_pid == 0 ) // child
            execv( cmd.name, cmd.argv );
         else  // parent
         {
            if( !cmd.concurrent )
            {
               int status;
               waitpid( child_pid, &status, 0 );
            }
         }
      }

      cleanup_cmd( &cmd );
         
         // get input
      print_prompt();
      read_cmd( line );
      parse_cmd( line, &cmd );
   }

   return 0;
}
Пример #12
0
/*
 * emulate_path
 *   Lookup a path of hops and start
 *   emulated the hops using emulate_nexthop().
 *   
 *   Returns 0 for success, errno otherwise.
 */
static int
emulate_path(struct packet *pkt)
{
    struct ip      *ip;

    ip = mtod(pkt->m, struct ip *);

    /*
     * set the src with the forcebit, if set on dst 
     */
    ip->ip_src.s_addr |= (ip->ip_dst.s_addr & MODEL_FORCEBIT);
    /*
     * clear the destination of forcebit
     */
    ip->ip_dst.s_addr &= ~(MODEL_FORCEBIT);

    pkt->path =
        lookup_path(MODEL_FORCEOFF(ip->ip_src.s_addr), ip->ip_dst.s_addr);


    if (pkt->path == NULL) {
        Dprintf(("emulate_path: no path for packet srcip(0x%x) dstip(0x%x)\n",
		 ip->ip_src.s_addr, ip->ip_dst.s_addr), MN_P_ERR);
        return ENOENT;
    } else {
        Dprintf(("emulate_path: beginning path for packet\n"), MN_P_PKTS);
    }

    if (xcp_initialized){
	    /* There are xcp links in this emulation.
	     * Record XCP info for remote 
	     * packets.  XCP is a special XTQ policy,
	     * b/c it's a different protocol too.
	     */
	    xcp_get_xcpinfo(pkt);
    }

    pkt->info.hop = 0;

    pkt->info.src = ip->ip_src.s_addr;
    pkt->info.dst = ip->ip_dst.s_addr;

    emulate_nexthop(pkt);

    return 0;
}
Пример #13
0
char *
gfs_i_realpath_canonical(const char *path, char **abspathp)
{
	struct node *n, *p;
	char *e, *abspath;
	int l, len;

	e = gfs_refreshdir();
	if (e != NULL) 
		return (e);
	e = lookup_path(path, -1, GFARM_INODE_LOOKUP, &n);
	if (e != NULL) {
		char *p_dir, *c_path;
		const char *base;
		struct gfarm_path_info info;
		/*
		 * Before uncaching the metadata, check a typical case
		 * such that the parent directory exists.
		 */
		if (gfs_realpath_canonical_parent(path, &p_dir) == NULL) {
			base = gfarm_path_dir_skip(path);
			c_path = malloc(strlen(p_dir) + 1 + strlen(base) + 1);
			if (c_path == NULL) {
				free(p_dir);
				return (GFARM_ERR_NO_MEMORY);
			}
			sprintf(c_path, "%s/%s", p_dir, base);
			free(p_dir);
			e = gfarm_i_path_info_get(c_path, &info);
			free(c_path);
			if (e != NULL)
				return (e);
			else
				gfarm_path_info_free(&info);
		}
		/* there may be inconsistency, refresh and lookup again. */
		gfs_i_uncachedir();
		if (gfs_refreshdir() == NULL)
			e = lookup_path(path, -1, GFARM_INODE_LOOKUP, &n);
	}
	if (e != NULL)
		return (e);
	len = 0;
	for (p = n; p != root; p = p->parent) {
		if (p != n)
			++len; /* for '/' */
		len += strlen(p->name);
	}
	abspath = malloc(len + 1);
	if (abspath == NULL)
		return (GFARM_ERR_NO_MEMORY);
	abspath[len] = '\0';
	for (p = n; p != root; p = p->parent) {
		if (p != n)
			abspath[--len] = '/';
		l = strlen(p->name);
		len -= l;
		memcpy(abspath + len, p->name, l);
	}
	*abspathp = abspath;
	return (NULL);
}
Пример #14
0
static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
						  const char *name,
						  const char **path)
{
	int idx;
	const char *arch, *cross_env;
	struct utsname uts;
	const char *const *path_list;
	char *buf = NULL;

	arch = normalize_arch(env->arch);

	if (uname(&uts) < 0)
		goto out;

	/*
	 * We don't need to try to find objdump path for native system.
	 * Just use default binutils path (e.g.: "objdump").
	 */
	if (!strcmp(normalize_arch(uts.machine), arch))
		goto out;

	cross_env = getenv("CROSS_COMPILE");
	if (cross_env) {
		if (asprintf(&buf, "%s%s", cross_env, name) < 0)
			goto out_error;
		if (buf[0] == '/') {
			if (access(buf, F_OK) == 0)
				goto out;
			goto out_error;
		}
		if (lookup_path(buf))
			goto out;
		zfree(&buf);
	}

	if (!strcmp(arch, "arm"))
		path_list = arm_triplets;
	else if (!strcmp(arch, "powerpc"))
		path_list = powerpc_triplets;
	else if (!strcmp(arch, "sh"))
		path_list = sh_triplets;
	else if (!strcmp(arch, "s390"))
		path_list = s390_triplets;
	else if (!strcmp(arch, "sparc"))
		path_list = sparc_triplets;
	else if (!strcmp(arch, "x86"))
		path_list = x86_triplets;
	else if (!strcmp(arch, "mips"))
		path_list = mips_triplets;
	else {
		ui__error("binutils for %s not supported.\n", arch);
		goto out_error;
	}

	idx = lookup_triplets(path_list, name);
	if (idx < 0) {
		ui__error("Please install %s for %s.\n"
			  "You can add it to PATH, set CROSS_COMPILE or "
			  "override the default using --%s.\n",
			  name, arch, name);
		goto out_error;
	}

	if (asprintf(&buf, "%s%s", path_list[idx], name) < 0)
		goto out_error;

out:
	*path = buf;
	return 0;
out_error:
	free(buf);
	*path = NULL;
	return -1;
}
Пример #15
0
static void
handle_packet_in( uint64_t datapath_id, uint32_t transaction_id,
                  uint32_t buffer_id, uint16_t total_len,
                  uint16_t in_port, uint8_t reason, const buffer *data,
                  void *user_data ) {
  assert( in_port != 0 );
  assert( data != NULL );
  assert( user_data != NULL );

  sliceable_switch *sliceable_switch = user_data;

  debug( "Packet-In received ( datapath_id = %#" PRIx64 ", transaction_id = %#lx, "
         "buffer_id = %#lx, total_len = %u, in_port = %u, reason = %#x, "
         "data_len = %u ).", datapath_id, transaction_id, buffer_id,
         total_len, in_port, reason, data->length );

  if ( in_port > OFPP_MAX && in_port != OFPP_LOCAL ) {
    error( "Packet-In from invalid port ( in_port = %u ).", in_port );
    return;
  }

  const port_info *port = lookup_port( sliceable_switch->switches, datapath_id, in_port );
  if ( port == NULL ) {
    debug( "Ignoring Packet-In from unknown port." );
    return;
  }

  packet_info packet_info = get_packet_info( data );
  const uint8_t *src = packet_info.eth_macsa;
  const uint8_t *dst = packet_info.eth_macda;

  if ( !port->external_link || port->switch_to_switch_reverse_link ) {
    if ( !port->external_link
         && port->switch_to_switch_link
         && port->switch_to_switch_reverse_link
         && !is_ether_multicast( dst )
         && lookup_fdb( sliceable_switch->fdb, src, &datapath_id, &in_port ) ) {
      debug( "Found a Packet-In from switch-to-switch link." );
    }
    else {
      debug( "Ignoring Packet-In from non-external link." );
      return;
    }
  }

  uint16_t vid = VLAN_NONE;
  if ( packet_type_eth_vtag( data ) ) {
    vid = packet_info.vlan_vid;
  }

  if ( !update_fdb( sliceable_switch->fdb, src, datapath_id, in_port ) ) {
    return;
  }

  char match_str[ 1024 ];
  struct ofp_match match;
  set_match_from_packet( &match, in_port, 0, data );
  match_to_string( &match, match_str, sizeof( match_str ) );

  uint16_t slice = lookup_slice( datapath_id, in_port, vid, src );
  if ( slice == SLICE_NOT_FOUND ) {
    warn( "No slice found ( dpid = %#" PRIx64 ", vid = %u, match = [%s] ).", datapath_id, vid, match_str );
    goto deny;
  }

  int action = filter( datapath_id, in_port, slice, data );
  switch ( action ) {
  case ALLOW:
    debug( "Filter: ALLOW ( dpid = %#" PRIx64 ", slice = %#x, match = [%s] ).", datapath_id, slice, match_str );
    goto allow;
  case DENY:
    debug( "Filter: DENY ( dpid = %#" PRIx64 ", slice = %#x, match = [%s] ).", datapath_id, slice, match_str );
    goto deny;
  case LOCAL:
    debug( "Filter: LOCAL ( dpid = %#" PRIx64 ", slice = %#x, match = [%s] ).", datapath_id, slice, match_str );
    goto local;
  default:
    error( "Undefined filter action ( action = %#x ).", action );
    goto deny;
  }

allow:
  {
    uint16_t out_port;
    uint64_t out_datapath_id;

    if ( lookup_fdb( sliceable_switch->fdb, dst, &out_datapath_id, &out_port ) ) {
      // Host is located, so resolve path and send flowmod
      if ( ( datapath_id == out_datapath_id ) && ( in_port == out_port ) ) {
        debug( "Input port and out port are the same ( datapath_id = %#llx, port = %u ).",
               datapath_id, in_port );
        return;
      }

      uint16_t out_vid = vid;
      bool found = get_port_vid( slice, out_datapath_id, out_port, &out_vid );
      if ( found == false ) {
        uint16_t out_slice = lookup_slice_by_mac( dst );
        if ( out_slice != slice ) {
          debug( "Destination is on different slice ( slice = %#x, out_slice = %#x ).",
                 slice, out_slice );
          goto deny;
        }
      }

      make_path( sliceable_switch, datapath_id, in_port, vid, out_datapath_id, out_port, out_vid, data );
    } else {
      if ( lookup_path( datapath_id, match, PRIORITY ) != NULL ) {
        teardown_path( datapath_id, match, PRIORITY );
      }

      // Host's location is unknown, so flood packet
      flood_packet( datapath_id, in_port, slice, data, sliceable_switch->switches );
    }
    return;
  }

deny:
  {
    // Drop packets for a certain period
    buffer *flow_mod = create_flow_mod( transaction_id, match, get_cookie(),
                                        OFPFC_ADD, 0, FLOW_TIMER,
                                        UINT16_MAX, UINT32_MAX,
                                        OFPP_NONE, 0, NULL );
    send_openflow_message( datapath_id, flow_mod );
    free_buffer( flow_mod );
    return;
  }

local:
  {
    // Redirect to controller's local IP stack
    redirect( datapath_id, in_port, data );
    return;
  }
}
Пример #16
0
static int myth_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
			off_t offset, struct fuse_file_info *fi)
{
	struct path_info info;
	int i;

	debug("%s(): path '%s'\n", __FUNCTION__, path);

	memset(&info, 0, sizeof(info));
	if (lookup_path(path, &info) < 0) {
		return -ENOENT;
	}


	if (info.host == NULL) {
		for (i=0; i<MAX_CONN; i++) {
			if (conn[i].host) {
				filler(buf, conn[i].host, NULL, 0);
			}
		}

		goto finish;
	}

	if (info.dir == NULL) {
		i = 0;
		while (dircb[i].name) {
			filler(buf, dircb[i].name, NULL, 0);
			i++;
		}
		goto finish;
	}

	i = 0;
	while (dircb[i].name) {
		if (strcmp(info.dir, dircb[i].name) == 0) {
			dircb[i].readdir(&info, buf, filler, offset, fi);
			goto finish;
		}
		i++;
	}

	return -ENOENT;

finish:
	filler(buf, ".", NULL, 0);
	filler(buf, "..", NULL, 0);

	if (strcmp(path, "/") == 0) {
		struct stat st;
		memset(&st, 0, sizeof(st));
		st.st_mode = S_IFREG | 0444;
		st.st_size = strlen(README);
		st.st_nlink = 1;

		if (readme_time == 0) {
			time(&readme_time);
			readme_atime = readme_time;
		}
		st.st_atime = readme_atime;
		st.st_mtime = readme_time;
		st.st_ctime = readme_time;

		filler(buf, "README", &st, 0);
	}

	return 0;
}
Пример #17
0
static int myth_readlink(const char *path, char *buf, size_t size)
{
	struct path_info info;
	int n;
	int i;
	cmyth_conn_t control;
	cmyth_proglist_t list;
	int count;

	debug("%s(): path '%s' size %lld\n", __FUNCTION__, path,
	      (long long)size);

	memset(&info, 0, sizeof(info));
	if (lookup_path(path, &info) < 0) {
		return -ENOENT;
	}

	if (strcmp(info.dir, "all") != 0) {
		return -ENOENT;
	}

	pthread_mutex_lock(&mutex);

	if ((i=lookup_server(info.host)) < 0) {
		pthread_mutex_unlock(&mutex);
		return -ENOENT;
	}

	control = ref_hold(conn[i].control);

	if (conn[i].list == NULL) {
		list = cmyth_proglist_get_all_recorded(control);
		conn[i].list = list;
	} else {
		list = conn[i].list;
	}

	list = ref_hold(list);

	pthread_mutex_unlock(&mutex);

	count = cmyth_proglist_get_count(list);

	for (i=0; i<count; i++) {
		cmyth_proginfo_t prog;
		char tmp[512];
		char *t, *s, *pn;

		prog = cmyth_proglist_get_item(list, i);
		t = cmyth_proginfo_title(prog);
		s = cmyth_proginfo_subtitle(prog);
		pn = cmyth_proginfo_pathname(prog);

		snprintf(tmp, sizeof(tmp), "%s - %s.nuv", t, s);

		if (strcmp(tmp, info.file) == 0) {
			snprintf(tmp, sizeof(tmp), "../files%s", pn);

			n = (strlen(tmp) > size) ? size : strlen(tmp);
			strncpy(buf, tmp, n);

			debug("%s(): link '%s' %d bytes\n", __FUNCTION__,
			      tmp, n);

			ref_release(t);
			ref_release(s);
			ref_release(pn);
			ref_release(prog);
			ref_release(control);
			ref_release(list);

			return 0;
		}

		ref_release(t);
		ref_release(s);
		ref_release(pn);
		ref_release(prog);
	}

	ref_release(control);
	ref_release(list);

	return -ENOENT;
}
Пример #18
0
			    )
			    mn.stats.mc_ttldrops++;
		    MN_LOG_PACKET(info->src, info->dst, info->hop, 1);
		    err = EINVAL;
#ifdef DEBUG_REMOTE_INPUT
		    goto error;
#else
		    MN_FREE_PKT(pkt);
		    continue;
#endif
	    }

	    /*
	     * XXX lookup_path happens for each new core in path 
	     */
	    pkt->path = lookup_path(MODEL_FORCEOFF(pkt->info.src), pkt->info.dst);
	    if (pkt->path == NULL){
		    err = ENOENT;
		    goto error;
	    }
	    pkt->cachehost = pkt->path[0]->emulator;
	    pkt->path = pkt->path + pkt->info.hop;
	    pkt->state = 0;

	    /*
	     * if home and we have a pointer, means pcache was enabled when we
	     * left, then even if pcache is now off, it should still be in the
	     * cache 
	     */
	    if (MC_PKT_HOME(pkt) && MC_PKT_PCACHED(pkt)) {
		    Dprintf(("mc_reunite: on pkt(0x%x) id(0x%x)\n",(u_int32_t)pkt,(u_int32_t)pkt->info.id),MN_P_PKTS);
Пример #19
0
// XXX root node data is not copied!
int insert_data( struct AffWriter_s *w,
                 const char *src_fname, const char *src_kpath, const char *dst_kpath )
{
    struct AffNode_s *w_root = aff_writer_root( w );
    const char *status = NULL;
    if( NULL == w_root )
    {
        fprintf(stderr, "%s: %s\n", __func__, aff_writer_errstr( w ) );
        return 1;
    }
    struct AffNode_s *w_node = aff_writer_mkpath(w, aff_writer_root(w),
                               dst_kpath);
    if( NULL == w_node )
    {
        fprintf(stderr, "%s: [%s]: %s\n", __func__, dst_kpath,
                aff_writer_errstr( w ) );
        return 1;
    }
    struct stat stat_fb;
    if (stat(src_fname, &stat_fb))
    {
        perror(src_fname);
        return !ignore_missing;
    }
    struct AffReader_s *r;
    if (NULL == (r = aff_reader( src_fname )))
    {
        fprintf(stderr, "%s: not enough memory\n", __func__);
        return 1;
    }
    if(NULL != (status = aff_reader_errstr(r)))
    {
        fprintf(stderr, "%s: %s: %s\n", __func__, src_fname, status);
        goto errclean_r;
    }
    struct AffNode_s *r_root = aff_reader_root( r );
    if( NULL == r_root )
    {
        fprintf(stderr, "%s: %s: %s\n", __func__,
                src_fname, aff_reader_errstr(r));
        goto errclean_r;
    }
    struct AffNode_s *r_node = lookup_path( r, r_root, src_kpath );
    if (NULL == r_node) {
        fprintf(stderr, "%s: %s[%s]: cannot read node\n", __func__,
                src_fname, src_kpath);
        if (ignore_missing)
            goto clean_r;
        else
            goto errclean_r;
    }

    struct copy_nodes_arg arg;
    arg.r   = r;
    arg.w   = w;
    arg.w_parent = w_node;
    arg.weak = COPY_NODE_WEAK;
    arg.errstr = NULL;
    aff_node_foreach( r_node, copy_nodes_recursive, &arg );
    if( NULL != arg.errstr )
    {
        fprintf(stderr, "%s: [%s] <- %s[%s]: %s\n", __func__, dst_kpath,
                src_fname, src_kpath, arg.errstr);
        return 1;
    }
clean_r:
    aff_reader_close( r );
    return 0;

errclean_r:
    aff_reader_close(r);
    return 1;
}