ReactOS 0.4.15-dev-7906-g1b85a5f
joliet.c File Reference
#include <schily/mconfig.h>
#include "mkisofs.h"
#include <schily/time.h>
#include <schily/utypes.h>
#include <schily/intcvt.h>
#include <schily/schily.h>
#include <schily/errno.h>
Include dependency graph for joliet.c:

Go to the source code of this file.

Functions

LOCAL void convert_to_unicode __PR ((unsigned char *buffer, int size, char *source, siconvt_t *inls))
 
LOCAL int joliet_strlen __PR ((const char *string, size_t maxlen, siconvt_t *inls))
 
LOCAL void get_joliet_vol_desc __PR ((struct iso_primary_descriptor *jvol_desc))
 
LOCAL void assign_joliet_directory_addresses __PR ((struct directory *node))
 
LOCAL int joliet_compare_paths __PR ((void const *r, void const *l))
 
LOCAL int generate_joliet_path_tables __PR ((void))
 
LOCAL void generate_one_joliet_directory __PR ((struct directory *dpnt, FILE *outfile))
 
LOCAL int joliet_sort_n_finish __PR ((struct directory *this_dir))
 
LOCAL int joliet_compare_dirs __PR ((const void *rr, const void *ll))
 
LOCAL int joliet_sort_directory __PR ((struct directory_entry **sort_dir))
 
LOCAL void generate_joliet_directories __PR ((struct directory *node, FILE *outfile))
 
LOCAL int jpathtab_write __PR ((FILE *outfile))
 
LOCAL int jdirtree_size __PR ((UInt32_t starting_extent))
 
EXPORT void conv_charset (unsigned char *to, size_t *tosizep, unsigned char *from, size_t *fromsizep, siconvt_t *inls, siconvt_t *onls)
 
LOCAL void convert_to_unicode (unsigned char *buffer, int size, char *source, siconvt_t *inls)
 
LOCAL int joliet_strlen (char *string, size_t maxlen, siconvt_t *inls) const
 
LOCAL void get_joliet_vol_desc (struct iso_primary_descriptor *jvol_desc)
 
LOCAL void assign_joliet_directory_addresses (struct directory *node)
 
LOCAL void build_jpathlist (struct directory *node)
 
LOCAL int joliet_compare_paths (void const *r, void const *l)
 
LOCAL int generate_joliet_path_tables ()
 
LOCAL void generate_one_joliet_directory (struct directory *dpnt, FILE *outfile)
 
LOCAL int joliet_sort_n_finish (struct directory *this_dir)
 
LOCAL int joliet_compare_dirs (void *rr, const void *ll) const
 
LOCAL int joliet_sort_directory (struct directory_entry **sort_dir)
 
EXPORT int joliet_sort_tree (struct directory *node)
 
LOCAL void generate_joliet_directories (struct directory *node, FILE *outfile)
 
LOCAL int jpathtab_write (FILE *outfile)
 
LOCAL int jdirtree_size (UInt32_t starting_extent)
 
LOCAL int jroot_gen ()
 
LOCAL int jdirtree_write (FILE *outfile)
 
LOCAL int jvd_write (FILE *outfile)
 
LOCAL int jpathtab_size (UInt32_t starting_extent)
 

Variables

static UConst char sccsid []
 
LOCAL Uint jpath_table_index
 
LOCAL struct directory ** jpathlist
 
LOCAL int next_jpath_index = 1
 
LOCAL int jsort_goof
 
LOCAL int jsort_glen
 
LOCAL char ucs_codes []
 
struct output_fragment joliet_desc = {NULL, oneblock_size, jroot_gen, jvd_write, "Joliet Volume Descriptor" }
 
struct output_fragment jpathtable_desc = {NULL, jpathtab_size, generate_joliet_path_tables, jpathtab_write, "Joliet path table" }
 
struct output_fragment jdirtree_desc = {NULL, jdirtree_size, NULL, jdirtree_write, "Joliet directory tree" }
 

Function Documentation

◆ __PR() [1/13]

LOCAL int joliet_strlen __PR ( (const char *string, size_t maxlen, siconvt_t *inls)  )

◆ __PR() [2/13]

◆ __PR() [3/13]

◆ __PR() [4/13]

◆ __PR() [5/13]

◆ __PR() [6/13]

◆ __PR() [7/13]

LOCAL int joliet_sort_n_finish __PR ( (struct directory *this_dir)  )

◆ __PR() [8/13]

◆ __PR() [9/13]

◆ __PR() [10/13]

LOCAL int jdirtree_size __PR ( (UInt32_t starting_extent)  )

◆ __PR() [11/13]

◆ __PR() [12/13]

◆ __PR() [13/13]

◆ assign_joliet_directory_addresses()

LOCAL void assign_joliet_directory_addresses ( struct directory node)

Definition at line 492 of file joliet.c.

494{
495 int dir_size;
496 struct directory *dpnt;
497
498 dpnt = node;
499
500 while (dpnt) {
501 if ((dpnt->dir_flags & INHIBIT_JOLIET_ENTRY) == 0) {
502 /*
503 * If we already have an extent for this
504 * (i.e. it came from a multisession disc), then
505 * don't reassign a new extent.
506 */
508 if (dpnt->jextent == 0) {
509 dpnt->jextent = last_extent;
510 dir_size = ISO_BLOCKS(dpnt->jsize);
511 last_extent += dir_size;
512 }
513 }
514 /* skip if hidden - but not for the rr_moved dir */
515 if (dpnt->subdir &&
516 ((dpnt->dir_flags & INHIBIT_JOLIET_ENTRY) == 0 ||
517 dpnt == reloc_dir)) {
519 }
520 dpnt = dpnt->next;
521 }
522}
LOCAL int next_jpath_index
Definition: joliet.c:95
LOCAL void assign_joliet_directory_addresses(struct directory *node)
Definition: joliet.c:492
UInt32_t last_extent
Definition: mkisofs.c:76
#define INHIBIT_JOLIET_ENTRY
Definition: mkisofs.h:799
struct directory * reloc_dir
Definition: tree.c:111
#define ISO_BLOCKS(X)
Definition: mkisofs.h:743
unsigned int jpath_index
Definition: mkisofs.h:284
unsigned short dir_flags
Definition: mkisofs.h:285
unsigned int jsize
Definition: mkisofs.h:281
struct directory * subdir
Definition: mkisofs.h:268
unsigned int jextent
Definition: mkisofs.h:282
struct directory * next
Definition: mkisofs.h:267
Definition: dlist.c:348

Referenced by assign_joliet_directory_addresses(), and jdirtree_size().

◆ build_jpathlist()

LOCAL void build_jpathlist ( struct directory node)

Definition at line 525 of file joliet.c.

527{
528 struct directory *dpnt;
529
530 dpnt = node;
531
532 while (dpnt) {
533 if ((dpnt->dir_flags & INHIBIT_JOLIET_ENTRY) == 0) {
534 jpathlist[dpnt->jpath_index] = dpnt;
535 }
536 if (dpnt->subdir)
537 build_jpathlist(dpnt->subdir);
538 dpnt = dpnt->next;
539 }
540} /* build_jpathlist(... */
LOCAL void build_jpathlist(struct directory *node)
Definition: joliet.c:525
LOCAL struct directory ** jpathlist
Definition: joliet.c:94

