-// static char temp[1024];
- static char temps[64];
-// char *dev_name;
-// char *file_name = NULL;
- phandle dev;
- int result;
- int partition;
-
- memset(file, 0, sizeof(struct boot_file_t*));
- file->fs = &fs_default;
-
- /* Lookup the OF device path */
- /* First, see if a device was specified for the kernel
- * if not, we hope that the user wants a kernel on the same
- * drive and partition as yaboot itself */
-#if 0 /* this is crap */
- if (!spec->dev)
- strcpy(spec->dev, bootdevice);
- strncpy(temp,spec->dev,1024);
- dev_name = parse_device_path(temp, &file_name, &partition);
- if (file_name == NULL)
- file_name = (char *)spec->file;
- if (file_name == NULL) {
- prom_printf("Configuration error: null filename\n");
- return FILE_ERR_NOTFOUND;
- }
- if (partition == -1)
-#endif
- partition = spec->part;
-
-
- DEBUG_F("dev_path = %s\nfile_name = %s\npartition = %d\n",
- spec->dev, spec->file, partition);
-
- /* Find OF device phandle */
- dev = prom_finddevice(spec->dev);
- if (dev == PROM_INVALID_HANDLE) {
- return FILE_ERR_BADDEV;
- }
-
- DEBUG_F("dev_phandle = %p\n", dev);
-
- /* Check the kind of device */
- result = prom_getprop(dev, "device_type", temps, 63);
- if (result == -1) {
- prom_printf("can't get <device_type> for device\n");
- return FILE_ERR_BADDEV;
- }
- temps[result] = 0;
- if (!strcmp(temps, "block"))
- file->device_kind = FILE_DEVICE_BLOCK;
- else if (!strcmp(temps, "network"))
- file->device_kind = FILE_DEVICE_NET;
- else {
- prom_printf("Unkown device type <%s>\n", temps);
- return FILE_ERR_BADDEV;
- }
-
- switch(file->device_kind) {
- case FILE_DEVICE_BLOCK:
- DEBUG_F("device is a block device\n");
- return file_block_open(file, spec->dev, spec->file, partition);
- case FILE_DEVICE_NET:
- DEBUG_F("device is a network device\n");
- return file_net_open(file, spec->dev, spec->file);
- }
- return 0;
+ int result;
+
+ memset(file, 0, sizeof(struct boot_file_t*));
+ file->fs = &fs_default;
+
+ DEBUG_F("dev_path = %s\nfile_name = %s\npartition = %d\n",
+ spec->dev, spec->file, spec->part);
+
+ result = prom_get_devtype(spec->dev);
+ if (result > 0)
+ file->device_kind = result;
+ else
+ return result;
+
+ switch(file->device_kind) {
+ case FILE_DEVICE_BLOCK:
+ DEBUG_F("device is a block device\n");
+ return file_block_open(file, spec->dev, spec->file, spec->part);
+ case FILE_DEVICE_NET:
+ DEBUG_F("device is a network device\n");
+ return file_net_open(file, spec->dev, spec->file);
+ }
+ return 0;