summaryrefslogtreecommitdiffstats
path: root/gnu
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1995-10-22 10:11:03 +0000
committerjoerg <joerg@FreeBSD.org>1995-10-22 10:11:03 +0000
commit4d9ef68f7ff8c82f93b68af32c8dcf7044b53c07 (patch)
tree03627cb1ad4cf99aab5c645979a4652c681ff301 /gnu
parent2c427653c39c60269b3a6243237a5ee2deccdbfb (diff)
downloadFreeBSD-src-4d9ef68f7ff8c82f93b68af32c8dcf7044b53c07.zip
FreeBSD-src-4d9ef68f7ff8c82f93b68af32c8dcf7044b53c07.tar.gz
Import version 1.04 of mkisofs.
This is a vendor-branch import by now, the merge with our regular tree will happen later. Obtained from: Eric Youngdale of Yggdrasil Computing Inc.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/usr.bin/mkisofs/ChangeLog37
-rw-r--r--gnu/usr.bin/mkisofs/Makefile.in4
-rw-r--r--gnu/usr.bin/mkisofs/README8
-rw-r--r--gnu/usr.bin/mkisofs/defaults.h9
-rw-r--r--gnu/usr.bin/mkisofs/diag/Makefile14
-rw-r--r--gnu/usr.bin/mkisofs/diag/isodump.c14
-rw-r--r--gnu/usr.bin/mkisofs/diag/isoinfo.c522
-rw-r--r--gnu/usr.bin/mkisofs/diag/isovfy.c13
-rw-r--r--gnu/usr.bin/mkisofs/exclude.c2
-rw-r--r--gnu/usr.bin/mkisofs/mkisofs.875
-rw-r--r--gnu/usr.bin/mkisofs/mkisofs.c189
-rw-r--r--gnu/usr.bin/mkisofs/mkisofs.h20
-rw-r--r--gnu/usr.bin/mkisofs/rock.c2
-rw-r--r--gnu/usr.bin/mkisofs/tree.c195
-rw-r--r--gnu/usr.bin/mkisofs/write.c17
15 files changed, 1032 insertions, 89 deletions
diff --git a/gnu/usr.bin/mkisofs/ChangeLog b/gnu/usr.bin/mkisofs/ChangeLog
index b31a554..8dc41be 100644
--- a/gnu/usr.bin/mkisofs/ChangeLog
+++ b/gnu/usr.bin/mkisofs/ChangeLog
@@ -1,4 +1,39 @@
-Wed Jan 11 13:46:50 1995 Eric Youngdale (eric@localhost)
+Sun Feb 26 01:52:06 1995 Eric Youngdale (eric@largo)
+
+ * Add patches from Ross Biro to allow you to merge arbitrary
+ trees into the image. This is not compiled in by default but
+ you need to add -DADD_FILES when compiling.
+
+Fri Feb 17 02:29:03 1995 Paul Eggert <eggert@twinsun.com>
+
+ * tree.c: Port to Solaris 2.4. Prefer <sys/mkdev.h> if
+ HASMKDEV. Cast unknown integer types to unsigned long and
+ print them with %lu or %lx.
+
+Thu Jan 26 15:25:00 1995 H. Peter Anvin (hpa@yggdrasil.com)
+
+ * mkisofs.c: Substitute underscore for leading dot in non-Rock
+ Ridge filenames, since MS-DOS cannot read files whose names
+ begin with a period.
+
+Mon Jan 16 18:31:41 1995 Eric Youngdale (eric@aib.com)
+
+ * rock.c (generate_rock_ridge_attributes): Only use ROOT
+ record for symlinks if we are at the start of the symlink.
+ Otherwise just generate an empty entry.
+
+Mon Jan 16 16:19:50 1995 Eric Youngdale (eric@aib.com)
+
+ * diag/isodump.c: Use isonum_733 instead of trying to dereference
+ pointers when trying to decode 733 numbers in the iso9660 image.
+
+ * diag/isovfy.c: Likewise.
+
+ * write.c: Always assign an extent number, even for zero length
+ files. A zero length file with a NULL extent is apparently dropped
+ by many readers.
+
+Wed Jan 11 13:46:50 1995 Eric Youngdale (eric@aib.com)
* mkisofs.c: Modify extension record to conform to IEEE P1282
specifications. This is commented out right now, but a trivial
diff --git a/gnu/usr.bin/mkisofs/Makefile.in b/gnu/usr.bin/mkisofs/Makefile.in
index 85cf95e..724ceb6 100644
--- a/gnu/usr.bin/mkisofs/Makefile.in
+++ b/gnu/usr.bin/mkisofs/Makefile.in
@@ -43,7 +43,9 @@ mkisofs.o: mkisofs.c iso9660.h mkisofs.h exclude.h
clean:
/bin/rm -f *.o core mkisofs *~ #*#
+ (cd diag/; make clean)
+ (cd cdwrite/; make clean)
dist:
- tar -cvf - README Configure Makefile.in make.com TODO COPYING ChangeLog *.8 *.c *.h diag | gzip > mkisofs-1.02.tar.gz
+ tar -cvf - README Configure Makefile.in make.com TODO COPYING ChangeLog *.8 *.c *.h diag cdwrite.old cdwrite-1.5 | gzip > mkisofs-1.04.tar.gz
diff --git a/gnu/usr.bin/mkisofs/README b/gnu/usr.bin/mkisofs/README
index f71e2d7..f2f415f 100644
--- a/gnu/usr.bin/mkisofs/README
+++ b/gnu/usr.bin/mkisofs/README
@@ -1,3 +1,8 @@
+Note:
+ There is a feature which can be optionally compiled into
+mkisofs that allows you to merge arbitrary directory trees into the
+image you are creating. You need to compile with -DADD_FILES for my
+changes to take effect. Thanks to Ross Biro biro@yggdrasil.com.
This program requires a lot of virtual memory to run since it
builds all of the directories in memory. The exact requirements
@@ -5,6 +10,9 @@ depend upon a lot of things, but for Rock Ridge discs 12Mb would not
be unreasonable. Without RockRidge and without the translation
tables, the requirements would be considerably less.
+ The cdwrite utility is maintained separately from mkisofs by
+yggdrasil.com. It is enclosed here as a convenience, since the two programs
+are often useful together.
*****************************
Notes for version 1.2.
diff --git a/gnu/usr.bin/mkisofs/defaults.h b/gnu/usr.bin/mkisofs/defaults.h
index 7367c0a..4e93814d0 100644
--- a/gnu/usr.bin/mkisofs/defaults.h
+++ b/gnu/usr.bin/mkisofs/defaults.h
@@ -11,8 +11,15 @@
#define ABSTRACT_DEFAULT NULL
#define VOLSET_ID_DEFAULT NULL
#define VOLUME_ID_DEFAULT "CDROM"
+
#ifdef __QNX__
#define SYSTEM_ID_DEFAULT "QNX"
-#else
+#endif
+
+#ifdef __osf__
+#define SYSTEM_ID_DEFAULT "OSF"
+#endif
+
+#ifndef SYSTEM_ID_DEFAULT
#define SYSTEM_ID_DEFAULT "LINUX"
#endif
diff --git a/gnu/usr.bin/mkisofs/diag/Makefile b/gnu/usr.bin/mkisofs/diag/Makefile
index 4f2a697..e6f3a12 100644
--- a/gnu/usr.bin/mkisofs/diag/Makefile
+++ b/gnu/usr.bin/mkisofs/diag/Makefile
@@ -1,10 +1,16 @@
+#CC = gcc
+CC = cc -traditional
+
all: dump isodump isovfy
+
+isoinfo:isoinfo.c
+ ${CC} -g -o isoinfo isoinfo.c
dump:dump.c
- gcc -o dump dump.c
+ ${CC} -o dump dump.c
isodump:isodump.c
- gcc -o isodump isodump.c
+ ${CC} -o isodump isodump.c
isovfy:isovfy.c
- gcc -o isovfy isovfy.c
+ ${CC} -o isovfy isovfy.c
clean:
- rm dump isodump isovfy \ No newline at end of file
+ rm -f dump isodump isovfy isoinfo
diff --git a/gnu/usr.bin/mkisofs/diag/isodump.c b/gnu/usr.bin/mkisofs/diag/isodump.c
index bca9a2f..439ee58 100644
--- a/gnu/usr.bin/mkisofs/diag/isodump.c
+++ b/gnu/usr.bin/mkisofs/diag/isodump.c
@@ -52,7 +52,7 @@ isonum_731 (char * p)
int
-isonum_733 (char * p)
+isonum_733 (unsigned char * p)
{
return (isonum_731 (p));
}
@@ -104,7 +104,7 @@ struct iso_directory_record {
unsigned char interleave [ISODCL (28, 28)]; /* 711 */
unsigned char volume_sequence_number [ISODCL (29, 32)]; /* 723 */
unsigned char name_len [ISODCL (33, 33)]; /* 711 */
- unsigned char name [0];
+ unsigned char name [1];
};
#ifdef USE_TERMIOS
@@ -285,13 +285,15 @@ int
dump_rr(struct iso_directory_record * idr)
{
int len;
- char * pnt;
+ unsigned char * pnt;
len = idr->length[0] & 0xff;
len -= sizeof(struct iso_directory_record);
+ len += sizeof(idr->name);
len -= idr->name_len[0];
- pnt = (char *) idr;
+ pnt = (unsigned char *) idr;
pnt += sizeof(struct iso_directory_record);
+ pnt -= sizeof(idr->name);
pnt += idr->name_len[0];
if((idr->name_len[0] & 1) == 0){
pnt++;
@@ -318,8 +320,8 @@ showblock(int flag){
if(idr->length[0] == 0) break;
printf("%3d ", idr->length[0]);
printf("[%2d] ", idr->volume_sequence_number[0]);
- printf("%5x ", *((unsigned int *) idr->extent));
- printf("%8d ", *((unsigned int *) idr->size));
+ printf("%5x ", isonum_733(idr->extent));
+ printf("%8d ", isonum_733(idr->size));
printf ((idr->flags[0] & 2) ? "*" : " ");
if(idr->name_len[0] == 1 && idr->name[0] == 0)
printf(". ");
diff --git a/gnu/usr.bin/mkisofs/diag/isoinfo.c b/gnu/usr.bin/mkisofs/diag/isoinfo.c
new file mode 100644
index 0000000..3f3b472
--- /dev/null
+++ b/gnu/usr.bin/mkisofs/diag/isoinfo.c
@@ -0,0 +1,522 @@
+/*
+ * File isodump.c - dump iso9660 directory information.
+ *
+
+ Written by Eric Youngdale (1993).
+
+ Copyright 1993 Yggdrasil Computing, Incorporated
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/*
+ * Simple program to dump contents of iso9660 image in more usable format.
+ *
+ * Usage:
+ * To list contents of image (with or without RR):
+ * isoinfo -l [-R] -i imagefile
+ * To extract file from image:
+ * isoinfo -i imagefile -x xtractfile > outfile
+ * To generate a "find" like list of files:
+ * isoinfo -f -i imagefile
+ */
+
+#include "../config.h"
+
+#include <stdio.h>
+#include <signal.h>
+#include <sys/stat.h>
+
+#ifdef __svr4__
+#include <stdlib.h>
+#else
+extern int optind;
+extern char *optarg;
+/* extern int getopt (int __argc, char **__argv, char *__optstring); */
+#endif
+
+FILE * infile;
+int use_rock = 0;
+int do_listing = 0;
+int do_find = 0;
+char * xtract = 0;
+
+struct stat fstat_buf;
+char name_buf[256];
+char xname[256];
+unsigned char date_buf[9];
+
+unsigned char buffer[2048];
+
+#define PAGE sizeof(buffer)
+
+#define ISODCL(from, to) (to - from + 1)
+
+
+int
+isonum_731 (char * p)
+{
+ return ((p[0] & 0xff)
+ | ((p[1] & 0xff) << 8)
+ | ((p[2] & 0xff) << 16)
+ | ((p[3] & 0xff) << 24));
+}
+
+
+int
+isonum_733 (unsigned char * p)
+{
+ return (isonum_731 (p));
+}
+
+struct iso_primary_descriptor {
+ unsigned char type [ISODCL ( 1, 1)]; /* 711 */
+ unsigned char id [ISODCL ( 2, 6)];
+ unsigned char version [ISODCL ( 7, 7)]; /* 711 */
+ unsigned char unused1 [ISODCL ( 8, 8)];
+ unsigned char system_id [ISODCL ( 9, 40)]; /* aunsigned chars */
+ unsigned char volume_id [ISODCL ( 41, 72)]; /* dunsigned chars */
+ unsigned char unused2 [ISODCL ( 73, 80)];
+ unsigned char volume_space_size [ISODCL ( 81, 88)]; /* 733 */
+ unsigned char unused3 [ISODCL ( 89, 120)];
+ unsigned char volume_set_size [ISODCL (121, 124)]; /* 723 */
+ unsigned char volume_sequence_number [ISODCL (125, 128)]; /* 723 */
+ unsigned char logical_block_size [ISODCL (129, 132)]; /* 723 */
+ unsigned char path_table_size [ISODCL (133, 140)]; /* 733 */
+ unsigned char type_l_path_table [ISODCL (141, 144)]; /* 731 */
+ unsigned char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */
+ unsigned char type_m_path_table [ISODCL (149, 152)]; /* 732 */
+ unsigned char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */
+ unsigned char root_directory_record [ISODCL (157, 190)]; /* 9.1 */
+ unsigned char volume_set_id [ISODCL (191, 318)]; /* dunsigned chars */
+ unsigned char publisher_id [ISODCL (319, 446)]; /* achars */
+ unsigned char preparer_id [ISODCL (447, 574)]; /* achars */
+ unsigned char application_id [ISODCL (575, 702)]; /* achars */
+ unsigned char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */
+ unsigned char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */
+ unsigned char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */
+ unsigned char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */
+ unsigned char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */
+ unsigned char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */
+ unsigned char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */
+ unsigned char file_structure_version [ISODCL (882, 882)]; /* 711 */
+ unsigned char unused4 [ISODCL (883, 883)];
+ unsigned char application_data [ISODCL (884, 1395)];
+ unsigned char unused5 [ISODCL (1396, 2048)];
+};
+
+struct iso_directory_record {
+ unsigned char length [ISODCL (1, 1)]; /* 711 */
+ unsigned char ext_attr_length [ISODCL (2, 2)]; /* 711 */
+ unsigned char extent [ISODCL (3, 10)]; /* 733 */
+ unsigned char size [ISODCL (11, 18)]; /* 733 */
+ unsigned char date [ISODCL (19, 25)]; /* 7 by 711 */
+ unsigned char flags [ISODCL (26, 26)];
+ unsigned char file_unit_size [ISODCL (27, 27)]; /* 711 */
+ unsigned char interleave [ISODCL (28, 28)]; /* 711 */
+ unsigned char volume_sequence_number [ISODCL (29, 32)]; /* 723 */
+ unsigned char name_len [ISODCL (33, 33)]; /* 711 */
+ unsigned char name [1];
+};
+
+
+int parse_rr(unsigned char * pnt, int len, int cont_flag)
+{
+ int slen;
+ int ncount;
+ int extent;
+ int cont_extent, cont_offset, cont_size;
+ int flag1, flag2;
+ unsigned char *pnts;
+ char symlink[1024];
+ int goof;
+
+ symlink[0] = 0;
+
+ cont_extent = cont_offset = cont_size = 0;
+
+ ncount = 0;
+ flag1 = flag2 = 0;
+ while(len >= 4){
+ if(pnt[3] != 1) {
+ printf("**BAD RRVERSION");
+ return;
+ };
+ ncount++;
+ if(pnt[0] == 'R' && pnt[1] == 'R') flag1 = pnt[4] & 0xff;
+ if(strncmp(pnt, "PX", 2) == 0) flag2 |= 1;
+ if(strncmp(pnt, "PN", 2) == 0) flag2 |= 2;
+ if(strncmp(pnt, "SL", 2) == 0) flag2 |= 4;
+ if(strncmp(pnt, "NM", 2) == 0) flag2 |= 8;
+ if(strncmp(pnt, "CL", 2) == 0) flag2 |= 16;
+ if(strncmp(pnt, "PL", 2) == 0) flag2 |= 32;
+ if(strncmp(pnt, "RE", 2) == 0) flag2 |= 64;
+ if(strncmp(pnt, "TF", 2) == 0) flag2 |= 128;
+
+ if(strncmp(pnt, "PX", 2) == 0) {
+ fstat_buf.st_mode = isonum_733(pnt+4);
+ fstat_buf.st_nlink = isonum_733(pnt+12);
+ fstat_buf.st_uid = isonum_733(pnt+20);
+ fstat_buf.st_gid = isonum_733(pnt+28);
+ };
+
+ if(strncmp(pnt, "NM", 2) == 0) {
+ strncpy(name_buf, pnt+5, pnt[2] - 5);
+ name_buf[pnt[2] - 5] = 0;
+ }
+
+ if(strncmp(pnt, "CE", 2) == 0) {
+ cont_extent = isonum_733(pnt+4);
+ cont_offset = isonum_733(pnt+12);
+ cont_size = isonum_733(pnt+20);
+ };
+
+ if(strncmp(pnt, "PL", 2) == 0 || strncmp(pnt, "CL", 2) == 0) {
+ extent = isonum_733(pnt+4);
+ };
+
+ if(strncmp(pnt, "SL", 2) == 0) {
+ int cflag;
+
+ cflag = pnt[4];
+ pnts = pnt+5;
+ slen = pnt[2] - 5;
+ while(slen >= 1){
+ switch(pnts[0] & 0xfe){
+ case 0:
+ strncat(symlink, pnts+2, pnts[1]);
+ break;
+ case 2:
+ strcat (symlink, ".");
+ break;
+ case 4:
+ strcat (symlink, "..");
+ break;
+ case 8:
+ if((pnts[0] & 1) == 0)strcat (symlink, "/");
+ break;
+ case 16:
+ strcat(symlink,"/mnt");
+ printf("Warning - mount point requested");
+ break;
+ case 32:
+ strcat(symlink,"kafka");
+ printf("Warning - host_name requested");
+ break;
+ default:
+ printf("Reserved bit setting in symlink", goof++);
+ break;
+ };
+ if((pnts[0] & 0xfe) && pnts[1] != 0) {
+ printf("Incorrect length in symlink component");
+ };
+ if((pnts[0] & 1) == 0) strcat(symlink,"/");
+
+ slen -= (pnts[1] + 2);
+ pnts += (pnts[1] + 2);
+ if(xname[0] == 0) strcpy(xname, "-> ");
+ strcat(xname, symlink);
+ };
+ symlink[0] = 0;
+ };
+
+ len -= pnt[2];
+ pnt += pnt[2];
+ if(len <= 3 && cont_extent) {
+ unsigned char sector[2048];
+ lseek(fileno(infile), cont_extent << 11, 0);
+ read(fileno(infile), sector, sizeof(sector));
+ flag2 |= parse_rr(&sector[cont_offset], cont_size, 1);
+ };
+ };
+ return flag2;
+}
+
+int
+dump_rr(struct iso_directory_record * idr)
+{
+ int len;
+ unsigned char * pnt;
+
+ len = idr->length[0] & 0xff;
+ len -= sizeof(struct iso_directory_record);
+ len += sizeof(idr->name);
+ len -= idr->name_len[0];
+ pnt = (unsigned char *) idr;
+ pnt += sizeof(struct iso_directory_record);
+ pnt -= sizeof(idr->name);
+ pnt += idr->name_len[0];
+ if((idr->name_len[0] & 1) == 0){
+ pnt++;
+ len--;
+ };
+ parse_rr(pnt, len, 0);
+}
+
+struct todo
+{
+ struct todo * next;
+ char * name;
+ int extent;
+ int length;
+};
+
+struct todo * todo_idr = NULL;
+
+char * months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
+ "Aug", "Sep", "Oct", "Nov", "Dec"};
+
+dump_stat()
+{
+ int i;
+ char outline[80];
+
+ memset(outline, ' ', sizeof(outline));
+
+ if(S_ISREG(fstat_buf.st_mode))
+ outline[0] = '-';
+ else if(S_ISDIR(fstat_buf.st_mode))
+ outline[0] = 'd';
+ else if(S_ISLNK(fstat_buf.st_mode))
+ outline[0] = 'l';
+ else if(S_ISCHR(fstat_buf.st_mode))
+ outline[0] = 'c';
+ else if(S_ISBLK(fstat_buf.st_mode))
+ outline[0] = 'b';
+ else if(S_ISFIFO(fstat_buf.st_mode))
+ outline[0] = 'f';
+ else if(S_ISSOCK(fstat_buf.st_mode))
+ outline[0] = 's';
+ else
+ outline[0] = '?';
+
+ memset(outline+1, '-', 9);
+ if( fstat_buf.st_mode & S_IRUSR )
+ outline[1] = 'r';
+ if( fstat_buf.st_mode & S_IWUSR )
+ outline[2] = 'w';
+ if( fstat_buf.st_mode & S_IXUSR )
+ outline[3] = 'x';
+
+ if( fstat_buf.st_mode & S_IRGRP )
+ outline[4] = 'r';
+ if( fstat_buf.st_mode & S_IWGRP )
+ outline[5] = 'w';
+ if( fstat_buf.st_mode & S_IXGRP )
+ outline[6] = 'x';
+
+ if( fstat_buf.st_mode & S_IROTH )
+ outline[7] = 'r';
+ if( fstat_buf.st_mode & S_IWOTH )
+ outline[8] = 'w';
+ if( fstat_buf.st_mode & S_IXOTH )
+ outline[9] = 'x';
+
+ sprintf(outline+11, "%3d", fstat_buf.st_nlink);
+ sprintf(outline+15, "%4o", fstat_buf.st_uid);
+ sprintf(outline+20, "%4o", fstat_buf.st_gid);
+ sprintf(outline+33, "%8d", fstat_buf.st_size);
+
+ memcpy(outline+42, months[date_buf[1]-1], 3);
+ sprintf(outline+46, "%2d", date_buf[2]);
+ sprintf(outline+49, "%4d", date_buf[0]+1900);
+
+ for(i=0; i<54; i++)
+ if(outline[i] == 0) outline[i] = ' ';
+ outline[54] = 0;
+
+ printf("%s %s %s\n", outline, name_buf, xname);
+}
+
+extract_file(struct iso_directory_record * idr)
+{
+ int extent, len, tlen;
+ unsigned char buff[2048];
+
+ extent = isonum_733(idr->extent);
+ len = isonum_733(idr->size);
+
+ while(len > 0)
+ {
+ lseek(fileno(infile), extent << 11, 0);
+ tlen = (len > sizeof(buff) ? sizeof(buff) : len);
+ read(fileno(infile), buff, tlen);
+ len -= tlen;
+ extent++;
+ write(1, buff, tlen);
+ }
+}
+
+parse_dir(char * rootname, int extent, int len){
+ unsigned int k;
+ char testname[256];
+ struct todo * td;
+ int i, j;
+ struct iso_directory_record * idr;
+
+
+ if( do_listing)
+ printf("\nDirectory listing of %s\n", rootname);
+
+ while(len > 0 )
+ {
+ lseek(fileno(infile), extent << 11, 0);
+ read(fileno(infile), buffer, sizeof(buffer));
+ len -= sizeof(buffer);
+ extent++;
+ i = 0;
+ while(1==1){
+ idr = (struct iso_directory_record *) &buffer[i];
+ if(idr->length[0] == 0) break;
+ memset(&fstat_buf, 0, sizeof(fstat_buf));
+ name_buf[0] = xname[0] = 0;
+ fstat_buf.st_size = isonum_733(idr->size);
+ if( idr->flags[0] & 2)
+ fstat_buf.st_mode |= S_IFDIR;
+ else
+ fstat_buf.st_mode |= S_IFREG;
+ if(idr->name_len[0] == 1 && idr->name[0] == 0)
+ strcpy(name_buf, ".");
+ else if(idr->name_len[0] == 1 && idr->name[0] == 1)
+ strcpy(name_buf, "..");
+ else {
+ strncpy(name_buf, idr->name, idr->name_len[0]);
+ name_buf[idr->name_len[0]] = 0;
+ };
+ memcpy(date_buf, idr->date, 9);
+ if(use_rock) dump_rr(idr);
+ if( (idr->flags[0] & 2) != 0
+ && (idr->name_len[0] != 1
+ || (idr->name[0] != 0 && idr->name[0] != 1)))
+ {
+ /*
+ * Add this directory to the todo list.
+ */
+ td = todo_idr;
+ if( td != NULL )
+ {
+ while(td->next != NULL) td = td->next;
+ td->next = (struct todo *) malloc(sizeof(*td));
+ td = td->next;
+ }
+ else
+ {
+ todo_idr = td = (struct todo *) malloc(sizeof(*td));
+ }
+ td->next = NULL;
+ td->extent = isonum_733(idr->extent);
+ td->length = isonum_733(idr->size);
+ td->name = (char *) malloc(strlen(rootname)
+ + strlen(name_buf) + 2);
+ strcpy(td->name, rootname);
+ strcat(td->name, name_buf);
+ strcat(td->name, "/");
+ }
+ else
+ {
+ strcpy(testname, rootname);
+ strcat(testname, name_buf);
+ if(xtract && strcmp(xtract, testname) == 0)
+ {
+ extract_file(idr);
+ }
+ }
+ if( do_find
+ && (idr->name_len[0] != 1
+ || (idr->name[0] != 0 && idr->name[0] != 1)))
+ {
+ strcpy(testname, rootname);
+ strcat(testname, name_buf);
+ printf("%s\n", testname);
+ }
+ if(do_listing)
+ dump_stat();
+ i += buffer[i];
+ if (i > 2048 - sizeof(struct iso_directory_record)) break;
+ }
+ }
+}
+
+usage()
+{
+ fprintf(stderr, "isoinfo -i filename [-l] [-R] [-x filename] [-f]\n");
+}
+
+main(int argc, char * argv[]){
+ char c;
+ char buffer[2048];
+ int nbyte;
+ char * filename = NULL;
+ int i,j;
+ struct todo * td;
+ struct iso_primary_descriptor ipd;
+ struct iso_directory_record * idr;
+
+ if(argc < 2) return 0;
+ while ((c = getopt(argc, argv, "i:Rlx:f")) != EOF)
+ switch (c)
+ {
+ case 'f':
+ do_find++;
+ break;
+ case 'R':
+ use_rock++;
+ break;
+ case 'l':
+ do_listing++;
+ break;
+ case 'i':
+ filename = optarg;
+ break;
+ case 'x':
+ xtract = optarg;
+ break;
+ default:
+ usage();
+ exit(1);
+ }
+
+ if( filename == NULL )
+ {
+ fprintf(stderr, "Error - file not specified\n");
+ exit(1);
+ }
+
+ infile = fopen(filename,"rb");
+
+ if( infile == NULL )
+ {
+ fprintf(stderr,"Unable to open file %s\n", filename);
+ exit(1);
+ }
+
+ lseek(fileno(infile), 16<<11, 0);
+ read(fileno(infile), &ipd, sizeof(ipd));
+
+ idr = (struct iso_directory_record *) &ipd.root_directory_record;
+
+ parse_dir("/", isonum_733(idr->extent), isonum_733(idr->size));
+ td = todo_idr;
+ while(td)
+ {
+ parse_dir(td->name, td->extent, td->length);
+ td = td->next;
+ }
+
+ fclose(infile);
+}
+
+
+
+
diff --git a/gnu/usr.bin/mkisofs/diag/isovfy.c b/gnu/usr.bin/mkisofs/diag/isovfy.c
index 5da5314..d341a34 100644
--- a/gnu/usr.bin/mkisofs/diag/isovfy.c
+++ b/gnu/usr.bin/mkisofs/diag/isovfy.c
@@ -112,7 +112,7 @@ isonum_732 (char * p)
}
int
-isonum_733 (char * p)
+isonum_733 (unsigned char * p)
{
return (isonum_731 (p));
}
@@ -312,14 +312,14 @@ check_tree(int file_addr, int file_size, int parent_addr){
else if(idr->name_len[0] == 1 && idr->name[0] == 0) {
iline += sprintf(&lbuffer[iline],". ");
rflag = 0;
- if(orig_file_addr !=*((unsigned int *) idr->extent))
+ if(orig_file_addr !=isonum_733(idr->extent))
iline += sprintf(&lbuffer[iline],"***** Directory has null extent.", goof++);
if(i1)
iline += sprintf(&lbuffer[iline],"***** . not first entry.", rr_goof++);
} else if(idr->name_len[0] == 1 && idr->name[0] == 1) {
iline += sprintf(&lbuffer[iline],".. ");
rflag = 0;
- if(parent_file_addr !=*((unsigned int *) idr->extent))
+ if(parent_file_addr !=isonum_733(idr->extent))
iline += sprintf(&lbuffer[iline],"***** Directory has null extent.", goof++);
if(i1 != 1)
iline += sprintf(&lbuffer[iline],"***** .. not second entry.", rr_goof++);
@@ -332,7 +332,10 @@ check_tree(int file_addr, int file_size, int parent_addr){
};
if(size && extent == 0) iline += sprintf(&lbuffer[iline],"****Extent==0, size != 0", goof++);
+#if 0
+ /* This is apparently legal. */
if(size == 0 && extent) iline += sprintf(&lbuffer[iline],"****Extent!=0, size == 0", goof++);
+#endif
if(idr->flags[0] & 0xfd)
iline += sprintf(&lbuffer[iline],"Flags=(%x) ", idr->flags[0], goof++);
@@ -361,8 +364,8 @@ check_tree(int file_addr, int file_size, int parent_addr){
- if(rflag && (idr->flags[0] & 2)) check_tree((*((unsigned int *) idr->extent)) << 11,
- *((unsigned int *) idr->size),
+ if(rflag && (idr->flags[0] & 2)) check_tree((isonum_733(idr->extent)) << 11,
+ isonum_733(idr->size),
orig_file_addr << 11);
i += buffer[i];
i1++;
diff --git a/gnu/usr.bin/mkisofs/exclude.c b/gnu/usr.bin/mkisofs/exclude.c
index 3be700b..6532079 100644
--- a/gnu/usr.bin/mkisofs/exclude.c
+++ b/gnu/usr.bin/mkisofs/exclude.c
@@ -30,7 +30,7 @@ char * fn;
}
- excl[i] = malloc(strlen(fn)+1);
+ excl[i] = (char *) malloc(strlen(fn)+1);
if (! excl[i]) {
fprintf(stderr,"Can't allocate memory for excluded filename\n");
return;
diff --git a/gnu/usr.bin/mkisofs/mkisofs.8 b/gnu/usr.bin/mkisofs/mkisofs.8
index 8eb29ec..d05909b 100644
--- a/gnu/usr.bin/mkisofs/mkisofs.8
+++ b/gnu/usr.bin/mkisofs/mkisofs.8
@@ -1,5 +1,5 @@
.\" -*- nroff -*-
-.TH MKISOFS 8 "August 1993" "Version 1.03"
+.TH MKISOFS 8 "January 1995" "Version 1.04"
.SH NAME
mkisofs \- create a iso9660 filesystem with optional Rock Ridge attributes.
.SH SYNOPSIS
@@ -32,6 +32,12 @@ mkisofs \- create a iso9660 filesystem with optional Rock Ridge attributes.
.B \-l
]
[
+.B \-L
+]
+[
+.B \-L
+]
+[
.B \-V
]
[
@@ -39,6 +45,10 @@ mkisofs \- create a iso9660 filesystem with optional Rock Ridge attributes.
.I volid
]
[
+.B \-i
+.I include-list
+]
+[
.B \-p
.I preparer
]
@@ -88,49 +98,76 @@ example of this would be the files foo.bar and
foo.bar.~1~ - the file foo.bar.~1~ would be written as FOO.000;1 and the file
foo.bar would be written as FOO.BAR;1
.PP
+Note that
+.B mkisofs
+is not designed to communicate with the writer directly. Most writers
+have proprietary command sets which vary from one manufacturer to
+another, and you need a specialized tool to actually burn the disk.
+The cdwrite utility that comes with mkisofs is capable of communicating
+with Phillips drives (newer versions of cdwrite should be available from
+Yggdrasil). Most writers come with some version of DOS software
+that allows a direct image copy of an iso9660 image to the writer.
+.PP
+Also you should know that most cd writers are very particular about timing.
+Once you start to burn a disc, you cannot let their buffer empty before you
+are done, or you will end up with a corrupt disc. Thus it is critical
+that you be able to maintain an uninterupted data stream to the writer
+for the entire time that the disc is being written.
+.PP
.br
.B path
is the path of the directory tree to be copied into the iso9660 filesystem.
.SH OPTIONS
.TP
-.I -a
+.I \-a
Include all files on the iso9660 filesystem. Normally files that contain the
characters '~' or '#' will not be included (these are typically backup files
for editors under unix).
.TP
-.I -A application_id
+.I \-A application_id
Specifies a text string that will be written into the volume header.
This should describe the application that will be on the disc. There
is space on the disc for 128 characters of information. This parameter can
also be set in the file .mkisofsrc with APPL=id. If specified in both
places, the command line version is used.
.TP
-.I -d
+.I \-d
Omit trailing period from files that do not have a period. This violates the
ISO9660 standard, but it happens to work on many systems. Use with caution.
.TP
-.I -D
+.I \-D
Do not use deep directory relocation, and instead just pack them in the
way we see them. This violates the ISO9660 standard, but it works on many
systems. Use with caution.
.TP
-.I -f
+.I \-f
Follow symbolic links when generating the filesystem. When this option is not
in use, symbolic links will be entered using Rock Ridge if enabled, otherwise
the file will be ignored.
.TP
-.I -l
+.I \-i include-list
+Use the specified file as a list of files to add to the directory tree.
+This is useful for quickly repacking a CD while adding files to it.
+The format of this file is path1/file=path2 where path1 is the directory
+in the ISO9660 file system where file should appear and path2 is the
+where to find the file.
+.TP
+.I \-l
Allow full 32 character filenames. Normally the ISO9660 filename will be in an
8.3 format which is compatible with MS-DOS, even though the ISO9660 standard
allows filenames of up to 32 characters. If you use this option, the disc may
be difficult to use on a MS-DOS system, but this comes in handy on some other
systems (such as the Amiga). Use with caution.
.TP
-.I -N
+.I \-L
+Allow filenames to begin with a period. Ususally, a leading dot is
+replaced with an underscore in order to maintain MS-DOS compatibility.
+.TP
+.I \-N
Omit version numbers from ISO9660 file names. This may violate the ISO9660
standard, but no one really uses the version numbers anyway. Use with caution.
.TP
-.I -o filename
+.I \-o filename
is the name of the file to which the iso9660 filesystem image should be
written. This can be a disk file, a tape drive, or it can correspond directly
to the device name of the optical disc writer. If not specified, stdout is
@@ -138,7 +175,7 @@ to the device name of the optical disc writer. If not specified, stdout is
disk drive, in which case the disk partition can be mounted and examined to
ensure that the premastering was done correctly.
.TP
-.I -P publisher_id
+.I \-P publisher_id
Specifies a text string that will be written into the volume header.
This should describe the publisher of the CDROM, usually with a
mailing address and phone number. There is space on the disc for 128
@@ -146,7 +183,7 @@ characters of information. This parameter can also be set in the file
.mkisofsrc with PUBL=. If specified in both places, the command line
version is used.
.TP
-.I -p preparer_id
+.I \-p preparer_id
Specifies a text string that will be written into the volume header.
This should describe the preparer of the CDROM, usually with a mailing
address and phone number. There is space on the disc for 128
@@ -154,26 +191,26 @@ characters of information. This parameter can also be set in the file
.mkisofsrc with PREP=. If specified in both places, the command
line version is used.
.TP
-.I -R
+.I \-R
Generate SUSP and RR records using the Rock Ridge protocol to further describe
the files on the iso9660 filesystem.
.TP
-.I -T
+.I \-T
Generate a file TRANS.TBL in each directory on the CDROM, which can be used
on non-Rock Ridge capable systems to help establish the correct file names.
There is also information present in the file that indicates the major and
minor numbers for block and character devices, and each symlink has the name of
the link file given.
.TP
-.I -V volid
+.I \-V volid
Specifies the volume ID to be written into the master block. This
parameter can also be set in the file .mkisofsrc with VOLI=id. If
specified in both places, the command line version is used.
.TP
-.I -v
+.I \-v
Verbose execution.
.TP
-.I -x path
+.I \-x path
Exclude
.I path
from being written to CDROM.
@@ -183,9 +220,9 @@ given as command line argument and the path relative to this directory.
Multiple paths may be excluded (up to 1000).
Example:
-mkisofs -o cd -x /local/dir1 -x /local/dir2 /local
+mkisofs \-o cd \-x /local/dir1 \-x /local/dir2 /local
.TP
-.I -z
+.I \-z
Generate special SUSP records for transparently compressed files. This is
only of use and interest for hosts that support transparent decompression.
This is an experimental feature, and no hosts yet support this, but there
@@ -215,7 +252,7 @@ filesystem. The name mkisofs is probably a bit of a misnomer, since it
not only creates the filesystem, but it also populates it as well.
.PP
.br
-Eric Youngdale <ericy@cais.com> wrote both the linux isofs9660 filesystem
+Eric Youngdale <eric@aib.com> wrote both the linux isofs9660 filesystem
and the mkisofs utility, and is currently maintaining them. The copyright for
the mkisofs utility is held by Yggdrasil Computing, Incorporated.
.SH BUGS
diff --git a/gnu/usr.bin/mkisofs/mkisofs.c b/gnu/usr.bin/mkisofs/mkisofs.c
index a77b815..f4840aa 100644
--- a/gnu/usr.bin/mkisofs/mkisofs.c
+++ b/gnu/usr.bin/mkisofs/mkisofs.c
@@ -20,6 +20,8 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+/* ADD_FILES changes made by Ross Biro biro@yggdrasil.com 2/23/95 */
+
#include "mkisofs.h"
#ifdef linux
@@ -52,7 +54,7 @@
struct directory * root = NULL;
-static char version_string[] = "mkisofs v1.03";
+static char version_string[] = "mkisofs v1.04";
FILE * discimage;
unsigned int next_extent = 0;
@@ -88,6 +90,7 @@ int omit_version_number = 0; /* May violate iso9660, but noone uses vers*/
int RR_relocation_depth = 6; /* Violates iso9660, but most systems work */
int full_iso9660_filenames = 0; /* Used with Amiga. Disc will not work with
DOS */
+int allow_leading_dots = 0; /* DOS cannot read names with leading dots */
struct rcopts{
char * tag;
@@ -183,7 +186,7 @@ void usage(){
fprintf(stderr,"Usage:\n");
fprintf(stderr,
"mkisofs [-o outfile] [-R] [-V volid] [-v] [-a] \
-[-T]\n [-l] [-d] [-V] [-D] [-p preparer] \
+[-T]\n [-l] [-d] [-V] [-D] [-L] [-p preparer] \
[-P publisher] [ -A app_id ] [-z] \
[-x path -x path ...] path\n");
exit(1);
@@ -278,9 +281,15 @@ int FDECL3(iso9660_file_length,const char*, name, struct directory_entry *, sres
if(current_length < 30) *result++ = (islower(*pnt) ? toupper(*pnt) : *pnt);
} else { /* Dos style filenames */
if(*pnt == '.') {
- if (seen_dot) {ignore++; continue;}
- if(result) *result++ = '.';
- seen_dot++;
+ if (!chars_before_dot && !allow_leading_dots) {
+ /* DOS can't read files with dot first */
+ chars_before_dot++;
+ if (result) *result++ = '_'; /* Substitute underscore */
+ } else {
+ if (seen_dot) {ignore++; continue;}
+ if(result) *result++ = '.';
+ seen_dot++;
+ }
} else if (seen_dot) {
if(chars_after_dot < 3) {
chars_after_dot++;
@@ -328,6 +337,154 @@ int FDECL3(iso9660_file_length,const char*, name, struct directory_entry *, sres
return chars_before_dot + chars_after_dot + seen_dot + extra;
}
+#ifdef ADD_FILES
+
+struct file_adds *root_file_adds = NULL;
+
+void
+FDECL2(add_one_file, char *, addpath, char *, path )
+{
+ char *cp;
+ char *name;
+ struct file_adds *f;
+ struct file_adds *tmp;
+
+ f = root_file_adds;
+ tmp = NULL;
+
+ name = rindex (addpath, PATH_SEPARATOR);
+ if (name == NULL) {
+ name = addpath;
+ } else {
+ name++;
+ }
+
+ cp = strtok (addpath, SPATH_SEPARATOR);
+
+ while (cp != NULL && strcmp (name, cp)) {
+ if (f == NULL) {
+ root_file_adds = e_malloc (sizeof *root_file_adds);
+ f=root_file_adds;
+ f->name = NULL;
+ f->child = NULL;
+ f->next = NULL;
+ f->add_count = 0;
+ f->adds = NULL;
+ f->used = 0;
+ }
+ if (f->child) {
+ for (tmp = f->child; tmp->next != NULL; tmp =tmp->next) {
+ if (strcmp (tmp->name, cp) == 0) {
+ f = tmp;
+ goto next;
+ }
+ }
+ if (strcmp (tmp->name, cp) == 0) {
+ f=tmp;
+ goto next;
+ }
+ /* add a new node. */
+ tmp->next = e_malloc (sizeof (*tmp->next));
+ f=tmp->next;
+ f->name = strdup (cp);
+ f->child = NULL;
+ f->next = NULL;
+ f->add_count = 0;
+ f->adds = NULL;
+ f->used = 0;
+ } else {
+ /* no children. */
+ f->child = e_malloc (sizeof (*f->child));
+ f = f->child;
+ f->name = strdup (cp);
+ f->child = NULL;
+ f->next = NULL;
+ f->add_count = 0;
+ f->adds = NULL;
+ f->used = 0;
+
+ }
+ next:
+ cp = strtok (NULL, SPATH_SEPARATOR);
+ }
+ /* Now f if non-null points to where we should add things */
+ if (f == NULL) {
+ root_file_adds = e_malloc (sizeof *root_file_adds);
+ f=root_file_adds;
+ f->name = NULL;
+ f->child = NULL;
+ f->next = NULL;
+ f->add_count = 0;
+ f->adds = NULL;
+ }
+
+ /* Now f really points to where we should add this name. */
+ f->add_count++;
+ f->adds = realloc (f->adds, sizeof (*f->adds)*f->add_count);
+ f->adds[f->add_count-1].path = strdup (path);
+ f->adds[f->add_count-1].name = strdup (name);
+}
+
+void
+FDECL3(add_file_list, int, argc, char **,argv, int, ind)
+{
+ char *ptr;
+ char *dup_arg;
+
+ while (ind < argc) {
+ dup_arg = strdup (argv[ind]);
+ ptr = index (dup_arg,'=');
+ if (ptr == NULL) {
+ free (dup_arg);
+ return;
+ }
+ *ptr = 0;
+ ptr++;
+ add_one_file (dup_arg, ptr);
+ free (dup_arg);
+ ind++;
+ }
+}
+void
+FDECL1(add_file, char *, filename)
+{
+ char buff[1024];
+ FILE *f;
+ char *ptr;
+ char *p2;
+ int count=0;
+
+ if (strcmp (filename, "-") == 0) {
+ f = stdin;
+ } else {
+ f = fopen (filename, "r");
+ if (f == NULL) {
+ perror ("fopen");
+ exit (1);
+ }
+ }
+ while (fgets (buff, 1024, f)) {
+ count++;
+ ptr = buff;
+ while (isspace (*ptr)) ptr++;
+ if (*ptr==0) continue;
+ if (*ptr=='#') continue;
+
+ if (ptr[strlen(ptr)-1]== '\n') ptr[strlen(ptr)-1]=0;
+ p2 = index (ptr, '=');
+ if (p2 == NULL) {
+ fprintf (stderr, "Error in line %d: %s\n", count, buff);
+ exit (1);
+ }
+ *p2 = 0;
+ p2++;
+ add_one_file (ptr, p2);
+ }
+ if (f != stdin) fclose (f);
+}
+
+#endif
+
int FDECL2(main, int, argc, char **, argv){
char * outfile;
struct directory_entry de;
@@ -335,6 +492,9 @@ int FDECL2(main, int, argc, char **, argv){
struct stat statbuf;
char * scan_tree;
int c;
+#ifdef ADD_FILES
+ char *add_file_file = NULL;
+#endif
if (argc < 2)
usage();
@@ -343,7 +503,7 @@ int FDECL2(main, int, argc, char **, argv){
read_rcfile(argv[0]);
outfile = NULL;
- while ((c = getopt(argc, argv, "o:V:RfvaTp:P:x:dDlNzA:")) != EOF)
+ while ((c = getopt(argc, argv, "i:o:V:RfvaTp:P:x:dDlLNzA:")) != EOF)
switch (c)
{
case 'p':
@@ -376,6 +536,9 @@ int FDECL2(main, int, argc, char **, argv){
case 'l':
full_iso9660_filenames++;
break;
+ case 'L':
+ allow_leading_dots++;
+ break;
case 'N':
omit_version_number++;
break;
@@ -411,6 +574,11 @@ int FDECL2(main, int, argc, char **, argv){
case 'x':
exclude(optarg);
break;
+ case 'i':
+#ifdef ADD_FILES
+ add_file_file = optarg;
+ break;
+#endif
default:
usage();
exit(1);
@@ -439,6 +607,13 @@ int FDECL2(main, int, argc, char **, argv){
scan_tree = argv[optind];
+#ifdef ADD_FILES
+ if (add_file_file) {
+ add_file(add_file_file);
+ }
+ add_file_list (argc, argv, optind+1);
+#endif
+
if(!scan_tree){
usage();
exit(1);
@@ -460,7 +635,7 @@ int FDECL2(main, int, argc, char **, argv){
#else
extension_record = generate_rr_extension_record("IEEE_P1282",
"THE IEEE P1282 PROTOCOL PROVIDES SUPPORT FOR POSIX FILE SYSTEM SEMANTICS",
- "PLEASE CONTACT THE IEEE STANDARDS DEPARTMENT,PISCATAWAY, NJ, USA FOR THE P1282 SPECIFICATION.", &extension_record_size);
+ "PLEASE CONTACT THE IEEE STANDARDS DEPARTMENT, PISCATAWAY, NJ, USA FOR THE P1282 SPECIFICATION.", &extension_record_size);
#endif
};
diff --git a/gnu/usr.bin/mkisofs/mkisofs.h b/gnu/usr.bin/mkisofs/mkisofs.h
index 89e9423..53d14b9 100644
--- a/gnu/usr.bin/mkisofs/mkisofs.h
+++ b/gnu/usr.bin/mkisofs/mkisofs.h
@@ -19,6 +19,8 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+/* ADD_FILES changes made by Ross Biro biro@yggdrasil.com 2/23/95 */
+
#include <stdio.h>
/* This symbol is used to indicate that we do not have things like
@@ -100,6 +102,7 @@ struct directory_entry{
unsigned int priority;
char * name;
char * table;
+ char * whole_name;
struct directory * filedir;
struct directory_entry * parent_rec;
unsigned int flags;
@@ -141,6 +144,23 @@ struct deferred{
unsigned int flags;
};
+#ifdef ADD_FILES
+struct file_adds {
+ char *name;
+ struct file_adds *child;
+ struct file_adds *next;
+ int add_count;
+ int used;
+ struct dirent de;
+ struct {
+ char *path;
+ char *name;
+ } *adds;
+};
+extern struct file_adds *root_file_adds;
+
+#endif
+
extern void DECL(sort_n_finish,(struct directory *));
extern int goof;
extern struct directory * root;
diff --git a/gnu/usr.bin/mkisofs/rock.c b/gnu/usr.bin/mkisofs/rock.c
index 6817a07..591fda5 100644
--- a/gnu/usr.bin/mkisofs/rock.c
+++ b/gnu/usr.bin/mkisofs/rock.c
@@ -279,7 +279,7 @@ int deep_opt;
nchar -= 1;
} else if(cpnt[0] == 0){
if(MAYBE_ADD_CE_ENTRY(2)) add_CE_entry();
- Rock[ipnt++] = SL_ROOT;
+ Rock[ipnt++] = (cpnt == &symlink_buff[0] ? SL_ROOT : 0);
Rock[ipnt++] = 0; /* length is zero */
lenval += 2;
} else {
diff --git a/gnu/usr.bin/mkisofs/tree.c b/gnu/usr.bin/mkisofs/tree.c
index fad1205..076f225 100644
--- a/gnu/usr.bin/mkisofs/tree.c
+++ b/gnu/usr.bin/mkisofs/tree.c
@@ -20,16 +20,22 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+/* ADD_FILES changes made by Ross Biro biro@yggdrasil.com 2/23/95 */
+
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#ifndef VMS
-#include <unistd.h>
-#ifdef HASSYSMACROS
+#if defined(HASSYSMACROS) && !defined(HASMKDEV)
#include <sys/sysmacros.h>
#endif
+#include <unistd.h>
+#ifdef HASMKDEV
+#include <sys/types.h>
+#include <sys/mkdev.h>
+#endif
#else
#include <sys/file.h>
#include <vms/fabdef.h>
@@ -468,6 +474,89 @@ void finish_cl_pl_entries(){
d_entry = d_entry->next;
};
}
+
+#ifdef ADD_FILES
+/* This function looks up additions. */
+char *
+FDECL3(look_up_addition,char **, newpath, char *,path, struct dirent **,de) {
+ char *dup_path;
+ char *cp;
+ struct file_adds *f;
+ struct file_adds *tmp;
+
+ f=root_file_adds;
+ if (!f) return NULL;
+
+ /* I don't trust strtok */
+ dup_path = strdup (path);
+
+ cp = strtok (dup_path, SPATH_SEPARATOR);
+ while (cp != NULL) {
+ for (tmp = f->child; tmp != NULL; tmp=tmp->next) {
+ if (strcmp (tmp->name, cp) == 0) break;
+ }
+ if (tmp == NULL) {
+ /* no match */
+ free (dup_path);
+ return (NULL);
+ }
+ f = tmp;
+ cp = strtok(NULL, SPATH_SEPARATOR);
+ }
+ free (dup_path);
+
+ /* looks like we found something. */
+ if (tmp->used >= tmp->add_count) return (NULL);
+
+ *newpath = tmp->adds[tmp->used].path;
+ tmp->used++;
+ *de = &(tmp->de);
+ return (tmp->adds[tmp->used-1].name);
+
+}
+
+/* This function lets us add files from outside the standard file tree.
+ It is useful if we want to duplicate a cd, but add/replace things.
+ We should note that the real path will be used for exclusions. */
+
+struct dirent *
+FDECL3(readdir_add_files, char **, pathp, char *,path, DIR *, dir){
+ struct dirent *de;
+
+ char *addpath;
+ char *name;
+
+ de = readdir (dir);
+ if (de) {
+ return (de);
+ }
+
+ name=look_up_addition (&addpath, path, &de);
+
+ if (!name) {
+ return;
+ }
+
+ *pathp=addpath;
+
+ /* Now we must create the directory entry. */
+ /* fortuneately only the name seems to matter. */
+ /*
+ de->d_ino = -1;
+ de->d_off = 0;
+ de->d_reclen = strlen (name);
+ */
+ strncpy (de->d_name, name, NAME_MAX);
+ de->d_name[NAME_MAX]=0;
+ return (de);
+
+}
+#else
+struct dirent *
+FDECL3(readdir_add_files, char **, pathp, char *,path, DIR *, dir){
+ return (readdir (dir));
+}
+#endif
/*
* This function scans the directory tree, looking for files, and it makes
* note of everything that is found. We also begin to construct the ISO9660
@@ -486,6 +575,7 @@ FDECL2(scan_directory_tree,char *, path, struct directory_entry *, de){
char * cpnt;
int new_reclen;
int deep_flag;
+ char *old_path;
current_dir = opendir(path);
d_entry = NULL;
@@ -493,7 +583,9 @@ FDECL2(scan_directory_tree,char *, path, struct directory_entry *, de){
/* Apparently NFS sometimes allows you to open the directory, but
then refuses to allow you to read the contents. Allow for this */
- if(current_dir) d_entry = readdir(current_dir);
+ old_path = path;
+
+ if(current_dir) d_entry = readdir_add_files(&path, old_path, current_dir);
if(!current_dir || !d_entry) {
fprintf(stderr,"Unable to open directory %s\n", path);
@@ -571,7 +663,7 @@ FDECL2(scan_directory_tree,char *, path, struct directory_entry *, de){
/* The first time through, skip this, since we already asked for
the first entry when we opened the directory. */
- if(dflag) d_entry = readdir(current_dir);
+ if(dflag) d_entry = readdir_add_files(&path, old_path, current_dir);
dflag++;
if(!d_entry) break;
@@ -622,10 +714,11 @@ FDECL2(scan_directory_tree,char *, path, struct directory_entry *, de){
if(S_ISLNK(lstatbuf.st_mode)){
- /* Here we decide how to handle the symbolic links. Here we
- handle the general case - if we are not following links or there is an
- error, then we must change something. If RR is in use, it is easy, we
- let RR describe the file. If not, then we punt the file. */
+ /* Here we decide how to handle the symbolic links. Here
+ we handle the general case - if we are not following
+ links or there is an error, then we must change
+ something. If RR is in use, it is easy, we let RR
+ describe the file. If not, then we punt the file. */
if((status || !follow_links)){
if(use_RockRidge){
@@ -645,35 +738,58 @@ FDECL2(scan_directory_tree,char *, path, struct directory_entry *, de){
};
}
- /* Here we handle a different kind of case. Here we have a symlink,
- but we want to follow symlinks. If we run across a directory loop,
- then we need to pretend that we are not following symlinks for this file.
- If this is the first time we have seen this, then make this seem
- as if there was no symlink there in the first place */
+ /* Here we handle a different kind of case. Here we have
+ a symlink, but we want to follow symlinks. If we run
+ across a directory loop, then we need to pretend that
+ we are not following symlinks for this file. If this
+ is the first time we have seen this, then make this
+ seem as if there was no symlink there in the first
+ place */
- else if(strcmp(d_entry->d_name, ".") &&
- strcmp(d_entry->d_name, "..")) {
- if(find_directory_hash(statbuf.st_dev, STAT_INODE(statbuf))){
- fprintf(stderr, "Infinite loop detected (%s)\n", whole_path);
- if(!use_RockRidge) continue;
- statbuf.st_size = 0;
- STAT_INODE(statbuf) = UNCACHED_INODE;
- statbuf.st_dev = (dev_t) UNCACHED_DEVICE;
- statbuf.st_mode = (statbuf.st_mode & ~S_IFMT) | S_IFREG;
+ if( follow_links
+ && S_ISDIR(statbuf.st_mode) )
+ {
+ if( strcmp(d_entry->d_name, ".")
+ && strcmp(d_entry->d_name, "..") )
+ {
+ if(find_directory_hash(statbuf.st_dev, STAT_INODE(statbuf)))
+ {
+ if(!use_RockRidge)
+ {
+ fprintf(stderr, "Already cached directory seen (%s)\n",
+ whole_path);
+ continue;
+ }
+ statbuf.st_size = 0;
+ STAT_INODE(statbuf) = UNCACHED_INODE;
+ statbuf.st_dev = (dev_t) UNCACHED_DEVICE;
+ statbuf.st_mode = (statbuf.st_mode & ~S_IFMT) | S_IFREG;
} else {
- lstatbuf = statbuf;
- add_directory_hash(statbuf.st_dev, STAT_INODE(statbuf));
- };
- };
- };
+ lstatbuf = statbuf;
+ add_directory_hash(statbuf.st_dev, STAT_INODE(statbuf));
+ }
+ }
+ }
+ }
+ /*
+ * Add directories to the cache so that we don't waste space even
+ * if we are supposed to be following symlinks.
+ */
+ if( follow_links
+ && strcmp(d_entry->d_name, ".")
+ && strcmp(d_entry->d_name, "..")
+ && S_ISDIR(statbuf.st_mode) )
+ {
+ add_directory_hash(statbuf.st_dev, STAT_INODE(statbuf));
+ }
#ifdef VMS
if(!S_ISDIR(lstatbuf.st_mode) && (statbuf.st_fab_rfm != FAB$C_FIX &&
statbuf.st_fab_rfm != FAB$C_STMLF)) {
fprintf(stderr,"Warning - file %s has an unsupported VMS record"
" format (%d)\n",
whole_path, statbuf.st_fab_rfm);
- };
+ }
#endif
if(S_ISREG(lstatbuf.st_mode) && (status = access(whole_path, R_OK))){
@@ -684,11 +800,15 @@ FDECL2(scan_directory_tree,char *, path, struct directory_entry *, de){
/* Add this so that we can detect directory loops with hard links.
If we are set up to follow symlinks, then we skip this checking. */
- if(!follow_links && S_ISDIR(lstatbuf.st_mode) && strcmp(d_entry->d_name, ".") &&
- strcmp(d_entry->d_name, "..")) {
+ if( !follow_links
+ && S_ISDIR(lstatbuf.st_mode)
+ && strcmp(d_entry->d_name, ".")
+ && strcmp(d_entry->d_name, "..") )
+ {
if(find_directory_hash(statbuf.st_dev, STAT_INODE(statbuf))) {
- fprintf(stderr,"Directory loop - fatal goof (%s %x %d).\n",
- whole_path, statbuf.st_dev, STAT_INODE(statbuf));
+ fprintf(stderr,"Directory loop - fatal goof (%s %lx %lu).\n",
+ whole_path, (unsigned long) statbuf.st_dev,
+ (unsigned long) STAT_INODE(statbuf));
exit(1);
};
add_directory_hash(statbuf.st_dev, STAT_INODE(statbuf));
@@ -720,6 +840,7 @@ FDECL2(scan_directory_tree,char *, path, struct directory_entry *, de){
s_entry->table = NULL;
s_entry->name = strdup(d_entry->d_name);
+ s_entry->whole_name = strdup (whole_path);
s_entry->filedir = this_dir;
s_entry->isorec.flags[0] = 0;
@@ -803,18 +924,20 @@ FDECL2(scan_directory_tree,char *, path, struct directory_entry *, de){
break;
#ifndef NON_UNIXFS
case S_IFBLK:
- sprintf(buffer,"B\t%s\t%d %d\n",
+ sprintf(buffer,"B\t%s\t%lu %lu\n",
s_entry->name,
- major(statbuf.st_rdev), minor(statbuf.st_rdev));
+ (unsigned long) major(statbuf.st_rdev),
+ (unsigned long) minor(statbuf.st_rdev));
break;
case S_IFIFO:
sprintf(buffer,"P\t%s\n",
s_entry->name);
break;
case S_IFCHR:
- sprintf(buffer,"C\t%s\t%d %d\n",
+ sprintf(buffer,"C\t%s\t%lu %lu\n",
s_entry->name,
- major(statbuf.st_rdev), minor(statbuf.st_rdev));
+ (unsigned long) major(statbuf.st_rdev),
+ (unsigned long) minor(statbuf.st_rdev));
break;
case S_IFLNK:
readlink(whole_path, symlink_buff, sizeof(symlink_buff));
diff --git a/gnu/usr.bin/mkisofs/write.c b/gnu/usr.bin/mkisofs/write.c
index 05450c7..efe86cd 100644
--- a/gnu/usr.bin/mkisofs/write.c
+++ b/gnu/usr.bin/mkisofs/write.c
@@ -375,11 +375,7 @@ static void FDECL1(assign_file_addresses, struct directory *, dpnt){
dwpnt->name = NULL;
} else {
dwpnt->table = NULL;
- strcpy(whole_path, s_entry->filedir->whole_name);
-#ifndef VMS
- if(strlen(whole_path)) strcat(whole_path, "/");
-#endif
- strcat(whole_path, s_entry->name);
+ strcpy(whole_path, s_entry->whole_name);
dwpnt->name = strdup(whole_path);
};
dwpnt->next = NULL;
@@ -406,8 +402,15 @@ static void FDECL1(assign_file_addresses, struct directory *, dpnt){
fprintf(stderr,"Reported file size is %d extents\n", s_entry->size);
exit(1);
};
- } else
- set_733(s_entry->isorec.extent, 0);
+ } else {
+ /*
+ * This is for zero-length files. If we leave the extent 0,
+ * then we get screwed, because many readers simply drop files
+ * that have an extent of zero. Thus we leave the size 0,
+ * and just assign the extent number.
+ */
+ set_733(s_entry->isorec.extent, last_extent);
+ }
};
};
};
OpenPOWER on IntegriCloud