]> git.ozlabs.org Git - yaboot.git/blobdiff - second/partition.c
Check for valid "looking" IPs before saving them.
[yaboot.git] / second / partition.c
index 12942a94cf6b4aacf1b240f3d55d58c4d1de643a..d20a0ede652c08a37494cd323146c59396541b71 100644 (file)
@@ -40,6 +40,8 @@
 #include "linux/iso_fs.h"
 #include "debug.h"
 #include "errors.h"
+#include "bootinfo.h"
+#include "byteorder.h"
 
 /* We currently don't check the partition type, some users
  * are putting crap there and still expect it to work...
@@ -58,9 +60,6 @@ static const char *valid_mac_partition_types[] = {
 #endif
 
 
-/* Local functions */
-static unsigned long swab32(unsigned long value);
-
 #define MAX_BLOCK_SIZE 2048
 static unsigned char block_buffer[MAX_BLOCK_SIZE];
 
@@ -177,8 +176,8 @@ partition_fdisk_lookup( const char *dev_name, prom_handle disk,
                                   partition,
                                   "Linux", /* type */
                                   '\0', /* name */
-                                  swab32(*(unsigned int *)(part->start4)),
-                                  swab32(*(unsigned int *)(part->size4)),
+                                  le32_to_cpu(*(unsigned int *)part->start4),
+                                  le32_to_cpu(*(unsigned int *)part->size4),
                                   512 /*blksize*/,
                                   part->sys_ind /* partition type */ );
          }
@@ -288,7 +287,7 @@ partition_amiga_lookup( const char *dev_name, prom_handle disk,
        for (i=0; i < possible; i++) used[i] = 0;
 
 
-       for (part = amiga_block[AMIGA_PARTITIONS], partition = 0;
+       for (part = amiga_block[AMIGA_PARTITIONS], partition = 1;
                part != AMIGA_END;
                part = amiga_block[AMIGA_PART_NEXT], partition++)
        {
@@ -339,7 +338,8 @@ partitions_lookup(const char *device)
      unsigned int prom_blksize, iso_root_block;
 
      strncpy(block_buffer, device, 2040);
-     strcat(block_buffer, ":0");
+     if (_machine != _MACH_bplan)
+         strcat(block_buffer, ":0");
 
      /* Open device */
      disk = prom_open(block_buffer);
@@ -434,18 +434,6 @@ partitions_free(struct partition_t* list)
          list = next;
      }
 }
-unsigned long
-swab32(unsigned long value)
-{
-     __u32 result;
-
-     __asm__("rlwimi %0,%1,24,16,23\n\t"
-            "rlwimi %0,%1,8,8,15\n\t"
-            "rlwimi %0,%1,24,0,7"
-            : "=r" (result)
-            : "r" (value), "0" (value >> 24));
-     return result;
-}
 
 
 /*