Ticket #3124: patch.4.fbsdcompat.diff
File patch.4.fbsdcompat.diff, 2.8 KB (added by , 16 years ago) |
---|
-
src/libs/compat/freebsd_network/if.c
28 28 if_alloc(u_char type) 29 29 { 30 30 char semName[64]; 31 int i; 31 32 32 33 struct ifnet *ifp = _kernel_malloc(sizeof(struct ifnet), M_ZERO); 33 34 if (ifp == NULL) … … 52 53 ifp->flags = 0; 53 54 ifq_init(&ifp->receive_queue, semName); 54 55 56 for (i=0; i < MAX_DEVICES; i++) 57 if (gDevices[i] == NULL) 58 { 59 ifp->if_index = i; 60 gDevices[i] = ifp; 61 gDeviceCount++; 62 break; 63 } 64 65 if (i == MAX_DEVICES) 66 panic("unit too large"); 67 55 68 ifp->if_type = type; 56 69 IF_ADDR_LOCK_INIT(ifp); 57 70 return ifp; … … 67 80 void 68 81 if_free(struct ifnet *ifp) 69 82 { 83 int i; 84 for (i=0; i < MAX_DEVICES; i++) 85 if (ifp->device_name == gDeviceNameList[i]) 86 { 87 int last; 88 for (last = 0; last < MAX_DEVICES; last++) 89 if (gDeviceNameList[last] == NULL) 90 break; 91 last--; 92 93 if (i == last) 94 gDeviceNameList[i] = NULL; 95 else { 96 gDeviceNameList[i] = gDeviceNameList[last]; 97 gDeviceNameList[last] = NULL; 98 } 99 break; 100 } 101 102 gDevices[ifp->if_index] = NULL; 103 gDeviceCount--; 104 70 105 IF_ADDR_LOCK_DESTROY(ifp); 71 106 if (ifp->if_type == IFT_ETHER) 72 107 _kernel_free(ifp->if_l2com); … … 81 116 void 82 117 if_initname(struct ifnet *ifp, const char *name, int unit) 83 118 { 119 int i; 84 120 dprintf("if_initname(%p, %s, %d)\n", ifp, name, unit); 85 121 122 //XXX what if name[0] == '\0' ? 86 123 if (name == NULL) 87 124 panic("interface goes unamed"); 88 125 89 if (gDeviceCount >= MAX_DEVICES)90 panic("unit too large");91 92 126 ifp->if_dname = name; 93 127 ifp->if_dunit = unit; 94 ifp->if_index = gDeviceCount++;95 128 96 129 strlcpy(ifp->if_xname, name, sizeof(ifp->if_xname)); 97 130 … … 100 133 101 134 driver_printf("%s: /dev/%s\n", gDriverName, ifp->device_name); 102 135 103 gDeviceNameList[ifp->if_index] = ifp->device_name; 104 gDevices[ifp->if_index] = ifp; 136 for (i=0; i < MAX_DEVICES; i++) 137 if (gDeviceNameList[i] == NULL) 138 { 139 gDeviceNameList[i] = ifp->device_name; 140 break; 141 } 142 if (i == MAX_DEVICES) 143 panic("unit too large"); 105 144 106 145 ifp->root_device = find_root_device(unit); 107 146 } -
src/libs/compat/freebsd_network/device.c
28 28 struct ifreq ifr; 29 29 int i; 30 30 31 for (i = 0; gDeviceNameList[i] != NULL; i++) { 32 if (strcmp(gDeviceNameList[i], name) == 0) 31 for (i = 0; i < MAX_DEVICES; i++) { 32 if (gDevices[i] != NULL 33 && strncmp(gDevices[i]->device_name, name, sizeof(gDevices[i]->device_name))==0) 33 34 break; 34 35 } 35 36 36 if ( gDeviceNameList[i] == NULL)37 if (i == MAX_DEVICES) 37 38 return B_ERROR; 38 39 39 40 if (get_module(NET_STACK_MODULE_NAME, (module_info **)&gStack) != B_OK)