10 typedef struct Extend Extend;
11 typedef struct Dir Dir;
42 BOOLEAN RemovableMedia;
44 BOOLEAN LogicalPartition;
57 EFI_BLOCK_IO_MEDIA *Media;
62 } EFI_BLOCK_IO_PROTOCOL;
65 EFI_BLOCK_IO_PROTOCO_GUID = {
66 0x964e5b21, 0x6459, 0x11d2,
67 0x8e, 0x39, 0x00, 0xa0,
68 0xc9, 0x69, 0x72, 0x3b,
71 static EFI_BLOCK_IO_PROTOCOL *bio;
74 readsect(ulong lba, void *buf)
76 lba *= Sectsz/bio->Media->BlockSize;
77 return eficall(bio->ReadBlocks, bio, (UINTN)bio->Media->MediaId, (UINT64)lba, (UINTN)Sectsz, buf);
81 isoread(void *f, void *data, int len)
85 if(ex->len > 0 && ex->rp >= ex->ep)
86 if(readsect(ex->lba++, ex->rp = ex->buf))
90 if(len > (ex->ep - ex->rp))
91 len = ex->ep - ex->rp;
92 memmove(data, ex->rp, len);
105 ex->rp = ex->ep = ex->buf + Sectsz;
109 isowalk(Extend *ex, char *path)
111 char name[MAXPATH], c, *end;
118 for(i=0x10; i<0x1000; i++){
119 if(readsect(i, ex->buf))
121 if(memcmp(ex->buf, "\001CD001\001", 7) == 0)
126 ex->lba = *((ulong*)(ex->buf + 156 + 2));
127 ex->len = *((ulong*)(ex->buf + 156 + 10));
132 if(readn(ex, &d, Dirsz) != Dirsz)
136 if(readn(ex, name, d.namelen) != d.namelen)
138 i = d.dirlen - (Dirsz + d.namelen);
141 for(i=0; i<d.namelen; i++){
143 if(c >= 'A' && c <= 'Z'){
152 if((end = strchr(path, '/')) == 0)
153 end = path + strlen(path);
155 if(d.namelen == i && memcmp(name, path, i) == 0){
157 ex->lba = *((ulong*)d.lba);
158 ex->len = *((ulong*)d.len);
161 else if(d.flags[0] & 2){
174 static uchar buf[sizeof(Extend)+8];
175 Extend *ex = (Extend*)((uintptr)(buf+7)&~7);
177 if(isowalk(ex, path))
185 EFI_BLOCK_IO_MEDIA *media;
193 if(eficall(ST->BootServices->LocateHandleBuffer,
194 ByProtocol, &EFI_BLOCK_IO_PROTOCO_GUID, nil, &Count, &Handles))
197 for(i=0; i<Count; i++){
199 if(eficall(ST->BootServices->HandleProtocol,
200 Handles[i], &EFI_BLOCK_IO_PROTOCO_GUID, &bio))
205 && media->MediaPresent
206 && media->LogicalPartition == 0
207 && media->BlockSize != 0
208 && isoopen("") != nil)
219 *fp = isoopen("/cfg/plan9.ini");