mkisofs.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. /*
  2. * Header file mkisofs.h - assorted structure definitions and typecasts.
  3. Written by Eric Youngdale (1993).
  4. Copyright 1993 Yggdrasil Computing, Incorporated
  5. Copyright (C) 2009,2010 Free Software Foundation, Inc.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3, or (at your option)
  9. any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /*
  18. * $Id: mkisofs.h,v 1.20 1999/03/02 04:16:41 eric Exp $
  19. */
  20. #include <stdio.h>
  21. #ifdef HAVE_STDINT_H
  22. #include <stdint.h>
  23. #endif
  24. #include <prototyp.h>
  25. #include <sys/stat.h>
  26. #if (defined(ENABLE_NLS) && ENABLE_NLS)
  27. # include <locale.h>
  28. # include <libintl.h>
  29. #else /* ! (defined(ENABLE_NLS) && ENABLE_NLS) */
  30. /* Disabled NLS.
  31. The casts to 'const char *' serve the purpose of producing warnings
  32. for invalid uses of the value returned from these functions.
  33. On pre-ANSI systems without 'const', the config.h file is supposed to
  34. contain "#define const". */
  35. # define gettext(Msgid) ((const char *) (Msgid))
  36. #endif /* (defined(ENABLE_NLS) && ENABLE_NLS) */
  37. #define _(str) gettext(str)
  38. #define N_(str) str
  39. /* This symbol is used to indicate that we do not have things like
  40. symlinks, devices, and so forth available. Just files and dirs */
  41. #ifdef VMS
  42. #define NON_UNIXFS
  43. #endif
  44. #ifdef DJGPP
  45. #define NON_UNIXFS
  46. #endif
  47. #ifdef VMS
  48. #include <sys/dir.h>
  49. #define dirent direct
  50. #endif
  51. #ifdef _WIN32
  52. #define NON_UNIXFS
  53. #endif /* _WIN32 */
  54. #ifndef S_IROTH
  55. #define S_IROTH 0
  56. #endif
  57. #ifndef S_IRGRP
  58. #define S_IRGRP 0
  59. #endif
  60. #ifndef HAVE_GETUID
  61. static inline int
  62. getuid ()
  63. {
  64. return 0;
  65. }
  66. #endif
  67. #ifndef HAVE_GETGID
  68. static inline int
  69. getgid ()
  70. {
  71. return 0;
  72. }
  73. #endif
  74. #ifndef HAVE_LSTAT
  75. static inline int
  76. lstat (const char *filename, struct stat *buf)
  77. {
  78. return stat (filename, buf);
  79. }
  80. #endif
  81. #include <string.h>
  82. #include <sys/types.h>
  83. #include <sys/stat.h>
  84. #if defined(HAVE_DIRENT_H)
  85. # include <dirent.h>
  86. # define NAMLEN(dirent) strlen((dirent)->d_name)
  87. #else
  88. # define dirent direct
  89. # define NAMLEN(dirent) (dirent)->d_namlen
  90. # if defined(HAVE_SYS_NDIR_H)
  91. # include <sys/ndir.h>
  92. # endif
  93. # if defined(HAVE_SYS_DIR_H)
  94. # include <sys/dir.h>
  95. # endif
  96. # if defined(HAVE_NDIR_H)
  97. # include <ndir.h>
  98. # endif
  99. #endif
  100. #if defined(HAVE_STRING_H)
  101. #include <string.h>
  102. #else
  103. #if defined(HAVE_STRINGS_H)
  104. #include <strings.h>
  105. #endif
  106. #endif
  107. #ifdef ultrix
  108. extern char *strdup();
  109. #endif
  110. #ifdef __STDC__
  111. #define DECL(NAME,ARGS) NAME ARGS
  112. #define FDECL1(NAME,TYPE0, ARG0) \
  113. NAME(TYPE0 ARG0)
  114. #define FDECL2(NAME,TYPE0, ARG0,TYPE1, ARG1) \
  115. NAME(TYPE0 ARG0, TYPE1 ARG1)
  116. #define FDECL3(NAME,TYPE0, ARG0,TYPE1, ARG1, TYPE2, ARG2) \
  117. NAME(TYPE0 ARG0, TYPE1 ARG1, TYPE2 ARG2)
  118. #define FDECL4(NAME,TYPE0, ARG0,TYPE1, ARG1, TYPE2, ARG2, TYPE3, ARG3) \
  119. NAME(TYPE0 ARG0, TYPE1 ARG1, TYPE2 ARG2, TYPE3 ARG3)
  120. #define FDECL5(NAME,TYPE0, ARG0,TYPE1, ARG1, TYPE2, ARG2, TYPE3, ARG3, TYPE4, ARG4) \
  121. NAME(TYPE0 ARG0, TYPE1 ARG1, TYPE2 ARG2, TYPE3 ARG3, TYPE4 ARG4)
  122. #define FDECL6(NAME,TYPE0, ARG0,TYPE1, ARG1, TYPE2, ARG2, TYPE3, ARG3, TYPE4, ARG4, TYPE5, ARG5) \
  123. NAME(TYPE0 ARG0, TYPE1 ARG1, TYPE2 ARG2, TYPE3 ARG3, TYPE4 ARG4, TYPE5 ARG5)
  124. #else
  125. #define DECL(NAME,ARGS) NAME()
  126. #define FDECL1(NAME,TYPE0, ARG0) NAME(ARG0) TYPE0 ARG0;
  127. #define FDECL2(NAME,TYPE0, ARG0,TYPE1, ARG1) NAME(ARG0, ARG1) TYPE0 ARG0; TYPE1 ARG1;
  128. #define FDECL3(NAME,TYPE0, ARG0,TYPE1, ARG1, TYPE2, ARG2) \
  129. NAME(ARG0, ARG1, ARG2) TYPE0 ARG0; TYPE1 ARG1; TYPE2 ARG2;
  130. #define FDECL4(NAME,TYPE0, ARG0,TYPE1, ARG1, TYPE2, ARG2, TYPE3, ARG3) \
  131. NAME(ARG0, ARG1, ARG2, ARG3, ARG4) TYPE0 ARG0; TYPE1 ARG1; TYPE2 ARG2; TYPE3 ARG3;
  132. #define FDECL5(NAME,TYPE0, ARG0,TYPE1, ARG1, TYPE2, ARG2, TYPE3, ARG3, TYPE4, ARG4) \
  133. NAME(ARG0, ARG1, ARG2, ARG3, ARG4) TYPE0 ARG0; TYPE1 ARG1; TYPE2 ARG2; TYPE3 ARG3; TYPE4 ARG4;
  134. #define FDECL6(NAME,TYPE0, ARG0,TYPE1, ARG1, TYPE2, ARG2, TYPE3, ARG3, TYPE4, ARG4, TYPE5, ARG5) \
  135. NAME(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5) TYPE0 ARG0; TYPE1 ARG1; TYPE2 ARG2; TYPE3 ARG3; TYPE4 ARG4; TYPE5 ARG5;
  136. #define const
  137. #endif
  138. #ifdef __SVR4
  139. #include <stdlib.h>
  140. #else
  141. extern int optind;
  142. extern char *optarg;
  143. /* extern int getopt (int __argc, char **__argv, char *__optstring); */
  144. #endif
  145. #include "iso9660.h"
  146. #include "defaults.h"
  147. struct directory_entry{
  148. struct directory_entry * next;
  149. struct directory_entry * jnext;
  150. struct iso_directory_record isorec;
  151. uint64_t starting_block;
  152. uint64_t size;
  153. unsigned short priority;
  154. unsigned char jreclen; /* Joliet record len */
  155. char * name;
  156. char * table;
  157. char * whole_name;
  158. struct directory * filedir;
  159. struct directory_entry * parent_rec;
  160. unsigned int de_flags;
  161. ino_t inode; /* Used in the hash table */
  162. dev_t dev; /* Used in the hash table */
  163. unsigned char * rr_attributes;
  164. unsigned int rr_attr_size;
  165. unsigned int total_rr_attr_size;
  166. unsigned int got_rr_name;
  167. };
  168. struct file_hash{
  169. struct file_hash * next;
  170. ino_t inode; /* Used in the hash table */
  171. dev_t dev; /* Used in the hash table */
  172. unsigned int starting_block;
  173. unsigned int size;
  174. };
  175. /*
  176. * This structure is used to control the output of fragments to the cdrom
  177. * image. Everything that will be written to the output image will eventually
  178. * go through this structure. There are two pieces - first is the sizing where
  179. * we establish extent numbers for everything, and the second is when we actually
  180. * generate the contents and write it to the output image.
  181. *
  182. * This makes it trivial to extend mkisofs to write special things in the image.
  183. * All you need to do is hook an additional structure in the list, and the rest
  184. * works like magic.
  185. *
  186. * The three passes each do the following:
  187. *
  188. * The 'size' pass determines the size of each component and assigns the extent number
  189. * for that component.
  190. *
  191. * The 'generate' pass will adjust the contents and pointers as required now that extent
  192. * numbers are assigned. In some cases, the contents of the record are also generated.
  193. *
  194. * The 'write' pass actually writes the data to the disc.
  195. */
  196. struct output_fragment
  197. {
  198. struct output_fragment * of_next;
  199. #ifdef __STDC__
  200. int (*of_size)(int);
  201. int (*of_generate)(void);
  202. int (*of_write)(FILE *);
  203. #else
  204. int (*of_size)();
  205. int (*of_generate)();
  206. int (*of_write)();
  207. #endif
  208. };
  209. extern struct output_fragment * out_list;
  210. extern struct output_fragment * out_tail;
  211. extern struct output_fragment padblock_desc;
  212. extern struct output_fragment voldesc_desc;
  213. extern struct output_fragment joliet_desc;
  214. extern struct output_fragment torito_desc;
  215. extern struct output_fragment end_vol;
  216. extern struct output_fragment pathtable_desc;
  217. extern struct output_fragment jpathtable_desc;
  218. extern struct output_fragment dirtree_desc;
  219. extern struct output_fragment dirtree_clean;
  220. extern struct output_fragment jdirtree_desc;
  221. extern struct output_fragment extension_desc;
  222. extern struct output_fragment files_desc;
  223. /*
  224. * This structure describes one complete directory. It has pointers
  225. * to other directories in the overall tree so that it is clear where
  226. * this directory lives in the tree, and it also must contain pointers
  227. * to the contents of the directory. Note that subdirectories of this
  228. * directory exist twice in this stucture. Once in the subdir chain,
  229. * and again in the contents chain.
  230. */
  231. struct directory{
  232. struct directory * next; /* Next directory at same level as this one */
  233. struct directory * subdir; /* First subdirectory in this directory */
  234. struct directory * parent;
  235. struct directory_entry * contents;
  236. struct directory_entry * jcontents;
  237. struct directory_entry * self;
  238. char * whole_name; /* Entire path */
  239. char * de_name; /* Entire path */
  240. unsigned int ce_bytes; /* Number of bytes of CE entries reqd for this dir */
  241. unsigned int depth;
  242. unsigned int size;
  243. unsigned int extent;
  244. unsigned int jsize;
  245. unsigned int jextent;
  246. unsigned short path_index;
  247. unsigned short jpath_index;
  248. unsigned short dir_flags;
  249. unsigned short dir_nlink;
  250. };
  251. extern int goof;
  252. extern struct directory * root;
  253. extern struct directory * reloc_dir;
  254. extern uint64_t next_extent;
  255. extern uint64_t last_extent;
  256. extern uint64_t last_extent_written;
  257. extern uint64_t session_start;
  258. extern unsigned int path_table_size;
  259. extern unsigned int path_table[4];
  260. extern unsigned int path_blocks;
  261. extern char * path_table_l;
  262. extern char * path_table_m;
  263. extern unsigned int jpath_table_size;
  264. extern unsigned int jpath_table[4];
  265. extern unsigned int jpath_blocks;
  266. extern char * jpath_table_l;
  267. extern char * jpath_table_m;
  268. extern struct iso_directory_record root_record;
  269. extern struct iso_directory_record jroot_record;
  270. extern int use_eltorito;
  271. extern int use_embedded_boot;
  272. extern int use_protective_msdos_label;
  273. extern int use_eltorito_emul_floppy;
  274. extern int use_boot_info_table;
  275. extern int use_RockRidge;
  276. extern int use_Joliet;
  277. extern int rationalize;
  278. extern int follow_links;
  279. extern int verbose;
  280. extern int all_files;
  281. extern int generate_tables;
  282. extern int print_size;
  283. extern int split_output;
  284. extern int omit_period;
  285. extern int omit_version_number;
  286. extern int transparent_compression;
  287. extern unsigned int RR_relocation_depth;
  288. extern int full_iso9660_filenames;
  289. extern int split_SL_component;
  290. extern int split_SL_field;
  291. /* tree.c */
  292. extern int DECL(stat_filter, (char *, struct stat *));
  293. extern int DECL(lstat_filter, (char *, struct stat *));
  294. extern int DECL(sort_tree,(struct directory *));
  295. extern struct directory *
  296. DECL(find_or_create_directory,(struct directory *, const char *,
  297. struct directory_entry * self, int));
  298. extern void DECL (finish_cl_pl_entries, (void));
  299. extern int DECL(scan_directory_tree,(struct directory * this_dir,
  300. char * path,
  301. struct directory_entry * self));
  302. extern int DECL(insert_file_entry,(struct directory *, char *,
  303. char *));
  304. extern void DECL(generate_iso9660_directories,(struct directory *, FILE*));
  305. extern void DECL(dump_tree,(struct directory * node));
  306. extern struct directory_entry * DECL(search_tree_file, (struct
  307. directory * node,char * filename));
  308. extern void DECL(update_nlink_field,(struct directory * node));
  309. extern void DECL (init_fstatbuf, (void));
  310. extern struct stat root_statbuf;
  311. /* eltorito.c */
  312. extern void DECL(init_boot_catalog, (const char * path ));
  313. extern void DECL(get_torito_desc, (struct eltorito_boot_descriptor * path ));
  314. /* write.c */
  315. extern int DECL(get_731,(char *));
  316. extern int DECL(get_733,(char *));
  317. extern int DECL(isonum_733,(unsigned char *));
  318. extern void DECL(set_723,(char *, unsigned int));
  319. extern void DECL(set_731,(char *, unsigned int));
  320. extern void DECL(set_721,(char *, unsigned int));
  321. extern void DECL(set_733,(char *, unsigned int));
  322. extern int DECL(sort_directory,(struct directory_entry **));
  323. extern void DECL(generate_one_directory,(struct directory *, FILE*));
  324. extern void DECL(memcpy_max, (char *, char *, int));
  325. extern int DECL(oneblock_size, (int starting_extent));
  326. extern struct iso_primary_descriptor vol_desc;
  327. extern void DECL(xfwrite, (void * buffer, uint64_t count, uint64_t size, FILE * file));
  328. extern void DECL(set_732, (char * pnt, unsigned int i));
  329. extern void DECL(set_722, (char * pnt, unsigned int i));
  330. extern void DECL(outputlist_insert, (struct output_fragment * frag));
  331. /*
  332. * Set by user command-line to override default date values
  333. */
  334. extern char *creation_date;
  335. extern char *modification_date;
  336. extern char *expiration_date;
  337. extern char *effective_date;
  338. /* multi.c */
  339. extern FILE * in_image;
  340. extern struct iso_directory_record *
  341. DECL(merge_isofs,(char * path));
  342. extern int DECL(free_mdinfo, (struct directory_entry **, int len));
  343. extern struct directory_entry **
  344. DECL(read_merging_directory,(struct iso_directory_record *, int*));
  345. extern void
  346. DECL(merge_remaining_entries, (struct directory *,
  347. struct directory_entry **, int));
  348. extern int
  349. DECL(merge_previous_session, (struct directory *,
  350. struct iso_directory_record *));
  351. extern int DECL(get_session_start, (int *));
  352. /* joliet.c */
  353. int DECL(joliet_sort_tree, (struct directory * node));
  354. /* match.c */
  355. extern int DECL(matches, (char *));
  356. extern void DECL(add_match, (char *));
  357. /* files.c */
  358. struct dirent * DECL(readdir_add_files, (char **, char *, DIR *));
  359. /* */
  360. extern int DECL(iso9660_file_length,(const char* name,
  361. struct directory_entry * sresult, int flag));
  362. extern int DECL(iso9660_date,(char *, time_t));
  363. extern void DECL(add_hash,(struct directory_entry *));
  364. extern struct file_hash * DECL(find_hash,(dev_t, ino_t));
  365. extern void DECL(add_directory_hash,(dev_t, ino_t));
  366. extern struct file_hash * DECL(find_directory_hash,(dev_t, ino_t));
  367. extern void DECL (flush_file_hash, (void));
  368. extern int DECL(delete_file_hash,(struct directory_entry *));
  369. extern struct directory_entry * DECL(find_file_hash,(char *));
  370. extern void DECL(add_file_hash,(struct directory_entry *));
  371. extern int DECL(generate_rock_ridge_attributes,(char *, char *,
  372. struct directory_entry *,
  373. struct stat *, struct stat *,
  374. int deep_flag));
  375. extern char * DECL(generate_rr_extension_record,(char * id, char * descriptor,
  376. char * source, int * size));
  377. extern int DECL(check_prev_session, (struct directory_entry **, int len,
  378. struct directory_entry *,
  379. struct stat *,
  380. struct stat *,
  381. struct directory_entry **));
  382. #ifdef USE_SCG
  383. /* scsi.c */
  384. #ifdef __STDC__
  385. extern int readsecs(int startsecno, void *buffer, int sectorcount);
  386. extern int scsidev_open(char *path);
  387. #else
  388. extern int readsecs();
  389. extern int scsidev_open();
  390. #endif
  391. #endif
  392. extern char * extension_record;
  393. extern int extension_record_extent;
  394. extern int n_data_extents;
  395. /* These are a few goodies that can be specified on the command line, and are
  396. filled into the root record */
  397. extern char *preparer;
  398. extern char *publisher;
  399. extern char *copyright;
  400. extern char *biblio;
  401. extern char *abstract;
  402. extern char *appid;
  403. extern char *volset_id;
  404. extern char *system_id;
  405. extern char *volume_id;
  406. extern char *boot_catalog;
  407. extern char *boot_image;
  408. extern char *boot_image_embed;
  409. extern int volume_set_size;
  410. extern int volume_sequence_number;
  411. extern void * DECL(e_malloc,(size_t));
  412. #define SECTOR_SIZE (2048)
  413. #define ROUND_UP(X) ((X + (SECTOR_SIZE - 1)) & ~(SECTOR_SIZE - 1))
  414. #define NEED_RE 1
  415. #define NEED_PL 2
  416. #define NEED_CL 4
  417. #define NEED_CE 8
  418. #define NEED_SP 16
  419. #define PREV_SESS_DEV (sizeof(dev_t) >= 4 ? 0x7ffffffd : 0x7ffd)
  420. #define TABLE_INODE (sizeof(ino_t) >= 4 ? 0x7ffffffe : 0x7ffe)
  421. #define UNCACHED_INODE (sizeof(ino_t) >= 4 ? 0x7fffffff : 0x7fff)
  422. #define UNCACHED_DEVICE (sizeof(dev_t) >= 4 ? 0x7fffffff : 0x7fff)
  423. #ifdef VMS
  424. #define STAT_INODE(X) (X.st_ino[0])
  425. #define PATH_SEPARATOR ']'
  426. #define SPATH_SEPARATOR ""
  427. #else
  428. #define STAT_INODE(X) (X.st_ino)
  429. #define PATH_SEPARATOR '/'
  430. #define SPATH_SEPARATOR "/"
  431. #endif
  432. /*
  433. * When using multi-session, indicates that we can reuse the
  434. * TRANS.TBL information for this directory entry. If this flag
  435. * is set for all entries in a directory, it means we can just
  436. * reuse the TRANS.TBL and not generate a new one.
  437. */
  438. #define SAFE_TO_REUSE_TABLE_ENTRY 0x01
  439. #define DIR_HAS_DOT 0x02
  440. #define DIR_HAS_DOTDOT 0x04
  441. #define INHIBIT_JOLIET_ENTRY 0x08
  442. #define INHIBIT_RR_ENTRY 0x10
  443. #define RELOCATED_DIRECTORY 0x20
  444. #define INHIBIT_ISO9660_ENTRY 0x40
  445. /*
  446. * Volume sequence number to use in all of the iso directory records.
  447. */
  448. #define DEF_VSN 1
  449. /*
  450. * Make sure we have a definition for this. If not, take a very conservative
  451. * guess. From what I can tell SunOS is the only one with this trouble.
  452. */
  453. #ifndef NAME_MAX
  454. #ifdef FILENAME_MAX
  455. #define NAME_MAX FILENAME_MAX
  456. #else
  457. #define NAME_MAX 128
  458. #endif
  459. #endif