rem: ei->fd = fd;
context: status_t lookup_devices(char *root, void *cookie){	DIR *dir;	struct dirent *de;	struct stat st;	char path[1024];	status_t status;	int fd;	dir = opendir(root);	if (!dir) {		printf("Couldn't open the directory %s\n", root);		return B_ERROR;	};	status = B_OK;	while ((de = readdir(dir)) != NULL) {		if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0)			continue;	// skip pseudo-directories				sprintf(path, "%s/%s", root, de->d_name);				if (stat(path, &st) < 0) {			printf("ethernet: Can't stat(%s) entry! Skipping...\n", path);			continue;		};				if (S_ISDIR(st.st_mode))			status = lookup_devices(path, cookie);		else if (S_ISCHR(st.st_mode)) {	// char device = driver!			ifnet_t *iface;			ethernet_interface *ei;			int frame_size;			ether_addr_t mac_address;				if (strcmp(de->d_name, "stack") == 0 ||	// OBOS stack driver				strcmp(de->d_name, "api") == 0)		// BONE stack driver				continue;	// skip pseudo-entries					fd = open(path, O_RDWR);			if (fd < B_OK) {				printf("ethernet: Unable to open(%s) -> %d [%s]. Skipping...\n", path,					fd, strerror(fd));				status = fd;				continue;			};						// Init the network card			status = ioctl(fd, ETHER_INIT, NULL, 0);			if (status < B_OK) {				printf("ethernet: Failed to init %s: %ld [%s]. Skipping...\n", path,					status, strerror(status));				close(fd);				continue;			};						// get the MAC address...			status = ioctl(fd, ETHER_GETADDR, &mac_address, 6);			if (status < B_OK) {				printf("ethernet: Failed to get %s MAC address: %ld [%s]. Skipping...\n",					path, status, strerror(status));				close(fd);				continue;			};									// Try to determine the MTU to use			status = ioctl(fd, ETHER_GETFRAMESIZE, &frame_size, sizeof(frame_size));			if (status < B_OK) {				frame_size = ETHERMTU;				printf("ethernet: %s device don't support IF_GETFRAMESIZE; defaulting to %d\n",				       path, frame_size);			};			printf("ethernet: interface '%s':\n"						"\tMAC address: %02x:%02x:%02x:%02x:%02x:%02x\n"						"\tMTU:         %d bytes\n",					path,					mac_address.byte[0], mac_address.byte[1],					mac_address.byte[2], mac_address.byte[3],					mac_address.byte[4], mac_address.byte[5], frame_size);						iface = (ifnet_t *) malloc(sizeof(*iface));			if (!iface)				break;					ei = (ethernet_interface *) iface;			iface->if_name 	= strdup(path);			iface->if_flags = (IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST);			iface->if_type 	= 0x20;			iface->if_mtu 	= frame_size;						iface->module = &nimi;			ei->fd = fd;						status = g_stack->register_interface(iface);		};	};		closedir(dir);		                	return status;}