Home | History | Annotate | Line # | Download | only in cd9660
iso9660_rrip.h revision 1.3
      1  1.3  dyoung /*	$NetBSD: iso9660_rrip.h,v 1.3 2005/10/30 03:10:28 dyoung Exp $	*/
      2  1.1    fvdl 
      3  1.1    fvdl /*
      4  1.1    fvdl  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
      5  1.1    fvdl  * Perez-Rathke and Ram Vedam.  All rights reserved.
      6  1.1    fvdl  *
      7  1.1    fvdl  * This code was written by Daniel Watt, Walter Deignan, Ryan Gabrys,
      8  1.1    fvdl  * Alan Perez-Rathke and Ram Vedam.
      9  1.1    fvdl  *
     10  1.1    fvdl  * Redistribution and use in source and binary forms, with or
     11  1.1    fvdl  * without modification, are permitted provided that the following
     12  1.1    fvdl  * conditions are met:
     13  1.1    fvdl  * 1. Redistributions of source code must retain the above copyright
     14  1.1    fvdl  *    notice, this list of conditions and the following disclaimer.
     15  1.1    fvdl  * 2. Redistributions in binary form must reproduce the above
     16  1.1    fvdl  *    copyright notice, this list of conditions and the following
     17  1.1    fvdl  *    disclaimer in the documentation and/or other materials provided
     18  1.1    fvdl  *    with the distribution.
     19  1.1    fvdl  *
     20  1.1    fvdl  * THIS SOFTWARE IS PROVIDED BY DANIEL WATT, WALTER DEIGNAN, RYAN
     21  1.1    fvdl  * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM ``AS IS'' AND ANY EXPRESS OR
     22  1.1    fvdl  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  1.3  dyoung  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     24  1.1    fvdl  * DISCLAIMED.  IN NO EVENT SHALL DANIEL WATT, WALTER DEIGNAN, RYAN
     25  1.1    fvdl  * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM BE LIABLE FOR ANY DIRECT, INDIRECT,
     26  1.1    fvdl  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27  1.1    fvdl  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
     28  1.1    fvdl  * USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     29  1.1    fvdl  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     30  1.1    fvdl  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31  1.1    fvdl  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
     32  1.1    fvdl  * OF SUCH DAMAGE.
     33  1.1    fvdl  */
     34  1.1    fvdl #ifndef __ISO9660_RRIP_H__
     35  1.1    fvdl #define __ISO9660_RRIP_H__
     36  1.1    fvdl 
     37  1.1    fvdl /*
     38  1.1    fvdl  * This will hold all the functions needed to
     39  1.1    fvdl  * write an ISO 9660 image with Rock Ridge Extensions
     40  1.1    fvdl  */
     41  1.1    fvdl 
     42  1.1    fvdl /* For writing must use ISO_RRIP_EXTREF structure */
     43  1.1    fvdl 
     44  1.1    fvdl #include "makefs.h"
     45  1.1    fvdl #include "cd9660/cd9660_rrip.h"
     46  1.1    fvdl #include "cd9660.h"
     47  1.1    fvdl #include <sys/queue.h>
     48  1.1    fvdl 
     49  1.1    fvdl #define	 PX_LENGTH	   0x2C
     50  1.1    fvdl #define	 PN_LENGTH	   0x14
     51  1.1    fvdl #define	 TF_CREATION	   0x00
     52  1.1    fvdl #define	 TF_MODIFY	   0x01
     53  1.1    fvdl #define	 TF_ACCESS	   0x02
     54  1.1    fvdl #define	 TF_ATTRIBUTES	   0x04
     55  1.1    fvdl #define	 TF_BACKUP	   0x08
     56  1.1    fvdl #define	 TF_EXPIRATION	   0x10
     57  1.1    fvdl #define	 TF_EFFECTIVE	   0x20
     58  1.1    fvdl #define	 TF_LONGFORM	   0x40
     59  1.1    fvdl #define  NM_CONTINUE	   0x80
     60  1.1    fvdl #define	 NM_CURRENT	   0x100
     61  1.1    fvdl #define	 NM_PARENT	   0x200
     62  1.1    fvdl 
     63  1.1    fvdl 
     64  1.1    fvdl #define	 SUSP_LOC_ENTRY	   0x01
     65  1.1    fvdl #define	 SUSP_LOC_DOT	   0x02
     66  1.1    fvdl #define	 SUSP_LOC_DOTDOT   0x04
     67  1.1    fvdl 
     68  1.1    fvdl #define SUSP_TYPE_SUSP		1
     69  1.1    fvdl #define SUSP_TYPE_RRIP		2
     70  1.1    fvdl 
     71  1.1    fvdl #define SUSP_ENTRY_SUSP_CE	1
     72  1.1    fvdl #define SUSP_ENTRY_SUSP_PD	2
     73  1.1    fvdl #define SUSP_ENTRY_SUSP_SP	3
     74  1.1    fvdl #define SUSP_ENTRY_SUSP_ST	4
     75  1.1    fvdl #define SUSP_ENTRY_SUSP_ER	5
     76  1.1    fvdl #define SUSP_ENTRY_SUSP_ES	6
     77  1.1    fvdl 
     78  1.1    fvdl #define SUSP_ENTRY_RRIP_PX	1
     79  1.1    fvdl #define SUSP_ENTRY_RRIP_PN	2
     80  1.1    fvdl #define SUSP_ENTRY_RRIP_SL	3
     81  1.1    fvdl #define SUSP_ENTRY_RRIP_NM	4
     82  1.1    fvdl #define SUSP_ENTRY_RRIP_CL	5
     83  1.1    fvdl #define SUSP_ENTRY_RRIP_PL	6
     84  1.1    fvdl #define SUSP_ENTRY_RRIP_RE	7
     85  1.1    fvdl #define SUSP_ENTRY_RRIP_TF	8
     86  1.1    fvdl #define SUSP_ENTRY_RRIP_SF	9
     87  1.1    fvdl 
     88  1.1    fvdl #define SUSP_RRIP_ER_EXT_ID "IEEE_P1282"
     89  1.1    fvdl #define SUSP_RRIP_ER_EXT_DES "THE IEEE P1282 PROTOCOL PROVIDES SUPPORT FOR POSIX FILE SYSTEM SEMANTICS."
     90  1.1    fvdl #define SUSP_RRIP_ER_EXT_SRC "PLEASE CONTACT THE IEEE STANDARDS DEPARTMENT, PISCATAWAY, NJ, USA FOR THE P1282 SPECIFICATION."
     91  1.1    fvdl 
     92  1.1    fvdl #define SL_FLAGS_NONE	        0
     93  1.1    fvdl #define SL_FLAGS_CONTINUE       1
     94  1.1    fvdl #define SL_FLAGS_CURRENT        2
     95  1.1    fvdl #define SL_FLAGS_PARENT	        4
     96  1.1    fvdl #define SL_FLAGS_ROOT	        8
     97  1.1    fvdl 
     98  1.1    fvdl typedef struct {
     99  1.1    fvdl 	ISO_SUSP_HEADER		 h;
    100  1.1    fvdl 	u_char mode		[ISODCL(5,12)];
    101  1.1    fvdl 	u_char links		[ISODCL(13,20)];
    102  1.1    fvdl 	u_char uid		[ISODCL(21,28)];
    103  1.1    fvdl 	u_char gid		[ISODCL(29,36)];
    104  1.1    fvdl 	u_char serial		[ISODCL(37,44)];/* Not used */
    105  1.1    fvdl } ISO_RRIP_PX;
    106  1.1    fvdl 
    107  1.1    fvdl typedef struct {
    108  1.1    fvdl 	ISO_SUSP_HEADER		 h;
    109  1.1    fvdl 	u_char high		[ISODCL(5,12)];
    110  1.1    fvdl 	u_char low		[ISODCL(13,20)];
    111  1.1    fvdl } ISO_RRIP_PN;
    112  1.1    fvdl 
    113  1.1    fvdl typedef struct {
    114  1.1    fvdl 	ISO_SUSP_HEADER		 h;
    115  1.1    fvdl 	u_char flags		 [ISODCL ( 4, 4)];
    116  1.1    fvdl 	u_char component	 [ISODCL ( 4, 256)];
    117  1.1    fvdl 	u_int  nBytes;
    118  1.1    fvdl } ISO_RRIP_SL;
    119  1.1    fvdl 
    120  1.1    fvdl typedef struct {
    121  1.1    fvdl 	ISO_SUSP_HEADER		 h;
    122  1.1    fvdl 	u_char flags		 [ISODCL ( 4, 4)];
    123  1.1    fvdl 	u_char timestamp	 [ISODCL ( 5, 256)];
    124  1.1    fvdl } ISO_RRIP_TF;
    125  1.1    fvdl 
    126  1.1    fvdl #define RRIP_NM_FLAGS_NONE 0x00
    127  1.1    fvdl #define RRIP_NM_FLAGS_CONTINUE 0x01
    128  1.1    fvdl #define RRIP_NM_FLAGS_CURRENT 0x02
    129  1.1    fvdl #define RRIP_NM_FLAGS_PARENT 0x04
    130  1.1    fvdl 
    131  1.1    fvdl typedef struct {
    132  1.1    fvdl 	ISO_SUSP_HEADER		 h;
    133  1.1    fvdl 	u_char flags		 [ISODCL ( 4, 4)];
    134  1.1    fvdl 	u_char altname		 [ISODCL ( 4, 256)];
    135  1.1    fvdl } ISO_RRIP_NM;
    136  1.1    fvdl 
    137  1.1    fvdl /* Note that this is the same structure as cd9660_rrip.h : ISO_RRIP_CONT */
    138  1.1    fvdl typedef struct {
    139  1.1    fvdl 	ISO_SUSP_HEADER		 h;
    140  1.1    fvdl 	u_char ca_sector	 [ISODCL ( 5, 12)];
    141  1.1    fvdl 	u_char offset		 [ISODCL ( 13, 20)];
    142  1.1    fvdl 	u_char length		 [ISODCL ( 21, 28)];
    143  1.3  dyoung } ISO_SUSP_CE;
    144  1.1    fvdl 
    145  1.1    fvdl typedef struct {
    146  1.1    fvdl 	ISO_SUSP_HEADER		 h;
    147  1.1    fvdl 	u_char padding_area	 [ISODCL ( 4, 256)];
    148  1.1    fvdl } ISO_SUSP_PD;
    149  1.1    fvdl 
    150  1.1    fvdl typedef struct {
    151  1.1    fvdl 	ISO_SUSP_HEADER		 h;
    152  1.1    fvdl 	u_char check		 [ISODCL ( 4, 5)];
    153  1.1    fvdl 	u_char len_skp		 [ISODCL ( 6, 6)];
    154  1.1    fvdl } ISO_SUSP_SP;
    155  1.1    fvdl 
    156  1.1    fvdl typedef struct {
    157  1.1    fvdl 	ISO_SUSP_HEADER		 h;
    158  1.1    fvdl } ISO_SUSP_ST;
    159  1.1    fvdl 
    160  1.1    fvdl typedef struct {
    161  1.1    fvdl 	ISO_SUSP_HEADER		 h;
    162  1.1    fvdl 	u_char len_id		 [ISODCL ( 4, 4)];
    163  1.1    fvdl 	u_char len_des		 [ISODCL ( 5, 5)];
    164  1.1    fvdl 	u_char len_src		 [ISODCL ( 6, 6)];
    165  1.1    fvdl 	u_char ext_ver		 [ISODCL ( 7, 7)];
    166  1.1    fvdl 	u_char ext_data		 [ISODCL (8,256)];
    167  1.1    fvdl /*	u_char ext_id		 [ISODCL ( 8, 256)];
    168  1.1    fvdl 	u_char ext_des		 [ISODCL ( 257, 513)];
    169  1.1    fvdl 	u_char ext_src		 [ISODCL ( 514, 770)];*/
    170  1.1    fvdl } ISO_SUSP_ER;
    171  1.1    fvdl 
    172  1.1    fvdl typedef struct {
    173  1.1    fvdl 	ISO_SUSP_HEADER		 h;
    174  1.1    fvdl 	u_char ext_seq		 [ISODCL ( 4, 4)];
    175  1.1    fvdl } ISO_SUSP_ES;
    176  1.1    fvdl 
    177  1.1    fvdl typedef union {
    178  1.1    fvdl 	ISO_RRIP_PX			PX;
    179  1.1    fvdl 	ISO_RRIP_PN			PN;
    180  1.1    fvdl 	ISO_RRIP_SL			SL;
    181  1.1    fvdl 	ISO_RRIP_NM			NM;
    182  1.1    fvdl 	ISO_RRIP_CLINK			CL;
    183  1.1    fvdl 	ISO_RRIP_PLINK			PL;
    184  1.1    fvdl 	ISO_RRIP_RELDIR			RE;
    185  1.1    fvdl 	ISO_RRIP_TF			TF;
    186  1.1    fvdl } rrip_entry;
    187  1.1    fvdl 
    188  1.1    fvdl typedef union {
    189  1.1    fvdl 	ISO_SUSP_CE			CE;
    190  1.1    fvdl 	ISO_SUSP_PD			PD;
    191  1.1    fvdl 	ISO_SUSP_SP			SP;
    192  1.1    fvdl 	ISO_SUSP_ST			ST;
    193  1.1    fvdl 	ISO_SUSP_ER			ER;
    194  1.1    fvdl 	ISO_SUSP_ES			ES;
    195  1.1    fvdl } susp_entry;
    196  1.1    fvdl 
    197  1.1    fvdl typedef union {
    198  1.1    fvdl 	susp_entry		  su_entry;
    199  1.1    fvdl 	rrip_entry		  rr_entry;
    200  1.1    fvdl } SUSP_ENTRIES;
    201  1.1    fvdl 
    202  1.1    fvdl struct ISO_SUSP_ATTRIBUTES {
    203  1.1    fvdl 	SUSP_ENTRIES attr;
    204  1.1    fvdl 	int type;
    205  1.1    fvdl 	char type_of[2];
    206  1.1    fvdl 	/* Dan's addons - will merge later. This allows use of a switch */
    207  1.1    fvdl 	char susp_type; 	/* SUSP or RRIP */
    208  1.1    fvdl 	char entry_type;	/* Record type */
    209  1.1    fvdl 	char write_location;
    210  1.2  dyoung 	TAILQ_ENTRY(ISO_SUSP_ATTRIBUTES) rr_ll;
    211  1.1    fvdl };
    212  1.1    fvdl 
    213  1.1    fvdl #define CD9660_SUSP_ENTRY_SIZE(entry)\
    214  1.1    fvdl 	((int) ((entry)->attr.su_entry.SP.h.length[0]))
    215  1.1    fvdl 
    216  1.1    fvdl /* Recursive function - move later to func pointer code*/
    217  1.1    fvdl int cd9660_susp_finalize(cd9660node *);
    218  1.1    fvdl 
    219  1.1    fvdl /* These two operate on single nodes */
    220  1.1    fvdl int cd9660_susp_finalize_node(cd9660node *);
    221  1.1    fvdl int cd9660_rrip_finalize_node(cd9660node *);
    222  1.1    fvdl 
    223  1.1    fvdl /* POSIX File attribute */
    224  1.1    fvdl int cd9660node_rrip_px(struct ISO_SUSP_ATTRIBUTES *, fsnode *);
    225  1.1    fvdl 
    226  1.1    fvdl /* Device number */
    227  1.1    fvdl int cd9660node_rrip_pn(struct ISO_SUSP_ATTRIBUTES *, fsnode *);
    228  1.1    fvdl 
    229  1.1    fvdl /* Symbolic link */
    230  1.1    fvdl int cd9660node_rrip_SL(struct ISO_SUSP_ATTRIBUTES *, fsnode *);
    231  1.1    fvdl 
    232  1.1    fvdl /* Alternate Name function */
    233  1.2  dyoung void cd9660_rrip_NM(cd9660node *);
    234  1.2  dyoung void cd9660_rrip_add_NM(cd9660node *,const char *);
    235  1.1    fvdl 
    236  1.1    fvdl /* Parent and child link function */
    237  1.1    fvdl int cd9660_rrip_PL(struct ISO_SUSP_ATTRIBUTES *, cd9660node *);
    238  1.1    fvdl int cd9660_rrip_CL(struct ISO_SUSP_ATTRIBUTES *, cd9660node *);
    239  1.1    fvdl int cd9660_rrip_RE(struct ISO_SUSP_ATTRIBUTES *, cd9660node *);
    240  1.1    fvdl 
    241  1.1    fvdl int cd9660node_rrip_tf(struct ISO_SUSP_ATTRIBUTES *, fsnode *);
    242  1.1    fvdl 
    243  1.1    fvdl 
    244  1.1    fvdl 
    245  1.1    fvdl /*
    246  1.1    fvdl  * Relocation directory function. I'm not quite sure what
    247  1.1    fvdl  * sort of parameters are needed, but personally I don't think
    248  1.1    fvdl  * any parameters are needed except for the memory address where
    249  1.1    fvdl  * the information needs to be put in
    250  1.1    fvdl  */
    251  1.1    fvdl int cd9660node_rrip_re(void *, fsnode *);
    252  1.1    fvdl 
    253  1.1    fvdl /*
    254  1.1    fvdl  * Don't know if this function is needed because it apparently is an
    255  1.1    fvdl  * optional feature that does not really need to be implemented but I
    256  1.1    fvdl  * thought I should add it anyway.
    257  1.1    fvdl  */
    258  1.1    fvdl int cd9660_susp_ce (struct ISO_SUSP_ATTRIBUTES *, cd9660node *);
    259  1.1    fvdl int cd9660_susp_pd (struct ISO_SUSP_ATTRIBUTES *, int);
    260  1.1    fvdl int cd9660_susp_sp (struct ISO_SUSP_ATTRIBUTES *, cd9660node *);
    261  1.1    fvdl int cd9660_susp_st (struct ISO_SUSP_ATTRIBUTES *, cd9660node *);
    262  1.1    fvdl 
    263  1.2  dyoung struct ISO_SUSP_ATTRIBUTES *cd9660_susp_ER(cd9660node *, u_char, const char *,
    264  1.2  dyoung     const char *, const char *);
    265  1.1    fvdl struct ISO_SUSP_ATTRIBUTES *cd9660_susp_ES(struct ISO_SUSP_ATTRIBUTES*,
    266  1.1    fvdl     cd9660node *);
    267  1.1    fvdl 
    268  1.1    fvdl 
    269  1.1    fvdl /* Helper functions */
    270  1.1    fvdl 
    271  1.1    fvdl /* Common SUSP/RRIP functions */
    272  1.2  dyoung int cd9660_susp_initialize(cd9660node *, cd9660node *, cd9660node *);
    273  1.1    fvdl int cd9660_susp_initialize_node(cd9660node *);
    274  1.1    fvdl struct ISO_SUSP_ATTRIBUTES *cd9660node_susp_create_node(int, int, const char *,
    275  1.1    fvdl     int);
    276  1.1    fvdl struct ISO_SUSP_ATTRIBUTES *cd9660node_susp_add_entry(cd9660node *,
    277  1.1    fvdl     struct ISO_SUSP_ATTRIBUTES *, struct ISO_SUSP_ATTRIBUTES *, int);
    278  1.1    fvdl 
    279  1.1    fvdl /* RRIP specific functions */
    280  1.2  dyoung int cd9660_rrip_initialize_node(cd9660node *, cd9660node *, cd9660node *);
    281  1.2  dyoung void cd9660_createSL(cd9660node *);
    282  1.1    fvdl 
    283  1.1    fvdl /* Functions that probably can be removed */
    284  1.1    fvdl /* int cd9660node_initialize_node(int, char *); */
    285  1.1    fvdl 
    286  1.1    fvdl 
    287  1.1    fvdl #endif
    288