"Fossies" - the Fresh Open Source Software Archive

Member "libisofs-1.5.4/libisofs/hfsplus.h" (15 Nov 2020, 4600 Bytes) of package /linux/misc/libisofs-1.5.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "hfsplus.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.5.2_vs_1.5.4.

    1 /*
    2  * Copyright (c) 2012 Vladimir Serbinenko
    3  * 
    4  * This file is part of the libisofs project; you can redistribute it and/or 
    5  * modify it under the terms of the GNU General Public License version 2 
    6  * or later as published by the Free Software Foundation. 
    7  * See COPYING file for details.
    8  */
    9 
   10 /**
   11  * Declare HFS+ related structures.
   12  */
   13 
   14 #ifndef LIBISO_HFSPLUS_H
   15 #define LIBISO_HFSPLUS_H
   16 
   17 #include "libisofs.h"
   18 #include "ecma119.h"
   19 
   20 #define LIBISO_HFSPLUS_NAME_MAX 255
   21 
   22 
   23 enum hfsplus_node_type {
   24   HFSPLUS_DIR = 1,
   25   HFSPLUS_FILE = 2,
   26   HFSPLUS_DIR_THREAD = 3,
   27   HFSPLUS_FILE_THREAD = 4
   28 };
   29 
   30 struct hfsplus_btree_node
   31 {
   32   uint32_t start;
   33   uint32_t cnt;
   34   uint32_t strlen;
   35   uint16_t *str;
   36   uint32_t parent_id;
   37 };
   38 
   39 struct hfsplus_btree_level
   40 {
   41   uint32_t level_size;
   42   struct hfsplus_btree_node *nodes;
   43 };
   44 
   45 struct hfsplus_node
   46 {
   47   /* Note: .type HFSPLUS_DIR_THREAD and HFSPLUS_FILE_THREAD do not own their
   48      .name and .cmp_name. They have copies of others, if ever.
   49   */
   50   uint16_t *name; /* Name in UTF-16BE, decomposed. */
   51   uint16_t *cmp_name; /* Name used for comparing.  */ 
   52 
   53   IsoNode *node; /*< reference to the iso node */
   54 
   55   enum { UNIX_NONE, UNIX_SYMLINK, UNIX_SPECIAL } unix_type;
   56   uint32_t symlink_block;
   57   char *symlink_dest;
   58 
   59   enum hfsplus_node_type type;
   60   IsoFileSrc *file;
   61   uint32_t cat_id;
   62   uint32_t parent_id;
   63   uint32_t nchildren;
   64 
   65   uint32_t strlen;
   66   uint32_t used_size;
   67 };
   68 
   69 int hfsplus_writer_create(Ecma119Image *target);
   70 int hfsplus_tail_writer_create(Ecma119Image *target);
   71 
   72 struct hfsplus_extent
   73 {
   74   /* The first block of a file on disk.  */
   75   uint32_t start;
   76   /* The amount of blocks described by this extent.  */
   77   uint32_t count;
   78 } __attribute__ ((packed));
   79 
   80 struct hfsplus_forkdata
   81 {
   82   uint64_t size;
   83   uint32_t clumpsize;
   84   uint32_t blocks;
   85   struct hfsplus_extent extents[8];
   86 } __attribute__ ((packed));
   87 
   88 struct hfsplus_volheader
   89 {
   90   uint16_t magic;
   91   uint16_t version;
   92   uint32_t attributes;
   93   uint32_t last_mounted_version;
   94   uint32_t journal;
   95   uint32_t ctime;
   96   uint32_t utime;
   97   uint32_t backup_time;
   98   uint32_t fsck_time;
   99   uint32_t file_count;
  100   uint32_t folder_count;
  101   uint32_t blksize;
  102   uint32_t total_blocks;
  103   uint32_t free_blocks;
  104   uint32_t next_allocation;
  105   uint32_t rsrc_clumpsize;
  106   uint32_t data_clumpsize;
  107   uint32_t catalog_node_id;
  108   uint32_t write_count;
  109   uint64_t encodings_bitmap;
  110   uint32_t ppc_bootdir;
  111   uint32_t intel_bootfile;
  112   /* Folder opened when disk is mounted.  */
  113   uint32_t showfolder;
  114   uint32_t os9folder;
  115   uint32_t unused;
  116   uint32_t osxfolder;
  117   uint64_t num_serial;
  118   struct hfsplus_forkdata allocations_file;
  119   struct hfsplus_forkdata extents_file;
  120   struct hfsplus_forkdata catalog_file;
  121   struct hfsplus_forkdata attrib_file;
  122   struct hfsplus_forkdata startup_file;
  123 } __attribute__ ((packed));
  124 
  125 struct hfsplus_btnode
  126 {
  127   uint32_t next;
  128   uint32_t prev;
  129   int8_t type;
  130   uint8_t height;
  131   uint16_t count;
  132   uint16_t unused;
  133 } __attribute__ ((packed));
  134 
  135 /* The header of a HFS+ B+ Tree.  */
  136 struct hfsplus_btheader
  137 {
  138   uint16_t depth;
  139   uint32_t root;
  140   uint32_t leaf_records;
  141   uint32_t first_leaf_node;
  142   uint32_t last_leaf_node;
  143   uint16_t nodesize;
  144   uint16_t keysize;
  145   uint32_t total_nodes;
  146   uint32_t free_nodes;
  147   uint16_t reserved1;
  148   uint32_t clump_size;
  149   uint8_t btree_type;
  150   uint8_t key_compare;
  151   uint32_t attributes;
  152   uint32_t reserved[16];
  153 } __attribute__ ((packed));
  154 
  155 struct hfsplus_catfile_thread
  156 {
  157   uint16_t type;
  158   uint16_t reserved;
  159   uint32_t parentid;
  160   uint16_t namelen;
  161 } __attribute__ ((packed));
  162 
  163 struct hfsplus_catfile_common
  164 {
  165   uint16_t type;
  166   uint16_t flags;
  167   uint32_t valence; /* for files: reserved.  */
  168   uint32_t fileid;
  169   uint32_t ctime;
  170   uint32_t mtime;
  171   uint32_t attr_mtime;
  172   uint32_t atime;
  173   uint32_t backup_time;
  174   uint32_t uid;
  175   uint32_t gid;
  176   uint8_t user_flags;
  177   uint8_t group_flags;
  178   uint16_t mode;
  179   uint32_t special; 
  180   uint8_t file_type[4]; /* For folders: window size */
  181   uint8_t file_creator[4]; /* For folders: window size */
  182   uint8_t finder_info[24];
  183   uint32_t text_encoding;
  184   uint32_t reserved;
  185 } __attribute__ ((packed));
  186 
  187 #define HFSPLUS_MAX_DECOMPOSE_LEN 4
  188 
  189 extern uint16_t (*hfsplus_decompose_pages[256])[HFSPLUS_MAX_DECOMPOSE_LEN + 1];
  190 void make_hfsplus_decompose_pages();
  191 
  192 extern uint16_t *hfsplus_class_pages[256];
  193 void make_hfsplus_class_pages();
  194 
  195 extern const uint16_t hfsplus_casefold[];
  196 
  197 int iso_get_hfsplus_name(char *input_charset, int imgid, char *name,
  198                  uint16_t **result, uint32_t *result_len, uint16_t **cmp_name);
  199 
  200 void iso_setup_hfsplus_block_size(Ecma119Image *target);
  201 
  202 #endif /* LIBISO_HFSPLUS_H */