1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 #pragma ident "%Z%%M% %I% %E% SMI" 23 24 /* 25 * High Sierra filesystem specification 26 * Copyright (c) 1989 by Sun Microsystem, Inc. 27 */ 28 29 #ifndef _HSFS_SPEC_H_ 30 #define _HSFS_SPEC_H_ 31 32 #include <sys/isa_defs.h> /* for ENDIAN defines */ 33 34 /* routines required for date parsing */ 35 extern void hs_parse_dirdate(); /* parse date in directory */ 36 extern void hs_parse_longdate(); /* parse date in volume id */ 37 38 /* macros to parse binary integers */ 39 #define ZERO(x) (u_int) (((u_char *)(x))[0]) 40 #define ONE(x) (u_int) (((u_char *)(x))[1]) 41 #define TWO(x) (u_int) (((u_char *)(x))[2]) 42 #define THREE(x) (u_int) (((u_char *)(x))[3]) 43 44 #define MSB_INT(x) \ 45 ((((((ZERO(x) << 8) | ONE(x)) << 8) | TWO(x)) << 8) | THREE(x)) 46 #define LSB_INT(x) \ 47 ((((((THREE(x) << 8) | TWO(x)) << 8) | ONE(x)) << 8) | ZERO(x)) 48 #define MSB_SHORT(x) ((ZERO(x) << 8) | ONE(x)) 49 #define LSB_SHORT(x) ((ONE(x) << 8) | ZERO(x)) 50 51 /* for sun 3 only */ 52 #if defined(_LITTLE_ENDIAN) 53 #define BOTH_SHORT(x) (short) *((short *)x) 54 #define BOTH_INT(x) (int) *((int *)x) 55 #endif 56 57 /* 58 * The following describes actual on-disk structures. 59 * To achieve portability, all structures are #defines 60 * rather than a structure definition. Macros are provided 61 * to get either the data or address of individual fields. 62 */ 63 64 /* Overall High Sierra disk structure */ 65 #define HS_SECTOR_SIZE 2048 /* bytes per logical sector */ 66 #define HS_SECTOR_SHIFT 11 /* sector<->byte shift count */ 67 #define HS_SEC_PER_PAGE (PAGESIZE/HS_SECTOR_SIZE) /* sectors per page */ 68 #define HS_SYSAREA_SEC 0 /* 1st sector of system area */ 69 #define HS_VOLDESC_SEC 16 /* 1st sector of volume descriptors */ 70 #define MAXHSOFFSET (HS_SECTOR_SIZE - 1) 71 #define MAXHSMASK (~MAXHSOFFSET) 72 73 /* Standard File Structure Volume Descriptor */ 74 75 enum hs_voldesc_type { 76 VD_BOOT=0, VD_SFS=1, VD_CCFS=2, VD_UNSPEC=3, VD_EOV=255 77 }; 78 #define HSV_ID_STRING "CDROM" /* HSV_std_id field */ 79 #define HSV_ID_STRLEN 5 /* HSV_std_id field length */ 80 #define HSV_ID_VER 1 /* HSV_std_ver field */ 81 #define HSV_FILE_STRUCT_ID_VER 1 /* HSV_file_struct_ver field */ 82 #define HSV_SYS_ID_STRLEN 32 /* HSV_sys_id field length */ 83 #define HSV_VOL_ID_STRLEN 32 /* HSV_vol_id field length */ 84 #define HSV_VOL_SET_ID_STRLEN 128 /* HSV_vol_set_id field length */ 85 #define HSV_PUB_ID_STRLEN 128 /* HSV_pub_id field length */ 86 #define HSV_PREP_ID_STRLEN 128 /* HSV_prep_id field length */ 87 #define HSV_APPL_ID_STRLEN 128 /* HSV_appl_id field length */ 88 #define HSV_COPYR_ID_STRLEN 32 /* HSV_copyr_id field length */ 89 #define HSV_ABSTR_ID_STRLEN 32 /* HSV_abstr_id field length */ 90 #define HSV_DATE_LEN 16 /* HSV date filed length */ 91 92 /* macros to get the address of each field */ 93 #define HSV_desc_lbn(x) (&((u_char *)x)[0]) 94 #define HSV_desc_type(x) (&((u_char *)x)[8]) 95 #define HSV_std_id(x) (&((u_char *)x)[9]) 96 #define HSV_std_ver(x) (&((u_char *)x)[14]) 97 #define HSV_sys_id(x) (&((u_char *)x)[16]) 98 #define HSV_vol_id(x) (&((u_char *)x)[48]) 99 #define HSV_vol_size(x) (&((u_char *)x)[88]) 100 #define HSV_set_size(x) (&((u_char *)x)[128]) 101 #define HSV_set_seq(x) (&((u_char *)x)[132]) 102 #define HSV_blk_size(x) (&((u_char *)x)[136]) 103 #define HSV_ptbl_size(x) (&((u_char *)x)[140]) 104 #define HSV_ptbl_man_ls(x) (&((u_char *)x)[148]) 105 #define HSV_ptbl_opt_ls1(x) (&((u_char *)x)[152]) 106 #define HSV_ptbl_opt_ls2(x) (&((u_char *)x)[156]) 107 #define HSV_ptbl_opt_ls3(x) (&((u_char *)x)[160]) 108 #define HSV_ptbl_man_ms(x) (&((u_char *)x)[164]) 109 #define HSV_ptbl_opt_ms1(x) (&((u_char *)x)[168]) 110 #define HSV_ptbl_opt_ms2(x) (&((u_char *)x)[172]) 111 #define HSV_ptbl_opt_ms3(x) (&((u_char *)x)[176]) 112 #define HSV_root_dir(x) (&((u_char *)x)[180]) 113 #define HSV_vol_set_id(x) (&((u_char *)x)[214]) 114 #define HSV_pub_id(x) (&((u_char *)x)[342]) 115 #define HSV_prep_id(x) (&((u_char *)x)[470]) 116 #define HSV_appl_id(x) (&((u_char *)x)[598]) 117 #define HSV_copyr_id(x) (&((u_char *)x)[726]) 118 #define HSV_abstr_id(x) (&((u_char *)x)[758]) 119 #define HSV_cre_date(x) (&((u_char *)x)[790]) 120 #define HSV_mod_date(x) (&((u_char *)x)[806]) 121 #define HSV_exp_date(x) (&((u_char *)x)[822]) 122 #define HSV_eff_date(x) (&((u_char *)x)[838]) 123 #define HSV_file_struct_ver(x) (&((u_char *)x)[854]) 124 125 /* macros to get the values of each field (strings are returned as ptrs) */ 126 #define HSV_DESC_LBN(x) BOTH_INT(HSV_desc_lbn(x)) 127 #define HSV_DESC_TYPE(x) ((enum hs_voldesc_type)*(HSV_desc_type(x))) 128 #define HSV_STD_ID(x) HSV_std_id(x) 129 #define HSV_STD_VER(x) *(HSV_std_ver(x)) 130 #define HSV_SYS_ID(x) HSV_sys_id(x) 131 #define HSV_VOL_ID(x) HSV_vol_id(x) 132 #define HSV_VOL_SIZE(x) BOTH_INT(HSV_vol_size(x)) 133 #define HSV_SET_SIZE(x) BOTH_SHORT(HSV_set_size(x)) 134 #define HSV_SET_SEQ(x) BOTH_SHORT(HSV_set_seq(x)) 135 #define HSV_BLK_SIZE(x) BOTH_SHORT(HSV_blk_size(x)) 136 #define HSV_PTBL_SIZE(x) BOTH_INT(HSV_ptbl_size(x)) 137 #define HSV_PTBL_MAN_LS(x) LSB_INT(HSV_ptbl_man_ls(x)) 138 #define HSV_PTBL_OPT_LS1(x) LSB_INT(HSV_ptbl_opt_ls1(x)) 139 #define HSV_PTBL_OPT_LS2(x) LSB_INT(HSV_ptbl_opt_ls2(x)) 140 #define HSV_PTBL_OPT_LS3(x) LSB_INT(HSV_ptbl_opt_ls3(x)) 141 #define HSV_PTBL_MAN_MS(x) MSB_INT(HSV_ptbl_man_ms(x)) 142 #define HSV_PTBL_OPT_MS1(x) MSB_INT(HSV_ptbl_opt_ms1(x)) 143 #define HSV_PTBL_OPT_MS2(x) MSB_INT(HSV_ptbl_opt_ms2(x)) 144 #define HSV_PTBL_OPT_MS3(x) MSB_INT(HSV_ptbl_opt_ms3(x)) 145 #define HSV_ROOT_DIR(x) HSV_root_dir(x) 146 #define HSV_VOL_SET_ID(x) HSV_vol_set_id(x) 147 #define HSV_PUB_ID(x) HSV_pub_id(x) 148 #define HSV_PREP_ID(x) HSV_prep_id(x) 149 #define HSV_APPL_ID(x) HSV_appl_id(x) 150 #define HSV_COPYR_ID(x) HSV_copyr_id(x) 151 #define HSV_ABSTR_ID(x) HSV_abstr_id(x) 152 #define HSV_CRE_DATE(x) HSV_cre_date(x) 153 #define HSV_MOD_DATE(x) HSV_mod_date(x) 154 #define HSV_EXP_DATE(x) HSV_exp_date(x) 155 #define HSV_EFF_DATE(x) HSV_eff_date(x) 156 #define HSV_FILE_STRUCT_VER(x) *(HSV_file_struct_ver(x)) 157 158 /* Standard File Structure Volume Descriptor date fields */ 159 #define HSV_DATE_2DIG(x) ( (((x)[0] - '0') * 10) + \ 160 ((x)[1] - '0') ) 161 #define HSV_DATE_4DIG(x) ( (((x)[0] - '0') * 1000) + \ 162 (((x)[1] - '0') * 100) + \ 163 (((x)[2] - '0') * 10) + \ 164 ((x)[3] - '0') ) 165 #define HSV_DATE_YEAR(x) HSV_DATE_4DIG(&((u_char *)x)[0]) 166 #define HSV_DATE_MONTH(x) HSV_DATE_2DIG(&((u_char *)x)[4]) 167 #define HSV_DATE_DAY(x) HSV_DATE_2DIG(&((u_char *)x)[6]) 168 #define HSV_DATE_HOUR(x) HSV_DATE_2DIG(&((u_char *)x)[8]) 169 #define HSV_DATE_MIN(x) HSV_DATE_2DIG(&((u_char *)x)[10]) 170 #define HSV_DATE_SEC(x) HSV_DATE_2DIG(&((u_char *)x)[12]) 171 #define HSV_DATE_HSEC(x) HSV_DATE_2DIG(&((u_char *)x)[14]) 172 173 /* Path table enry */ 174 /* fix size of path table entry */ 175 #define HPE_FPESIZE 8 176 /* macros to get the address of each field */ 177 #define HPE_ext_lbn(x) (&((u_char *)x)[0]) 178 #define HPE_xar_len(x) (&((u_char *)x)[4]) 179 #define HPE_name_len(x) (&((u_char *)x)[5]) 180 #define HPE_parent_no(x) (&((u_char *)x)[6]) 181 #define HPE_name(x) (&((u_char *)x)[8]) 182 183 /* macros to get the values of each field */ 184 #if sun4 185 #define HPE_EXT_LBN(x) (MSB_INT(HPE_ext_lbn(x))) 186 #else 187 #define HPE_EXT_LBN(x) *(int *)(HPE_ext_lbn(x)) 188 #endif 189 #define HPE_XAR_LEN(x) *(HPE_xar_len(x)) 190 #define HPE_NAME_LEN(x) *(HPE_name_len(x)) 191 #define HPE_PARENT_NO(x) *(short *)(HPE_parent_no(x)) 192 #define HPE_NAME(x) HPE_name(x) 193 194 /* root record */ 195 #define HDE_ROOT_DIR_REC_SIZE 34 /* size of root directory record */ 196 #define HDE_FDESIZE 33 /* fixed size for hsfs directory area */ 197 #define HDE_FUSIZE 12 /* fixed size for unix areaa */ 198 /* max size of a name */ 199 #define HDE_MAX_NAME_LEN (255 - HDE_FDESIZE - HDE_FUSIZE) 200 201 /* Directory Entry (Directory Record) */ 202 203 #define UNIX_TO_HDE_DATE(t,p) parse_unixdate(t, p) /* return val at p */ 204 205 /* macros to get the address of each field */ 206 #define HDE_dir_len(x) (&((u_char *)x)[0]) 207 #define HDE_xar_len(x) (&((u_char *)x)[1]) 208 #define HDE_ext_lbn(x) (&((u_char *)x)[2]) 209 #define HDE_ext_size(x) (&((u_char *)x)[10]) 210 #define HDE_cdate(x) (&((u_char *)x)[18]) 211 #define HDE_flags(x) (&((u_char *)x)[24]) 212 #define HDE_reserved(x) (&((u_char *)x)[25]) 213 #define HDE_intrlv_size(x) (&((u_char *)x)[26]) 214 #define HDE_intrlv_skip(x) (&((u_char *)x)[27]) 215 #define HDE_vol_set(x) (&((u_char *)x)[28]) 216 #define HDE_name_len(x) (&((u_char *)x)[32]) 217 #define HDE_name(x) (&((u_char *)x)[33]) 218 219 /***UNIX extension****/ 220 #define HDE_mode(x) (&((u_char *)x)[0]) 221 #define HDE_uid(x) (&((u_char *)x)[4]) 222 #define HDE_gid(x) (&((u_char *)x)[8]) 223 224 /* macros to get the values of each field (strings are returned as ptrs) */ 225 #define HDE_DIR_LEN(x) *(HDE_dir_len(x)) 226 #define HDE_XAR_LEN(x) *(HDE_xar_len(x)) 227 #define HDE_EXT_LBN(x) BOTH_INT(HDE_ext_lbn(x)) 228 #define HDE_EXT_SIZE(x) BOTH_INT(HDE_ext_size(x)) 229 #define HDE_CDATE(x) HDE_cdate(x) 230 #define HDE_FLAGS(x) *(HDE_flags(x)) 231 #define HDE_RESERVED(x) *(HDE_reserved(x)) 232 #define HDE_INTRLV_SIZE(x) *(HDE_intrlv_size(x)) 233 #define HDE_INTRLV_SKIP(x) *(HDE_intrlv_skip(x)) 234 #define HDE_VOL_SET(x) BOTH_SHORT(HDE_vol_set(x)) 235 #define HDE_NAME_LEN(x) *(HDE_name_len(x)) 236 #define HDE_NAME(x) HDE_name(x) 237 238 /***UNIX EXTENSION*****/ 239 #define HDE_MODE(x) *(HDE_mode(x)) 240 #define HDE_UID(x) *(HDE_uid(x)) 241 #define HDE_GID(x) *(HDE_gid(x)) 242 243 /* mask bits for HDE_FLAGS */ 244 #define HDE_EXISTENCE 0x01 /* zero if file exists */ 245 #define HDE_DIRECTORY 0x02 /* zero if file is not a directory */ 246 #define HDE_ASSOCIATED 0x04 /* zero if file is not Associated */ 247 #define HDE_RECORD 0x08 /* zero if no record attributes */ 248 #define HDE_PROTECTION 0x10 /* zero if no protection attributes */ 249 #define HDE_UNUSED_FLAGS 0x60 250 #define HDE_LAST_EXTENT 0x80 /* zero if last extent in file */ 251 #define HDE_PROHIBITED (HDE_DIRECTORY | HDE_ASSOCIATED | HDE_RECORD | \ 252 HDE_LAST_EXTENT | HDE_UNUSED_FLAGS) 253 254 /* Directory Record date fields */ 255 #define HDE_DATE_YEAR(x) (((u_char *)x)[0] + 1900) 256 #define HDE_DATE_MONTH(x) (((u_char *)x)[1]) 257 #define HDE_DATE_DAY(x) (((u_char *)x)[2]) 258 #define HDE_DATE_HOUR(x) (((u_char *)x)[3]) 259 #define HDE_DATE_MIN(x) (((u_char *)x)[4]) 260 #define HDE_DATE_SEC(x) (((u_char *)x)[5]) 261 262 /* tests for Interchange Levels 1 & 2 file types */ 263 #define HDE_REGULAR_FILE(x) (((x) & HDE_PROHIBITED) == 0) 264 #define HDE_REGULAR_DIR(x) (((x) & HDE_PROHIBITED) == HDE_DIRECTORY) 265 266 #define HS_DIR_NAMELEN 31 /* max length of a directory name */ 267 #define HS_FILE_NAMELEN 31 /* max length of a filename */ 268 269 #endif /*!_HSFS_SPEC_H_*/ 270