]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/boot/efi/iso.c
kernel: implement portable userinit() and simplify process creation
[plan9front.git] / sys / src / boot / efi / iso.c
index b11e19d2edbcc9d5072c25d55e0b859b0c45f95b..05b54ca4a4992421dce8e9b73835f4f206336490 100644 (file)
@@ -73,6 +73,7 @@ static EFI_BLOCK_IO_PROTOCOL *bio;
 static int
 readsect(ulong lba, void *buf)
 {
+       lba *= Sectsz/bio->Media->BlockSize;
        return eficall(bio->ReadBlocks, bio, (UINTN)bio->Media->MediaId, (UINT64)lba, (UINTN)Sectsz, buf);
 }
 
@@ -117,11 +118,15 @@ isowalk(Extend *ex, char *path)
        for(i=0x10; i<0x1000; i++){
                if(readsect(i, ex->buf))
                        return -1;
-               if(*ex->buf == 1)
-                       break;
+               if(memcmp(ex->buf, "\001CD001\001", 7) == 0)
+                       goto Foundpvd;
        }
+       return -1;
+Foundpvd:
        ex->lba = *((ulong*)(ex->buf + 156 + 2));
        ex->len = *((ulong*)(ex->buf + 156 + 10));
+       if(*path == 0)
+               return 0;
 
        for(;;){
                if(readn(ex, &d, Dirsz) != Dirsz)
@@ -166,9 +171,10 @@ isowalk(Extend *ex, char *path)
 static void*
 isoopen(char *path)
 {
-       static Extend ex[1];
+       static uchar buf[sizeof(Extend)+8];
+       Extend *ex = (Extend*)((uintptr)(buf+7)&~7);
 
-       if(isowalk(ex,  path))
+       if(isowalk(ex, path))
                return nil;
        return ex;
 }
@@ -197,9 +203,9 @@ isoinit(void **fp)
                media = bio->Media;
                if(media != nil
                && media->MediaPresent
-               && media->RemovableMedia
                && media->LogicalPartition == 0
-               && media->BlockSize == Sectsz)
+               && media->BlockSize != 0
+               && isoopen("") != nil)
                        goto Found;
        }
        return -1;