Referenced by build_jpathlist(), and generate_joliet_path_tables().

◆ conv_charset()

EXPORT void conv_charset ( unsigned char to,
size_t tosizep,
unsigned char from,
size_t fromsizep,
siconvt_t inls,
siconvt_t onls 
)

Definition at line 148 of file joliet.c.

155{
156 UInt16_t unichar;
157 size_t fromsize = *fromsizep;
158 size_t tosize = *tosizep;
159 Uchar ob[2]; /* 2 octets (16 Bit) UCS-2 */
160
161 if (fromsize == 0 || tosize == 0)
162 return;
163
164 /*
165 * If we have a null mapping, just return the input character
166 */
167 if (inls->sic_name == onls->sic_name) {
168 *to = *from;
169 (*fromsizep)--;
170 (*tosizep)--;
171 return;
172 }
173#ifdef USE_ICONV
174#ifdef HAVE_ICONV_CONST
175#define __IC_CONST const
176#else
177#define __IC_CONST
178#endif
179 if (use_iconv(inls)) {
180 char *obuf = (char *)ob;
181 size_t osize = 2; /* UCS-2 character size */
182
183 if (iconv(inls->sic_cd2uni, (__IC_CONST char **)&from,
184 fromsizep,
185 &obuf, &osize) == -1) {
186 int err = geterrno();
187
188 if ((err == EINVAL || err == EILSEQ) &&
189 *fromsizep == fromsize) {
190 ob[0] = 0; ob[1] = '_';
191 (*fromsizep)--;
192 }
193 }
194 unichar = ob[0] * 256 + ob[1]; /* Compute 16 Bit UCS-2 char */
195 } else
196#endif
197 {
198 unsigned char c = *from;
199
200 unichar = sic_c2uni(inls, c); /* Get the UNICODE char */
201 (*fromsizep)--;
202
203 if (unichar == 0)
204 unichar = '_';
205
206 ob[0] = unichar >> 8 & 0xFF; /* Compute 2 octet variant */
207 ob[1] = unichar & 0xFF;
208 }
209
210#ifdef USE_ICONV
211 if (use_iconv(onls)) {
212 char *ibuf = (char *)ob;
213 size_t isize = 2; /* UCS-2 character size */
214
215 if (iconv(onls->sic_uni2cd, (__IC_CONST char **)&ibuf, &isize,
216 (char **)&to, tosizep) == -1) {
217 int err = geterrno();
218
219 if ((err == EINVAL || err == EILSEQ) &&
220 *tosizep == tosize) {
221 *to = '_';
222 (*tosizep)--;
223 }
224 }
225 } else
226#endif
227 {
228 *to = sic_uni2c(onls, unichar); /* Get the backconverted char */
229 (*tosizep)--;
230 }
231}
#define EINVAL
Definition: acclib.h:90
EXPORT int geterrno()
Definition: geterrno.c:34
const GLubyte * c
Definition: glext.h:8905
static char obuf[100]
Definition: i386-dis.c:1281
size_t iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Definition: win_iconv.c:771
#define err(...)
#define EILSEQ
Definition: errno.h:109
#define sic_uni2c(t, c)
Definition: siconv.h:52
#define use_iconv(t)
Definition: siconv.h:49
#define sic_c2uni(t, c)
Definition: siconv.h:51
CardRegion * from
Definition: spigame.cpp:19
iconv_t sic_cd2uni
Definition: siconv.h:42
char * sic_name
Definition: siconv.h:39
iconv_t sic_uni2cd
Definition: siconv.h:43
unsigned char Uchar
Definition: utypes.h:45

Referenced by iso9660_file_length(), and rstrncpy().

◆ convert_to_unicode()

LOCAL void convert_to_unicode ( unsigned char buffer,
int  size,
char source,
siconvt_t inls 
)

Definition at line 247 of file joliet.c.

252{
253 unsigned char *tmpbuf;
254 int i;
255 int j;
256 UInt16_t unichar;
257 unsigned char uc;
258 int jsize = size;
259
260 /*
261 * If we get a NULL pointer for the source, it means we have an
262 * inplace copy, and we need to make a temporary working copy first.
263 */
264 if (source == NULL) {
265 tmpbuf = (Uchar *) e_malloc(size);
266 memcpy(tmpbuf, buffer, size);
267 } else {
268 tmpbuf = (Uchar *) source;
269 }
270
271 /*
272 * Now start copying characters. If the size was specified to be 0,
273 * then assume the input was 0 terminated.
274 */
275 j = 0;
276 for (i = 0; (i + 1) < size; i += 2, j++) { /* Size may be odd! */
277 /*
278 * Let all valid unicode characters pass
279 * through (according to charset). Others are set to '_' .
280 */
281 if (j < jsize)
282 uc = tmpbuf[j]; /* temporary copy */
283 else
284 uc = '\0';
285 if (uc == '\0') {
286 jsize = j;
287 unichar = 0;
288 } else { /* must be converted */
289#ifdef USE_ICONV
290 if (use_iconv(inls)) {
291 Uchar ob[2];
292 __IC_CONST char *inbuf = (char *)&tmpbuf[j];
293 size_t isize = 3;
294 char *obuf = (char *)ob;
295 size_t osize = 2;
296
297 /*
298 * iconv() from glibc ignores osize and thus
299 * may try to access more than a single multi
300 * byte character from the input and read from
301 * non-existent memory.
302 */
303 if (iconv(inls->sic_cd2uni, &inbuf, &isize,
304 &obuf, &osize) == -1) {
305 int err = geterrno();
306
307 if ((err == EINVAL || err == EILSEQ) &&
308 isize == 3) {
309 ob[0] = ob[1] = 0;
310 isize--;
311 }
312 }
313 unichar = ob[0] * 256 + ob[1];
314 j += 2 - isize;
315 } else
316#endif
317 unichar = sic_c2uni(inls, uc); /* Get the UNICODE */
318
319 /*
320 * This code is currently also used for UDF formatting.
321 * Do not enforce silly Microsoft limitations in case
322 * that we only create UDF extensions.
323 */
324 if (!use_Joliet)
325 goto all_chars;
326
327 if (unichar <= 0x1f || unichar == 0x7f)
328 unichar = '\0'; /* control char */
329
330 switch (unichar) { /* test special characters */
331
332 case '*':
333 case '/':
334 case ':':
335 case ';':
336 case '?':
337 case '\\':
338 case '\0': /* illegal char mark */
339 /*
340 * Even Joliet has some standards as to what is
341 * allowed in a pathname. Pretty tame in
342 * comparison to what DOS restricts you to.
343 */
344 unichar = '_';
345 }
346 all_chars:
347 ;
348 }
349 buffer[i] = unichar >> 8 & 0xFF; /* final UNICODE */
350 buffer[i + 1] = unichar & 0xFF; /* conversion */
351 }
352
353 if (size & 1) { /* beautification */
354 buffer[size - 1] = 0;
355 }
356 if (source == NULL) {
357 free(tmpbuf);
358 }
359}
static int inbuf
Definition: adnsresfilter.c:73
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
EXPORT void * e_malloc(size_t size)
Definition: mkisofs.c:3921
int use_Joliet
Definition: mkisofs.c:113
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by generate_joliet_path_tables(), generate_one_joliet_directory(), get_joliet_vol_desc(), joliet_compare_dirs(), and joliet_compare_paths().

