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 59dc9a52b9SAxel Dörfler typedef struct ISORecDate { 60dc9a52b9SAxel Dörfler uint8 year; // Year - 1900 61dc9a52b9SAxel Dörfler uint8 month; 62dc9a52b9SAxel Dörfler uint8 date; 63dc9a52b9SAxel Dörfler uint8 hour; 64dc9a52b9SAxel Dörfler uint8 minute; 65dc9a52b9SAxel Dörfler uint8 second; 66dc9a52b9SAxel Dörfler int8 offsetGMT; 67dc9a52b9SAxel Dörfler } ISORecDate; 68dc9a52b9SAxel Dörfler 69eb097431SAxel Dörfler // This next section is data structure to hold the data found in the 70eb097431SAxel Dörfler // rock ridge extensions. 71eb097431SAxel Dörfler struct rock_ridge_attributes { 72dc9a52b9SAxel Dörfler char* slName; 73dc9a52b9SAxel Dörfler struct stat stat[2]; 74dc9a52b9SAxel Dörfler uint8 nmVer; 75dc9a52b9SAxel Dörfler uint8 pxVer; 76dc9a52b9SAxel Dörfler uint8 slVer; 77eb097431SAxel Dörfler }; 78dc9a52b9SAxel Dörfler 7941b19806SAxel Dörfler struct iso9660_volume; 8041b19806SAxel Dörfler 81eb097431SAxel Dörfler struct iso9660_inode { 82dc9a52b9SAxel Dörfler /* Most drivers will probably want the first things defined here. */ 83dc9a52b9SAxel Dörfler ino_t id; 84dc9a52b9SAxel Dörfler ino_t parID; // parent vnode ID. 8541b19806SAxel Dörfler struct iso9660_volume* volume; 86dc9a52b9SAxel Dörfler void *cache; // for file cache 87dc9a52b9SAxel Dörfler 88dc9a52b9SAxel Dörfler // End of members other drivers will definitely want. 89dc9a52b9SAxel Dörfler 90dc9a52b9SAxel Dörfler /* The rest of this struct is very ISO-specific. You should replace the rest of this 91dc9a52b9SAxel Dörfler definition with the stuff your file system needs. 92dc9a52b9SAxel Dörfler */ 93dc9a52b9SAxel Dörfler uint8 extAttrRecLen; // Length of extended attribute record. 94dc9a52b9SAxel Dörfler uint32 startLBN[2]; // Logical block # of start of file/directory data 95dc9a52b9SAxel Dörfler uint32 dataLen[2]; // Length of file section in bytes 96dc9a52b9SAxel Dörfler ISORecDate recordDate; // Date file was recorded. 97dc9a52b9SAxel Dörfler 98dc9a52b9SAxel Dörfler // BIT MEANING 99dc9a52b9SAxel Dörfler // --- ----------------------------- 100dc9a52b9SAxel Dörfler uint8 flags; // 0 - is hidden 101dc9a52b9SAxel Dörfler // 1 - is directory 102dc9a52b9SAxel Dörfler // 2 - is "Associated File" 103dc9a52b9SAxel Dörfler // 3 - Info is structed according to extended attr record 104dc9a52b9SAxel Dörfler // 4 - Owner, group, ppermisssions are specified in the 105dc9a52b9SAxel Dörfler // extended attr record 106dc9a52b9SAxel Dörfler // 5 - Reserved 107dc9a52b9SAxel Dörfler // 6 - Reserved 108dc9a52b9SAxel Dörfler // 7 - File has more that one directory record 109dc9a52b9SAxel Dörfler 110dc9a52b9SAxel Dörfler uint8 fileUnitSize; // Interleave only 111dc9a52b9SAxel Dörfler uint8 interleaveGapSize; // Interleave only 112dc9a52b9SAxel Dörfler uint32 volSeqNum; // Volume sequence number of volume 113eb097431SAxel Dörfler char* name; 114eb097431SAxel Dörfler uint32 name_length; 115dc9a52b9SAxel Dörfler 116dc9a52b9SAxel Dörfler // The rest is Rock Ridge extensions. I suggest www.leo.org for spec info. 117eb097431SAxel Dörfler rock_ridge_attributes attr; 118eb097431SAxel Dörfler }; 119dc9a52b9SAxel Dörfler 120eb097431SAxel Dörfler // These go with the flags member of the iso9660_volume struct. 121dc9a52b9SAxel Dörfler enum { 12247a214deSAxel Dörfler ISO_IS_HIDDEN = 0x01, 12347a214deSAxel Dörfler ISO_IS_DIR = 0x02, 12447a214deSAxel Dörfler ISO_IS_ASSOCIATED_FILE = 0x04, 12547a214deSAxel Dörfler ISO_EXTENDED_ATTRIBUTE = 0x08, 12647a214deSAxel Dörfler ISO_EXTENDED_PERMISSIONS = 0x10, 12747a214deSAxel Dörfler ISO_MORE_DIRS = 0x80 128dc9a52b9SAxel Dörfler }; 129dc9a52b9SAxel Dörfler 130dc9a52b9SAxel Dörfler 131dc9a52b9SAxel Dörfler // Arbitrarily - selected root vnode id 132dc9a52b9SAxel Dörfler #define ISO_ROOTNODE_ID 1 133dc9a52b9SAxel Dörfler 134dc9a52b9SAxel Dörfler /* Structure used for directory "cookie". When you are asked 135dc9a52b9SAxel Dörfler to open a directory, you are asked to create a cookie for it 136dc9a52b9SAxel Dörfler and pass it back. The cookie should contain the information you 137dc9a52b9SAxel Dörfler need to determine where you are at in reading the directory 138dc9a52b9SAxel Dörfler entries, incremented every time readdir is called, until finally 139dc9a52b9SAxel Dörfler the end is reached, when readdir returns NULL. */ 140dc9a52b9SAxel Dörfler typedef struct dircookie { 141dc9a52b9SAxel Dörfler off_t startBlock; 142dc9a52b9SAxel Dörfler off_t block; // Current block 143dc9a52b9SAxel Dörfler off_t pos; // Position within block. 144dc9a52b9SAxel Dörfler off_t totalSize; // Size of directory file 145dc9a52b9SAxel Dörfler off_t id; 146dc9a52b9SAxel Dörfler } dircookie; 147dc9a52b9SAxel Dörfler 148dc9a52b9SAxel Dörfler /* You may also need to define a cookie for files, which again is 149dc9a52b9SAxel Dörfler allocated every time a file is opened and freed when the free 150dc9a52b9SAxel Dörfler cookie function is called. For ISO, we didn't need one. 151dc9a52b9SAxel Dörfler */ 152dc9a52b9SAxel Dörfler 153dc9a52b9SAxel Dörfler typedef struct attrfilemap { 154dc9a52b9SAxel Dörfler char *name; 155dc9a52b9SAxel Dörfler off_t offset; 156dc9a52b9SAxel Dörfler } attrfilemap; 157dc9a52b9SAxel Dörfler 158eb097431SAxel Dörfler // This is the global volume iso9660_volume struct. 159eb097431SAxel Dörfler struct iso9660_volume { 160dc9a52b9SAxel Dörfler // Start of members other drivers will definitely want. 1610eaadd30SMichael Lotz fs_volume *volume; // volume passed fo fs_mount 1620eaadd30SMichael Lotz dev_t id; 163dc9a52b9SAxel Dörfler int fd; // File descriptor 164dc9a52b9SAxel Dörfler int fdOfSession; // File descriptor of the (mounted) session 165dc9a52b9SAxel Dörfler //unsigned int blockSize; // usually need this, but it's part of ISO 166dc9a52b9SAxel Dörfler void *fBlockCache; 167dc9a52b9SAxel Dörfler 168dc9a52b9SAxel Dörfler char devicePath[127]; 169dc9a52b9SAxel Dörfler //off_t numBlocks; // May need this, but it's part of ISO 170dc9a52b9SAxel Dörfler 171dc9a52b9SAxel Dörfler // End of members other drivers will definitely want. 172dc9a52b9SAxel Dörfler 173dc9a52b9SAxel Dörfler // attribute extensions 174dc9a52b9SAxel Dörfler int32 readAttributes; 175dc9a52b9SAxel Dörfler attrfilemap *attrFileMap; 176dc9a52b9SAxel Dörfler ino_t attributesID; 177dc9a52b9SAxel Dörfler 178dc9a52b9SAxel Dörfler // JOLIET extension: joliet_level for this volume 179dc9a52b9SAxel Dörfler uint8 joliet_level; 180dc9a52b9SAxel Dörfler 181dc9a52b9SAxel Dörfler // All this stuff comes straight from ISO primary volume 182dc9a52b9SAxel Dörfler // descriptor structure. 183dc9a52b9SAxel Dörfler uint8 volDescType; // Volume Descriptor type byte1 184dc9a52b9SAxel Dörfler char stdIDString[6]; // Standard ID, 1 extra for null byte2-6 185dc9a52b9SAxel Dörfler uint8 volDescVersion; // Volume Descriptor version byte7 186dc9a52b9SAxel Dörfler // 8th byte unused 187dc9a52b9SAxel Dörfler char systemIDString[33]; // System ID, 1 extra for null byte9-40 188dc9a52b9SAxel Dörfler char volIDString[33]; // Volume ID, 1 extra for null byte41-72 189dc9a52b9SAxel Dörfler // bytes 73-80 unused 190dc9a52b9SAxel Dörfler uint32 volSpaceSize[2]; // #logical blocks, lsb and msb byte81-88 191dc9a52b9SAxel Dörfler // bytes 89-120 unused 192dc9a52b9SAxel Dörfler uint16 volSetSize[2]; // Assigned Volume Set Size of Vol byte121-124 193dc9a52b9SAxel Dörfler uint16 volSeqNum[2]; // Ordinal number of volume in Set byte125-128 194dc9a52b9SAxel Dörfler uint16 logicalBlkSize[2]; // Logical blocksize, usually 2048 byte129-132 195dc9a52b9SAxel Dörfler uint32 pathTblSize[2]; // Path table size byte133-149 196dc9a52b9SAxel Dörfler uint16 lPathTblLoc[2]; // Loc (Logical block #) of "Type L" path table byte141-144 197dc9a52b9SAxel Dörfler uint16 optLPathTblLoc[2]; // Loc (Logical block #) of optional Type L path tbl byte145-148 198dc9a52b9SAxel Dörfler uint16 mPathTblLoc[2]; // Loc (Logical block #) of "Type M" path table byte149-152 199dc9a52b9SAxel Dörfler uint16 optMPathTblLoc[2]; // Loc (Logical block #) of optional Type M path tbl byte153-156 200eb097431SAxel Dörfler iso9660_inode rootDirRec; // Directory record for root directory byte157-190 201*1216557eSAxel Dörfler char volSetIDString[129]; // Name of multi-volume set where vol is member byte191-318 202dc9a52b9SAxel Dörfler char pubIDString[129]; // Name of publisher byte319-446 203dc9a52b9SAxel Dörfler char dataPreparer[129]; // Name of data preparer byte447-574 204dc9a52b9SAxel Dörfler char appIDString[129]; // Identifies data fomrat byte575-702 205dc9a52b9SAxel Dörfler char copyright[38]; // Copyright string byte703-739 206dc9a52b9SAxel Dörfler char abstractFName[38]; // Name of file in root that has abstract byte740-776 207dc9a52b9SAxel Dörfler char biblioFName[38]; // Name of file in root that has biblio byte777-813 208dc9a52b9SAxel Dörfler 209dc9a52b9SAxel Dörfler ISOVolDate createDate; // Creation date byte 210dc9a52b9SAxel Dörfler ISOVolDate modDate; // Modification date 211dc9a52b9SAxel Dörfler ISOVolDate expireDate; // Data expiration date 212dc9a52b9SAxel Dörfler ISOVolDate effectiveDate; // Data effective data 213dc9a52b9SAxel Dörfler 214dc9a52b9SAxel Dörfler uint8 fileStructVers; // File structure version byte882 215eb097431SAxel Dörfler }; 216dc9a52b9SAxel Dörfler 217dc9a52b9SAxel Dörfler 218eb097431SAxel Dörfler status_t ISOMount(const char *path, uint32 flags, iso9660_volume** _newVolume, 219dc9a52b9SAxel Dörfler bool allowJoliet); 220eb097431SAxel Dörfler status_t ISOReadDirEnt(iso9660_volume* ns, dircookie* cookie, 221eb097431SAxel Dörfler struct dirent* buffer, size_t bufferSize); 22256b2febaSMichael Lotz status_t InitNode(iso9660_volume* volume, iso9660_inode* rec, char* buf, 22356b2febaSMichael Lotz size_t* bytesRead, bool relocated = false); 224eb097431SAxel Dörfler status_t ConvertRecDate(ISORecDate* inDate, time_t* outDate); 225dc9a52b9SAxel Dörfler 226dc9a52b9SAxel Dörfler #endif /* ISO_9660_H */ 227