File indexing completed on 2024-05-12 17:22:22

0001 /*
0002     SPDX-FileCopyrightText: 2002 Szombathelyi György <gyurco@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2004-2022 Krusader Krew <https://krusader.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef ISOFS_H
0009 #define ISOFS_H
0010 
0011 #ifdef __cplusplus
0012 extern "C" {
0013 #endif
0014 
0015 #include "el_torito.h"
0016 #include "iso_fs.h"
0017 #include "rock.h"
0018 #include <stdlib.h>
0019 #include <time.h>
0020 
0021 typedef struct _rr_entry {
0022     int len; /* length of structure */
0023     char *name; /* Name from 'NM' */
0024     char *sl; /* symbolic link data */
0025     time_t t_creat;
0026     time_t t_mtime;
0027     time_t t_atime;
0028     time_t t_ctime;
0029     time_t t_backup;
0030     time_t t_expire;
0031     time_t t_effect;
0032     int mode; /* POSIX file modes */
0033     int nlink;
0034     int uid;
0035     int gid;
0036     int serno;
0037     int dev_major;
0038     int dev_minor;
0039     int pl; /* parent location */
0040     int cl; /* child location */
0041     int re; /* relocated */
0042     char z_algo[2]; /* zizofs algorithm */
0043     char z_params[2]; /* zizofs parameters */
0044     unsigned int z_size; /* zizofs real_size */
0045 } rr_entry;
0046 
0047 typedef struct _iso_vol_desc {
0048     struct _iso_vol_desc *next;
0049     struct _iso_vol_desc *prev;
0050     struct iso_volume_descriptor data;
0051 } iso_vol_desc;
0052 
0053 union default_entry_as_data {
0054     char c[32];
0055     struct default_entry d_e;
0056 };
0057 
0058 typedef struct _boot_entry {
0059     struct _boot_entry *next;
0060     struct _boot_entry *prev;
0061     struct _boot_entry *parent;
0062     struct _boot_entry *child;
0063     union default_entry_as_data data;
0064 } boot_entry;
0065 
0066 typedef struct _boot_head {
0067     struct validation_entry ventry;
0068     struct _boot_entry *defentry;
0069     struct _boot_entry *sections;
0070 } boot_head;
0071 
0072 /**
0073  * this callback function needs to read 'len' sectors from 'start' into 'buf'
0074  */
0075 typedef int readfunc(char *buf, unsigned int start, unsigned int len, void *);
0076 
0077 /**
0078  * ProcessDir uses this callback
0079  */
0080 typedef int dircallback(struct iso_directory_record *, void *);
0081 
0082 /**
0083  * Returns the Unix from the ISO9660 9.1.5 (7 bytes) time format
0084  * This function is from the linux kernel.
0085  * Set 'hs' to non-zero if it's a HighSierra volume
0086  */
0087 time_t isodate_915(char *p, int hs);
0088 
0089 /**
0090  * Returns the Unix time from the ISO9660 8.4.26.1 (17 bytes) time format
0091  * BUG: hundredth of seconds are ignored, because time_t has one second
0092  * resolution (I think it's no problem at all)
0093  * Set 'hs' to non-zero if it's a HighSierra volume
0094  */
0095 time_t isodate_84261(char *p, int hs);
0096 
0097 /**
0098  * Creates the linked list of the volume descriptors
0099  * 'sector' is the starting sector number of where the filesystem start
0100  * (starting sector of a session on a CD-ROM)
0101  * If the function fails, returns NULL
0102  * Don't forget to call FreeISO9660 after using the volume descriptor list!
0103  */
0104 iso_vol_desc *ReadISO9660(readfunc *read, unsigned int sector, void *udata);
0105 
0106 /**
0107  * Frees the linked list of volume descriptors.
0108  */
0109 void FreeISO9660(iso_vol_desc *data);
0110 
0111 /**
0112  * Iterates over the directory entries. The directory is in 'buf',
0113  * the size of the directory is 'size'. 'callback' is called for each
0114  * directory entry with the parameter 'udata'.
0115  */
0116 int ProcessDir(readfunc *read, int extent, int size, dircallback *callback, void *udata);
0117 
0118 /**
0119  * Parses the System Use area and fills rr_entry with values
0120  */
0121 int ParseRR(struct iso_directory_record *idr, rr_entry *rrentry);
0122 
0123 /**
0124  * Frees the strings in 'rrentry'
0125  */
0126 void FreeRR(rr_entry *rrentry);
0127 
0128 /**
0129  * returns the joliet level from the volume descriptor
0130  */
0131 int JolietLevel(struct iso_volume_descriptor *ivd);
0132 
0133 /**
0134  * Returns the size of the boot image (in 512 byte sectors)
0135  */
0136 long long BootImageSize(int media, unsigned int len);
0137 
0138 /**
0139  * Frees the boot catalog entries in 'boot'. If you ever called ReadBootTable,
0140  * then don't forget to call FreeBootTable!
0141  */
0142 void FreeBootTable(boot_head *boot);
0143 
0144 /**
0145  * Reads the boot catalog into 'head'. Don't forget to call FreeBootTable!
0146  */
0147 int ReadBootTable(readfunc *read, unsigned int sector, boot_head *head, void *udata);
0148 
0149 #ifdef __cplusplus
0150 } // extern "C"
0151 #endif
0152 
0153 #endif