◆ generate_joliet_directories()

LOCAL void generate_joliet_directories ( struct directory node,
FILE outfile 
)

Definition at line 1341 of file joliet.c.

1344{
1345 struct directory *dpnt;
1346
1347 dpnt = node;
1348
1349 while (dpnt) {
1350 if ((dpnt->dir_flags & INHIBIT_JOLIET_ENTRY) == 0) {
1351 /*
1352 * In theory we should never reuse a directory, so this
1353 * doesn't make much sense.
1354 */
1355 if (dpnt->jextent > session_start) {
1357 }
1358 }
1359 /* skip if hidden - but not for the rr_moved dir */
1360 if (dpnt->subdir &&
1361 (!(dpnt->dir_flags & INHIBIT_JOLIET_ENTRY) ||
1362 dpnt == reloc_dir)) {
1364 }
1365 dpnt = dpnt->next;
1366 }
1367}
LOCAL void generate_one_joliet_directory(struct directory *dpnt, FILE *outfile)
Definition: joliet.c:795
LOCAL void generate_joliet_directories(struct directory *node, FILE *outfile)
Definition: joliet.c:1341
UInt32_t session_start
Definition: mkisofs.c:77
static FILE * outfile
Definition: wrjpgcom.c:81

Referenced by generate_joliet_directories(), and jdirtree_write().

◆ generate_joliet_path_tables()

LOCAL int generate_joliet_path_tables ( )

Definition at line 629 of file joliet.c.

630{
631 struct directory_entry *de;
632 struct directory *dpnt;
633 int fix;
634 int j;
635 int namelen;
636 char *npnt;
637 char *npnt1;
638 int tablesize;
639 unsigned int jpindex;
640
641 /* First allocate memory for the tables and initialize the memory */
642 tablesize = jpath_blocks << 11;
643 jpath_table_m = (char *)e_malloc(tablesize);
644 jpath_table_l = (char *)e_malloc(tablesize);
645 memset(jpath_table_l, 0, tablesize);
646 memset(jpath_table_m, 0, tablesize);
647
648 /* Now start filling in the path tables. Start with root directory */
650 jpathlist = (struct directory **)e_malloc(sizeof (struct directory *)
652 memset(jpathlist, 0, sizeof (struct directory *) * next_jpath_index);
654
655 do {
656 fix = 0;
657#ifdef PROTOTYPES
658 qsort(&jpathlist[1], next_jpath_index - 1, sizeof (struct directory *),
659 (int (*) (const void *, const void *)) joliet_compare_paths);
660#else
661 qsort(&jpathlist[1], next_jpath_index - 1, sizeof (struct directory *),
663#endif
664
665 for (j = 1; j < next_jpath_index; j++) {
666 if (jpathlist[j]->jpath_index != j) {
667 jpathlist[j]->jpath_index = j;
668 fix++;
669 }
670 }
671 } while (fix);
672
673 for (j = 1; j < next_jpath_index; j++) {
674 dpnt = jpathlist[j];
675 if (!dpnt) {
676 comerrno(EX_BAD, _("Entry %d not in path tables\n"), j);
677 }
678 npnt = dpnt->de_name;
679
680 npnt1 = strrchr(npnt, PATH_SEPARATOR);
681 if (npnt1) {
682 npnt = npnt1 + 1;
683 }
684 de = dpnt->self;
685 if (!de) {
687 _("Fatal Joliet goof - directory has amnesia\n"));
688 }
689#ifdef APPLE_HYB
690 if (USE_MAC_NAME(de))
691 namelen = joliet_strlen(de->hfs_ent->name, jlen, hfs_inls);
692 else
693#endif /* APPLE_HYB */
695
696 if (dpnt == root) {
699 } else {
702 }
704
708
709
710 if (dpnt->parent != reloc_dir) {
712 dpnt->parent->jpath_index);
714 dpnt->parent->jpath_index);
715 jpindex = dpnt->parent->jpath_index;
716 } else {
718 dpnt->self->parent_rec->filedir->jpath_index);
720 dpnt->self->parent_rec->filedir->jpath_index);
721 jpindex = dpnt->self->parent_rec->filedir->jpath_index;
722 }
723
724 if (jpindex > 0xffff) {
725 static int warned = 0;
726
727 if (!warned) {
728 warned++;
730 _("Unable to generate sane Joliet path tables - too many directories (%u)\n"),
731 jpindex);
734 _("Try to use the option -no-limit-pathtables\n"));
735 }
737 exit(EX_BAD);
738 /*
739 * Let it point to the root directory instead.
740 */
743 }
744
746
747 /*
748 * The root directory is still represented in non-unicode
749 * fashion.
750 */
751 if (dpnt == root) {
755 } else {
756#ifdef APPLE_HYB
757 if (USE_MAC_NAME(de)) {
760 namelen, de->hfs_ent->name, hfs_inls);
763 namelen, de->hfs_ent->name, hfs_inls);
764 } else {
765#endif /* APPLE_HYB */
768 namelen, de->name, in_nls);
771 namelen, de->name, in_nls);
772#ifdef APPLE_HYB
773 }
774#endif /* APPLE_HYB */
775
777 }
778
779 if (jpath_table_index & 1) {
780 jpath_table_index++; /* For odd lengths we pad */
781 }
782 }
783
787 _("Joliet path table lengths do not match %d expected: %d\n"),
790 }
791 return (0);
792} /* generate_path_tables(... */
EXPORT void comerrno(int err, char *msg, va_alist)
Definition: comerr.c:137
EXPORT int errmsgno(int err, char *msg, va_alist)
Definition: comerr.c:219
GLint namelen
Definition: glext.h:7232
#define _(X)
Definition: i386-dis.c:35
EXPORT void set_731(void *vp, UInt32_t i)
Definition: isonum.c:91
EXPORT void set_722(void *vp, UInt32_t i)
Definition: isonum.c:61
EXPORT void set_721(void *vp, UInt32_t i)
Definition: isonum.c:46
EXPORT void set_732(void *vp, UInt32_t i)
Definition: isonum.c:108
LOCAL Uint jpath_table_index
Definition: joliet.c:93
LOCAL int joliet_strlen(char *string, size_t maxlen, siconvt_t *inls) const
Definition: joliet.c:375
LOCAL int joliet_compare_paths(void const *r, void const *l)
Definition: joliet.c:543
LOCAL void convert_to_unicode(unsigned char *buffer, int size, char *source, siconvt_t *inls)
Definition: joliet.c:247
int jlen
Definition: mkisofs.c:114
char * jpath_table_l
Definition: mkisofs.c:1634
unsigned int jpath_table_size
Definition: mkisofs.c:83
unsigned int jpath_blocks
Definition: mkisofs.c:85
siconvt_t * in_nls
Definition: mkisofs.c:332
int nolimitpathtables
Definition: mkisofs.c:245
char * jpath_table_m
Definition: mkisofs.c:1635
siconvt_t * hfs_inls
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
#define exit(n)
Definition: config.h:202
#define memset(x, y, z)
Definition: compat.h:39
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
#define EX_BAD
Definition: standard.h:62
Definition: mkisofs.h:107
char * name
Definition: mkisofs.h:116
struct directory * parent
Definition: mkisofs.h:269
char * de_name
Definition: mkisofs.h:275
struct directory_entry * self
Definition: mkisofs.h:272
#define PATH_SEPARATOR
Definition: xmllint.c:205

