Only in MFSTools-snapshot050221: .DS_Store Only in MFSTools-snapshot050221: Makefile Only in MFSTools-snapshot050221/backup: Makefile Only in MFSTools-snapshot050221/backup: backmain.o Only in MFSTools-snapshot050221/backup: backup Only in MFSTools-snapshot050221/backup: backup.o Only in MFSTools-snapshot050221/backup: libbackup.a Only in MFSTools-snapshot050221: config.log Only in MFSTools-snapshot050221: config.status diff -ru MFSTools-snapshot050221.orig/include/config.h MFSTools-snapshot050221/include/config.h --- MFSTools-snapshot050221.orig/include/config.h 2005-02-21 21:02:25.000000000 -0800 +++ MFSTools-snapshot050221/include/config.h 2007-03-29 04:37:45.000000000 -0700 @@ -1,3 +1,6 @@ +#define TARGET_OS_MAC 1 +#include "/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/headers/Endian.h" + /* include/config.h. Generated by configure. */ /* include/config.h.in. Generated from configure.in by autoheader. */ @@ -14,7 +17,7 @@ /* #undef BUILD_MFSAPPS */ /* Build the mfs dump standalone utility or mfstool utility. */ -/* #undef BUILD_MFSD */ +#define BUILD_MFSD 1 /* Build the utilities into a single mfstool command. */ #define BUILD_MFSINFO 1 @@ -26,13 +29,13 @@ #define BUILD_RESTORE 1 /* Build with debug symbols and debug messages enabled. */ -/* #undef DEBUG */ +#define DEBUG 1 /* Define to 1 if you have the header file. */ -#define HAVE_ASM_PAGE_H 1 +/* #undef HAVE_ASM_PAGE_H */ /* Define to 1 if you have the header file. */ -#define HAVE_ASM_TYPES_H 1 +/* #undef HAVE_ASM_TYPES_H */ /* Define to 1 if you have the header file. */ #define HAVE_CTYPE_H 1 @@ -47,16 +50,16 @@ #define HAVE_INTTYPES_H 1 /* Define to 1 if you have the header file. */ -#define HAVE_LINUX_FS_H 1 +/* #undef HAVE_LINUX_FS_H */ /* Define to 1 if you have the header file. */ /* #undef HAVE_LINUX_IDE_TIVO_H */ /* Define to 1 if you have the header file. */ -#define HAVE_LINUX_UNISTD_H 1 +/* #undef HAVE_LINUX_UNISTD_H */ /* Define to 1 if you have the header file. */ -#define HAVE_MALLOC_H 1 +/* #undef HAVE_MALLOC_H */ /* Define to 1 if you have the header file. */ #define HAVE_MEMORY_H 1 Only in MFSTools-snapshot050221/lib: Makefile Only in MFSTools-snapshot050221/lib: crc.o Only in MFSTools-snapshot050221/lib: inode.o Only in MFSTools-snapshot050221/lib: libmacpart.a Only in MFSTools-snapshot050221/lib: libmfs.a Only in MFSTools-snapshot050221/lib: libmfsvol.a Only in MFSTools-snapshot050221/lib: log.o diff -ru MFSTools-snapshot050221.orig/lib/macpart.c MFSTools-snapshot050221/lib/macpart.c --- MFSTools-snapshot050221.orig/lib/macpart.c 2005-02-21 01:02:56.000000000 -0800 +++ MFSTools-snapshot050221/lib/macpart.c 2007-03-31 10:27:04.000000000 -0700 @@ -26,6 +26,9 @@ #ifdef HAVE_LINUX_UNISTD_H #include #endif +#if TARGET_OS_MAC +#include +#endif /* For htonl() */ #include @@ -54,6 +57,10 @@ struct stat st; #endif +#if DEBUG +printf("file_or_dev_size: Here\n"); +#endif + #ifdef DKIOCGETBLOCKCOUNT /* For Mac OS X */ { uint32_t blocksize; @@ -63,11 +70,20 @@ ioctl(fd, DKIOCGETBLOCKCOUNT, &size64) == 0) { if ((sizeof(*size) < sizeof(unsigned long long)) - && ((size64 * (blocksize / 512)) > 0xFFFFFFFF)) + && ((size64 * (blocksize / 512)) > 0xFFFFFFFF)) { +#if DEBUG + printf("file_or_dev_size: size of would overflow.\n"); +#endif return EFBIG; + } *size = size64 * (blocksize / 512); +#if DEBUG + printf("file_or_dev_size: set size to %lld * %d / 512, or %lld\n", size64, blocksize, *size); +#endif return 1; + } else { + fprintf(stderr, "IOCTL failed. Error was: %s\n", strerror(errno)); } } #endif @@ -126,6 +142,8 @@ } } + printf("Table in memory? 0x%x\n", table); + /* If not, open it and read the partition table. */ if (!table) { @@ -150,10 +168,17 @@ *fd = lfopen (device, flags); if (*fd < 0) { +#if DEBUG + printf("Could not open device %s\n", device); +#endif free (table); return 0; } +#if DEBUG + printf("Checkpoint 1.\n"); +#endif + /* Get the size and if it is a file or device. */ switch (file_or_dev_size (*fd, &table->devsize)) { @@ -162,11 +187,18 @@ case 1: break; default: +#if DEBUG + printf("file_or_dev_size returned %d\n", file_or_dev_size (*fd, &table->devsize)); +#endif close (*fd); free (table); return 0; } +#if DEBUG + printf("Checkpoint 2.\n"); +#endif + /* Read the boot block. */ lseek (*fd, 0, SEEK_SET); if (read (*fd, buf, 512) != 512) @@ -180,9 +212,15 @@ switch (htons (*(unsigned short *) buf)) { case TIVO_BOOT_MAGIC: +#if DEBUG + printf("Magic found.\n"); +#endif /* It is the right magic. Do nothing. */ break; case TIVO_BOOT_AMIGC: +#if DEBUG + printf("Byte-swapped magic found.\n"); +#endif /* It is the right magic, but it is byte-swapped. Enable byte-swapping. */ table->vol_flags |= VOL_SWAB; break; @@ -192,13 +230,24 @@ free (table); return 0; } +#if DEBUG + printf("Checkpoint 3.\n"); +#endif /* At this point, the size of the partition table is not known. However, it */ /* is the first sector. So the maxsec is bootstrapped to 1, and is updated */ /* after the first sector. */ +#if DEBUG +int itercount=0; +#endif for (cursec = 1; cursec <= maxsec && partitions < 256; cursec++) { struct mac_partition *part; + +#if DEBUG + printf("iteration %d\n", itercount++); +#endif + lseek (*fd, 512 * cursec, SEEK_SET); if (read (*fd, buf, 512) != 512) { @@ -215,6 +264,9 @@ /* If it doesn't have the magic, it's not hip. No more partitions. */ if (htons (part->signature) != MAC_PARTITION_MAGIC) { +#if DEBUG + printf("signature is 0x%x, not 0x%x as expected. Ditching.\n", part->signature, MAC_PARTITION_MAGIC); +#endif break; } @@ -232,6 +284,9 @@ parts[partitions].refs = 1; partitions++; } +#if DEBUG + printf("Checkpoint 4. Partitions %d\n", partitions); +#endif /* No partitions. None. Nada. */ if (partitions == 0) @@ -354,19 +409,31 @@ unsigned int loop; char partsused[256]; - if (!table) + if (!table) { +#if DEBUG + printf("tivo_partition_validate: No table.\n"); +#endif return -1; + } /* Only need to validate once. */ - if (table->vol_flags & VOL_VALID) + if (table->vol_flags & VOL_VALID) { +#if DEBUG + printf("tivo_partition_validate: already valid\n"); +#endif return 0; + } bzero (&partsused, sizeof (partsused)); loop = 1; - if (table->count >= 256) + if (table->count >= 256) { +#if DEBUG + printf("tivo_partition_validate: count >= 256\n"); +#endif return -1; + } /* Loop through each sector on the drive. */ while (loop < table->devsize) @@ -392,8 +459,12 @@ { /* If the table is too big for the first partition or for a max of 256, */ /* which is very generous since TiVo only allows 15 max, report an error. */ - if (table->count >= table->allocated || table->count >= 256) + if (table->count >= table->allocated || table->count >= 256) { +#if DEBUG + printf("tivo_partition_validate: gap would overflow.\n"); +#endif return -1; + } /* Create the new partition. */ table->partitions[table->count].sectors = table->partitions[loop2].start - loop; @@ -412,23 +483,35 @@ /* sector number is greater than the max int - the partition size, there */ /* will be wrap. In this case, 0 is taking the place of maxint, since it */ /* will wrap. If a partition is 0 bytes, it's considered an error. */ - if (loop > (unsigned int)(0 - table->partitions[partno].sectors)) + if (loop > (unsigned int)(0 - table->partitions[partno].sectors)) { +#if DEBUG + printf("tivo_partition_validate: integer wrap (bug)\n"); +#endif return -1; + } loop += table->partitions[partno].sectors; } /* If the partition table describes too many partitions, it is an error. */ - if (loop > table->devsize) + if (loop > table->devsize) { +#if DEBUG + printf("tivo_partition_validate: devsize exceeded by loop. (0x%x > 0x%x; %d > %d)\n", loop, table->devsize, loop, table->devsize); +#endif return -1; + } /* If the partition table describes too few partitions, create a filler. */ if (loop < table->devsize) { /* If the table is too big for the first partition or for a max of 256, */ /* which is very generous since TiVo only allows 15 max, report an error. */ - if (table->count >= table->allocated || table->count >= 256) + if (table->count >= table->allocated || table->count >= 256) { +#if DEBUG + printf("tivo_partition_validate: filler would overflow (2)\n"); +#endif return -1; + } /* Create the new partition. */ table->partitions[table->count].sectors = table->devsize - loop; @@ -444,17 +527,30 @@ for (loop = 0; loop < table->count; loop++) { /* Check that all the partitions were used in this walk. */ - if (!partsused[loop]) + if (!partsused[loop]) { +#if DEBUG + printf("tivo_partition_validate: not all partitions used.\n"); +#endif return -1; + } /* Check that the partitions have valid names and types, needed for write */ /* back to the drive. */ - if (!table->partitions[loop].name || !table->partitions[loop].type) + if (!table->partitions[loop].name || !table->partitions[loop].type) { +#if DEBUG + printf("tivo_partition_validate: empty name or type.\n"); +#endif return -1; + } } /* All should be A-Ok now. */ table->vol_flags |= VOL_VALID; + +#if DEBUG +printf("tivo_partition_validate passed.\n"); +#endif + return 0; } @@ -882,6 +978,10 @@ newfile.fd = -1; +#if DEBUG + printf("tivo_partition_accmode is %s\n", tivo_partition_accmode == accAUTO ? "accAUTO" : (tivo_partition_accmode == accKERNEL ? "accKERNEL" : "accDIRECT")); +#endif + /* If the preferred access mode is kernel, or if it is auto, try to open it. */ if (tivo_partition_accmode == accAUTO || tivo_partition_accmode == accKERNEL) { @@ -911,14 +1011,22 @@ bzero (file, sizeof (newfile)); newfile.fd = -1; } +#if DEBUG + } else { + printf("File does not exist.\n"); +#endif } } /* If the type is still unknown and it is auto mode, or if the mode is direct */ /* only, try opening the main device. */ + printf("newfile.tptype: %s\n", newfile.tptype == pUNKNOWN ? "pUNKNOWN" : (newfile.tptype == pDIRECTFILE ? "pDIRECTFILE" : (newfile.tptype == pFILE ? "pFILE" : (newfile.tptype == pDEVICE ? "pDEVICE" : "pDIRECT")))); if ((newfile.tptype == pUNKNOWN && tivo_partition_accmode == accAUTO) || tivo_partition_accmode == accDIRECT) { /* Find the device name. */ +#if DEBUG + printf("Checking for device name\n"); +#endif #if TARGET_OS_MAC int disk; @@ -928,11 +1036,20 @@ { sprintf (devpath, "/dev/disk%d", disk); +#if DEBUG + printf("DISK %d part %d extra %c\n", disk, partnum, extra); + printf("devpath %s flags %d\n", devpath, flags); +#endif + /* Read the partition. Don't care about the return value, cause the type */ /* set will be enough to know if it succeeded. */ tivo_partition_open_direct_int (&newfile, devpath, partnum, flags); +#if DEBUG + } else { + printf("Format wrong. Name was \"%s\"\n", path); +#endif } -#else +#else // Not Mac int tmp = 0; size_t partoff; @@ -964,7 +1081,7 @@ strcpy (devpath + partoff - 5, "/disc"); } /* Likewise, the old devfs naming scheme called partitions /dev/XX/cXbXtXuXpX */ -/* and whole drives /dev/XX/cXbXtXuX. Even though this naming is depricated, */ +/* and whole drives /dev/XX/cXbXtXuX. Even though this naming is deprecated, */ /* it is still an option in devfsd, which creates a compatibility namespace. */ else if (devpath[partoff - 1] == 'p' && isdigit (devpath[partoff - 2])) { @@ -982,6 +1099,10 @@ #endif } +#if DEBUG + printf("newfile.tptype now %s\n", newfile.tptype == pUNKNOWN ? "pUNKNOWN" : (newfile.tptype == pDIRECTFILE ? "pDIRECTFILE" : (newfile.tptype == pFILE ? "pFILE" : (newfile.tptype == pDEVICE ? "pDEVICE" : "pDIRECT")))); +#endif + /* If the type is still unknown, it is an error, the file was unable to be */ /* opened, or the default access mode is invalid. */ if (newfile.tptype == pUNKNOWN) @@ -1020,6 +1141,10 @@ /* Get the partition table for that dev. This may have to read it. */ table = tivo_read_partition_table (path, flags); +#if DEBUG + printf("Table: 0x%x\n", table); +#endif + /* Make sure the table and partition are valid. */ if (table && table->count >= partnum && partnum > 0) { Only in MFSTools-snapshot050221/lib: macpart.o diff -ru MFSTools-snapshot050221.orig/lib/mfs.c MFSTools-snapshot050221/lib/mfs.c --- MFSTools-snapshot050221.orig/lib/mfs.c 2005-02-21 17:00:07.000000000 -0800 +++ MFSTools-snapshot050221/lib/mfs.c 2007-03-30 19:14:03.000000000 -0700 @@ -145,6 +145,9 @@ mfshnd->vols = mfsvol_init (hda, hdb); if (!mfshnd->vols) { +#if DEBUG +printf("mfsvol_init failed.\n"); +#endif free (mfshnd); return -1; } @@ -152,18 +155,27 @@ /* Load the first volume by hand. */ if (mfsvol_add_volume (mfshnd->vols, cur_volume, flags) < 0) { +#if DEBUG +printf("mfsvol_add_volume failed.\n"); +#endif return -1; } /* Take care of loading the rest. */ if (mfs_load_volume_header (mfshnd, flags) <= 0) { +#if DEBUG +printf("mfsvol_load_volume_header failed.\n"); +#endif return -1; } /* Load the zone maps. */ if (mfs_load_zone_maps (mfshnd) < 0) { +#if DEBUG +printf("mfsvol_load_zone_map failed.\n"); +#endif return -1; } Only in MFSTools-snapshot050221/lib: mfs.o diff -ru MFSTools-snapshot050221.orig/lib/readwrite.c MFSTools-snapshot050221/lib/readwrite.c --- MFSTools-snapshot050221.orig/lib/readwrite.c 2005-02-20 21:29:44.000000000 -0800 +++ MFSTools-snapshot050221/lib/readwrite.c 2007-03-30 20:51:57.000000000 -0700 @@ -57,11 +57,11 @@ /* Do it 32 bits at a time if possible. */ while (size > 3) { -#if TARGET_OS_MAC - *idata = Endian32_Swap (*idata); -#else +// #if TARGET_OS_MAC + // *idata = Endian32_Swap (*idata); +// #else *idata = ((*idata << 8) & 0xff00ff00) | ((*idata & 0xff00ff00) >> 8); -#endif +// #endif size -= 4; idata++; } Only in MFSTools-snapshot050221/lib: readwrite.o diff -ru MFSTools-snapshot050221.orig/lib/volume.c MFSTools-snapshot050221/lib/volume.c --- MFSTools-snapshot050221.orig/lib/volume.c 2005-02-21 17:00:35.000000000 -0800 +++ MFSTools-snapshot050221/lib/volume.c 2007-03-30 19:17:49.000000000 -0700 @@ -89,15 +89,25 @@ if (!newvol) { +#if DEBUG + printf("mfsvol_add_volume: Out of memory error.\n"); +#endif hnd->err_msg = "Out of memory"; return -1; } /* Translate the device name to it's real world equivelent. */ +#if DEBUG + printf("mfsvol_add_volume: leading device path: %s\n", path); +#endif path = mfsvol_device_translate (hnd, path); - if (!path) + if (!path) { +#if DEBUG + printf("mfsvol_add_volume: mfsvol_device_translate failed.\n"); +#endif return -1; + } /* If the user requested RO, let them have it. This may break a writer */ /* program, but thats what it is intended to do. Also if fake_write is set, */ @@ -116,6 +126,9 @@ hnd->err_msg = "%s: %s"; hnd->err_arg1 = path; hnd->err_arg2 = strerror (errno); +#if DEBUG + printf("mfsvol_add_volume: mfsvol_partition_open failed. Volume was %s\n", path); +#endif return -1; } @@ -144,6 +157,9 @@ hnd->err_arg1 = path; tivo_partition_close (newvol->file); free (newvol); +#if DEBUG + printf("mfsvol_add_volume: Empty volume\n"); +#endif return -1; } Only in MFSTools-snapshot050221/lib: volume.o Only in MFSTools-snapshot050221/lib: zonemap.o Only in MFSTools-snapshot050221/mfsadd: Makefile Only in MFSTools-snapshot050221/mfsadd: libmfsadd.a Only in MFSTools-snapshot050221/mfsadd: mfsadd diff -ru MFSTools-snapshot050221.orig/mfsadd/mfsadd.c MFSTools-snapshot050221/mfsadd/mfsadd.c --- MFSTools-snapshot050221.orig/mfsadd/mfsadd.c 2005-02-21 16:17:29.000000000 -0800 +++ MFSTools-snapshot050221/mfsadd/mfsadd.c 2007-03-31 10:10:11.000000000 -0700 @@ -101,6 +101,11 @@ unsigned int part1, part2; int devn = xdevs[loop] == drives[0]? 0: 1; +#if DEBUG + printf("mfsadd_add_extends: maxfree %d totalfree %d used %d required %d\n", + maxfree, totalfree, used, required); +#endif + if (maxfree < 1024 * 1024 * 2) continue; @@ -248,6 +253,10 @@ if (isdigit (argv[optind][len - 1])) #endif { +#if DEBUG + printf("Partition %s\n", argv[optind]); +#endif + /* If the device is a partition, add that partition to the list. */ if (npairs + 4 >= sizeof (pairs) / sizeof (*pairs)) { @@ -259,6 +268,9 @@ } else { +#if DEBUG + printf("Drive %s\n", argv[optind]); +#endif /* If the device is a drive, set it as the A or B drive. */ if (!drives[0]) drives[0] = argv[optind]; Only in MFSTools-snapshot050221/mfsadd: mfsadd.o Only in MFSTools-snapshot050221/mfscopy: Makefile Only in MFSTools-snapshot050221/mfscopy: backup.o Only in MFSTools-snapshot050221/mfscopy: copy.o Only in MFSTools-snapshot050221/mfscopy: libmfscopy.a Only in MFSTools-snapshot050221/mfscopy: mfscopy Only in MFSTools-snapshot050221/mfscopy: restore.o Only in MFSTools-snapshot050221/mfsd: Makefile Only in MFSTools-snapshot050221/mfsd: libmfsd.a Only in MFSTools-snapshot050221/mfsd: mfsd Only in MFSTools-snapshot050221/mfsd: mfsd.o Only in MFSTools-snapshot050221/mfsinfo: Makefile Only in MFSTools-snapshot050221/mfsinfo: libmfsinfo.a Only in MFSTools-snapshot050221/mfsinfo: mfsinfo diff -ru MFSTools-snapshot050221.orig/mfsinfo/mfsinfo.c MFSTools-snapshot050221/mfsinfo/mfsinfo.c --- MFSTools-snapshot050221.orig/mfsinfo/mfsinfo.c 2005-02-21 16:19:38.000000000 -0800 +++ MFSTools-snapshot050221/mfsinfo/mfsinfo.c 2007-03-30 20:55:26.000000000 -0700 @@ -1,6 +1,7 @@ #include #include #include "mfs.h" +#include "config.h" void mfsinfo_usage (char *progname) @@ -102,7 +103,7 @@ mfsinfo_usage (argv[0]); return 1; } - +printf("Point a\n"); mfs = mfs_init (drives[0], drives[1], O_RDONLY); if (!mfs) { @@ -110,12 +111,14 @@ return 1; } +printf("Point b\n"); if (mfs_has_error (mfs)) { mfs_perror (mfs, argv[0]); return 1; } +printf("Point c\n"); fprintf (stderr, "MFS volume set for %s%s%s\n", drives[0], ndrives > 1? " and ": "", ndrives > 1? drives[1]: ""); nparts = partition_info (mfs, drives); Only in MFSTools-snapshot050221/mfsinfo: mfsinfo.o Only in MFSTools-snapshot050221/mfstool: Makefile Only in MFSTools-snapshot050221/mfstool: mfstool Only in MFSTools-snapshot050221/mfstool: mfstool.o Only in MFSTools-snapshot050221/mls: Makefile Only in MFSTools-snapshot050221/mls: libmls.a Only in MFSTools-snapshot050221/mls: mls Only in MFSTools-snapshot050221/mls: mls.o Only in MFSTools-snapshot050221: partition_table Only in MFSTools-snapshot050221/restore: Makefile Only in MFSTools-snapshot050221/restore: librestore.a Only in MFSTools-snapshot050221/restore: restmain.o Only in MFSTools-snapshot050221/restore: restore Only in MFSTools-snapshot050221/restore: restore.o