struct jffs2_inode_cache *jffs2_alloc_inode_cache(void) { struct jffs2_inode_cache *ret = kmem_cache_alloc(inode_cache_slab, GFP_KERNEL); D3 (printk(KERN_DEBUG "Allocated inocache at %p\n", ret)); return ret; }
void jffs2_free_inode_cache(struct jffs2_inode_cache *x) { D3 (printk(KERN_DEBUG "Freeing inocache at %p\n", x)); kmem_cache_free(inode_cache_slab, x); }
struct jffs2_node_frag *jffs2_alloc_node_frag(void) { struct jffs2_node_frag *ret = kmem_cache_alloc(node_frag_slab, GFP_KERNEL); D3 (printk (KERN_DEBUG "alloc_node_frag at %p\n", ret)); return ret; }
void jffs2_free_node_frag(struct jffs2_node_frag *x) { D3 (printk (KERN_DEBUG "free_node_frag at %p\n", x)); kmem_cache_free(node_frag_slab, x); }
struct jffs2_raw_node_ref *jffs2_alloc_raw_node_ref(void) { struct jffs2_raw_node_ref *ret = kmem_cache_alloc(raw_node_ref_slab, GFP_KERNEL); D3 (printk (KERN_DEBUG "alloc_raw_node_ref at %p\n", ret)); return ret; }
void jffs2_free_raw_node_ref(struct jffs2_raw_node_ref *x) { D3 (printk (KERN_DEBUG "free_raw_node_ref at %p\n", x)); kmem_cache_free(raw_node_ref_slab, x); }
struct jffs2_tmp_dnode_info *jffs2_alloc_tmp_dnode_info(void) { struct jffs2_tmp_dnode_info *ret = kmem_cache_alloc(tmp_dnode_info_slab, GFP_KERNEL); D3 (printk (KERN_DEBUG "alloc_tmp_dnode_info at %p\n", ret)); return ret; }
/* vntsd_read worker */ int vntsd_read(vntsd_client_t *clientp) { char c; int rv; assert(clientp); D3(stderr, "t@%d vntsd_read@%d\n", thr_self(), clientp->sockfd); for (; ; ) { /* client input */ rv = read_char(clientp, &c); if (rv == VNTSD_STATUS_INTR) { rv = vntsd_cons_chk_intr(clientp); } if (rv != VNTSD_SUCCESS) { return (rv); } assert(clientp->cons); /* * Only keyboard inputs from first connection to a * guest console should be accepted. Check to see if * this client is the first connection in console * queue */ if (clientp->cons->clientpq->handle != clientp) { /* * Since this console connection is not the first * connection in the console queue, * it is operating in 'reader' * mode, print warning and ignore the input. */ rv = vntsd_write_line(clientp, gettext(VNTSD_NO_WRITE_ACCESS_MSG)); /* check errors and interrupts */ if (rv == VNTSD_STATUS_INTR) { rv = vntsd_cons_chk_intr(clientp); } if (rv != VNTSD_SUCCESS) { return (rv); } continue; } rv = vntsd_ctrl_cmd(clientp, c); switch (rv) { case VNTSD_STATUS_CONTINUE: continue; break; case VNTSD_STATUS_INTR: rv = vntsd_cons_chk_intr(clientp); if (rv != VNTSD_SUCCESS) { return (rv); } break; case VNTSD_SUCCESS: break; default: return (rv); } /* write to vcc */ rv = write_vcc(clientp, c); if (rv == VNTSD_STATUS_INTR) { rv = vntsd_cons_chk_intr(clientp); } if (rv != VNTSD_SUCCESS) { return (rv); } } /*NOTREACHED*/ return (NULL); }
void jffs2_free_raw_dirent(struct jffs2_raw_dirent *x) { D3 (printk (KERN_DEBUG "free_raw_dirent at %p\n", x)); kmem_cache_free(raw_dirent_slab, x); }
void jffs2_free_raw_inode(struct jffs2_raw_inode *x) { D3 (printk (KERN_DEBUG "free_raw_inode at %p\n", x)); kmem_cache_free(raw_inode_slab, x); }
struct jffs2_raw_dirent *jffs2_alloc_raw_dirent(void) { struct jffs2_raw_dirent *ret = kmem_cache_alloc(raw_dirent_slab, GFP_KERNEL); D3 (printk (KERN_DEBUG "alloc_raw_dirent\n", ret)); return ret; }
struct jffs2_full_dnode *jffs2_alloc_full_dnode(void) { struct jffs2_full_dnode *ret = kmem_cache_alloc(full_dnode_slab, GFP_KERNEL); D3 (printk (KERN_DEBUG "alloc_full_dnode at %p\n", ret)); return ret; }
/* listen thread */ void * vntsd_listen_thread(vntsd_group_t *groupp) { int newsockfd; size_t clilen; struct sockaddr_in cli_addr; int rv; int num_cons; vntsd_t *vntsdp; assert(groupp); D1(stderr, "t@%d listen@%lld\n", thr_self(), groupp->tcp_port); vntsdp = groupp->vntsd; /* initialize listen socket */ (void) mutex_lock(&groupp->lock); rv = open_socket(groupp->tcp_port, &groupp->sockfd); (void) mutex_unlock(&groupp->lock); listen_chk_status(groupp, rv); for (; ; ) { clilen = sizeof (cli_addr); /* listen to the socket */ newsockfd = accept(groupp->sockfd, (struct sockaddr *)&cli_addr, &clilen); D1(stderr, "t@%d listen_thread() connected sockfd=%d\n", thr_self(), newsockfd); if (newsockfd <= 0) { if (errno == EINTR) { listen_chk_status(groupp, VNTSD_STATUS_INTR); } else { listen_chk_status(groupp, VNTSD_STATUS_ACCEPT_ERR); } continue; } /* Check authorization if enabled */ if ((vntsdp->options & VNTSD_OPT_AUTH_CHECK) != 0) { rv = auth_check_fd(newsockfd, groupp->group_name); if (rv != B_TRUE) { D3(stderr, "t@%d listen@%lld group@%s: " "authorization failure\n", thr_self(), groupp->tcp_port, groupp->group_name); (void) close(newsockfd); continue; } } num_cons = vntsd_chk_group_total_cons(groupp); if (num_cons == 0) { (void) close(newsockfd); listen_chk_status(groupp, VNTSD_STATUS_NO_CONS); continue; } /* a connection is established */ rv = vntsd_set_telnet_options(newsockfd); if (rv != VNTSD_SUCCESS) { (void) close(newsockfd); listen_chk_status(groupp, rv); } rv = create_console_thread(groupp, newsockfd); if (rv != VNTSD_SUCCESS) { (void) close(newsockfd); listen_chk_status(groupp, rv); } } /*NOTREACHED*/ return (NULL); }
int main(void){ // hier komt de test /* int i = 0, j; char letter = 'a'; char buffer[3]; std::string* hulp; for(; i < h_nodes; i++){ for(j = 0; j < v_nodes; j++){ sprintf(buffer, "%c%d" , letter, j); hulp = new std::string(buffer); new Node(*hulp); delete hulp; } letter++; if(letter > 'z'){ letter = 'a'; } } printf("%p\n", Node::getParticularNode(std::string("a1"))); Node::getParticularNode(std::string("a1"))->print(); printf("%p\n", Node::getParticularNode(std::string("b1"))); Node::getParticularNode(std::string("b1"))->print(); Node::deleteAllNodes(); printf("%p\n", Node::getParticularNode(std::string("a1"))); Node::getParticularNode(std::string("a1"))->print(); */ Node A1("A1"); A1.addNeighbournode("B1", 4); A1.addNeighbournode("B2", 2); Node B1("B1"); B1.addNeighbournode("C1", 2); Node B2("B2"); B2.addNeighbournode("C3", 1); B2.setState(nodeUsed); Node C1("C1"); C1.addNeighbournode("D1", 1); Node C2("C2"); C2.addNeighbournode("D2", 3); C2.addNeighbournode("D3", 6); Node C3("C3"); C3.addNeighbournode("C2", 1); C3.addNeighbournode("D4", 3); Node D1("D1"); D1.addNeighbournode("D2", 9); Node D2("D2"); D2.addNeighbournode("D1", 9); D2.addNeighbournode("C2", 3); Node D3("D3"); D3.addNeighbournode("D4", 2); Node D4("D4"); D4.addNeighbournode("D3", 2); dijkstra planner; planner.calculateRoute(&A1, &D4); planner.printpath(); return 0; }
void jffs2_free_tmp_dnode_info(struct jffs2_tmp_dnode_info *x) { D3 (printk (KERN_DEBUG "free_tmp_dnode_info at %p\n", x)); kmem_cache_free(tmp_dnode_info_slab, x); }
/* * Add or remove multicast address(es). * * Returns 0 on success, 1 on failure. */ int vsw_add_rem_mcst(vnet_mcast_msg_t *mcst_pkt, vsw_port_t *port) { mcst_addr_t *mcst_p = NULL; vsw_t *vswp = port->p_vswp; uint64_t addr = 0x0; int i; D1(vswp, "%s: enter", __func__); D2(vswp, "%s: %d addresses", __func__, mcst_pkt->count); for (i = 0; i < mcst_pkt->count; i++) { /* * Convert address into form that can be used * as hash table key. */ KEY_HASH(addr, &(mcst_pkt->mca[i])); /* * Add or delete the specified address/port combination. */ if (mcst_pkt->set == 0x1) { D3(vswp, "%s: adding multicast address 0x%llx for " "port %ld", __func__, addr, port->p_instance); if (vsw_add_mcst(vswp, VSW_VNETPORT, addr, port) == 0) { /* * Update the list of multicast * addresses contained within the * port structure to include this new * one. */ mcst_p = kmem_zalloc(sizeof (mcst_addr_t), KM_NOSLEEP); if (mcst_p == NULL) { DERR(vswp, "%s: unable to alloc mem", __func__); (void) vsw_del_mcst(vswp, VSW_VNETPORT, addr, port); return (1); } mcst_p->nextp = NULL; mcst_p->addr = addr; ether_copy(&mcst_pkt->mca[i], &mcst_p->mca); /* * Program the address into HW. If the addr * has already been programmed then the MAC * just increments a ref counter (which is * used when the address is being deleted) */ if (vsw_mac_multicast_add(vswp, port, mcst_p, VSW_VNETPORT)) { (void) vsw_del_mcst(vswp, VSW_VNETPORT, addr, port); kmem_free(mcst_p, sizeof (*mcst_p)); return (1); } mutex_enter(&port->mca_lock); mcst_p->nextp = port->mcap; port->mcap = mcst_p; mutex_exit(&port->mca_lock); } else { DERR(vswp, "%s: error adding multicast " "address 0x%llx for port %ld", __func__, addr, port->p_instance); return (1); } } else { /* * Delete an entry from the multicast hash * table and update the address list * appropriately. */ if (vsw_del_mcst(vswp, VSW_VNETPORT, addr, port) == 0) { D3(vswp, "%s: deleting multicast address " "0x%llx for port %ld", __func__, addr, port->p_instance); mcst_p = vsw_del_addr(VSW_VNETPORT, port, addr); ASSERT(mcst_p != NULL); /* * Remove the address from HW. The address * will actually only be removed once the ref * count within the MAC layer has dropped to * zero. I.e. we can safely call this fn even * if other ports are interested in this * address. */ vsw_mac_multicast_remove(vswp, port, mcst_p, VSW_VNETPORT); kmem_free(mcst_p, sizeof (*mcst_p)); } else { DERR(vswp, "%s: error deleting multicast " "addr 0x%llx for port %ld", __func__, addr, port->p_instance); return (1); } } } D1(vswp, "%s: exit", __func__); return (0); }
/* When the flash memory scan has completed, this function should be called before use of the control structure. */ int jffs_build_end(struct jffs_fmcontrol *fmc, __u32 head_offset) { D3(printk("jffs_build_end()\n")); if (!fmc->head) { fmc->head = fmc->head_extra; fmc->tail = fmc->tail_extra; } else if (fmc->head_extra) { struct jffs_fm *fm, *cur; if (head_offset == fmc->head->offset){ fmc->tail->next = fmc->head_extra; fmc->head_extra->prev = fmc->tail; fmc->tail = fmc->tail_extra; } else { fmc->tail_extra->next = fmc->head; fmc->head->prev = fmc->tail_extra; fmc->head = fmc->head_extra; while (fmc->head->offset != head_offset){ fmc->tail->next = fmc->head; fmc->head = fmc->head->next; fmc->head->prev = 0; fmc->tail->next->prev = fmc->tail; fmc->tail = fmc->tail->next; fmc->tail->next = 0; } } /* Make sure the only free space we have is between tail and head. */ for (cur = fmc->head; cur && cur != fmc->tail;) { if (cur->offset + cur->size < cur->next->offset) { if (!(fm = kmalloc(sizeof(struct jffs_fm), GFP_KERNEL))) { D(printk("jffs_buid_end(): kmalloc failed!\n")); return -ENOMEM; } DJM(no_jffs_fm++); fm->size = cur->next->offset - cur->offset - cur->size; fm->offset = cur->offset + cur->size; fm->nodes = 0; fm->next = cur->next; fm->prev = cur; cur->next->prev = fm; cur->next = fm; cur = fm->next; fmc->free_size -= fm->size; fmc->dirty_size += fm->size; } else if (cur->offset > cur->next->offset) { if (cur->offset + cur->size < fmc->flash_size){ if (!(fm = kmalloc(sizeof(struct jffs_fm), GFP_KERNEL))){ D(printk("jffs_buid_end(): kmalloc failed!\n")); return -ENOMEM; } DJM(no_jffs_fm++); fm->size = fmc->flash_size - cur->offset - cur->size; fm->nodes = 0; fm->offset = cur->offset + cur->size; fm->next = cur->next; fm->prev = cur; cur->next->prev = fm; cur->next = fm; cur = fm->next; fmc->free_size -= fm->size; fmc->dirty_size += fm->size; } else { cur = cur->next; } if (cur->offset > 0) { if (!(fm = kmalloc(sizeof(struct jffs_fm), GFP_KERNEL))) { D(printk("jffs_buid_end(): kmalloc failed!\n")); return -ENOMEM; } DJM(no_jffs_fm++); fm->size = cur->offset; fm->nodes = 0; fm->offset = 0; fm->next = cur; fm->prev = cur->prev; cur->prev->next = fm; cur->prev = fm; fmc->free_size -= fm->size; fmc->dirty_size += fm->size; } } else if (cur->offset + cur->size != cur->next->offset) { printk("jffs_build_end(): Internal error.\n"); return -EINVAL; } else { cur = cur->next; } } } fmc->head_extra = 0; /* These two instructions should be omitted. */ fmc->tail_extra = 0; D3(jffs_print_fmcontrol(fmc)); return 0; }