◆ generate_one_joliet_directory()

LOCAL void generate_one_joliet_directory ( struct directory dpnt,
FILE outfile 
)

Definition at line 795 of file joliet.c.

798{
799 unsigned int dir_index;
800 char *directory_buffer;
801 int new_reclen;
802 struct directory_entry *s_entry;
803 struct directory_entry *s_entry1;
804 struct iso_directory_record jrec;
805 unsigned int total_size;
806 int cvt_len;
807 struct directory *finddir;
808
809 total_size = ISO_ROUND_UP(dpnt->jsize);
810 directory_buffer = (char *)e_malloc(total_size);
811 memset(directory_buffer, 0, total_size);
812 dir_index = 0;
813
814 s_entry = dpnt->jcontents;
815 while (s_entry) {
816 if (s_entry->de_flags & INHIBIT_JOLIET_ENTRY) {
817 s_entry = s_entry->jnext;
818 continue;
819 }
820 /*
821 * If this entry was a directory that was relocated,
822 * we have a bit of trouble here. We need to dig out the real
823 * thing and put it back here. In the Joliet tree, there is
824 * no relocated rock ridge, as there are no depth limits to a
825 * directory tree.
826 */
827 if ((s_entry->de_flags & RELOCATED_DIRECTORY) != 0) {
828 for (s_entry1 = reloc_dir->contents; s_entry1;
829 s_entry1 = s_entry1->next) {
830 if (s_entry1->parent_rec == s_entry) {
831 break;
832 }
833 }
834 if (s_entry1 == NULL) {
835 /* We got trouble. */
837 _("Unable to locate relocated directory\n"));
838 }
839 } else {
840 s_entry1 = s_entry;
841 }
842
843 /*
844 * We do not allow directory entries to cross sector
845 * boundaries. Simply pad, and then start the next entry at
846 * the next sector
847 */
848 new_reclen = s_entry1->jreclen;
849 if ((dir_index & (SECTOR_SIZE - 1)) + new_reclen >= SECTOR_SIZE) {
850 dir_index = ISO_ROUND_UP(dir_index);
851 }
852 memcpy(&jrec, &s_entry1->isorec, offsetof(struct iso_directory_record, name[0]));
853
854#ifdef APPLE_HYB
855 /* Use the HFS name if it exists */
856 if (USE_MAC_NAME(s_entry1))
857 cvt_len = joliet_strlen(s_entry1->hfs_ent->name, jlen, hfs_inls);
858 else
859#endif /* APPLE_HYB */
860 cvt_len = joliet_strlen(s_entry1->name, jlen, in_nls);
861
862 /*
863 * Fix the record length
864 * - this was the non-Joliet version we were seeing.
865 */
866 jrec.name_len[0] = cvt_len;
867 jrec.length[0] = s_entry1->jreclen;
868
869 /*
870 * If this is a directory,
871 * fix the correct size and extent number.
872 */
873 if ((jrec.flags[0] & ISO_DIRECTORY) != 0) {
874 if (strcmp(s_entry1->name, ".") == 0) {
875 jrec.name_len[0] = 1;
876 set_733((char *)jrec.extent, dpnt->jextent);
877 set_733((char *)jrec.size, ISO_ROUND_UP(dpnt->jsize));
878 } else if (strcmp(s_entry1->name, "..") == 0) {
879 jrec.name_len[0] = 1;
880 if (dpnt->parent == reloc_dir) {
881 set_733((char *)jrec.extent, dpnt->self->parent_rec->filedir->jextent);
882 set_733((char *)jrec.size, ISO_ROUND_UP(dpnt->self->parent_rec->filedir->jsize));
883 } else {
884 set_733((char *)jrec.extent, dpnt->parent->jextent);
885 set_733((char *)jrec.size, ISO_ROUND_UP(dpnt->parent->jsize));
886 }
887 } else {
888 if ((s_entry->de_flags & RELOCATED_DIRECTORY) != 0) {
889 finddir = reloc_dir->subdir;
890 } else {
891 finddir = dpnt->subdir;
892 }
893 while (finddir && finddir->self != s_entry1) {
894 finddir = finddir->next;
895 }
896 if (!finddir) {
898 _("Fatal goof - unable to find directory location\n"));
899 }
900 set_733((char *)jrec.extent, finddir->jextent);
901 set_733((char *)jrec.size,
902 ISO_ROUND_UP(finddir->jsize));
903 }
904 }
905 memcpy(directory_buffer + dir_index, &jrec,
907
908 dir_index += offsetof(struct iso_directory_record, name[0]);
909
910 /*
911 * Finally dump the Unicode version of the filename.
912 * Note - . and .. are the same as with non-Joliet discs.
913 */
914 if ((jrec.flags[0] & ISO_DIRECTORY) != 0 &&
915 strcmp(s_entry1->name, ".") == 0) {
916 directory_buffer[dir_index++] = 0;
917 } else if ((jrec.flags[0] & ISO_DIRECTORY) != 0 &&
918 strcmp(s_entry1->name, "..") == 0) {
919 directory_buffer[dir_index++] = 1;
920 } else {
921#ifdef APPLE_HYB
922 if (USE_MAC_NAME(s_entry1)) {
923 /* Use the HFS name if it exists */
925 (Uchar *) directory_buffer+dir_index,
926 cvt_len,
927 s_entry1->hfs_ent->name, hfs_inls);
928 } else
929#endif /* APPLE_HYB */
930 {
932 (Uchar *) directory_buffer+dir_index,
933 cvt_len,
934 s_entry1->name, in_nls);
935 }
936 dir_index += cvt_len;
937 }
938
939 if (dir_index & 1) {
940 directory_buffer[dir_index++] = 0;
941 }
942 s_entry = s_entry->jnext;
943 }
944
945 if (dpnt->jsize != dir_index) {
947 _("Unexpected joliet directory length %d expected: %d '%s'\n"),
948 dpnt->jsize,
949 dir_index, dpnt->de_name);
950 }
951 xfwrite(directory_buffer, total_size, 1, outfile, 0, FALSE);
952 last_extent_written += total_size >> 11;
953 free(directory_buffer);
954} /* generate_one_joliet_directory(... */
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define SECTOR_SIZE
Definition: fs.h:22
#define FALSE
Definition: types.h:117
#define ISO_DIRECTORY
Definition: iso9660.h:265
EXPORT void set_733(void *vp, UInt32_t i)
Definition: isonum.c:125
#define RELOCATED_DIRECTORY
Definition: mkisofs.h:801
UInt32_t last_extent_written
Definition: write.c:303
#define ISO_ROUND_UP(X)
Definition: mkisofs.h:742
#define offsetof(TYPE, MEMBER)
EXPORT void xfwrite(void *buffer, int size, int count, FILE *file, int submode, BOOL islast)
Definition: write.c:168
struct directory_entry * next
Definition: mkisofs.h:108
unsigned int de_flags
Definition: mkisofs.h:122
struct iso_directory_record isorec
Definition: mkisofs.h:110
struct directory_entry * parent_rec
Definition: mkisofs.h:120
unsigned char jreclen
Definition: mkisofs.h:115
struct directory_entry * jnext
Definition: mkisofs.h:109
struct directory_entry * jcontents
Definition: mkisofs.h:271
Definition: name.c:39

