--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>OpenSourceLicense</key>
+ <string>BSD</string>
+ <key>OpenSourceLicenseFile</key>
+ <string>BootX.txt</string>
+ </dict>
+</array>
+</plist>
--- /dev/null
+================================================================================
+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.
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
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 = ();
};
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
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
/*
- * 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.
*
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,
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;
static long ReadDirEntry(InodePtr dirInode, long *fileInodeNum,
- long *dirIndex, char **name)
+ unsigned long *dirIndex, char **name)
{
struct ext2fs_direct *dir;
char *buffer;
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) {
/*
- * 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.
*
*/
#include <sl.h>
-#include <sys/md5.h>
+#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);
// 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)
long GetFileInfo(char *dirSpec, char *name, long *flags, long *time)
{
- long ret, index = 0;
+ long ret;
+ unsigned long index = 0;
char *curName;
if (!dirSpec) {
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];
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);
/*
- * 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+.
*
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];
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);
long HFSInitPartition(CICell ih)
{
- long extentSize, extentFile, nodeSize;
+ unsigned long extentFile;
+ long nodeSize;
+ u_int64_t extentSize;
void *extent;
if (ih == gCurrentIH) return 0;
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) {
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;
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;
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;
}
if ((*length == 0) || ((offset + *length) > fileLength)) {
- *length = fileLength - offset;
+ *length = (long)(fileLength - offset);
}
if (*length > kLoadSize) {
return -1;
}
- *length = ReadExtent((char *)extents, fileLength, fileID,
+ *length = ReadExtent(extents, fileLength, fileID,
offset, *length, base, 0);
return 0;
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
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;
// 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);
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)];
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;
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) {
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;
}
}
-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;
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;
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;
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;
static long CompareHFSCatalogKeys(void *key, void *testKey)
{
HFSCatalogKey *searchKey, *trialKey;
- long result, searchParentID, trialParentID;
+ long result;
+ unsigned long searchParentID, trialParentID;
searchKey = key;
trialKey = 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;
--- /dev/null
+/* 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 <sys/appleapiopts.h>
+
+#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 <sys/cdefs.h>
+
+__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_ */
* 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.
#include <string.h>
#endif
-#include <sys/md5.h>
+#include "md5.h"
#ifdef KERNEL
/*
- * 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.
*
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;
/*
- * 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.
*
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,
}
-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;
static long ReadDirEntry(InodePtr dirInode, long *fileInodeNum,
- long *dirIndex, char **name)
+ unsigned long *dirIndex, char **name)
{
struct direct *dir;
char *buffer;
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) {
/*
- * 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
*
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);
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);
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);
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);
// 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, ...);
// 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);
return 0;
}
+
+#if DEBUG
+#include <stdint.h>
+
+#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
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);
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)
+ // <http://developer.apple.com/documentation/Darwin/Conceptual/KEXTConcept/KEXTConceptLoading/loading_kexts.html>
+ // 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")) {
}
tmpModule->dict = moduleDict;
- // For now, load any module that has OSBundleRequired != "Safe Boot".
tmpModule->willLoad = 1;
*module = tmpModule;
* DRI: Josh de Cesare
*/
+#define __srr0 srr0 // so we can build in both (conformant/not) worlds
#include <mach-o/fat.h>
#include <mach-o/loader.h>
#include <mach/machine/thread_status.h>
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;
/*
- * 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.
*
#include <sl.h>
#include "aes.h"
#include <IOKit/IOHibernatePrivate.h>
+#include <bootfiles.h>
static void Start(void *unused1, void *unused2, ClientInterfacePtr ciPtr);
static void Main(ClientInterfacePtr ciPtr);
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};
#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)
//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);
// 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
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++;
// 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);
}
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;
}
#include <sl.h>
+//#define PLIST_DEBUG 1 // whether to report detailed parsing errors
+
#define kXMLTagPList "plist"
#define kXMLTagDict "dict"
#define kXMLTagKey "key"
}
}
- *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();
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;
}
* DRI: Josh de Cesare
*/
+#define __srr0 srr0 // works with or without conformance
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
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));