2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Can this disk boot on your architecture?
9 #include <aros/debug.h>
10 #include <exec/alerts.h>
11 #include <proto/exec.h>
12 #include <proto/dos.h>
14 #include "dos_intern.h"
16 /* Signature file, contains (for example) 'pc-i386' */
17 #define AROS_BOOT_CHECKSIG ":AROS.boot"
18 /* Alternate variant: check if Shell is loadable
19 #define AROS_BOOT_CHECKEXEC ":C/Shell" */
21 BOOL
__dos_IsBootable(struct DosLibrary
* DOSBase
, BPTR lock
)
23 #if defined(AROS_BOOT_CHECKSIG)
27 struct FileInfoBlock
*abfile_fib
;
30 D(bug("[__dos_IsBootable] __dos_IsBootable('%s')\n", AROS_BOOT_CHECKSIG
));
33 fh
= Open(AROS_BOOT_CHECKSIG
, MODE_OLDFILE
);
38 * Original Amiga disks don't contain this signature. They are obviously bootable on m68k.
39 * However if the disk DOES contain a signature, we should check it. This can happen to be
40 * a disk for another architecture. Attempting to boot from it will cause crash.
48 D(bug("[__dos_IsBootable] Opened succesfully\n"));
50 abfile_fib
= AllocDosObject(DOS_FIB
, NULL
);
53 if (ExamineFH(fh
, abfile_fib
))
57 bufferLength
= abfile_fib
->fib_Size
+ 1;
59 buffer
= AllocMem(bufferLength
, MEMF_ANY
);
60 D(bug("[__dos_IsBootable] Allocated %d bytes for Buffer @ %p\n", bufferLength
, buffer
));
64 Alert(AT_DeadEnd
| AG_NoMemory
| AN_DOSLib
);
67 readsize
= Read(fh
, buffer
, bufferLength
- 1);
72 buffer
[readsize
] = '\0';
73 D(bug("[__dos_IsBootable] Buffer contains '%s'\n", buffer
));
75 if ((sigptr
= strstr(buffer
, AROS_CPU
)) != 0)
77 D(bug("[__dos_IsBootable] Signature '%s' found\n", AROS_CPU
));
82 /* Something to more or less reflect "This disk is not bootable" */
83 SetIoErr(ERROR_OBJECT_WRONG_TYPE
);
87 FreeDosObject(DOS_FIB
, abfile_fib
);
92 D(bug("[__dos_IsBootable] returned %d\n", result
));
95 #elif defined(AROS_BOOT_CHECKEXEC)
98 D(bug("[__dos_IsBootable]: Trying to load '%s' as an executable\n", AROS_BOOT_CHECKEXEC
));
101 if ((seg
= LoadSeg(AROS_BOOT_CHECKEXEC
)))
105 D(bug("[__dos_IsBootable] Success!\n"));