Referenced by generate_joliet_directories().

◆ get_joliet_vol_desc()

LOCAL void get_joliet_vol_desc ( struct iso_primary_descriptor jvol_desc)

Definition at line 436 of file joliet.c.

438{
439 jvol_desc->type[0] = ISO_VD_SUPPLEMENTARY;
440 jvol_desc->version[0] = 1;
441 jvol_desc->file_structure_version[0] = 1;
442 /*
443 * For now, always do Unicode level 3.
444 * I don't really know what 1 and 2 are - perhaps a more limited
445 * Unicode set.
446 * FIXME(eric) - how does Romeo fit in here?
447 */
448 sprintf(jvol_desc->escape_sequences, "%%/%c", ucs_codes[ucs_level]);
449
450 /* Until we have Unicode path tables, leave these unset. */
451 set_733((char *)jvol_desc->path_table_size, jpath_table_size);
452 set_731(jvol_desc->type_l_path_table, jpath_table[0]);
454 set_732(jvol_desc->type_m_path_table, jpath_table[2]);
456
457 /* Set this one up. */
459 offsetof(struct iso_directory_record, name[0]) + 1);
460
461 /*
462 * Finally, we have a bunch of strings to convert to Unicode.
463 * FIXME(eric) - I don't know how to do this in general,
464 * so we will just be really lazy and do a char -> short conversion.
465 * We probably will want to filter any characters >= 0x80.
466 */
467 convert_to_unicode((Uchar *)jvol_desc->system_id,
468 sizeof (jvol_desc->system_id), NULL, in_nls);
469 convert_to_unicode((Uchar *)jvol_desc->volume_id,
470 sizeof (jvol_desc->volume_id), NULL, in_nls);
472 sizeof (jvol_desc->volume_set_id), NULL, in_nls);
474 sizeof (jvol_desc->publisher_id), NULL, in_nls);
476 sizeof (jvol_desc->preparer_id), NULL, in_nls);
478 sizeof (jvol_desc->application_id), NULL, in_nls);
480 sizeof (jvol_desc->copyright_file_id), NULL, in_nls);
482 sizeof (jvol_desc->abstract_file_id), NULL, in_nls);
484 sizeof (jvol_desc->bibliographic_file_id), NULL, in_nls);
485}
#define ISO_VD_SUPPLEMENTARY
Definition: iso9660.h:44
LOCAL char ucs_codes[]
Definition: joliet.c:99
int ucs_level
Definition: mkisofs.c:171
struct iso_directory_record jroot_record
Definition: mkisofs.c:88
unsigned int jpath_table[4]
Definition: mkisofs.c:84
#define sprintf(buf, format,...)
Definition: sprintf.c:55
char type_m_path_table[ISODCL(149, 152)]
Definition: iso9660.h:80
char system_id[ISODCL(9, 40)]
Definition: iso9660.h:69
char path_table_size[ISODCL(133, 140)]
Definition: iso9660.h:77
char abstract_file_id[ISODCL(740, 776)]
Definition: iso9660.h:88
char type[ISODCL(1, 1)]
Definition: iso9660.h:65
char escape_sequences[ISODCL(89, 120)]
Definition: iso9660.h:73
char publisher_id[ISODCL(319, 446)]
Definition: iso9660.h:84
char root_directory_record[ISODCL(157, 190)]
Definition: iso9660.h:82
char volume_id[ISODCL(41, 72)]
Definition: iso9660.h:70
char application_id[ISODCL(575, 702)]
Definition: iso9660.h:86
char volume_set_id[ISODCL(191, 318)]
Definition: iso9660.h:83
char opt_type_l_path_table[ISODCL(145, 148)]
Definition: iso9660.h:79
char copyright_file_id[ISODCL(703, 739)]
Definition: iso9660.h:87
char preparer_id[ISODCL(447, 574)]
Definition: iso9660.h:85
char bibliographic_file_id[ISODCL(777, 813)]
Definition: iso9660.h:89
char opt_type_m_path_table[ISODCL(153, 156)]
Definition: iso9660.h:81
char version[ISODCL(7, 7)]
Definition: iso9660.h:67
char file_structure_version[ISODCL(882, 882)]
Definition: iso9660.h:94
char type_l_path_table[ISODCL(141, 144)]
Definition: iso9660.h:78
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by jvd_write().

◆ jdirtree_size()

LOCAL int jdirtree_size ( UInt32_t  starting_extent)

Definition at line 1389 of file joliet.c.

1391{
1393 return (0);
1394}

◆ jdirtree_write()

LOCAL int jdirtree_write ( FILE outfile)

Definition at line 1414 of file joliet.c.

1416{
1418 return (0);
1419}

◆ joliet_compare_dirs()

LOCAL int joliet_compare_dirs ( void rr,
const void ll 
) const

Definition at line 1080 of file joliet.c.

