From: Apple Date: Fri, 6 Jul 2007 23:29:24 +0000 (+0000) Subject: BootX-81.tar.gz X-Git-Tag: mac-os-x-105^0 X-Git-Url: https://git.saurik.com/apple/bootx.git/commitdiff_plain/873b6fa6cf80d0a40f1034a98e6e43765a5ae456 BootX-81.tar.gz --- diff --git a/BootX.plist b/BootX.plist new file mode 100644 index 0000000..5fc6d48 --- /dev/null +++ b/BootX.plist @@ -0,0 +1,12 @@ + + + + + + OpenSourceLicense + BSD + OpenSourceLicenseFile + BootX.txt + + + diff --git a/BootX.txt b/BootX.txt new file mode 100644 index 0000000..249cf72 --- /dev/null +++ b/BootX.txt @@ -0,0 +1,339 @@ +================================================================================ +aes.h, aescrypt.c, aeskey.c, aesopt.h, aestab.h +================================================================================ +Copyright (c) 2003, Dr Brian Gladman, Worcester, UK. All rights reserved. + +LICENSE TERMS + +The free distribution and use of this software in both source and binary +form is allowed (with or without changes) provided that: + + 1. distributions of this source code include the above copyright + notice, this list of conditions and the following disclaimer; + + 2. distributions in binary form include the above copyright + notice, this list of conditions and the following disclaimer + in the documentation and/or other associated materials; + + 3. the copyright holder's name is not used to endorse products + built using this software without specific written permission. + +ALTERNATIVELY, provided that this notice is retained in full, this product +may be distributed under the terms of the GNU General Public License (GPL), +in which case the provisions of the GPL apply INSTEAD OF those given above. + +DISCLAIMER + +This software is provided 'as is' with no explicit or implied warranties +in respect of its properties, including, but not limited to, correctness +and/or fitness for purpose. + +================================================================================ +ext2fs.h +================================================================================ +Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + +@APPLE_LICENSE_HEADER_START@ + +The contents of this file constitute Original Code as defined in and +are subject to the Apple Public Source License Version 1.1 (the +"License"). You may not use this file except in compliance with the +License. Please obtain a copy of the License at +http://www.apple.com/publicsource and read it before using this file. + +This Original Code and all software distributed under the License are +distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the +License for the specific language governing rights and limitations +under the License. + +@APPLE_LICENSE_HEADER_END@ + + $NetBSD: ext2fs.h,v 1.10 2000/01/28 16:00:23 bouyer Exp $ + +Copyright (c) 1997 Manuel Bouyer. +Copyright (c) 1982, 1986, 1993 +The Regents of the University of California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. All advertising materials mentioning features or use of this software + must display the following acknowledgement: + This product includes software developed by the University of + California, Berkeley and its contributors. +4. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +================================================================================ +ext2fs_bswap.c +================================================================================ +Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + +@APPLE_LICENSE_HEADER_START@ + +The contents of this file constitute Original Code as defined in and +are subject to the Apple Public Source License Version 1.1 (the +"License"). You may not use this file except in compliance with the +License. Please obtain a copy of the License at +http://www.apple.com/publicsource and read it before using this file. + +This Original Code and all software distributed under the License are +distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the +License for the specific language governing rights and limitations +under the License. + +@APPLE_LICENSE_HEADER_END@ + + $NetBSD: ext2fs_bswap.c,v 1.4 2000/01/28 16:00:23 bouyer Exp $ + +Copyright (c) 1997 Manuel Bouyer. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. All advertising materials mentioning features or use of this software + must display the following acknowledgement: + This product includes software developed by the University of + California, Berkeley and its contributors. +4. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +================================================================================ +ext2fs_dinode.h +================================================================================ +Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + +@APPLE_LICENSE_HEADER_START@ + +The contents of this file constitute Original Code as defined in and +are subject to the Apple Public Source License Version 1.1 (the +"License"). You may not use this file except in compliance with the +License. Please obtain a copy of the License at +http://www.apple.com/publicsource and read it before using this file. + +This Original Code and all software distributed under the License are +distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the +License for the specific language governing rights and limitations +under the License. + +@APPLE_LICENSE_HEADER_END@ + + $NetBSD: ext2fs_dinode.h,v 1.6 2000/01/26 16:21:33 bouyer Exp $ + +Copyright (c) 1997 Manuel Bouyer. +Copyright (c) 1982, 1989, 1993 +The Regents of the University of California. All rights reserved. +(c) UNIX System Laboratories, Inc. +All or some portions of this file are derived from material licensed +to the University of California by American Telephone and Telegraph +Co. or Unix System Laboratories, Inc. and are reproduced herein with +the permission of UNIX System Laboratories, Inc. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. All advertising materials mentioning features or use of this software + must display the following acknowledgement: + This product includes software developed by the University of + California, Berkeley and its contributors. +4. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +================================================================================ +ext2fs_dir.h +================================================================================ +Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + +@APPLE_LICENSE_HEADER_START@ + +The contents of this file constitute Original Code as defined in and +are subject to the Apple Public Source License Version 1.1 (the +"License"). You may not use this file except in compliance with the +License. Please obtain a copy of the License at +http://www.apple.com/publicsource and read it before using this file. + +This Original Code and all software distributed under the License are +distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the +License for the specific language governing rights and limitations +under the License. + +@APPLE_LICENSE_HEADER_END@ + + $NetBSD: ext2fs_dir.h,v 1.4 2000/01/28 16:00:23 bouyer Exp $ + +Copyright (c) 1997 Manuel Bouyer. +Copyright (c) 1982, 1986, 1989, 1993 +The Regents of the University of California. All rights reserved. +(c) UNIX System Laboratories, Inc. +All or some portions of this file are derived from material licensed +to the University of California by American Telephone and Telegraph +Co. or Unix System Laboratories, Inc. and are reproduced herein with +the permission of UNIX System Laboratories, Inc. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. All advertising materials mentioning features or use of this software + must display the following acknowledgement: + This product includes software developed by the University of + California, Berkeley and its contributors. +4. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + + @(#)dir.h 8.4 (Berkeley) 8/10/94 +Modified for ext2fs by Manuel Bouyer. + +ext2fs_dir.h - Headers for Ext2 disk directory structures. + +Copyright (c) 2000 Apple Computer, Inc. + +================================================================================ +md5.h, md5c.c +================================================================================ +Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All +rights reserved. + +License to copy and use this software is granted provided that it +is identified as the "RSA Data Security, Inc. MD5 Message-Digest +Algorithm" in all material mentioning or referencing this software +or this function. + +License is also granted to make and use derivative works provided +that such works are identified as "derived from the RSA Data +Security, Inc. MD5 Message-Digest Algorithm" in all material +mentioning or referencing the derived work. + +RSA Data Security, Inc. makes no representations concerning either +the merchantability of this software or the suitability of this +software for any particular purpose. It is provided "as is" +without express or implied warranty of any kind. + +These notices must be retained in any copies of any part of this +documentation and/or software. + +================================================================================ +prf.c +================================================================================ +Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +@APPLE_LICENSE_HEADER_START@ + +The contents of this file constitute Original Code as defined in and +are subject to the Apple Public Source License Version 1.1 (the +"License"). You may not use this file except in compliance with the +License. Please obtain a copy of the License at +http://www.apple.com/publicsource and read it before using this file. + +This Original Code and all software distributed under the License are +distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the +License for the specific language governing rights and limitations +under the License. + +@APPLE_LICENSE_HEADER_END@ + + +Mach Operating System +Copyright (c) 1990 Carnegie-Mellon University +Copyright (c) 1989 Carnegie-Mellon University +Copyright (c) 1988 Carnegie-Mellon University +Copyright (c) 1987 Carnegie-Mellon University +All rights reserved. The CMU software License Agreement specifies +the terms and conditions for use and redistribution. + + +Copyright (c) 1982, 1986 Regents of the University of California. +All rights reserved. The Berkeley software License Agreement +specifies the terms and conditions for redistribution. + + @(#)prf.c 7.1 (Berkeley) 6/5/86 + + +prf.c - Helpers for the printf function. + +Copyright (c) 1998-2002 Apple Computer, Inc. diff --git a/Makefile b/Makefile index 9be0273..9211a04 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ PROJECT_TYPE = Aggregate TOOLS = macho-to-xcoff.tproj fcode-to-c.tproj bootx.tproj -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble +OTHERSRCS = Makefile.preamble Makefile Makefile.postamble BootX.plist BootX.txt MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles diff --git a/PB.project b/PB.project index 8d52710..f1360b8 100644 --- a/PB.project +++ b/PB.project @@ -9,7 +9,7 @@ H_FILES = (); M_FILES = (); OTHER_LINKED = (); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); + OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble, BootX.plist, BootX.txt); SUBPROJECTS = ("macho-to-xcoff.tproj", "fcode-to-c.tproj", bootx.tproj); TOOLS = (); }; diff --git a/bootx.tproj/Makefile.postamble b/bootx.tproj/Makefile.postamble index f855ea0..dd80b2b 100644 --- a/bootx.tproj/Makefile.postamble +++ b/bootx.tproj/Makefile.postamble @@ -120,3 +120,7 @@ bootx_after_install: install -d -m 555 $(DSTROOT)/usr/standalone/ppc install -c -m 444 $(SYMROOT)/bootx.bootinfo $(DSTROOT)/usr/standalone/ppc/bootx.bootinfo install -c -m 444 $(SYMROOT)/bootx.xcoff $(DSTROOT)/usr/standalone/ppc/bootx.xcoff + install -d -m 555 $(DSTROOT)/usr/local/OpenSourceVersions + install -m 444 $(SRCROOT)/BootX.plist $(DSTROOT)/usr/local/OpenSourceVersions/BootX.plist + install -d -m 555 $(DSTROOT)/usr/local/OpenSourceLicenses + install -m 444 $(SRCROOT)/BootX.txt $(DSTROOT)/usr/local/OpenSourceLicenses/BootX.txt diff --git a/bootx.tproj/fs.subproj/Makefile b/bootx.tproj/fs.subproj/Makefile index aab1a6d..5064c5f 100644 --- a/bootx.tproj/fs.subproj/Makefile +++ b/bootx.tproj/fs.subproj/Makefile @@ -13,7 +13,7 @@ PROJECTVERSION = 2.8 PROJECT_TYPE = Component HFILES = CaseTables.h ext2fs.h ext2fs_dinode.h ext2fs_dir.h\ - ufs_byteorder.h + ufs_byteorder.h md5.h CFILES = cache.c ext2fs.c ext2fs_bswap.c fs.c hfs.c HFSCompare.c\ net.c ufs.c ufs_byteorder.c md5c.c diff --git a/bootx.tproj/fs.subproj/ext2fs.c b/bootx.tproj/fs.subproj/ext2fs.c index c8bdc99..47b0e4f 100644 --- a/bootx.tproj/fs.subproj/ext2fs.c +++ b/bootx.tproj/fs.subproj/ext2fs.c @@ -1,24 +1,31 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ + /* * ext2.c - File System Module for Ext2. * @@ -44,7 +51,7 @@ static long ReadInode(long inodeNum, InodePtr inode, long *flags, long *time); static long ResolvePathToInode(char *filePath, long *flags, InodePtr fileInode, InodePtr dirInode); static long ReadDirEntry(InodePtr dirInode, long *fileInodeNum, - long *dirIndex, char **name); + unsigned long *dirIndex, char **name); static long FindFileInDir(char *fileName, long *flags, InodePtr fileInode, InodePtr dirInode); static char *ReadFileBlock(InodePtr fileInode, long blockNum, long blockOffset, @@ -146,8 +153,7 @@ long Ext2LoadFile(CICell ih, char *filePath) return length; } - -long Ext2GetDirEntry(CICell ih, char *dirPath, long *dirIndex, +long Ext2GetDirEntry(CICell ih, char *dirPath, unsigned long *dirIndex, char **name, long *flags, long *time) { long ret, fileInodeNum, dirFlags; @@ -269,7 +275,7 @@ static long ResolvePathToInode(char *filePath, long *flags, static long ReadDirEntry(InodePtr dirInode, long *fileInodeNum, - long *dirIndex, char **name) + unsigned long *dirIndex, char **name) { struct ext2fs_direct *dir; char *buffer; @@ -304,7 +310,8 @@ static long ReadDirEntry(InodePtr dirInode, long *fileInodeNum, static long FindFileInDir(char *fileName, long *flags, InodePtr fileInode, InodePtr dirInode) { - long ret, inodeNum, index = 0; + long ret, inodeNum; + unsigned long index = 0; char *name; while (1) { diff --git a/bootx.tproj/fs.subproj/fs.c b/bootx.tproj/fs.subproj/fs.c index 98f5e79..51054c7 100644 --- a/bootx.tproj/fs.subproj/fs.c +++ b/bootx.tproj/fs.subproj/fs.c @@ -1,24 +1,31 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ + /* * fs.c - Generic access to the file system modules. * @@ -28,14 +35,14 @@ */ #include -#include +#include "md5.h" typedef long (* FSLoadFile)(CICell ih, char *filePath); typedef long (* FSReadFile)(CICell ih, char *filePath, void *base, unsigned long offset, unsigned long length); typedef long (* FSGetDirEntry)(CICell ih, char *dirPath, - long *dirIndex, char **name, + unsigned long *dirIndex, char **name, long *flags, long *time); typedef long (* FSGetUUID)(CICell ih, char *uuidStr); @@ -156,7 +163,7 @@ long GetFSUUID(char *spec, char *uuidStr) // from our uuid/namespace.h (UFS and HFS uuids can live in the same space?) -static char kFSUUIDNamespaceSHA1[] = {0xB3,0xE2,0x0F,0x39,0xF2,0x92,0x11,0xD6,0x97,0xA4,0x00,0x30,0x65,0x43,0xEC,0xAC}; +static unsigned char kFSUUIDNamespaceSHA1[] = {0xB3,0xE2,0x0F,0x39,0xF2,0x92,0x11,0xD6,0x97,0xA4,0x00,0x30,0x65,0x43,0xEC,0xAC}; // filesystem-specific getUUID functions call this shared string generator long CreateUUIDString(uint8_t uubytes[], int nbytes, char *uuidStr) @@ -211,7 +218,8 @@ long CreateUUIDString(uint8_t uubytes[], int nbytes, char *uuidStr) long GetFileInfo(char *dirSpec, char *name, long *flags, long *time) { - long ret, index = 0; + long ret; + unsigned long index = 0; char *curName; if (!dirSpec) { @@ -236,7 +244,7 @@ long GetFileInfo(char *dirSpec, char *name, long *flags, long *time) return ret; } -long GetDirEntry(char *dirSpec, long *dirIndex, char **name, +long GetDirEntry(char *dirSpec, unsigned long *dirIndex, char **name, long *flags, long *time) { char devSpec[256]; @@ -260,7 +268,8 @@ long GetDirEntry(char *dirSpec, long *dirIndex, char **name, long DumpDir(char *dirSpec) { - long ret, flags, time, index = 0; + long ret, flags, time; + unsigned long index = 0; char *name; printf("DumpDir on [%s]\n", dirSpec); diff --git a/bootx.tproj/fs.subproj/hfs.c b/bootx.tproj/fs.subproj/hfs.c index 610e504..198b4ef 100644 --- a/bootx.tproj/fs.subproj/hfs.c +++ b/bootx.tproj/fs.subproj/hfs.c @@ -1,24 +1,31 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ + /* * hfs.c - File System Module for HFS and HFS+. * @@ -41,7 +48,7 @@ static CICell gCurrentIH; static long long gAllocationOffset; static long gIsHFSPlus; static long gCaseSensitive; -static long gBlockSize; +static unsigned long gBlockSize; static char gBTreeHeaderBuffer[512]; static BTHeaderRec *gBTHeaders[2]; static char gHFSMdbVib[kBlockSize]; @@ -54,24 +61,25 @@ static long long gVolID; static long ReadFile(void *file, long *length, void *base, long offset); static long GetCatalogEntryInfo(void *entry, long *flags, long *time); -static long ResolvePathToCatalogEntry(char *filePath, long *flags, - void *entry, long dirID, long *dirIndex); +static long ResolvePathToCatalogEntry(char *filePath, long *flags, void *entry, + unsigned long dirID, unsigned long *dirIndex); -static long GetCatalogEntry(long *dirIndex, char **name, +static long GetCatalogEntry(unsigned long *dirIndex, char **name, long *flags, long *time); -static long ReadCatalogEntry(char *fileName, long dirID, void *entry, - long *dirIndex); -static long ReadExtentsEntry(long fileID, long startBlock, void *entry); +static long ReadCatalogEntry(char *fileName, unsigned long dirID, void *entry, + unsigned long *dirIndex); +static long ReadExtentsEntry(unsigned long fileID, unsigned long startBlock, void *entry); -static long ReadBTreeEntry(long btree, void *key, char *entry, long *dirIndex); +static long ReadBTreeEntry(long btree, void *key, char *entry, + unsigned long *dirIndex); static void GetBTreeRecord(long index, char *nodeBuffer, long nodeSize, char **key, char **data); -static long ReadExtent(char *extent, long extentSize, long extentFile, - long offset, long size, void *buffer, long cache); +static long ReadExtent(void *extent, u_int64_t extentSize, unsigned long extentFile, + u_int64_t offset, long size, void *buffer, long cache); -static long GetExtentStart(void *extents, long index); -static long GetExtentSize(void *extents, long index); +static unsigned long GetExtentStart(void *extents, long index); +static unsigned long GetExtentSize(void *extents, long index); static long CompareHFSCatalogKeys(void *key, void *testKey); static long CompareHFSPlusCatalogKeys(void *key, void *testKey); @@ -91,7 +99,9 @@ extern void utf_decodestr(const u_int8_t *utf8p, u_int16_t *ucsp, long HFSInitPartition(CICell ih) { - long extentSize, extentFile, nodeSize; + unsigned long extentFile; + long nodeSize; + u_int64_t extentSize; void *extent; if (ih == gCurrentIH) return 0; @@ -105,7 +115,7 @@ long HFSInitPartition(CICell ih) gBTHeaders[1] = 0; // Look for the HFS MDB - Seek(ih, kMDBBaseOffset); + Seek(ih, (long long)kMDBBaseOffset); Read(ih, (long)gHFSMdbVib, kBlockSize); if (gHFSMDB->drSigWord == kHFSSigWord) { @@ -180,7 +190,8 @@ extern long HFSReadFile(CICell ih, char *filePath, void *base, unsigned long offset, unsigned long length) { char entry[512]; - long dirID, result, flags; + unsigned long dirID; + long result, flags; if (HFSInitPartition(ih) == -1) return -1; @@ -215,11 +226,11 @@ extern long HFSReadFile(CICell ih, char *filePath, void *base, return length; } -long HFSGetDirEntry(CICell ih, char *dirPath, long *dirIndex, char **name, - long *flags, long *time) +long HFSGetDirEntry(CICell ih, char *dirPath, unsigned long *dirIndex, + char **name, long *flags, long *time) { char entry[512]; - long dirID, dirFlags; + unsigned long dirID, dirFlags; if (HFSInitPartition(ih) == -1) return -1; @@ -264,7 +275,8 @@ long HFSGetUUID(CICell ih, char *uuidStr) static long ReadFile(void *file, long *length, void *base, long offset) { void *extents; - long fileID, fileLength; + unsigned long fileID; + u_int64_t fileLength; HFSCatalogFile *hfsFile = file; HFSPlusCatalogFile *hfsPlusFile = file; @@ -284,7 +296,7 @@ static long ReadFile(void *file, long *length, void *base, long offset) } if ((*length == 0) || ((offset + *length) > fileLength)) { - *length = fileLength - offset; + *length = (long)(fileLength - offset); } if (*length > kLoadSize) { @@ -292,7 +304,7 @@ static long ReadFile(void *file, long *length, void *base, long offset) return -1; } - *length = ReadExtent((char *)extents, fileLength, fileID, + *length = ReadExtent(extents, fileLength, fileID, offset, *length, base, 0); return 0; @@ -355,11 +367,12 @@ static long GetCatalogEntryInfo(void *entry, long *flags, long *time) return 0; } -static long ResolvePathToCatalogEntry(char *filePath, long *flags, - void *entry, long dirID, long *dirIndex) +static long ResolvePathToCatalogEntry(char *filePath, long *flags, void *entry, + unsigned long dirID, unsigned long *dirIndex) { char *restPath; - long result, cnt, subFolderID = 0, tmpDirIndex; + long result, cnt; + unsigned long subFolderID = 0, tmpDirIndex; HFSPlusCatalogFile *hfsPlusFile; // Copy the file name to gTempStr @@ -402,10 +415,12 @@ static long ResolvePathToCatalogEntry(char *filePath, long *flags, return result; } -static long GetCatalogEntry(long *dirIndex, char **name, +static long GetCatalogEntry(unsigned long *dirIndex, char **name, long *flags, long *time) { - long extentSize, nodeSize, curNode, index; + long nodeSize, index; + u_int32_t curNode; + u_int64_t extentSize; void *extent; char *nodeBuf, *testKey, *entry; BTNodeDescriptor *node; @@ -427,7 +442,7 @@ static long GetCatalogEntry(long *dirIndex, char **name, // Read the BTree node and get the record for index. ReadExtent(extent, extentSize, kHFSCatalogFileID, - curNode * nodeSize, nodeSize, nodeBuf, 1); + curNode * (u_int32_t)nodeSize, nodeSize, nodeBuf, 1); GetBTreeRecord(index, nodeBuf, nodeSize, &testKey, &entry); GetCatalogEntryInfo(entry, flags, time); @@ -457,8 +472,8 @@ static long GetCatalogEntry(long *dirIndex, char **name, return 0; } -static long ReadCatalogEntry(char *fileName, long dirID, - void *entry, long *dirIndex) +static long ReadCatalogEntry(char *fileName, unsigned long dirID, + void *entry, unsigned long *dirIndex) { long length; char key[sizeof(HFSPlusCatalogKey)]; @@ -483,7 +498,7 @@ static long ReadCatalogEntry(char *fileName, long dirID, return ReadBTreeEntry(kBTreeCatalog, &key, entry, dirIndex); } -static long ReadExtentsEntry(long fileID, long startBlock, void *entry) +static long ReadExtentsEntry(unsigned long fileID, unsigned long startBlock, void *entry) { char key[sizeof(HFSPlusExtentKey)]; HFSExtentKey *hfsKey = (HFSExtentKey *)key; @@ -503,16 +518,16 @@ static long ReadExtentsEntry(long fileID, long startBlock, void *entry) return ReadBTreeEntry(kBTreeExtents, &key, entry, 0); } -static long ReadBTreeEntry(long btree, void *key, char *entry, long *dirIndex) +static long ReadBTreeEntry(long btree, void *key, char *entry, unsigned long *dirIndex) { - long extentSize; + u_int64_t extentSize; void *extent; - short extentFile; + unsigned long extentFile; char *nodeBuf; BTNodeDescriptor *node; long nodeSize, result = 0, entrySize = 0; long curNode, index = 0, lowerBound, upperBound; - char *testKey, *recordData; + char *testKey, *recordData = NULL; // Figure out which tree is being looked at. if (btree == kBTreeCatalog) { @@ -556,7 +571,7 @@ static long ReadBTreeEntry(long btree, void *key, char *entry, long *dirIndex) while (1) { // Read the current node. ReadExtent(extent, extentSize, extentFile, - curNode * nodeSize, nodeSize, nodeBuf, 1); + (u_int64_t)curNode * (u_int64_t)nodeSize, nodeSize, nodeBuf, 1); // Find the matching key. lowerBound = 0; @@ -649,16 +664,16 @@ static void GetBTreeRecord(long index, char *nodeBuffer, long nodeSize, } } -static long ReadExtent(char *extent, long extentSize, - long extentFile, long offset, long size, - void *buffer, long cache) +static long ReadExtent(void *extent, u_int64_t extentSize, unsigned long extentFile, + u_int64_t offset, long size, void *buffer, long cache) { - long lastOffset, blockNumber, countedBlocks = 0; - long nextExtent = 0, sizeRead = 0, readSize; - long nextExtentBlock, currentExtentBlock = 0; - long long readOffset; - long extentDensity, sizeofExtent, currentExtentSize; - char *currentExtent, *extentBuffer = 0, *bufferPos = buffer; + u_int64_t lastOffset; + unsigned long blockNumber, countedBlocks = 0, nextExtent = 0, sizeRead = 0; + u_int64_t readSize; + unsigned long nextExtentBlock, currentExtentBlock = 0; + u_int64_t readOffset; + long extentDensity, sizeofExtent, currentExtentSize; + char *currentExtent, *extentBuffer = 0, *bufferPos = buffer; if (offset >= extentSize) return 0; @@ -709,17 +724,18 @@ static long ReadExtent(char *extent, long extentSize, countedBlocks += currentExtentSize; } - readOffset = ((blockNumber - countedBlocks) * gBlockSize) + - (offset % gBlockSize); + readOffset = ((u_int64_t)(blockNumber - countedBlocks) * (u_int64_t)gBlockSize) + + (offset % gBlockSize); - readSize = GetExtentSize(currentExtent, 0) * gBlockSize - readOffset; + readSize = ((u_int64_t)GetExtentSize(currentExtent, 0) * (u_int64_t)gBlockSize) - readOffset; if (readSize > (size - sizeRead)) readSize = size - sizeRead; - readOffset += (long long)GetExtentStart(currentExtent, 0) * gBlockSize; + readOffset += (u_int64_t)GetExtentStart(currentExtent, 0) * gBlockSize; CacheRead(gCurrentIH, bufferPos, gAllocationOffset + readOffset, - readSize, cache); + (long)readSize, cache); + // truncation: readSize capped pre-CacheRead sizeRead += readSize; offset += readSize; bufferPos += readSize; @@ -730,9 +746,9 @@ static long ReadExtent(char *extent, long extentSize, return sizeRead; } -static long GetExtentStart(void *extents, long index) +static unsigned long GetExtentStart(void *extents, long index) { - long start; + unsigned long start; HFSExtentDescriptor *hfsExtents = extents; HFSPlusExtentDescriptor *hfsPlusExtents = extents; @@ -742,9 +758,9 @@ static long GetExtentStart(void *extents, long index) return start; } -static long GetExtentSize(void *extents, long index) +static unsigned long GetExtentSize(void *extents, long index) { - long size; + unsigned long size; HFSExtentDescriptor *hfsExtents = extents; HFSPlusExtentDescriptor *hfsPlusExtents = extents; @@ -757,7 +773,8 @@ static long GetExtentSize(void *extents, long index) static long CompareHFSCatalogKeys(void *key, void *testKey) { HFSCatalogKey *searchKey, *trialKey; - long result, searchParentID, trialParentID; + long result; + unsigned long searchParentID, trialParentID; searchKey = key; trialKey = testKey; @@ -779,7 +796,8 @@ static long CompareHFSCatalogKeys(void *key, void *testKey) static long CompareHFSPlusCatalogKeys(void *key, void *testKey) { HFSPlusCatalogKey *searchKey, *trialKey; - long result, searchParentID, trialParentID; + long result; + unsigned long searchParentID, trialParentID; searchKey = key; trialKey = testKey; diff --git a/bootx.tproj/fs.subproj/md5.h b/bootx.tproj/fs.subproj/md5.h new file mode 100644 index 0000000..5376cbc --- /dev/null +++ b/bootx.tproj/fs.subproj/md5.h @@ -0,0 +1,51 @@ +/* MD5.H - header file for MD5C.C + */ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All +rights reserved. + +License to copy and use this software is granted provided that it +is identified as the "RSA Data Security, Inc. MD5 Message-Digest +Algorithm" in all material mentioning or referencing this software +or this function. + +License is also granted to make and use derivative works provided +that such works are identified as "derived from the RSA Data +Security, Inc. MD5 Message-Digest Algorithm" in all material +mentioning or referencing the derived work. + +RSA Data Security, Inc. makes no representations concerning either +the merchantability of this software or the suitability of this +software for any particular purpose. It is provided "as is" +without express or implied warranty of any kind. + +These notices must be retained in any copies of any part of this +documentation and/or software. + */ + +#ifndef _SYS_MD5_H_ +#define _SYS_MD5_H_ + +#include + +#if !defined(KERNEL) || defined(__APPLE_API_PRIVATE) +/* MD5 context. */ +typedef struct MD5Context { + u_int32_t state[4]; /* state (ABCD) */ + u_int32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[64]; /* input buffer */ +} MD5_CTX; + +#include + +__BEGIN_DECLS +void MD5Init (MD5_CTX *); +void MD5Update (MD5_CTX *, const unsigned char *, unsigned int); +void MD5Pad (MD5_CTX *); +void MD5Final (unsigned char [16], MD5_CTX *); +char * MD5End(MD5_CTX *, char *); +char * MD5File(const char *, char *); +char * MD5Data(const unsigned char *, unsigned int, char *); +__END_DECLS +#endif /* !KERNEL || __APPLE_API_PRIVATE */ +#endif /* _SYS_MD5_H_ */ diff --git a/bootx.tproj/fs.subproj/md5c.c b/bootx.tproj/fs.subproj/md5c.c index a1700d0..c7fa8af 100644 --- a/bootx.tproj/fs.subproj/md5c.c +++ b/bootx.tproj/fs.subproj/md5c.c @@ -22,7 +22,7 @@ * These notices must be retained in any copies of any part of this * documentation and/or software. * - * $Id: md5c.c,v 1.2 2005/02/03 05:16:40 lindak Exp $ + * $Id: md5c.c,v 1.3 2006/09/27 05:17:00 sspies Exp $ * * This code is the same as the code published by RSA Inc. It has been * edited for clarity and style only. @@ -36,7 +36,7 @@ #include #endif -#include +#include "md5.h" #ifdef KERNEL diff --git a/bootx.tproj/fs.subproj/net.c b/bootx.tproj/fs.subproj/net.c index 44882bc..92b052b 100644 --- a/bootx.tproj/fs.subproj/net.c +++ b/bootx.tproj/fs.subproj/net.c @@ -1,24 +1,31 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ + /* * net.c - File System Module for wrapping TFTP. * @@ -90,7 +97,7 @@ long NetLoadFile(CICell ih, char *filePath) return length; } -long NetGetDirEntry(CICell ih, char *dirPath, long *dirIndex, +long NetGetDirEntry(CICell ih, char *dirPath, unsigned long *dirIndex, char **name, long *flags, long *time) { return -1; diff --git a/bootx.tproj/fs.subproj/ufs.c b/bootx.tproj/fs.subproj/ufs.c index f6aa107..0f6aa71 100644 --- a/bootx.tproj/fs.subproj/ufs.c +++ b/bootx.tproj/fs.subproj/ufs.c @@ -1,24 +1,31 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ + /* * ufs.c - File System Module for UFS. * @@ -43,7 +50,7 @@ static long ReadInode(long inodeNum, InodePtr inode, long *flags, long *time); static long ResolvePathToInode(char *filePath, long *flags, InodePtr fileInode, InodePtr dirInode); static long ReadDirEntry(InodePtr dirInode, long *fileInodeNum, - long *dirIndex, char **name); + unsigned long *dirIndex, char **name); static long FindFileInDir(char *fileName, long *flags, InodePtr fileInode, InodePtr dirInode); static char *ReadFileBlock(InodePtr fileInode, long fragNum, long blockOffset, @@ -167,7 +174,7 @@ long UFSReadFile(CICell ih, char *filePath, void *base, } -long UFSGetDirEntry(CICell ih, char *dirPath, long *dirIndex, +long UFSGetDirEntry(CICell ih, char *dirPath, unsigned long *dirIndex, char **name, long *flags, long *time) { long ret, fileInodeNum, dirFlags; @@ -284,7 +291,7 @@ static long ResolvePathToInode(char *filePath, long *flags, static long ReadDirEntry(InodePtr dirInode, long *fileInodeNum, - long *dirIndex, char **name) + unsigned long *dirIndex, char **name) { struct direct *dir; char *buffer; @@ -318,7 +325,8 @@ static long ReadDirEntry(InodePtr dirInode, long *fileInodeNum, static long FindFileInDir(char *fileName, long *flags, InodePtr fileInode, InodePtr dirInode) { - long ret, inodeNum, index = 0; + long ret, inodeNum; + unsigned long index = 0; char *name; while (1) { diff --git a/bootx.tproj/include.subproj/fs.h b/bootx.tproj/include.subproj/fs.h index 4c95151..e61bc02 100644 --- a/bootx.tproj/include.subproj/fs.h +++ b/bootx.tproj/include.subproj/fs.h @@ -1,24 +1,31 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ + /* * fs.h - Externs for the File System Modules * @@ -34,7 +41,7 @@ extern long LoadFile(char *fileSpec); extern long LoadThinFatFile(char *fileSpec, void **binary); extern long GetFileInfo(char *dirSpec, char *name, long *flags, long *time); -extern long GetDirEntry(char *dirSpec, long *dirIndex, char **name, +extern long GetDirEntry(char *dirSpec, unsigned long *dirIndex, char **name, long *flags, long *time); extern long DumpDir(char *dirSpec); extern long GetFSUUID(char *devSpec, char *uuidStr); @@ -53,17 +60,19 @@ extern long CacheRead(CICell ih, char *buffer, long long offset, extern CICell NetInitPartition(char *devSpec); extern long NetLoadFile(CICell ih, char *filePath); extern long NetGetDirEntry(CICell ih, char *dirPath, - long *dirIndex, char **name, + unsigned long *dirIndex, char **name, long *flags, long *time); // Externs for hfs.c +// Note: the offset parameters are only used by mach-o routines. +// We don't support mach-o binaries > 4 GB. extern long HFSInitPartition(CICell ih); extern long HFSLoadFile(CICell ih, char *filePath); extern long HFSReadFile(CICell ih, char *filePath, void *base, unsigned long offset, unsigned long length); extern long HFSGetDirEntry(CICell ih, char *dirPath, - long *dirIndex, char **name, + unsigned long *dirIndex, char **name, long *flags, long *time); extern long HFSGetUUID(CICell ih, char *uuidStr); @@ -74,7 +83,7 @@ extern long UFSReadFile(CICell ih, char *filePath, void *base, unsigned long offset, unsigned long length); extern long UFSGetDirEntry(CICell ih, char *dirPath, - long *dirIndex, char **name, + unsigned long *dirIndex, char **name, long *flags, long *time); extern long UFSGetUUID(CICell ih, char *uuidStr); @@ -82,7 +91,7 @@ extern long UFSGetUUID(CICell ih, char *uuidStr); extern long Ext2InitPartition(CICell ih); extern long Ext2LoadFile(CICell ih, char *filePath); extern long Ext2GetDirEntry(CICell ih, char *dirPath, - long *dirIndex, char **name, + unsigned long *dirIndex, char **name, long *flags, long *time); extern long Ext2GetUUID(CICell ih, char *uuidStr); diff --git a/bootx.tproj/include.subproj/libclite.h b/bootx.tproj/include.subproj/libclite.h index 132c39e..e1095fe 100644 --- a/bootx.tproj/include.subproj/libclite.h +++ b/bootx.tproj/include.subproj/libclite.h @@ -47,6 +47,10 @@ extern void prf(const char *fmt, unsigned int *adx, int (*putfn_p)(int ch), // printf.c extern int printf(const char *format, ...); +#if DEBUG +extern unsigned OSBacktrace_ppc(void **bt, unsigned maxAddrs); +extern void dump_backtrace(char *ctx, int id); // ctx and id optional +#endif // DEBUG // sprintf.c extern int sprintf(char *str, const char *fmt, ...); diff --git a/bootx.tproj/include.subproj/sl.h b/bootx.tproj/include.subproj/sl.h index 9c6f971..99a1e84 100644 --- a/bootx.tproj/include.subproj/sl.h +++ b/bootx.tproj/include.subproj/sl.h @@ -272,8 +272,6 @@ extern int decompress_lzss(u_int8_t *dst, u_int8_t *src, u_int32_t srclen); // Externs for plist.c -#define PLIST_DEBUG 0 // whether report parsing errors, etc - extern TagPtr GetProperty(TagPtr dict, char *key); extern long ParseXML(char *buffer, TagPtr *dict); extern void FreeTag(TagPtr tag); diff --git a/bootx.tproj/libclite.subproj/printf.c b/bootx.tproj/libclite.subproj/printf.c index df2ccee..361baaa 100644 --- a/bootx.tproj/libclite.subproj/printf.c +++ b/bootx.tproj/libclite.subproj/printf.c @@ -38,3 +38,68 @@ int printf(const char *format, ...) return 0; } + +#if DEBUG +#include + +#define BTLEN 10 +// ctx and id optional +void dump_backtrace(char *ctx, int id) +{ + void *bt[BTLEN]; + int cnt; + + if (ctx) + printf("%s ", ctx); + if (id) + printf("(%d)", id); + if (ctx || id) + printf(":\n"); + + cnt = OSBacktrace_ppc(bt, BTLEN); + while(cnt <= BTLEN && cnt--) + printf("bt[%d]: %x\n", cnt, bt[cnt]); +} + +// ported from xnu/libkern/gen/OSDebug.cpp +// (non-__ppc__ #if branches and min/maxstackaddr checks omitted) +unsigned OSBacktrace_ppc(void **bt, unsigned maxAddrs) +{ + unsigned frame; + +#if __ppc__ + uint32_t stackptr, stackptr_prev; + const uint32_t * const mem = (uint32_t *) 0; + unsigned i = 0; + + __asm__ volatile("mflr %0" : "=r" (stackptr)); + bt[i++] = (void *) stackptr; + + __asm__ volatile("mr %0,r1" : "=r" (stackptr)); + for ( ; i < maxAddrs; i++) { + // Validate we have a reasonable stackptr + if ( /* !(minstackaddr <= stackptr && stackptr < maxstackaddr) + || */ (stackptr & 3)) + break; + + stackptr_prev = stackptr; + stackptr = mem[stackptr_prev >> 2]; + if ((stackptr_prev ^ stackptr) > 8 * 1024) // Sanity check + break; + + uint32_t addr = mem[(stackptr >> 2) + 2]; + if ((addr & 3) || (addr < 0x8000)) // More sanity checks + break; + bt[i] = (void *) addr; + } + frame = i; + + for ( ; i < maxAddrs; i++) + bt[i] = (void *) 0; +#else +#warning "BootX's OSBacktrace_ppc() not intended for other architectures" +#endif + + return frame; +} +#endif // DEBUG diff --git a/bootx.tproj/sl.subproj/drivers.c b/bootx.tproj/sl.subproj/drivers.c index d0c324d..cd5385b 100644 --- a/bootx.tproj/sl.subproj/drivers.c +++ b/bootx.tproj/sl.subproj/drivers.c @@ -126,8 +126,8 @@ static long FileLoadDrivers(char *dirSpec, long plugin) ret = GetFileInfo(dirSpec, "Extensions.mkext", &flags, &time); if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeFlat)) { ret = GetFileInfo(dirSpec, "Extensions", &flags, &time2); - // use mkext if if it looks right or if the folder was bad - if ((ret != 0) || + // try mkext if if it looks right or if the folder was bad + if ((ret != 0) || // ret == 0 -> flags is good ((flags & kFileTypeMask) != kFileTypeDirectory) || (((gBootMode & kBootModeSafe) == 0) && (time == (time2 + 1)))) { sprintf(gDriverSpec, "%sExtensions.mkext", dirSpec); @@ -485,6 +485,11 @@ static long XML2Module(char *buffer, ModulePtr *module, TagPtr *personalities) if(ParseXML(buffer, &moduleDict) < 0) return -1; + // to be loaded by BootX, you must have OSBundleRequired and it + // must not be set to Safe Boot (that's for kextd later) + // + // in other words, BootX always loads the minimal number of kexts + // if loading them one at a time required = GetProperty(moduleDict, kPropOSBundleRequired); if ((required == 0) || (required->type != kTagTypeString) || !strcmp(required->string, "Safe Boot")) { @@ -499,7 +504,6 @@ static long XML2Module(char *buffer, ModulePtr *module, TagPtr *personalities) } tmpModule->dict = moduleDict; - // For now, load any module that has OSBundleRequired != "Safe Boot". tmpModule->willLoad = 1; *module = tmpModule; diff --git a/bootx.tproj/sl.subproj/macho.c b/bootx.tproj/sl.subproj/macho.c index 9fb35aa..333cbe1 100644 --- a/bootx.tproj/sl.subproj/macho.c +++ b/bootx.tproj/sl.subproj/macho.c @@ -27,6 +27,7 @@ * DRI: Josh de Cesare */ +#define __srr0 srr0 // so we can build in both (conformant/not) worlds #include #include #include @@ -208,11 +209,11 @@ static long DecodeSegment(long cmdBase) static long DecodeUnixThread(long cmdBase) { - struct ppc_thread_state *ppcThreadState; + ppc_thread_state_t *ppcThreadState; // The PPC Thread State starts after the thread command stuct plus, // 2 longs for the flaver an num longs. - ppcThreadState = (struct ppc_thread_state *) + ppcThreadState = (ppc_thread_state_t *) (cmdBase + sizeof(struct thread_command) + 8); gKernelEntryPoint = ppcThreadState->srr0; diff --git a/bootx.tproj/sl.subproj/main.c b/bootx.tproj/sl.subproj/main.c index a5362f2..4ad9b72 100644 --- a/bootx.tproj/sl.subproj/main.c +++ b/bootx.tproj/sl.subproj/main.c @@ -1,24 +1,31 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ + /* * main.c - Main functions for BootX. * @@ -31,6 +38,7 @@ #include #include "aes.h" #include +#include static void Start(void *unused1, void *unused2, ClientInterfacePtr ciPtr); static void Main(ClientInterfacePtr ciPtr); @@ -43,7 +51,8 @@ static long InitMemoryMap(void); static long GetOFVersion(void); static long TestForKey(long key); static long GetBootPaths(void); -static long ReadBootPlist(char *devSpec); +static long ReadBootPlist(char *devSpec, char *rpsDir); +static long FindRPSDir(char *bootDevice, char **rpsDir); const unsigned long StartTVector[2] = {(unsigned long)Start, 0}; @@ -1206,13 +1215,21 @@ static long TestForKey(long key) #define kBootpBootFileOffset (108) - +#define UUIDLEN 63 static long GetBootPaths(void) { long ret, cnt, cnt2, cnt3, cnt4, size, partNum, bootplen, bsdplen; unsigned long adler32; - char *filePath, *buffer, uuidStr[64]; + char *filePath, *buffer, uuidStr[UUIDLEN+1] = { '\0' }; + char *rpsDir = ""; // perhaps to be one of "com.apple.Boot.[RPS]" +/* +printf("accessing the first few bytes of memory...\n"); +unsigned *mem = NULL; +for(cnt=0; cnt<10; cnt++) +printf("mem[%d]: %x ('%c')\n", cnt, mem[cnt], mem[cnt]); +*/ + if (gBootSourceNumber == -1) { // Get the boot device and derive its type // (try chosen "bootpath", then boot-device in the options) @@ -1234,13 +1251,24 @@ static long GetBootPaths(void) //strcpy(gBootDevice, "fw/node@50770e0000725b/sbp-2@4000/@0:3"); // m120 - // Look for Boot.plist-based booter stuff (like RAID :) - ret = ReadBootPlist(gBootDevice); + // check for Boot != Root + ret = FindRPSDir(gBootDevice, &rpsDir); // rpsDir set on success if (ret == 0) { - // success -> gBootDevice = "AppleRAID/#:0,\\\\:tbxi" - (void)LookForRAID(gBootDict); // could take gBootDevice? + SetProp(gChosenPH, kBootRootActiveKey, NULL, 0); // crumb for the OS + // would be nice to set gBootSourceNumberMax = 1, but overridden below + } + + // Load any Boot.plist data (for Tiger RAID, BootRoot, etc) + ret = ReadBootPlist(gBootDevice, rpsDir); // sets gBootDict on success + if (ret == 0) { + // XX until we decide to be rid of the RAID implementation, short- + // circuit common 10.5 case (Boot.plist exists but doesn't mean RAID) + if (gBootDict->type != kTagTypeDict || + GetProperty(gBootDict, kKernelNameKey) == NULL) { + (void)LookForRAID(gBootDict); // might change gBootDevice + // LFR() success -> gBootDevice = "AppleRAID/#:0,\\:tbxi" + } } - // note RAID itself is of "block" type like members gBootDeviceType = GetDeviceType(gBootDevice); @@ -1368,8 +1396,8 @@ static long GetBootPaths(void) // Construct the boot-file strncpy(gBootFile, gBootDevice, cnt + 1); - sprintf(gBootFile + cnt + 1, "%d,%s\\mach_kernel", - partNum, ((gBootSourceNumber & 1) ? "" : "\\")); + sprintf(gBootFile + cnt + 1, "%d,%s%s\\mach_kernel", + partNum, ((gBootSourceNumber & 1) ? "" : "\\"), rpsDir); // and the cache file name @@ -1398,7 +1426,7 @@ static long GetBootPaths(void) strcat(gExtensionsSpec, ","); - // Add in any extra path to gRootDir. + // Add in any extra path to gRootDir (handles com.apple.boot.[RPS]). cnt = 0; while (filePath[cnt] != '\0') cnt++; @@ -1422,7 +1450,17 @@ static long GetBootPaths(void) // technically could just do this once at the end SetProp(gChosenPH, "rootpath", gBootFile, strlen(gBootFile) + 1); - if (GetFSUUID(gBootFile, uuidStr) == 0) { + if (gBootDict && gBootDict->type == kTagTypeDict) { + TagPtr prop = GetProperty(gBootDict, kRootUUIDKey); + if (prop && prop->type == kTagTypeString) + strncpy(uuidStr, prop->string, UUIDLEN); + } + + if (uuidStr[0] == '\0') { + (void)GetFSUUID(gBootFile, uuidStr); + } + + if (uuidStr[0]) { printf("setting boot-uuid to: %s\n", uuidStr); SetProp(gChosenPH, "boot-uuid", uuidStr, strlen(uuidStr) + 1); } @@ -1432,27 +1470,98 @@ static long GetBootPaths(void) return 0; } -#define BOOTPLIST_PATH "com.apple.Boot.plist" +/* + * FindRPSDir looks for a "rock," "paper," or "scissors" directory + * - handle all permutations: 3 dirs, any 2 dirs, any 1 dir + */ +#define SPECLEN 1024 +static char rootDirSpec[SPECLEN+1]; // not sure how big our stacks are +static long FindRPSDir(char *bootDevice, char **rpsDir) +{ + long rval = 0; + long flags, time; + char haveR, haveP, haveS; + + unsigned long index = 0; + char *curName; + + haveR = haveP = haveS = 0; + + // strip any file specifier and start at the root + if (ConvertFileSpec(bootDevice, rootDirSpec, NULL)) return -1; + strncat(rootDirSpec, ",\\", SPECLEN-strlen(rootDirSpec)); + + // walk the directory looking for com.apple.Boot.[RPS] + while (GetDirEntry(rootDirSpec, &index, &curName, &flags, &time) != -1) { + if (!strcmp(curName, kBootDirR)) { haveR = 1; continue; } + if (!strcmp(curName, kBootDirP)) { haveP = 1; continue; } + if (!strcmp(curName, kBootDirS)) { haveS = 1; continue; } + } + + if (haveR && haveP && haveS) { // NComb(3,3) = 1 + printf("WARNING: all of R,P,S exist: booting from 'R'\n"); + *rpsDir = kBootDirR; + } else if (haveR && haveP) { // NComb(3,2) = 3 + // p wins + *rpsDir = kBootDirP; + } else if (haveR && haveS) { + // r wins + *rpsDir = kBootDirR; + } else if (haveP && haveS) { + // s wins + *rpsDir = kBootDirS; + } else if (haveR) { // NComb(3,1) = 3 + // wins by default + *rpsDir = kBootDirR; + } else if (haveP) { + // wins by default + *rpsDir = kBootDirP; + } else if (haveS) { + // wins by default + *rpsDir = kBootDirS; + } else { // NComb(3,0) = 0 + rval = -1; + } + + return rval; +} -// ReadBootPlist could live elsewhere -static long ReadBootPlist(char *devSpec) +/* + * ReadBootPlist looks around for com.apple.Boot.plist, populates gBootDict + * could live elsewhere + */ +#define OF_BLESSEDDIR ",\\\\" +#define BOOTPLIST_NAME "com.apple.Boot.plist" +#define BOOTPLIST_PATH OF_BLESSEDDIR BOOTPLIST_NAME +#define PREF_BOOTPLIST_PATH "\\Library\\Preferences\\SystemConfiguration\\" \ + BOOTPLIST_NAME +static char plistSpec[SPECLEN+1]; // save stack space +static long ReadBootPlist(char *devSpec, char *rpsDir) { - char plistSpec[256]; int len; do { - // construct the Boot.plist spec if (ConvertFileSpec(devSpec, plistSpec, NULL)) break; - strncat(plistSpec, ",\\\\", 255-strlen(plistSpec)); - strncat(plistSpec, BOOTPLIST_PATH, 255-strlen(plistSpec)); - - // load the contents - if ((len = LoadFile(plistSpec)) < 0) break; - // we could try for the root as well as the blessed folder + strncat(plistSpec, ",", SPECLEN-strlen(plistSpec)); + strncat(plistSpec, rpsDir, SPECLEN-strlen(plistSpec)); // may be "" + strncat(plistSpec, PREF_BOOTPLIST_PATH, SPECLEN-strlen(plistSpec)); + + // try to load the contents + if ((len = LoadFile(plistSpec)) < 0) { + // construct old-style spec for Boot.plist (in blessed folder == root) + if (ConvertFileSpec(devSpec, plistSpec, NULL)) break; + strncat(plistSpec, BOOTPLIST_PATH, SPECLEN-strlen(plistSpec)); + + // and try to load again + if ((len = LoadFile(plistSpec)) < 0) { + printf("couldn't load %s\n", BOOTPLIST_NAME); + break; + } + } *((char*)kLoadAddr + len) = '\0'; // terminate for parser safety if (ParseXML((char*)kLoadAddr, &gBootDict) < 0 || !gBootDict) { - printf("couldn't parse %s\n", BOOTPLIST_PATH); + printf("couldn't parse %s\n", BOOTPLIST_NAME); break; } diff --git a/bootx.tproj/sl.subproj/plist.c b/bootx.tproj/sl.subproj/plist.c index fb8c6c2..18a6e4b 100644 --- a/bootx.tproj/sl.subproj/plist.c +++ b/bootx.tproj/sl.subproj/plist.c @@ -30,6 +30,8 @@ #include +//#define PLIST_DEBUG 1 // whether to report detailed parsing errors + #define kXMLTagPList "plist" #define kXMLTagDict "dict" #define kXMLTagKey "key" @@ -211,13 +213,15 @@ long ParseXML(char *buffer, TagPtr *dict) } } - *dict = moduleDict; + if (length != -1) { + *dict = moduleDict; #if PLIST_DEBUG - if (length == -1) - printf("ParseXML gagged (-1) after %s (%d tags); buf+pos: %s\n", + } else { + printf("ParseXML gagged (-1) after '%s' (%d tags); buf+pos: %s\n", gLastTag,gTagsParsed,buffer+pos); #endif + } // for tidyness even though kext parsing resets all of malloc FreeTagCache(); diff --git a/bootx.tproj/sl.subproj/raid.c b/bootx.tproj/sl.subproj/raid.c index b57d96b..5adc12b 100644 --- a/bootx.tproj/sl.subproj/raid.c +++ b/bootx.tproj/sl.subproj/raid.c @@ -433,9 +433,11 @@ int nsuccesses = 0; RAIDDevicePtr newLeaf = &gMembers[gTotalMembers++]; // burn entries if(FillInLeaf(partSpec, newLeaf)) continue; - // is this the master (from whose Apple_Boot we loaded? + // is this the master (from whose Apple_Boot we loaded)? + // if either device doesn't exist (e.g. if both FindDevice calls + // returned NULL), we'd fail later. if(FindDevice(newLeaf->path) == FindDevice(masterMemberPath)) { -printf("raid: found member affiliated with our boot device\n"); + printf("raid: found member affiliated with our boot device\n"); gRAIDMaster = newLeaf; } diff --git a/macho-to-xcoff.tproj/macho-to-xcoff.c b/macho-to-xcoff.tproj/macho-to-xcoff.c index 02e9af5..3ef6cfe 100644 --- a/macho-to-xcoff.tproj/macho-to-xcoff.c +++ b/macho-to-xcoff.tproj/macho-to-xcoff.c @@ -27,6 +27,7 @@ * DRI: Josh de Cesare */ +#define __srr0 srr0 // works with or without conformance #include #include #include @@ -260,7 +261,7 @@ int main (int argc, char **argv) case LC_THREAD: case LC_UNIXTHREAD: - xHead.opt.entryPoint = ((ppc_saved_state_t *) + xHead.opt.entryPoint = ((ppc_thread_state_t *) (cp + sizeof(struct thread_command) + 2 * sizeof(unsigned long)) )->srr0; printf("Entry point %lx\n\n", SWAPL(xHead.opt.entryPoint));