diff options
Diffstat (limited to 'qemu/roms/openbios/fs/hfsplus/include')
-rw-r--r-- | qemu/roms/openbios/fs/hfsplus/include/apple.h | 111 | ||||
-rw-r--r-- | qemu/roms/openbios/fs/hfsplus/include/blockiter.h | 59 | ||||
-rw-r--r-- | qemu/roms/openbios/fs/hfsplus/include/btree.h | 50 | ||||
-rw-r--r-- | qemu/roms/openbios/fs/hfsplus/include/hfs.h | 32 | ||||
-rw-r--r-- | qemu/roms/openbios/fs/hfsplus/include/hfsp.h | 305 | ||||
-rw-r--r-- | qemu/roms/openbios/fs/hfsplus/include/hfstime.h | 34 | ||||
-rw-r--r-- | qemu/roms/openbios/fs/hfsplus/include/libhfsp.h | 201 | ||||
-rw-r--r-- | qemu/roms/openbios/fs/hfsplus/include/record.h | 80 | ||||
-rw-r--r-- | qemu/roms/openbios/fs/hfsplus/include/swab.h | 64 | ||||
-rw-r--r-- | qemu/roms/openbios/fs/hfsplus/include/unicode.h | 28 | ||||
-rw-r--r-- | qemu/roms/openbios/fs/hfsplus/include/volume.h | 87 |
11 files changed, 1051 insertions, 0 deletions
diff --git a/qemu/roms/openbios/fs/hfsplus/include/apple.h b/qemu/roms/openbios/fs/hfsplus/include/apple.h new file mode 100644 index 000000000..7ba836db6 --- /dev/null +++ b/qemu/roms/openbios/fs/hfsplus/include/apple.h @@ -0,0 +1,111 @@ +/* + * libhfsp - library for reading and writing Macintosh HFS+ volumes + * + * This file contains defintions that are special for Apple. + * The names match the defintions found in Apple Header files. + * + * Copyright (C) 2000 Klaus Halfmann <khalfmann@libra.de> + * Original code 1996-1998 by Robert Leslie <rob@mars.rog> + * other work 2000 from Brad Boyer (flar@pants.nu) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * $Id: apple.h,v 1.2 2000/09/08 14:55:08 hasi Exp $ + */ + +typedef signed char Char; +typedef unsigned char UChar; +typedef signed char SInt8; +typedef unsigned char UInt8; +typedef signed short SInt16; +typedef unsigned short UInt16; +typedef signed long SInt32; +typedef unsigned long UInt32; +typedef unsigned long OSType; +typedef unsigned long long UInt64; + +/* A point, normally used by Quickdraw, + * but found in Finderinformation, too + */ +typedef struct { + SInt16 v; /* vertical coordinate */ + SInt16 h; /* horizontal coordinate */ +} Point; + +/* A rectancle, normally used by Quickdraw, + * but found in Finderinformation, too. + */ +typedef struct { + SInt16 top; /* top edge of rectangle */ + SInt16 left; /* left edge */ + SInt16 bottom; /* bottom edge */ + SInt16 right; /* right edge */ +} Rect; + +/* Information about the location and size of a folder + * used by the Finder. + */ +typedef struct { + Rect frRect; /* folder's rectangle */ + SInt16 frFlags; /* flags */ + Point frLocation; /* folder's location */ + SInt16 frView; /* folder's view */ +} DInfo; + +/* Extended folder information used by the Finder ... + */ +typedef struct { + Point frScroll; /* scroll position */ + SInt32 frOpenChain; /* directory ID chain of open folders */ + SInt16 frUnused; /* reserved */ + SInt16 frComment; /* comment ID */ + SInt32 frPutAway; /* directory ID */ +} DXInfo; + +/* Finder information for a File + */ +typedef struct { + OSType fdType; /* file type */ + OSType fdCreator; /* file's creator */ + SInt16 fdFlags; /* flags */ + Point fdLocation; /* file's location */ + SInt16 fdFldr; /* file's window */ +} FInfo; + +/* Extendend Finder Information for a file + */ +typedef struct { + SInt16 fdIconID; /* icon ID */ + SInt16 fdUnused[4]; /* reserved */ + SInt16 fdComment; /* comment ID */ + SInt32 fdPutAway; /* home directory ID */ +} FXInfo; + +/* Flagvalues for FInfo and DInfo */ +# define HFS_FNDR_ISONDESK (1 << 0) +# define HFS_FNDR_COLOR 0x0e +# define HFS_FNDR_COLORRESERVED (1 << 4) +# define HFS_FNDR_REQUIRESSWITCHLAUNCH (1 << 5) +# define HFS_FNDR_ISSHARED (1 << 6) +# define HFS_FNDR_HASNOINITS (1 << 7) +# define HFS_FNDR_HASBEENINITED (1 << 8) +# define HFS_FNDR_RESERVED (1 << 9) +# define HFS_FNDR_HASCUSTOMICON (1 << 10) +# define HFS_FNDR_ISSTATIONERY (1 << 11) +# define HFS_FNDR_NAMELOCKED (1 << 12) +# define HFS_FNDR_HASBUNDLE (1 << 13) +# define HFS_FNDR_ISINVISIBLE (1 << 14) +# define HFS_FNDR_ISALIAS (1 << 15) diff --git a/qemu/roms/openbios/fs/hfsplus/include/blockiter.h b/qemu/roms/openbios/fs/hfsplus/include/blockiter.h new file mode 100644 index 000000000..da3e480fd --- /dev/null +++ b/qemu/roms/openbios/fs/hfsplus/include/blockiter.h @@ -0,0 +1,59 @@ +/* + * libhfs - library for reading and writing Macintosh HFS volumes + * + * The iterator shown here iterates over the blocks of a fork. + * + * Copyright (C) 2000 Klaus Halfmann <khalfmann@libra.de> + * Original work by 1996-1998 Robert Leslie <rob@mars.org> + * other work 2000 from Brad Boyer (flar@pants.nu) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * $Id: blockiter.h,v 1.1 2000/10/10 11:14:05 hasi Exp $ + */ + +/* Structure of the blockiterator */ +typedef struct +{ + volume* vol; // volume we iterate over + UInt32 curr_block; // current, absolute block + UInt32 block; // relative block in current extent + UInt32 max_block; // Maximum allowed block + UInt32 fileId; // id of file we iterate over + int index; // 0 .. 7 in current extent + hfsp_extent* file; // original extent record from file + hfsp_extent* e; // current extentent under examination + UInt8 forktype; // type of fork we iterate over + UInt8 in_extent; // boolean 0 - in file extent + // 1 - in extents file + extent_record er; // record to iterate in extents file. +} blockiter; + +/* Initialize iterator for a given fork */ +extern void blockiter_init(blockiter* b, volume* vol, hfsp_fork_raw* f, + UInt8 forktype, UInt32 fileId); + +/* find next block of the fork iterating over */ +extern int blockiter_next(blockiter *b); + +/* skip the indicated number of blocks */ +extern int blockiter_skip(blockiter *b, UInt32 skip); + +/* return current block */ +static inline UInt32 blockiter_curr(blockiter *b) +{ + return b->e->start_block + b->block; +} diff --git a/qemu/roms/openbios/fs/hfsplus/include/btree.h b/qemu/roms/openbios/fs/hfsplus/include/btree.h new file mode 100644 index 000000000..46ac8501f --- /dev/null +++ b/qemu/roms/openbios/fs/hfsplus/include/btree.h @@ -0,0 +1,50 @@ +/* + * libhfs - library for reading and writing Macintosh HFS volumes. + * + * The fucntions are used to handle the various forms of btrees + * found on HFS+ volumes. + * + * Copyright (C) 2000 Klaus Halfmann <khalfmann@libra.de> + * Original 1996-1998 Robert Leslie <rob@mars.org> + * Additional work by Brad Boyer (flar@pants.nu) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * $Id: btree.h,v 1.10 2000/10/25 05:43:04 hasi Exp $ + */ + +/** Intialize catalog btree, so that btree_close can safely be called. */ +extern void btree_reset(btree* bt); + +/** Intialize catalog btree */ +extern int btree_init_cat(btree* bt, volume* vol, hfsp_fork_raw* fork); + +/** Intialize extents btree */ +extern int btree_init_extent(btree* bt, volume* vol, hfsp_fork_raw* fork); + +/** close the btree and free any resources */ +extern void btree_close(btree* bt); + +/* Read node at given index */ +extern node_buf* btree_node_by_index(btree* bt, UInt16 index); + +/* returns pointer to key given by index in current node */ +extern void* btree_key_by_index(btree* bt, node_buf* buf, UInt16 index); + +#ifdef DEBUG + /* Dump all the btree information to stdout */ + extern void btree_print(btree* bt); +#endif diff --git a/qemu/roms/openbios/fs/hfsplus/include/hfs.h b/qemu/roms/openbios/fs/hfsplus/include/hfs.h new file mode 100644 index 000000000..5b0cbb490 --- /dev/null +++ b/qemu/roms/openbios/fs/hfsplus/include/hfs.h @@ -0,0 +1,32 @@ +/* + * libhfsp - library for reading and writing Macintosh HFS+ volumes + * + * This file includes definitions for access to old HFS structures. + * + * Copyright (C) 2000 Klaus Halfmann <khalfmann@libra.de> + * Original code 1996-1998 by Robert Leslie <rob@mars.rog> + * other work 2000 from Brad Boyer (flar@pants.nu) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * $Id: hfs.h,v 1.1.1.1 2000/07/25 10:33:40 kkaempf Exp $ + */ + + +#define HFS_BLOCKSZ 512 + /* A sector for Apple is always 512 bytes */ +#define HFS_BLOCKSZ_BITS 9 /* 1<<9 == 512 */ +#define HFS_VOLHEAD_SIG 0x4244 /* 'BD' */ diff --git a/qemu/roms/openbios/fs/hfsplus/include/hfsp.h b/qemu/roms/openbios/fs/hfsplus/include/hfsp.h new file mode 100644 index 000000000..e916473c6 --- /dev/null +++ b/qemu/roms/openbios/fs/hfsplus/include/hfsp.h @@ -0,0 +1,305 @@ +/* + * libhfsp - library for reading and writing Macintosh HFS+ volumes + * + * This file includes definitions for the structures found on + * HFS+ Volumes. The structures are further wrapped by struct + * found in libhfsp.h. fucntions on those enhanced structures + * are found in files mentioned in comments below. + * + * Copyright (C) 2000 Klaus Halfmann <khalfmann@libra.de> + * Original code 1996-1998 by Robert Leslie <rob@mars.rog> + * other work 2000 from Brad Boyer (flar@pants.nu) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * $Id: hfsp.h,v 1.17 2000/10/20 06:16:52 hasi Exp $ + */ + +#define HFSP_BLOCKSZ 512 /* A sector for Apple is always 512 bytes */ +#define HFSP_BLOCKSZ_BITS 9 /* 1<<9 == 512 */ +#define HFSP_VOLHEAD_SIG 0x482B /* 'H+' */ + +/* HFS+ includes POSIX permissions , although marked as reserved they will be + * used as such. Is ignored by MacOS 8-9 but probably not by MacOS X. + */ +typedef struct { + UInt32 owner; + UInt32 group; + UInt32 mode; + UInt32 dev; +} hfsp_perm; + +/* A single contiguous area (fragment) of a file */ +typedef struct { + UInt32 start_block; + UInt32 block_count; +} hfsp_extent; + +/* A file may contain up to 8 normale extents, all other + are found in some extra extent area */ +typedef hfsp_extent hfsp_extent_rec[8]; + +/* Information for a "Fork" in a file + * Forks are the "usual" DATA and RSRC forks or special files + * (e.g. the Volume Bitmap) + */ +typedef struct { + UInt64 total_size; // logical size + UInt32 clump_size; // number of bytes to preallocate + UInt32 total_blocks; + hfsp_extent_rec extents; // initial (8) extents +} hfsp_fork_raw; + +/* HFS+ Volume Header + * Always found at block 2 of the disk, a copy is stored + * at the second to last block of the disk. + */ +typedef struct hfsp_vh { + UInt16 signature; // must be HFSPLUS_VOLHEAD_SIG 'H+' + UInt16 version; // currently 4, ignored + UInt32 attributes; // See bit constants below + UInt32 last_mount_vers; + // Use a registered creator code here (what do we use ?) + // Mac OS uses '8.10' well + UInt32 reserved; + + UInt32 create_date; // local time ! + UInt32 modify_date; // GMT (?) + UInt32 backup_date; // GMT (?) + UInt32 checked_date; // GMT (?) fsck ? + + UInt32 file_count; + // not including special files but including DATA and RSRC forks + UInt32 folder_count; // excluding the root folder + + UInt32 blocksize; + // must be multiple of HFSPLUS_SECTOR_SIZE, + // should be a multiple of 4k for harddisk + UInt32 total_blocks; + UInt32 free_blocks; + // The total number of unused allocation blocks on the disk. + + UInt32 next_alloc; + // hint wher to search for next allocation blocks + UInt32 rsrc_clump_sz; + // default clump size for rsrc forks + UInt32 data_clump_sz; + // default clump size for data forks + UInt32 next_cnid; + // next unused catalog id + UInt32 write_count; + // increment on every mount (and write ?) + UInt64 encodings_bmp; + // for every encoding used on the disk a bit is set + // ignored but eventually must be cared for + Char finder_info[32]; + hfsp_fork_raw alloc_file; + // stores bitmap of use/free blocks + hfsp_fork_raw ext_file; + // stores oferflow extents + hfsp_fork_raw cat_file; + // This contains the root directory + hfsp_fork_raw attr_file; + hfsp_fork_raw start_file; + // a special startup file may be described here (used by ?) +} hfsp_vh; + +/* HFS+ volume attributes */ +/* 0-6 reserved, may be used in memory only */ +#define HFSPLUS_VOL_RESERVED1 0x000000FF +#define HFSPLUS_VOL_HARDLOCK 0x00000080 // Used in Memory by finder only +#define HFSPLUS_VOL_UNMNT 0x00000100 + // clear this bit when mounting, set as last step of unmounting + // This is checked by (slower) ROM code +#define HFSPLUS_VOL_SPARE_BLK 0x00000200 +#define HFSPLUS_VOL_NOCACHE 0x00000400 + // in case of RAM or ROM disk (try a HFS+ Ramdisk :) +#define HFSPLUS_VOL_INCNSTNT 0x00000800 + // Reverse meaning as of HFSPLUS_VOL_UNMNT + // This is checked by (faster) Mac OS code +/* 12-14 reserved */ +#define HFSPLUS_VOL_RESERVED2 0x00007000 +#define HFSPLUS_VOL_SOFTLOCK 0x00008000 +#define HFSPLUS_VOL_RESERVED3 0xFFFF0000 + +/* HFS+ Btree node descriptor */ +typedef struct { + UInt32 next; /* pointer to next node of this kind, or 0 */ + UInt32 prev; /* pointer to previous node of this kind, or 0 */ + UInt8 kind; /* see below */ + UInt8 height; /* root node starts with 0 */ + UInt16 num_rec; /* number of records in this node */ + UInt16 reserved; /* fill up to 4 byte alignment */ +} btree_node_desc; + +/* HFS+ Btree Node types */ +#define HFSP_NODE_NDX 0x00 +#define HFSP_NODE_HEAD 0x01 +#define HFSP_NODE_MAP 0x02 +#define HFSP_NODE_LEAF 0xFF + +#define HFSP_CATALOG_MIN_NODE_SIZE 0x1000 +#define HFSP_ATTRMIN_DOE_SIZE 0x1000 + +/* The record offsets are found at the end of the fork + * containing the Btree */ + +typedef UInt16 btree_record_offset; + +typedef struct { + UInt16 depth; + // equal to height of btree_node_desc + UInt32 root; + // root node of the hierarchy + UInt32 leaf_count; + UInt32 leaf_head; + UInt32 leaf_tail; + UInt16 node_size; + // node size of _all_ nodes in this fork + UInt16 max_key_len; + UInt32 node_count; + // count of all (free and used) nodes in tree + UInt32 free_nodes; + UInt16 reserved1; + UInt32 clump_size; + // ignored my MacOS used by ? + UInt8 btree_type; + // always 0 for HFS+ + UInt8 reserved2; + UInt32 attributes; + // see below + UInt32 reserved3[16]; +} btree_head; + +/* BTree attributes */ +#define HFSPLUS_BAD_CLOSE 0x01 + // Btree was not properly closed and should be checked + // not used for HFS+ but reserved +#define HFSPLUS_TREE_BIGKEYS 0x02 + // always set for HFS+ +#define HFSPLUS_TREE_VAR_NDXKEY_SIZE 0x04 + // use variable length index nodes, always set for catalog btree, + // always cleared for extents btree. + +#define HFSPLUS_TREE_UNUSED 0xFFFFFFF8 + +/* Some special File ID numbers */ +#define HFSP_POR_CNID 1 /* Parent Of the Root */ +#define HFSP_ROOT_CNID 2 /* ROOT directory */ +#define HFSP_EXT_CNID 3 /* EXTents B-tree */ +#define HFSP_CAT_CNID 4 /* CATalog B-tree */ +#define HFSP_BAD_CNID 5 /* BAD blocks file */ +#define HFSP_ALLOC_CNID 6 /* ALLOCation file */ +#define HFSP_START_CNID 7 /* STARTup file */ +#define HFSP_ATTR_CNID 8 /* ATTRibutes file */ +#define HFSP_EXCH_CNID 15 /* ExchangeFiles temp id */ +#define HFPS_MIN_CNID 15 /* Minimum expected value */ + +/* Unicode String */ +typedef struct { + UInt16 strlen; + UInt16 name[255]; // unicode charcters +} hfsp_unistr255; + +/* HFS+ catalog entry key */ +typedef struct { + UInt16 key_length; /* excluding length */ + UInt32 parent_cnid; + hfsp_unistr255 name; +} hfsp_cat_key; + +/* HFS+ exnteds entry key */ +typedef struct { + UInt16 key_length; /* excluding length */ + UInt8 fork_type; /* Seee below */ + UInt8 filler; + UInt32 file_id; + UInt32 start_block; +} hfsp_extent_key; + +#define HFSP_EXTENT_DATA 0x00 +#define HFSP_EXTENT_RSRC 0xFF + +/* The key is followed by a record, an index or some other data */ + +/* The types of these records are defined as follows */ + +#define HFSP_FOLDER 0x0001 // entry fo a Folder +#define HFSP_FILE 0x0002 // entry for a File +#define HFSP_FOLDER_THREAD 0x0003 + // Like '.' in unix, identifies the folder by its id, only +#define HFSP_FILE_THREAD 0x0004 + // Im unsure if this is used by HFS+, too + +/* HFS+ folder data (part of an hfsp_cat_entry) */ +typedef struct { + UInt16 flags; /* no flags defined yet */ + UInt32 valence; /* Numer of files and folders contained in folder */ + UInt32 id; + UInt32 create_date; // GMT + UInt32 content_mod_date; // GMT + UInt32 attribute_mod_date; // GMT + UInt32 access_date; // GMT + UInt32 backup_date; // GMT + hfsp_perm permissions; + DInfo user_info; + DXInfo finder_info; + UInt32 text_encoding; + // hint fo the finder what encoding to use, unused here + UInt32 reserved; +} hfsp_cat_folder; + +/* HFS+ file data (part of a cat_entry) */ +typedef struct { + UInt16 flags; /* See below */ + UInt32 reserved1; + UInt32 id; + UInt32 create_date; + UInt32 content_mod_date; + UInt32 attribute_mod_date; + UInt32 access_date; + UInt32 backup_date; + hfsp_perm permissions; + FInfo user_info; + FXInfo finder_info; + UInt32 text_encoding; + UInt32 reserved2; + + hfsp_fork_raw data_fork; + hfsp_fork_raw res_fork; +} hfsp_cat_file; + +/* File attribute bits */ +#define HFSP_FILE_LOCKED 0x0001 +#define HFSP_THREAD_EXISTS 0x0002 /* Always set in HFS+ */ + +/* HFS+ catalog thread (part of a cat_entry) */ +typedef struct { + UInt16 reserved; + UInt32 parentID; + hfsp_unistr255 nodeName; +} hfsp_cat_thread; + + +/* A data record in the catalog tree */ +typedef struct { + UInt16 type; + union { + hfsp_cat_folder folder; + hfsp_cat_file file; + hfsp_cat_thread thread; + } u; +} hfsp_cat_entry; diff --git a/qemu/roms/openbios/fs/hfsplus/include/hfstime.h b/qemu/roms/openbios/fs/hfsplus/include/hfstime.h new file mode 100644 index 000000000..bb6bd4a6e --- /dev/null +++ b/qemu/roms/openbios/fs/hfsplus/include/hfstime.h @@ -0,0 +1,34 @@ +/* + * libhfs - library for reading and writing Macintosh HFS volumes + * Copyright (C) 2000 Klaus Halfmann <khalfmann@libra.de>^ + * Original 1996-1998 Robert Leslie <rob@mars.org> + * other work 2000 from Brad Boyer (flar@pants.nu) + * + * The HFS+ dates are stored as UInt32 containing the number of seconds since + * midnight, January 1, 1904, GMT. This is slightly different from HFS, + * where the value represents local time. A notable exception is the + * creationdate !. Linux uses times in GMT starting at January 1, 1970 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * $Id: hfstime.h,v 1.2 2000/10/19 13:33:38 hasi Exp $ + */ + + /* The number of seconds between 1.1.1904 and 1.1.1970 */ +#define HFSPTIMEDIFF 2082844800U + + /* return the given apple time as UNIX time */ +extern char* get_atime(UInt32 atime); diff --git a/qemu/roms/openbios/fs/hfsplus/include/libhfsp.h b/qemu/roms/openbios/fs/hfsplus/include/libhfsp.h new file mode 100644 index 000000000..912cfbd05 --- /dev/null +++ b/qemu/roms/openbios/fs/hfsplus/include/libhfsp.h @@ -0,0 +1,201 @@ +/* + * libhfs - library for reading and writing Macintosh HFS volumes + * Copyright (C) 2000 Klaus Halfmann (khalfmann@libra.de) + * Original work by 1996-1998 Robert Leslie (rob@mars.org) + * + * This file defines constants,structs etc needed for this library. + * Everything found here is usually not related to Apple defintions. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * $Id: libhfsp.h,v 1.17 2000/10/20 06:16:52 hasi Exp $ + */ + +# include "apple.h" +# include "hfs.h" +# include "hfsp.h" + +/* Last error is eventually found here */ +extern const char *hfsp_error; + +# define HFSP_ERROR(code, str) \ + do { hfsp_error = (str), errno = (code); goto fail; } while (0) + +# ifdef DEBUG +# define ASSERT(cond) do { if (! (cond)) abort(); } while (0) +# else +# define ASSERT(cond) /* nothing */ +# endif + +# define SIZE(type, n) ((size_t) (sizeof(type) * (n))) +# define ALLOC(type, n) ((type *) malloc(SIZE(type, n))) +# define ALLOCX(type, n) ((n) ? ALLOC(type, n) : (type *) 0) +# define FREE(ptr) ((ptr) ? (void) free((void *) ptr) : (void) 0) + +# define REALLOC(ptr, type, n) \ + ((type *) ((ptr) ? realloc(ptr, SIZE(type, n)) : malloc(SIZE(type, n)))) +# define REALLOCX(ptr, type, n) \ + ((n) ? REALLOC(ptr, type, n) : (FREE(ptr), (type *) 0)) + +# define BMTST(bm, num) \ + (((const byte *) (bm))[(num) >> 3] & (0x80 >> ((num) & 0x07))) +# define BMSET(bm, num) \ + (((byte *) (bm))[(num) >> 3] |= (0x80 >> ((num) & 0x07))) +# define BMCLR(bm, num) \ + (((byte *) (bm))[(num) >> 3] &= ~(0x80 >> ((num) & 0x07))) + +# define STRINGIZE(x) #x +# define STR(x) STRINGIZE(x) + +/* used by internal routines to specify the open modes */ +# define HFSP_MODE_RDONLY 0 +# define HFSP_MODE_RDWR 1 +# define HFSP_MODE_ANY 2 + +/* Signatures registered with Apple to identify this driver */ + /* Identifies the userland implementation */ +# define HPLS_SIGNATURE 0x482B4C58 // 'H+LX' + /* Identifies the kernel module by Brad Boyer (flar@pants.nu) */ +# define HPLS_SIGRES1 0x482B4C78 // 'H+Lx' + /* not jet in use ... */ +# define HPLS_SIGRES2 0x482B6C78 // 'H+lx' + /* Signature used by Apple */ +# define HPAPPLE_SIGNATURE 0x382e3130 // '8.10' + +/* Version used for this implementation of HFS+. This is not related + * to the VERSION file found at the top-level of this package, + * but designates the version of the low level code */ +#define HPLS_VERSION 1 /* must fit in a short */ + + +/* Othe Signatures may follow for informational purpos */ + +/* prototype for key comparing functions. */ +typedef int (*hfsp_key_compare) (void* key1, void* key2); + +/* prototype for key reading (necessary for byte swapping) */ +typedef void* (*hfsp_key_read) (void* p, void* key); + +struct volume; /* foreward declaration for btree needed */ + +/* Structures for a node cache. The cache is an array + * with linear search. (So making it to big may make + * things slower). It is searched in a round robin + * fashion. + */ + +typedef struct +{ + UInt32 priority; + // as lower this number as higher the priority. + // decremetned on any sucessfull usage + // incremented else, intial value height*DEPTHFACTOR + UInt16 index; // of node in fork + // 0 means empty, since first node is node header + // contents of node in original byte order + UInt16 flags; // like DIRTY etc. +} node_entry; + +typedef struct +{ + UInt32 index; // duplicate of above + btree_node_desc desc; // header of node + char node[0]; // actual node_size + // contents of node in original byte order +} node_buf; + +typedef struct +{ + int size; // number of nodes in the cache + int currindex; // round robin index + int nodebufsize; // size of complete node_buf, including node + node_entry *entries; + char *buffers; // actually *node_buf +} node_cache; + +typedef struct +{ + struct volume* vol; /* pointer to volume this tree is part of */ + hfsp_fork_raw* fork; /* pointer to fork this tree is part of */ + UInt32 cnid; /* (pseudo) file id for the fork */ + hfsp_key_compare kcomp; + /* function used for key compare in _this_ btree */ + hfsp_key_read kread; + /* fucntion used to read a key int _this_ btree */ + btree_head head; + + UInt16 blkpernode; + /* Number of volume blocks per node (usually 1-4) */ + node_cache cache; + /* Warning all functions of btrees and records may modify + the following values ! */ + // UInt16 node_index; /* index of node in fork */ + // btree_node_desc node; /* current node under examination */ + // char* buf; /* buf with size of a node */ +} btree; + +/* Function on btrees are defined in btree.h */ + +/* A Wrapper around the raw hfs+ volume header for additional information + * needed by this library. + */ + +typedef struct volume +{ + int os_fd; /* OS dependend reference to device */ + UInt16 blksize_bits; /* blocksize of device = 1 << blksize_bits */ + UInt16 filler; + UInt32 blksize; /* always 1 << blksize_bits */ + UInt32 startblock; + /* Offset from physical to logical blocks, + eventually intodruced by HFS wrapper */ + UInt32 maxblocks; /* maximum number of blocks in device */ + // UInt32 currblock; /* value of current block, to cache blocks */ + hfsp_vh vol; /* raw volume data */ + // void* blockbuf; /* (single) buffer for fetching one block */ + /* Buffer has double size of blksize to allow cross block reading */ + + btree* extents; /* is NULL by default and intialized when needed */ + btree catalog; /* This is always neeeded */ +} volume; + +/* Functions on volumes are defined in volume.h */ + +typedef struct { // may not be used as found here + btree* tree; // tree where this record is contained in. + UInt16 node_index; /* index of record in btree */ + UInt16 keyind; /* index of current key in btree */ + hfsp_cat_key key; /* current key */ + UInt32 child; /* child node belonging to this key */ +} index_record; + +typedef struct { + btree* tree; // tree where this record is contained in. + UInt16 node_index; /* index of record in btree */ + UInt16 keyind; /* index of current key in btree */ + hfsp_extent_key key; /* current key */ + hfsp_extent_rec extent; /* The payload carried around */ +} extent_record; + +typedef struct { + btree* tree; // tree where this record is contained in. + UInt16 node_index; /* index of record in btree */ + UInt16 keyind; /* index of current key in btree */ + hfsp_cat_key key; /* current key */ + hfsp_cat_entry record; /* current record */ +} record; + +/* Functions on records are defined in record.h */ diff --git a/qemu/roms/openbios/fs/hfsplus/include/record.h b/qemu/roms/openbios/fs/hfsplus/include/record.h new file mode 100644 index 000000000..6454f552a --- /dev/null +++ b/qemu/roms/openbios/fs/hfsplus/include/record.h @@ -0,0 +1,80 @@ +/* + * libhfs - library for reading and writing Macintosh HFS volumes. + * + * a record contains a key and a folder or file and is part + * of a btree. + * + * Copyright (C) 2000 Klaus Halfmann <khalfmann@libra.de> + * Original 1996-1998 Robert Leslie <rob@mars.org> + * Additional work by Brad Boyer (flar@pants.nu) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * $Id: record.h,v 1.10 2000/10/01 17:08:05 hasi Exp $ + */ + +/* Compare two cat_keys ... */ +extern int record_key_compare(void* k1, void* k2); + +/* Compare two extent_keys ... */ +extern int record_extent_key_compare(void* k1, void* k2); + +/* read a catalog key into a given buffer */ +extern void* record_readkey(void* p, void* buf); + +/* read an extent key into a given buffer */ +extern void* record_extent_readkey(void* p, void* buf); + +/* intialize the record to the first record of the tree + * which is (per design) the root node. + */ +extern int record_init_root(record* r, btree* tree); + +/* intialize the record to the folder given by cnid. + */ +extern int record_init_cnid(record* r, btree* tree, UInt32 cnid); + +/* intialize the record to the first record of the parent. + */ +extern int record_init_parent(record* r, record* parent); + +/* intialize the record by searching for the given string in the given folder. + * + * parent and r may be the same. + */ +extern int record_init_string_parent(record* r, record* parent, char* key); + +/* move record up in folder hierarchy (if possible) */ +extern int record_up(record* r); + +/* move record foreward to next entry. + * + * In case of an error the value of *r is undefined ! + */ +extern int record_next(record* r); + +/* intialize the extent_record to the extent identified by + * a given file */ +extern int record_init_file(extent_record* r, btree* tree, + UInt8 forktype, UInt32 fileId, UInt32 blockindex); + +/* move foreward to next entent record. */ +extern int record_next_extent(extent_record *r); + +#ifdef DEBUG + /* Dump all the record information to stdout */ + extern void record_print(record* r); +#endif diff --git a/qemu/roms/openbios/fs/hfsplus/include/swab.h b/qemu/roms/openbios/fs/hfsplus/include/swab.h new file mode 100644 index 000000000..c424008ee --- /dev/null +++ b/qemu/roms/openbios/fs/hfsplus/include/swab.h @@ -0,0 +1,64 @@ +/* + * libhfs - library for reading and writing Macintosh HFS volumes + * + * Copyright (C) 2000 Klaus Halfmann <klaus.halfmann@feri.de> + * Original work 1996-1998 Robert Leslie <rob@mars.org> + * + * This file defines some byte swapping function. I did not find this + * in any standard or linux way. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * $Id: swab.h,v 1.1.1.1 2002/03/05 19:50:29 klaus Exp $ + */ + +#include "config.h" +#include "libc/byteorder.h" + + /* basic fuction: + value = swab_inc(ptr); + ptr is afterwards incremented by sizeof(value) + */ + +#ifndef CONFIG_BIG_ENDIAN + +#define bswabU16(val) __bswap16(val) + +#define bswabU16_inc(ptr) (__extension__ ({ UInt16 v=__bswap16(*((UInt16*) (ptr))); ptr+=sizeof(UInt16);v;})) +#define bswabU32_inc(ptr) (__extension__ ({ UInt32 v=__bswap32(*((UInt32*) (ptr))); ptr+=sizeof(UInt32);v;})) +#define bswabU64_inc(ptr) (__extension__ ({ UInt64 v=__bswap64(*((UInt64*) (ptr))); ptr+=sizeof(UInt64);v;})) + +#define bstoreU16_inc(ptr, val) do {(*((UInt16*) (ptr))) = __bswap16(val); ptr+=sizeof(UInt16);} while (0) +#define bstoreU32_inc(ptr, val) do {(*((UInt32*) (ptr))) = __bswap32(val); ptr+=sizeof(UInt32);} while (0) +#define bstoreU64_inc(ptr, val) do {(*((UInt64*) (ptr))) = __bswap64(val); ptr+=sizeof(UInt64);} while (0) + +#else // BYTE_ORDER == BIG_ENDIAN + +#define bswabU16(val) val + +#define bswabU16_inc(ptr) (__extension__ ({ UInt16 v=(*((UInt16*) (ptr))); ptr+=sizeof(UInt16);v;})) +#define bswabU32_inc(ptr) (__extension__ ({ UInt32 v=(*((UInt32*) (ptr))); ptr+=sizeof(UInt32);v;})) +#define bswabU64_inc(ptr) (__extension__ ({ UInt64 v=(*((UInt64*) (ptr))); ptr+=sizeof(UInt64);v;})) + +#define bstoreU16_inc(ptr, val) do {(*((UInt16*) (ptr))) = val; ptr+=sizeof(UInt16);} while (0) +#define bstoreU32_inc(ptr, val) do {(*((UInt32*) (ptr))) = val; ptr+=sizeof(UInt32);} while (0) +#define bstoreU64_inc(ptr, val) do {(*((UInt64*) (ptr))) = val; ptr+=sizeof(UInt64);} while (0) + +#endif + +/* for the sake of compleetness and readability */ +#define bswabU8_inc(ptr) (__extension__ ({ UInt8 v=(*((UInt8*) (ptr))); ptr+=sizeof(UInt8);v;})) +#define bstoreU8_inc(ptr,val) do {(*((UInt8*) (ptr))) = val; ptr+=sizeof(UInt8);} while (0) diff --git a/qemu/roms/openbios/fs/hfsplus/include/unicode.h b/qemu/roms/openbios/fs/hfsplus/include/unicode.h new file mode 100644 index 000000000..e7c86f78a --- /dev/null +++ b/qemu/roms/openbios/fs/hfsplus/include/unicode.h @@ -0,0 +1,28 @@ +/* + * linux/fs/hfsplus/unicode.c + * + * Copyright (C) 1999-2000 Brad Boyer (flar@pants.nu) + * This file may be distributed under the terms of the GNU Public License. + * + * The routines found here convert hfs-unicode string into ascii Strings + * and vice versa. And the correct comparison between Strings. + */ + +/* convert the asci string astr into a unicode string given by ustr. + * + * returns actual length of convertet string. + */ + +int unicode_asc2uni(hfsp_unistr255 *ustr, const char *astr); + +/* Convert an unicode string ustr to a ascii string astr of given maximum len + * + * returns actual length of convertet string. + */ + +int unicode_uni2asc(char *astr, const hfsp_unistr255 *ustr, int maxlen); + +/* similar to strcmp for unicode, pascal strings */ + +SInt32 fast_unicode_compare (const hfsp_unistr255 *ustr1, + const hfsp_unistr255 *ustr2); diff --git a/qemu/roms/openbios/fs/hfsplus/include/volume.h b/qemu/roms/openbios/fs/hfsplus/include/volume.h new file mode 100644 index 000000000..19be05500 --- /dev/null +++ b/qemu/roms/openbios/fs/hfsplus/include/volume.h @@ -0,0 +1,87 @@ +/* + * libhfs - library for reading and writing Macintosh HFS volumes + * Copyright (C) 2000 Klaus Halfmann <khalfmann@libra.de>^ + * Original 1996-1998 Robert Leslie <rob@mars.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * $Id: volume.h,v 1.11 2000/10/17 05:58:46 hasi Exp $ + */ + +#ifndef _H_VOLUME +#define _H_VOLUME + +/* Open the device, read and verify the volume header + (and its backup) */ +extern int volume_open(volume* vol, int os_fd); + +/* Write back all data eventually cached and close the device. */ +extern int volume_close(volume* vol); + +/* read multiple blocks into given memory. + * + * returns given pointer or NULL on failure. + */ +extern void* volume_readfromfork(volume* vol, void* buf, + hfsp_fork_raw* f, UInt32 block, + UInt32 count, UInt8 forktype, UInt32 fileId); + +/* Fill a given buffer with the given block in volume. + */ +int volume_readinbuf(volume * vol,void* buf, long block); + +/* invalidat cache hold in volume, will be removed when + * caching strategy is clear to me. */ +/* +extern inline void volume_invalidate_cache(volume* vol) +{ + vol -> currblock = (UInt32) -1; +} +*/ + +/* Check in Allocation file if given block is allocated. */ +extern int volume_allocated(volume* v, UInt32 block); + +/* Read a raw hfsp_extent_rec from memory. */ +extern void* volume_readextent(void *p, hfsp_extent_rec er); + +/* Read fork information from raw memory */ +extern void* volume_readfork(void *p, hfsp_fork_raw* f); + +/* internal function used to create the extents btree, + is called by following inline fucntion when needed */ +extern void volume_create_extents_tree(volume* vol); + +/* accessor for entends btree, is created on demand */ +static inline btree* volume_get_extents_tree(volume* vol) { + if (!vol->extents) + volume_create_extents_tree(vol); + return vol->extents; +} + +/* Determine whether the volume is a HFS-plus volume */ +int volume_probe(int fd, long long offset); + +#ifdef DEBUG + /* Print raw fork information to stdout */ + void volume_print_fork(hfsp_fork_raw* f); + /* Dump all the volume information to stdout */ + void volume_print(hfsp_vh* vol); +#endif + + + +#endif /* _H_VOLUME */ |