1dc9a52b9SAxel Dörfler /* 2dc9a52b9SAxel Dörfler * Copyright 1999, Be Incorporated. All Rights Reserved. 3dc9a52b9SAxel Dörfler * This file may be used under the terms of the Be Sample Code License. 4dc9a52b9SAxel Dörfler * 5dc9a52b9SAxel Dörfler * Copyright 2001, pinc Software. All Rights Reserved. 6dc9a52b9SAxel Dörfler */ 7dc9a52b9SAxel Dörfler #ifndef ISO_9660_H 8dc9a52b9SAxel Dörfler #define ISO_9660_H 9dc9a52b9SAxel Dörfler 10dc9a52b9SAxel Dörfler 11f47bff08SAxel Dörfler #if FS_SHELL 12f47bff08SAxel Dörfler # include "fssh_api_wrapper.h" 13f47bff08SAxel Dörfler #else 14dc9a52b9SAxel Dörfler # include <stdio.h> 15dc9a52b9SAxel Dörfler # include <sys/types.h> 16dc9a52b9SAxel Dörfler # include <time.h> 17dc9a52b9SAxel Dörfler # include <endian.h> 18dc9a52b9SAxel Dörfler 19f47bff08SAxel Dörfler # include <fs_interface.h> 20f47bff08SAxel Dörfler # include <SupportDefs.h> 21f47bff08SAxel Dörfler 22f47bff08SAxel Dörfler # include <lock.h> 23f47bff08SAxel Dörfler #endif 24f47bff08SAxel Dörfler 25dc9a52b9SAxel Dörfler 26dc9a52b9SAxel Dörfler // Size of primary volume descriptor for ISO9660 27dc9a52b9SAxel Dörfler #define ISO_PVD_SIZE 882 28dc9a52b9SAxel Dörfler 29dc9a52b9SAxel Dörfler // ISO structure has both msb and lsb first data. These let you do a 30dc9a52b9SAxel Dörfler // compile-time switch for different platforms. 31dc9a52b9SAxel Dörfler 32dc9a52b9SAxel Dörfler enum { 33dc9a52b9SAxel Dörfler LSB_DATA = 0, 34dc9a52b9SAxel Dörfler MSB_DATA 35dc9a52b9SAxel Dörfler }; 36dc9a52b9SAxel Dörfler 37dc9a52b9SAxel Dörfler // This defines the data format for the platform we are compiling 38dc9a52b9SAxel Dörfler // for. 39dc9a52b9SAxel Dörfler #if BYTE_ORDER == __LITTLE_ENDIAN 40dc9a52b9SAxel Dörfler # define FS_DATA_FORMAT LSB_DATA 41dc9a52b9SAxel Dörfler #else 42dc9a52b9SAxel Dörfler # define FS_DATA_FORMAT MSB_DATA 43dc9a52b9SAxel Dörfler #endif 44dc9a52b9SAxel Dörfler 45dc9a52b9SAxel Dörfler // ISO pdf file spec I read appears to be WRONG about the date format. See 46dc9a52b9SAxel Dörfler // www.alumni.caltech.edu/~pje/iso9660.html, definition there seems 47dc9a52b9SAxel Dörfler // to match. 48dc9a52b9SAxel Dörfler typedef struct ISOVolDate { 49dc9a52b9SAxel Dörfler char year[5]; 50dc9a52b9SAxel Dörfler char month[3]; 51dc9a52b9SAxel Dörfler char day[3]; 52dc9a52b9SAxel Dörfler char hour[3]; 53dc9a52b9SAxel Dörfler char minute[3]; 54dc9a52b9SAxel Dörfler char second[3]; 55dc9a52b9SAxel Dörfler char hunSec[3]; 56dc9a52b9SAxel Dörfler int8 offsetGMT; 57dc9a52b9SAxel Dörfler } ISOVolDate; 58dc9a52b9SAxel Dörfler 59*723f4b6aSGediminas Jarulaitis // Size of volume date and time data 60*723f4b6aSGediminas Jarulaitis #define ISO_VOL_DATE_SIZE 17 61*723f4b6aSGediminas Jarulaitis 62dc9a52b9SAxel Dörfler typedef struct ISORecDate { 63dc9a52b9SAxel Dörfler uint8 year; // Year - 1900 64dc9a52b9SAxel Dörfler uint8 month; 65dc9a52b9SAxel Dörfler uint8 date; 66dc9a52b9SAxel Dörfler uint8 hour; 67dc9a52b9SAxel Dörfler uint8 minute; 68dc9a52b9SAxel Dörfler uint8 second; 69dc9a52b9SAxel Dörfler int8 offsetGMT; 70dc9a52b9SAxel Dörfler } ISORecDate; 71dc9a52b9SAxel Dörfler 72eb097431SAxel Dörfler // This next section is data structure to hold the data found in the 73eb097431SAxel Dörfler // rock ridge extensions. 74eb097431SAxel Dörfler struct rock_ridge_attributes { 75dc9a52b9SAxel Dörfler char* slName; 76dc9a52b9SAxel Dörfler struct stat stat[2]; 77dc9a52b9SAxel Dörfler uint8 nmVer; 78dc9a52b9SAxel Dörfler uint8 pxVer; 79dc9a52b9SAxel Dörfler uint8 slVer; 80eb097431SAxel Dörfler }; 81dc9a52b9SAxel Dörfler 8241b19806SAxel Dörfler struct iso9660_volume; 8341b19806SAxel Dörfler 84eb097431SAxel Dörfler struct iso9660_inode { 85dc9a52b9SAxel Dörfler /* Most drivers will probably want the first things defined here. */ 86dc9a52b9SAxel Dörfler ino_t id; 87dc9a52b9SAxel Dörfler ino_t parID; // parent vnode ID. 8841b19806SAxel Dörfler struct iso9660_volume* volume; 89dc9a52b9SAxel Dörfler void *cache; // for file cache 90dc9a52b9SAxel Dörfler 91dc9a52b9SAxel Dörfler // End of members other drivers will definitely want. 92dc9a52b9SAxel Dörfler 93dc9a52b9SAxel Dörfler /* The rest of this struct is very ISO-specific. You should replace the rest of this 94dc9a52b9SAxel Dörfler definition with the stuff your file system needs. 95dc9a52b9SAxel Dörfler */ 96dc9a52b9SAxel Dörfler uint8 extAttrRecLen; // Length of extended attribute record. 97dc9a52b9SAxel Dörfler uint32 startLBN[2]; // Logical block # of start of file/directory data 98dc9a52b9SAxel Dörfler uint32 dataLen[2]; // Length of file section in bytes 99dc9a52b9SAxel Dörfler ISORecDate recordDate; // Date file was recorded. 100dc9a52b9SAxel Dörfler 101dc9a52b9SAxel Dörfler // BIT MEANING 102dc9a52b9SAxel Dörfler // --- ----------------------------- 103dc9a52b9SAxel Dörfler uint8 flags; // 0 - is hidden 104dc9a52b9SAxel Dörfler // 1 - is directory 105dc9a52b9SAxel Dörfler // 2 - is "Associated File" 106dc9a52b9SAxel Dörfler // 3 - Info is structed according to extended attr record 107dc9a52b9SAxel Dörfler // 4 - Owner, group, ppermisssions are specified in the 108dc9a52b9SAxel Dörfler // extended attr record 109dc9a52b9SAxel Dörfler // 5 - Reserved 110dc9a52b9SAxel Dörfler // 6 - Reserved 111dc9a52b9SAxel Dörfler // 7 - File has more that one directory record 112dc9a52b9SAxel Dörfler 113dc9a52b9SAxel Dörfler uint8 fileUnitSize; // Interleave only 114dc9a52b9SAxel Dörfler uint8 interleaveGapSize; // Interleave only 115dc9a52b9SAxel Dörfler uint32 volSeqNum; // Volume sequence number of volume 116eb097431SAxel Dörfler char* name; 117eb097431SAxel Dörfler uint32 name_length; 118dc9a52b9SAxel Dörfler 119dc9a52b9SAxel Dörfler // The rest is Rock Ridge extensions. I suggest www.leo.org for spec info. 120eb097431SAxel Dörfler rock_ridge_attributes attr; 121eb097431SAxel Dörfler }; 122dc9a52b9SAxel Dörfler 123eb097431SAxel Dörfler // These go with the flags member of the iso9660_volume struct. 124dc9a52b9SAxel Dörfler enum { 12547a214deSAxel Dörfler ISO_IS_HIDDEN = 0x01, 12647a214deSAxel Dörfler ISO_IS_DIR = 0x02, 12747a214deSAxel Dörfler ISO_IS_ASSOCIATED_FILE = 0x04, 12847a214deSAxel Dörfler ISO_EXTENDED_ATTRIBUTE = 0x08, 12947a214deSAxel Dörfler ISO_EXTENDED_PERMISSIONS = 0x10, 13047a214deSAxel Dörfler ISO_MORE_DIRS = 0x80 131dc9a52b9SAxel Dörfler }; 132dc9a52b9SAxel Dörfler 133dc9a52b9SAxel Dörfler 134dc9a52b9SAxel Dörfler // Arbitrarily - selected root vnode id 135dc9a52b9SAxel Dörfler #define ISO_ROOTNODE_ID 1 136dc9a52b9SAxel Dörfler 137dc9a52b9SAxel Dörfler /* Structure used for directory "cookie". When you are asked 138dc9a52b9SAxel Dörfler to open a directory, you are asked to create a cookie for it 139dc9a52b9SAxel Dörfler and pass it back. The cookie should contain the information you 140dc9a52b9SAxel Dörfler need to determine where you are at in reading the directory 141dc9a52b9SAxel Dörfler entries, incremented every time readdir is called, until finally 142dc9a52b9SAxel Dörfler the end is reached, when readdir returns NULL. */ 143dc9a52b9SAxel Dörfler typedef struct dircookie { 144dc9a52b9SAxel Dörfler off_t startBlock; 145dc9a52b9SAxel Dörfler off_t block; // Current block 146dc9a52b9SAxel Dörfler off_t pos; // Position within block. 147dc9a52b9SAxel Dörfler off_t totalSize; // Size of directory file 148dc9a52b9SAxel Dörfler off_t id; 149dc9a52b9SAxel Dörfler } dircookie; 150dc9a52b9SAxel Dörfler 151dc9a52b9SAxel Dörfler /* You may also need to define a cookie for files, which again is 152dc9a52b9SAxel Dörfler allocated every time a file is opened and freed when the free 153dc9a52b9SAxel Dörfler cookie function is called. For ISO, we didn't need one. 154dc9a52b9SAxel Dörfler */ 155dc9a52b9SAxel Dörfler 156dc9a52b9SAxel Dörfler typedef struct attrfilemap { 157dc9a52b9SAxel Dörfler char *name; 158dc9a52b9SAxel Dörfler off_t offset; 159dc9a52b9SAxel Dörfler } attrfilemap; 160dc9a52b9SAxel Dörfler 161eb097431SAxel Dörfler // This is the global volume iso9660_volume struct. 162eb097431SAxel Dörfler struct iso9660_volume { 163dc9a52b9SAxel Dörfler // Start of members other drivers will definitely want. 1640eaadd30SMichael Lotz fs_volume *volume; // volume passed fo fs_mount 1650eaadd30SMichael Lotz dev_t id; 166dc9a52b9SAxel Dörfler int fd; // File descriptor 167dc9a52b9SAxel Dörfler int fdOfSession; // File descriptor of the (mounted) session 168dc9a52b9SAxel Dörfler //unsigned int blockSize; // usually need this, but it's part of ISO 169dc9a52b9SAxel Dörfler void *fBlockCache; 170dc9a52b9SAxel Dörfler 171dc9a52b9SAxel Dörfler char devicePath[127]; 172dc9a52b9SAxel Dörfler //off_t numBlocks; // May need this, but it's part of ISO 173dc9a52b9SAxel Dörfler 174dc9a52b9SAxel Dörfler // End of members other drivers will definitely want. 175dc9a52b9SAxel Dörfler 176dc9a52b9SAxel Dörfler // attribute extensions 177dc9a52b9SAxel Dörfler int32 readAttributes; 178dc9a52b9SAxel Dörfler attrfilemap *attrFileMap; 179dc9a52b9SAxel Dörfler ino_t attributesID; 180dc9a52b9SAxel Dörfler 181dc9a52b9SAxel Dörfler // JOLIET extension: joliet_level for this volume 182dc9a52b9SAxel Dörfler uint8 joliet_level; 183dc9a52b9SAxel Dörfler 184dc9a52b9SAxel Dörfler // All this stuff comes straight from ISO primary volume 185dc9a52b9SAxel Dörfler // descriptor structure. 186dc9a52b9SAxel Dörfler uint8 volDescType; // Volume Descriptor type byte1 187dc9a52b9SAxel Dörfler char stdIDString[6]; // Standard ID, 1 extra for null byte2-6 188dc9a52b9SAxel Dörfler uint8 volDescVersion; // Volume Descriptor version byte7 189*723f4b6aSGediminas Jarulaitis uint8 unused1; // Unused Field byte8 190dc9a52b9SAxel Dörfler char systemIDString[33]; // System ID, 1 extra for null byte9-40 191dc9a52b9SAxel Dörfler char volIDString[33]; // Volume ID, 1 extra for null byte41-72 192*723f4b6aSGediminas Jarulaitis char unused2[9]; // Unused Field byte73-80 193dc9a52b9SAxel Dörfler uint32 volSpaceSize[2]; // #logical blocks, lsb and msb byte81-88 194*723f4b6aSGediminas Jarulaitis char unused3[33]; // Unused Field byte89-120 195dc9a52b9SAxel Dörfler uint16 volSetSize[2]; // Assigned Volume Set Size of Vol byte121-124 196dc9a52b9SAxel Dörfler uint16 volSeqNum[2]; // Ordinal number of volume in Set byte125-128 197dc9a52b9SAxel Dörfler uint16 logicalBlkSize[2]; // Logical blocksize, usually 2048 byte129-132 198dc9a52b9SAxel Dörfler uint32 pathTblSize[2]; // Path table size byte133-149 199dc9a52b9SAxel Dörfler uint16 lPathTblLoc[2]; // Loc (Logical block #) of "Type L" path table byte141-144 200dc9a52b9SAxel Dörfler uint16 optLPathTblLoc[2]; // Loc (Logical block #) of optional Type L path tbl byte145-148 201dc9a52b9SAxel Dörfler uint16 mPathTblLoc[2]; // Loc (Logical block #) of "Type M" path table byte149-152 202dc9a52b9SAxel Dörfler uint16 optMPathTblLoc[2]; // Loc (Logical block #) of optional Type M path tbl byte153-156 203eb097431SAxel Dörfler iso9660_inode rootDirRec; // Directory record for root directory byte157-190 2041216557eSAxel Dörfler char volSetIDString[129]; // Name of multi-volume set where vol is member byte191-318 205dc9a52b9SAxel Dörfler char pubIDString[129]; // Name of publisher byte319-446 206dc9a52b9SAxel Dörfler char dataPreparer[129]; // Name of data preparer byte447-574 207dc9a52b9SAxel Dörfler char appIDString[129]; // Identifies data fomrat byte575-702 208dc9a52b9SAxel Dörfler char copyright[38]; // Copyright string byte703-739 209dc9a52b9SAxel Dörfler char abstractFName[38]; // Name of file in root that has abstract byte740-776 210dc9a52b9SAxel Dörfler char biblioFName[38]; // Name of file in root that has biblio byte777-813 211dc9a52b9SAxel Dörfler 212dc9a52b9SAxel Dörfler ISOVolDate createDate; // Creation date byte 213dc9a52b9SAxel Dörfler ISOVolDate modDate; // Modification date 214dc9a52b9SAxel Dörfler ISOVolDate expireDate; // Data expiration date 215dc9a52b9SAxel Dörfler ISOVolDate effectiveDate; // Data effective data 216dc9a52b9SAxel Dörfler 217dc9a52b9SAxel Dörfler uint8 fileStructVers; // File structure version byte882 218eb097431SAxel Dörfler }; 219dc9a52b9SAxel Dörfler 220*723f4b6aSGediminas Jarulaitis // Size of root directory record 221*723f4b6aSGediminas Jarulaitis #define ISO_ROOT_DIR_REC_SIZE 34 222dc9a52b9SAxel Dörfler 223eb097431SAxel Dörfler status_t ISOMount(const char *path, uint32 flags, iso9660_volume** _newVolume, 224dc9a52b9SAxel Dörfler bool allowJoliet); 225eb097431SAxel Dörfler status_t ISOReadDirEnt(iso9660_volume* ns, dircookie* cookie, 226eb097431SAxel Dörfler struct dirent* buffer, size_t bufferSize); 22756b2febaSMichael Lotz status_t InitNode(iso9660_volume* volume, iso9660_inode* rec, char* buf, 22856b2febaSMichael Lotz size_t* bytesRead, bool relocated = false); 229eb097431SAxel Dörfler status_t ConvertRecDate(ISORecDate* inDate, time_t* outDate); 230dc9a52b9SAxel Dörfler 231dc9a52b9SAxel Dörfler #endif /* ISO_9660_H */ 232