1083{
1084 char *rpnt,
1085 *lpnt;
1086 struct directory_entry **r,
1087 **l;
1088 unsigned char rtmp[2],
1089 ltmp[2];
1090 siconvt_t *linls, *rinls;
1091
1092 r = (struct directory_entry **)rr;
1093 l = (struct directory_entry **)ll;
1094
1095#ifdef APPLE_HYB
1096 /*
1097 * we may be using the HFS name - so select the correct input
1098 * charset
1099 */
1100 if (USE_MAC_NAME(*r)) {
1101 rpnt = (*r)->hfs_ent->name;
1102 rinls = hfs_inls;
1103 } else {
1104 rpnt = (*r)->name;
1105 rinls = in_nls;
1106 }
1107
1108 if (USE_MAC_NAME(*l)) {
1109 lpnt = (*l)->hfs_ent->name;
1110 linls = hfs_inls;
1111 } else {
1112 lpnt = (*l)->name;
1113 linls = in_nls;
1114 }
1115#else
1116 rpnt = (*r)->name;
1117 lpnt = (*l)->name;
1118 rinls = linls = in_nls;
1119#endif /* APPLE_HYB */
1120
1121 /*
1122 * If the entries are the same, this is an error.
1123 * Joliet specs allow for a maximum of 64 characters.
1124 * If we see different multi extent parts, it is OK to
1125 * have the same name more than once.
1126 */
1127 if (strncmp(rpnt, lpnt, jlen) == 0) {
1128#ifdef USE_LARGEFILES
1129 if ((*r)->mxpart == (*l)->mxpart)
1130#endif
1131 {
1133 _("Error: %s and %s have the same Joliet name\n"),
1134 (*r)->whole_name, (*l)->whole_name);
1135 jsort_goof++;
1136 {
1137 char *p1 = rpnt;
1138 char *p2 = lpnt;
1139 int len = 0;
1140
1141 for (; *p1 == *p2; p1++, p2++, len++) {
1142 if (*p1 == '\0')
1143 break;
1144 }
1145 if (len > jsort_glen)
1146 jsort_glen = len;
1147 }
1148 }
1149 }
1150 /*
1151 * Put the '.' and '..' entries on the head of the sorted list.
1152 * For normal ASCII, this always happens to be the case, but out of
1153 * band characters cause this not to be the case sometimes.
1154 */
1155 if (strcmp(rpnt, ".") == 0)
1156 return (-1);
1157 if (strcmp(lpnt, ".") == 0)
1158 return (1);
1159
1160 if (strcmp(rpnt, "..") == 0)
1161 return (-1);
1162 if (strcmp(lpnt, "..") == 0)
1163 return (1);
1164
1165#ifdef DVD_AUD_VID
1166 /*
1167 * There're rumors claiming that some players assume VIDEO_TS.IFO
1168 * to be the first file in VIDEO_TS/ catalog. Well, it's basically
1169 * the only file a player has to actually look for, as the whole
1170 * video content can be "rolled down" from this file alone.
1171 * <appro@fy.chalmers.se>
1172 */
1173 /*
1174 * XXX This code has to be moved from the Joliet implementation
1175 * XXX to the UDF implementation if we implement decent UDF support
1176 * XXX with a separate name space for the UDF file tree.
1177 */
1178 if (dvd_aud_vid_flag & DVD_SPEC_VIDEO) {
1179 if (strcmp(rpnt, "VIDEO_TS.IFO") == 0)
1180 return (-1);
1181 if (strcmp(lpnt, "VIDEO_TS.IFO") == 0)
1182 return (1);
1183 }
1184#endif
1185
1186 while (*rpnt && *lpnt) {
1187 if (*rpnt == ';' && *lpnt != ';')
1188 return (-1);
1189 if (*rpnt != ';' && *lpnt == ';')
1190 return (1);
1191
1192 if (*rpnt == ';' && *lpnt == ';')
1193 return (0);
1194
1195 /*
1196 * Extensions are not special here.
1197 * Don't treat the dot as something that must be bumped to
1198 * the start of the list.
1199 */
1200#if 0
1201 if (*rpnt == '.' && *lpnt != '.')
1202 return (-1);
1203 if (*rpnt != '.' && *lpnt == '.')
1204 return (1);
1205#endif
1206
1207 convert_to_unicode(rtmp, 2, rpnt, rinls);
1208 convert_to_unicode(ltmp, 2, lpnt, linls);
1209
1210 if (a_to_u_2_byte(rtmp) < a_to_u_2_byte(ltmp))
1211 return (-1);
1212 if (a_to_u_2_byte(rtmp) > a_to_u_2_byte(ltmp))
1213 return (1);
1214
1215 rpnt++;
1216 lpnt++;
1217 }
1218 if (*rpnt)
1219 return (1);
1220 if (*lpnt)
1221 return (-1);
1222#ifdef USE_LARGEFILES
1223 /*
1224 * (*r)->mxpart == (*l)->mxpart cannot happen here
1225 */
1226 if ((*r)->mxpart < (*l)->mxpart)
1227 return (-1);
1228 else if ((*r)->mxpart > (*l)->mxpart)
1229 return (1);
1230#endif
1231 return (0);
1232}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
w ll
Definition: byte_order.h:167
r l[0]
Definition: byte_order.h:168
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLenum GLsizei len
Definition: glext.h:6722
#define a_to_u_2_byte(a)
Definition: intcvt.h:50
LOCAL int jsort_goof
Definition: joliet.c:96
LOCAL int jsort_glen
Definition: joliet.c:97
#define dvd_aud_vid_flag

Referenced by joliet_sort_directory().

◆ joliet_compare_paths()

LOCAL int joliet_compare_paths ( void const r,
void const l 
)

Definition at line 543 of file joliet.c.

546{
547 struct directory const *ll = *(struct directory * const *) l;
548 struct directory const *rr = *(struct directory * const *) r;
549 int rparent,
550 lparent;
551 char *rpnt,
552 *lpnt;
553 unsigned char rtmp[2],
554 ltmp[2];
555 siconvt_t *rinls, *linls;
556
557 /* make sure root directory is first */
558 if (rr == root)
559 return (-1);
560
561 if (ll == root)
562 return (1);
563
564 rparent = rr->parent->jpath_index;
565 lparent = ll->parent->jpath_index;
566 if (rr->parent == reloc_dir) {
567 rparent = rr->self->parent_rec->filedir->jpath_index;
568 }
569 if (ll->parent == reloc_dir) {
570 lparent = ll->self->parent_rec->filedir->jpath_index;
571 }
572 if (rparent < lparent) {
573 return (-1);
574 }
575 if (rparent > lparent) {
576 return (1);
577 }
578#ifdef APPLE_HYB
579 /*
580 * we may be using the HFS name - so select the correct input
581 * charset
582 */
583 if (USE_MAC_NAME(rr->self)) {
584 rpnt = rr->self->hfs_ent->name;
585 rinls = hfs_inls;
586 } else {
587 rpnt = rr->self->name;
588 rinls = in_nls;
589 }
590
591 if (USE_MAC_NAME(ll->self)) {
592 lpnt = ll->self->hfs_ent->name;
593 linls = hfs_inls;
594 } else {
595 lpnt = ll->self->name;
596 linls = in_nls;
597 }
598#else
599 rpnt = rr->self->name;
600 lpnt = ll->self->name;
601 linls = rinls = in_nls;
602#endif /* APPLE_HYB */
603
604 /* compare the Unicode names */
605
606 while (*rpnt && *lpnt) {
607 convert_to_unicode(rtmp, 2, rpnt, rinls);
608 convert_to_unicode(ltmp, 2, lpnt, linls);
609
610 if (a_to_u_2_byte(rtmp) < a_to_u_2_byte(ltmp))
611 return (-1);
612 if (a_to_u_2_byte(rtmp) > a_to_u_2_byte(ltmp))
613 return (1);
614
615 rpnt++;
616 lpnt++;
617 }
618
619 if (*rpnt)
620 return (1);
621 if (*lpnt)
622 return (-1);
623
624 return (0);
625
626} /* compare_paths(... */
#define const
Definition: zconf.h:233

