2N/A * GRUB -- GRand Unified Bootloader 2N/A * Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc. 2N/A * GRUB is free software: you can redistribute it and/or modify 2N/A * it under the terms of the GNU General Public License as published by 2N/A * the Free Software Foundation, either version 3 of the License, or 2N/A * (at your option) any later version. 2N/A * GRUB is distributed in the hope that it will be useful, 2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of 2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 2N/A * GNU General Public License for more details. 2N/A * You should have received a copy of the GNU General Public License 2N/A /* The first block of a file on disk. */ 2N/A /* The amount of blocks described by this extent. */ 2N/A/* The descriptor of a fork. */ 2N/A/* The HFS+ Volume Header. */ 2N/A/* The type of node. */ 2N/A/* The header of a HFS+ B+ Tree. */ 2N/A/* The on disk layout of a catalog key. */ 2N/A/* The on disk layout of an extent overflow file key. */ 2N/A/* Filetype information as used in inodes. */ 2N/A/* Some pre-defined file IDs. */ 2N/A/* Internal representation of a catalog key. */ 2N/A/* Internal representation of an extent overflow key. */ 2N/A /* Catalog file node. */ 2N/A/* Information about a "mounted" HFS+ filesystem. */ 2N/A /* This is the offset into the physical disk for an embedded HFS+ 2N/A filesystem (one inside a plain HFS wrapper). */ 2N/A/* Return the offset of the record with the index INDEX, in the node 2N/A NODE which is part of the B+ tree BTREE. */ 2N/A/* Return a pointer to the record with the index INDEX, in the node 2N/A NODE which is part of the B+ tree BTREE. */ 2N/A/* Find the extent that points to FILEBLOCK. If it is not in one of 2N/A the 8 extents described by EXTENT, return -1. In that case set 2N/A FILEBLOCK to the next block. */ 2N/A /* First lookup the file in the given extents. */ 2N/A for (i = 0; i <
8; i++)
2N/A return 0xffffffffffffffffULL;
2N/A/* Search for the block FILEBLOCK inside the file NODE. Return the 2N/A blocknumber of this block on disk. */ 2N/A /* Try to find this block in the current set of extents. */ 2N/A /* The previous iteration of this loop allocated memory. The 2N/A code above used this memory, it can be freed now. */ 2N/A if (
blk !=
0xffffffffffffffffULL)
2N/A /* For the extent overflow file, extra extents can't be found in 2N/A the extent overflow file. If this happens, you found a 2N/A "extra extents found in an extend overflow file");
2N/A /* Set up the key to look for in the extent overflow file. */ 2N/A "no block found for the file id 0x%x and the block offset 0x%x",
2N/A /* The extent overflow file has 8 extents right after the key. */ 2N/A /* The block wasn't found. Perhaps the next iteration will find 2N/A it. The last block we found is stored in BLKSLEFT now. */ 2N/A /* Too bad, you lose. */ 2N/A/* Read LEN bytes from the file described by DATA starting with byte 2N/A POS. Return the amount of read bytes in READ. */ 2N/A /* Read the bootblock. */ 2N/A /* See if there's an embedded HFS+ filesystem. */ 2N/A /* Calculate the offset needed to translate HFS+ sector numbers. */ 2N/A /* Make sure this is an HFS+ filesystem. XXX: Do we really support 2N/A /* Make a new node for the catalog tree. */ 2N/A /* Make a new node for the extent overflow file. */ 2N/A /* Read the essential information about the trees. */ 2N/A/* Compare the on disk catalog key KEYA with the catalog key we are 2N/A looking for (KEYB). */ 2N/A /* Safe unsigned comparison */ 2N/A/* Compare the on disk catalog key KEYA with the catalog key we are 2N/A looking for (KEYB). */ 2N/A /* Safe unsigned comparison */ 2N/A/* Compare the on disk extent overflow key KEYA with the extent 2N/A overflow key we are looking for (KEYB). */ 2N/A /* Safe unsigned comparison */ 2N/A /* Iterate over all records in this node. */ 2N/A /* Don't skip any record in the next iteration. */ 2N/A/* Lookup the node described by KEY in the B+ Tree BTREE. Compare 2N/A keys using the function COMPARE_KEYS. When a match is found, 2N/A return the node in MATCHNODE and a pointer to the data in this node 2N/A in KEYOFFSET. MATCHNODE should be freed by the caller. */ 2N/A /* Find the record in this tree. */ 2N/A /* The action that has to be taken depend on the type of 2N/A /* An exact match was found! */ 2N/A /* The place where the key could have been found didn't 2N/A contain the key. This means that the previous match 2N/A is the one that should be followed. */ 2N/A /* Mark the last key which is lower or equal to the key 2N/A that we are looking for. The last match that is 2N/A found will be used to locate the child which can 2N/A contain the record. */ 2N/A /* No match is found, no record with this key exists in the 2N/A /* Stop iterating when the last directory entry is found. */ 2N/A /* Determine the type of the node that is found. */ 2N/A /* Make sure the byte order of the UTF16 string is correct. */ 2N/A /* If the name is obviously invalid, skip this node. */ 2N/A /* Restore the byte order to what it was previously. */ 2N/A /* hfs+ is case insensitive. */ 2N/A /* A valid node is found; setup the node and call the 2N/A callback function. */ 2N/A /* Create a key that points to the first entry in the directory. */ 2N/A /* First lookup the first entry. */ 2N/A /* Iterate over all entries in this directory. */ 2N/A/* Open a file named NAME and initialize FILE. */ 2N/A/* Read LEN bytes data from FILE into BUF. */ 2N/A /* Find the directory that should be opened. */ 2N/A /* Iterate over all entries in this directory. */ 2N/A /* Create a key that points to the label. */ 2N/A /* First lookup the first entry. */ 2N/A /* If the name is obviously invalid, skip this node. */ 2N/A (
unsigned long long)