Referenced by generate_joliet_path_tables().

◆ joliet_sort_directory()

LOCAL int joliet_sort_directory ( struct directory_entry **  sort_dir)

Definition at line 1244 of file joliet.c.

1246{
1247 int dcount = 0;
1248 int i;
1249 struct directory_entry *s_entry;
1250 struct directory_entry **sortlist;
1251
1252 s_entry = *sort_dir;
1253 while (s_entry) {
1254 /*
1255 * only colletc non-hidden entries
1256 */
1257 if ((s_entry->de_flags & (INHIBIT_JOLIET_ENTRY|INHIBIT_UDF_ENTRY)) !=
1259 dcount++;
1260 s_entry = s_entry->next;
1261 }
1262
1263 /* OK, now we know how many there are. Build a vector for sorting. */
1264 sortlist = (struct directory_entry **)
1265 e_malloc(sizeof (struct directory_entry *) * dcount);
1266
1267 dcount = 0;
1268 s_entry = *sort_dir;
1269 while (s_entry) {
1270 /*
1271 * only collect non-hidden entries
1272 */
1273 if ((s_entry->de_flags & (INHIBIT_JOLIET_ENTRY|INHIBIT_UDF_ENTRY)) !=
1275 sortlist[dcount] = s_entry;
1276 dcount++;
1277 }
1278 s_entry = s_entry->next;
1279 }
1280
1281 jsort_goof = 0;
1282 jsort_glen = 0;
1283#ifdef PROTOTYPES
1284 qsort(sortlist, dcount, sizeof (struct directory_entry *),
1285 (int (*) (const void *, const void *)) joliet_compare_dirs);
1286#else
1287 qsort(sortlist, dcount, sizeof (struct directory_entry *),
1289#endif
1290
1291 if (jsort_goof) {
1293 _("Joliet file names differ after %d chars\n"),
1294 jsort_glen);
1295 if (jsort_glen > JLONGMAX) {
1297 _("Cannot use Joliet, please remove -J from the option list.\n"));
1298 } else if (jsort_glen > JMAX) {
1300 _("Try to use the option -joliet-long\n"));
1301 }
1302 }
1303
1304 /* Now reassemble the linked list in the proper sorted order */
1305 for (i = 0; i < dcount - 1; i++) {
1306 sortlist[i]->jnext = sortlist[i + 1];
1307 }
1308
1309 sortlist[dcount - 1]->jnext = NULL;
1310 *sort_dir = sortlist[0];
1311
1312 free(sortlist);
1313 return (jsort_goof);
1314}
LOCAL int joliet_compare_dirs(void *rr, const void *ll) const
Definition: joliet.c:1080
#define JLONGMAX
Definition: mkisofs.h:420
#define JMAX
Definition: mkisofs.h:419
#define INHIBIT_UDF_ENTRY
Definition: mkisofs.h:809

Referenced by joliet_sort_n_finish().

◆ joliet_sort_n_finish()

LOCAL int joliet_sort_n_finish ( struct directory this_dir)

Definition at line 957 of file joliet.c.

959{
960 struct directory_entry *s_entry;
961 int status = 0;
962
963 /*
964 * don't want to skip this directory if it's the reloc_dir
965 * at the moment
966 */
967 if (this_dir != reloc_dir &&
968 this_dir->dir_flags & INHIBIT_JOLIET_ENTRY) {
969 return (0);
970 }
971 for (s_entry = this_dir->contents; s_entry; s_entry = s_entry->next) {
972 /* skip hidden entries */
973 if ((s_entry->de_flags & INHIBIT_JOLIET_ENTRY) != 0) {
974 continue;
975 }
976 /*
977 * First update the path table sizes for directories.
978 *
979 * Finally, set the length of the directory entry if Joliet is
980 * used. The name is longer, but no Rock Ridge is ever used
981 * here, so depending upon the options the entry size might
982 * turn out to be about the same. The Unicode name is always
983 * a multiple of 2 bytes, so we always add 1 to make it an
984 * even number.
985 */
986 if (s_entry->isorec.flags[0] & ISO_DIRECTORY) {
987 if (strcmp(s_entry->name, ".") != 0 &&
988 strcmp(s_entry->name, "..") != 0) {
989#ifdef APPLE_HYB
990 if (USE_MAC_NAME(s_entry))
991 /* Use the HFS name if it exists */
993 joliet_strlen(s_entry->hfs_ent->name, jlen, hfs_inls) +
994 offsetof(struct iso_path_table, name[0]);
995 else
996#endif /* APPLE_HYB */
998 joliet_strlen(s_entry->name, jlen, in_nls) +
999 offsetof(struct iso_path_table, name[0]);
1000 if (jpath_table_size & 1) {
1002 }
1003 } else {
1004 if (this_dir == root &&
1005 strlen(s_entry->name) == 1) {
1006
1007 jpath_table_size += 1 + offsetof(struct iso_path_table, name[0]);
1008 if (jpath_table_size & 1)
1010 }
1011 }
1012 }
1013 if (strcmp(s_entry->name, ".") != 0 &&
1014 strcmp(s_entry->name, "..") != 0) {
1015#ifdef APPLE_HYB
1016 if (USE_MAC_NAME(s_entry))
1017 /* Use the HFS name if it exists */
1018 s_entry->jreclen =
1020 + joliet_strlen(s_entry->hfs_ent->name, jlen, hfs_inls)
1021 + 1;
1022 else
1023#endif /* APPLE_HYB */
1024 s_entry->jreclen =
1026 + joliet_strlen(s_entry->name, jlen, in_nls)
1027 + 1;
1028 } else {
1029 /*
1030 * Special - for '.' and '..' we generate the same
1031 * records we did for non-Joliet discs.
1032 */
1033 s_entry->jreclen =
1035 + 1;
1036 }
1037
1038
1039 }
1040
1041 if ((this_dir->dir_flags & INHIBIT_JOLIET_ENTRY) != 0) {
1042 return (0);
1043 }
1044 this_dir->jcontents = this_dir->contents;
1046
1047 /*
1048 * Now go through the directory and figure out how large this one will
1049 * be. Do not split a directory entry across a sector boundary
1050 */
1051 s_entry = this_dir->jcontents;
1052 /*
1053 * XXX Is it ok to comment this out?
1054 */
1055/*XXX JS this_dir->ce_bytes = 0;*/
1056 for (s_entry = this_dir->jcontents; s_entry;
1057 s_entry = s_entry->jnext) {
1058 int jreclen;
1059
1060 if ((s_entry->de_flags & INHIBIT_JOLIET_ENTRY) != 0) {
1061 continue;
1062 }
1063 jreclen = s_entry->jreclen;
1064
1065 if ((this_dir->jsize & (SECTOR_SIZE - 1)) + jreclen >=
1066 SECTOR_SIZE) {
1067 this_dir->jsize = ISO_ROUND_UP(this_dir->jsize);
1068 }
1069 this_dir->jsize += jreclen;
1070 }
1071 return (status);
1072}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
LOCAL int joliet_sort_directory(struct directory_entry **sort_dir)
Definition: joliet.c:1244
struct directory_entry * contents
Definition: mkisofs.h:270
Definition: ps.c:97

Referenced by joliet_sort_tree().

◆ joliet_sort_tree()

EXPORT int joliet_sort_tree ( struct directory node)

Definition at line 1317 of file joliet.c.

1319{
1320 struct directory *dpnt;
1321 int ret = 0;
1322
1323 dpnt = node;
1324
1325 while (dpnt) {
1326 ret = joliet_sort_n_finish(dpnt);
1327 if (ret) {
1328 break;
1329 }
1330 if (dpnt->subdir)
1331 ret = joliet_sort_tree(dpnt->subdir);
1332 if (ret) {
1333 break;
1334 }
1335 dpnt = dpnt->next;
1336 }
1337 return (ret);
1338}
EXPORT int joliet_sort_tree(struct directory *node)
Definition: joliet.c:1317
LOCAL int joliet_sort_n_finish(struct directory *this_dir)
Definition: joliet.c:957
int ret

Referenced by joliet_sort_tree(), and main().

◆ joliet_strlen()

LOCAL int joliet_strlen ( char string,
size_t  maxlen,
siconvt_t inls 
) const

Definition at line 375 of file joliet.c.

379{
380 int rtn = 0;
381
382#ifdef USE_ICONV
383 if (use_iconv(inls)) {
384 int j = 0;
385
386 while (string[j] != '\0') {
387 Uchar ob[2];
388 __IC_CONST char *inbuf = (char *)&string[j];
389 size_t isize = 3;
390 char *obuf = (char *)ob;
391 size_t osize = 2;
392
393 /*
394 * iconv() from glibc ignores osize and thus
395 * may try to access more than a single multi
396 * byte character from the input and read from
397 * non-existent memory.
398 */
399 if (iconv(inls->sic_cd2uni, &inbuf, &isize,
400 &obuf, &osize) == -1) {
401 int err = geterrno();
402
403 if ((err == EINVAL || err == EILSEQ) &&
404 isize == 3) {
405 ob[0] = ob[1] = 0;
406 isize--;
407 }
408 }
409 j += 3 - isize;
410 rtn += 2;
411 }
412 } else
413#endif
414 rtn = strlen(string) << 1;
415
416 /*
417 * We do clamp the maximum length of a Joliet or UDF string to be the
418 * maximum path size.
419 */
420 if (rtn > 2*maxlen) {
421 rtn = 2*maxlen;
422 }
423 return (rtn);
424}
NTSTATUS rtn

Referenced by generate_joliet_path_tables(), generate_one_joliet_directory(), and joliet_sort_n_finish().

◆ jpathtab_size()

LOCAL int jpathtab_size ( UInt32_t  starting_extent)

Definition at line 1442 of file joliet.c.

1444{
1445 jpath_table[0] = starting_extent;
1446 jpath_table[1] = 0;
1448 jpath_table[3] = 0;
1449
1451 return (0);
1452}

◆ jpathtab_write()

LOCAL int jpathtab_write ( FILE outfile)

Definition at line 1374 of file joliet.c.

1376{
1377 /* Next we write the path tables */
1385 return (0);
1386}

◆ jroot_gen()

LOCAL int jroot_gen ( )

Definition at line 1397 of file joliet.c.

1398{
1399 jroot_record.length[0] =
1400 1 + offsetof(struct iso_directory_record, name[0]);
1401 jroot_record.ext_attr_length[0] = 0;
1402 set_733((char *)jroot_record.extent, root->jextent);
1403 set_733((char *)jroot_record.size, ISO_ROUND_UP(root->jsize));
1404 iso9660_date(jroot_record.date, root_statbuf.st_mtime);
1405 jroot_record.flags[0] = ISO_DIRECTORY;
1406 jroot_record.file_unit_size[0] = 0;
1407 jroot_record.interleave[0] = 0;
1408 set_723(jroot_record.volume_sequence_number, volume_sequence_number);
1409 jroot_record.name_len[0] = 1;
1410 return (0);
1411}
EXPORT void set_723(void *vp, UInt32_t i)
Definition: isonum.c:76
EXPORT int iso9660_date(char *result, time_t crtime)
Definition: mkisofs.c:1868
int volume_sequence_number
Definition: mkisofs.c:173
struct stat root_statbuf
Definition: tree.c:110

◆ jvd_write()

LOCAL int jvd_write ( FILE outfile)

Definition at line 1425 of file joliet.c.

1427{
1428 struct iso_primary_descriptor jvol_desc;
1429
1430 /* Next we write out the boot volume descriptor for the disc */
1431 jvol_desc = vol_desc;
1432 get_joliet_vol_desc(&jvol_desc);
1433 xfwrite(&jvol_desc, SECTOR_SIZE, 1, outfile, 0, FALSE);
1435 return (0);
1436}
LOCAL void get_joliet_vol_desc(struct iso_primary_descriptor *jvol_desc)
Definition: joliet.c:436
struct iso_primary_descriptor vol_desc
Definition: write.c:77

Variable Documentation

◆ jdirtree_desc

struct output_fragment jdirtree_desc = {NULL, jdirtree_size, NULL, jdirtree_write, "Joliet directory tree" }

Definition at line 1456 of file joliet.c.

Referenced by main().

◆ joliet_desc

struct output_fragment joliet_desc = {NULL, oneblock_size, jroot_gen, jvd_write, "Joliet Volume Descriptor" }

Definition at line 1454 of file joliet.c.

Referenced by main().

◆ jpath_table_index

LOCAL Uint jpath_table_index

Definition at line 93 of file joliet.c.

Referenced by generate_joliet_path_tables().

◆ jpathlist

LOCAL struct directory** jpathlist

Definition at line 94 of file joliet.c.

Referenced by build_jpathlist(), and generate_joliet_path_tables().

◆ jpathtable_desc

Definition at line 1455 of file joliet.c.

Referenced by main().

◆ jsort_glen

LOCAL int jsort_glen

Definition at line 97 of file joliet.c.

Referenced by joliet_compare_dirs(), and joliet_sort_directory().

◆ jsort_goof

LOCAL int jsort_goof

Definition at line 96 of file joliet.c.

Referenced by joliet_compare_dirs(), and joliet_sort_directory().

◆ next_jpath_index

LOCAL int next_jpath_index = 1

Definition at line 95 of file joliet.c.

Referenced by assign_joliet_directory_addresses(), and generate_joliet_path_tables().

◆ sccsid

UConst char sccsid[]
static
Initial value:
=
"@(#)joliet.c 1.68 15/12/30 joerg"

Definition at line 4 of file joliet.c.

◆ ucs_codes

LOCAL char ucs_codes[]
Initial value:
= {
'\0',
'@',
'C',
'E',
}

Definition at line 99 of file joliet.c.

Referenced by get_joliet_vol_desc().