summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Zoffoli <xmerlin@gentoo.org>2005-03-31 20:57:46 +0000
committerChristian Zoffoli <xmerlin@gentoo.org>2005-03-31 20:57:46 +0000
commit8df5d47887e37f8caca3ebadb434757e172a3c94 (patch)
tree0ff97364df39eba684972335c27db0cfd284eec8 /sys-block/partimage/files
parentstable amd64 (diff)
downloadgentoo-2-8df5d47887e37f8caca3ebadb434757e172a3c94.tar.gz
gentoo-2-8df5d47887e37f8caca3ebadb434757e172a3c94.tar.bz2
gentoo-2-8df5d47887e37f8caca3ebadb434757e172a3c94.zip
backported some fixes from mdk (64-bit & lib64 fixes, fflush before re-read partition table, added save all and rest all actions)
(Portage version: 2.0.51.19)
Diffstat (limited to 'sys-block/partimage/files')
-rw-r--r--sys-block/partimage/files/digest-partimage-0.6.4-r31
-rw-r--r--sys-block/partimage/files/partimage-0.6.4-LP64-fixes.patch60
-rw-r--r--sys-block/partimage/files/partimage-0.6.4-fflush-before-re-read-partition-table.patch11
-rw-r--r--sys-block/partimage/files/partimage-0.6.4-lib64.patch44
-rw-r--r--sys-block/partimage/files/partimage-0.6.4-save_all_and_rest_all_actions.patch335
5 files changed, 451 insertions, 0 deletions
diff --git a/sys-block/partimage/files/digest-partimage-0.6.4-r3 b/sys-block/partimage/files/digest-partimage-0.6.4-r3
new file mode 100644
index 000000000000..f525923985b4
--- /dev/null
+++ b/sys-block/partimage/files/digest-partimage-0.6.4-r3
@@ -0,0 +1 @@
+MD5 ee56df4a6be1f78f53dc48454655aa8a partimage-0.6.4.tar.bz2 654707
diff --git a/sys-block/partimage/files/partimage-0.6.4-LP64-fixes.patch b/sys-block/partimage/files/partimage-0.6.4-LP64-fixes.patch
new file mode 100644
index 000000000000..3880067e6340
--- /dev/null
+++ b/sys-block/partimage/files/partimage-0.6.4-LP64-fixes.patch
@@ -0,0 +1,60 @@
+--- partimage-0.6.4/src/client/fs/fs_xfs.h.LP64-fixes 2004-02-03 19:57:36.000000000 -0500
++++ partimage-0.6.4/src/client/fs/fs_xfs.h 2005-02-21 10:25:06.220053947 -0500
+@@ -19,6 +19,7 @@
+ #define FS_XFS_H
+
+ #include <ctype.h>
++#include <stdint.h>
+
+ #include "partimage.h"
+ #include "common.h"
+@@ -99,22 +100,14 @@ class CRestoringWindow;
+ #define XFS_BTNUM_INO ((xfs_btnum_t)XFS_BTNUM_INOi)
+
+ #define XFS_SB_MAGIC 0x58465342 // 'XFSB'
+-typedef signed char __int8_t;
+-typedef unsigned char __uint8_t;
+-typedef signed short int __int16_t;
+-typedef unsigned short int __uint16_t;
+-typedef signed int __int32_t;
+-typedef unsigned int __uint32_t;
+-#ifdef __ia64__
+-typedef signed long int __int64_t;
+-typedef unsigned long int __uint64_t;
+-#elif __alpha__
+-typedef signed long int __int64_t;
+-typedef unsigned long int __uint64_t;
+-#else
+-typedef signed long long int __int64_t;
+-typedef unsigned long long int __uint64_t;
+-#endif
++typedef int8_t __int8_t;
++typedef uint8_t __uint8_t;
++typedef int16_t __int16_t;
++typedef uint16_t __uint16_t;
++typedef int32_t __int32_t;
++typedef uint32_t __uint32_t;
++typedef int64_t __int64_t;
++typedef uint64_t __uint64_t;
+
+ // POSIX Extensions
+ typedef unsigned char uchar_t;
+@@ -157,16 +150,8 @@ typedef __uint64_t xfs_drtbno_t; // exte
+ typedef __uint64_t xfs_dfiloff_t; // block number in a file
+ typedef __uint64_t xfs_dfilblks_t; // number of blocks in a file
+
+-#ifdef __ia64__
+-typedef unsigned long __u64;
+-typedef signed long __s64;
+-#elif __alpha__
+-typedef unsigned long __u64;
+-typedef signed long __s64;
+-#else
+-typedef unsigned long long __u64;
+-typedef signed long long __s64;
+-#endif
++typedef uint64_t __u64;
++typedef int64_t __s64;
+
+ typedef __u64 xfs_off_t;
+ //typedef __s32 xfs32_off_t;
diff --git a/sys-block/partimage/files/partimage-0.6.4-fflush-before-re-read-partition-table.patch b/sys-block/partimage/files/partimage-0.6.4-fflush-before-re-read-partition-table.patch
new file mode 100644
index 000000000000..f60a5bc27489
--- /dev/null
+++ b/sys-block/partimage/files/partimage-0.6.4-fflush-before-re-read-partition-table.patch
@@ -0,0 +1,11 @@
+--- partimage-0.6.4/src/client/misc.cpp.pix 2004-02-05 21:19:00.000000000 +0100
++++ partimage-0.6.4/src/client/misc.cpp 2005-01-21 11:43:19.439462188 +0100
+@@ -294,6 +294,8 @@
+ nRes = fwrite(mbrOriginal[dwOriginalMbrNb].cData+MBR_SIZE_BOOT, MBR_SIZE_TABLE+2, 1, fDevice); // table + 0xAA55
+ }
+
++ fflush(fDevice);
++
+ // re-read partition table
+ if (ioctl(fileno(fDevice), BLKRRPART))
+ {
diff --git a/sys-block/partimage/files/partimage-0.6.4-lib64.patch b/sys-block/partimage/files/partimage-0.6.4-lib64.patch
new file mode 100644
index 000000000000..19bbf154c4b8
--- /dev/null
+++ b/sys-block/partimage/files/partimage-0.6.4-lib64.patch
@@ -0,0 +1,44 @@
+--- partimage-0.6.4/src/client/Makefile.am.chris 2005-03-29 13:34:39.129627648 +0200
++++ partimage-0.6.4/src/client/Makefile.am 2005-03-29 13:34:49.238090928 +0200
+@@ -33,7 +33,7 @@
+ mbr_backup.cpp
+
+ # all libs are added in LIBS, we needn't add them to partimage_LDADD
+-partimage_LDADD = -L/usr/lib -lslang fs/libfs.a ../shared/libshared.a
++partimage_LDADD = -L$(libdir) -lslang fs/libfs.a ../shared/libshared.a
+ partimage_LDFLAGS = @PARTIMAGE_LDFLAGS@
+
+ DEFS=@DEFS@ -DLOCALEDIR=\"${localedir}\" -D_REENTRANT -D_FILE_OFFSET_BITS=64
+--- partimage-0.6.4/src/client/Makefile.in.chris 2005-03-29 13:33:23.625106080 +0200
++++ partimage-0.6.4/src/client/Makefile.in 2005-03-29 13:33:53.689535592 +0200
+@@ -253,7 +253,7 @@
+
+
+ # all libs are added in LIBS, we needn't add them to partimage_LDADD
+-partimage_LDADD = -L/usr/lib -lslang fs/libfs.a ../shared/libshared.a
++partimage_LDADD = -L$(libdir) -lslang fs/libfs.a ../shared/libshared.a
+ partimage_LDFLAGS = @PARTIMAGE_LDFLAGS@
+ MAINTAINERCLEANFILES = Makefile.in
+ all: all-recursive
+--- partimage-0.6.4/src/server/Makefile.am.chris 2005-03-29 13:34:55.995063712 +0200
++++ partimage-0.6.4/src/server/Makefile.am 2005-03-29 13:35:05.279652240 +0200
+@@ -21,7 +21,7 @@
+ partimaged-gui_dummy.h partimaged-gui_newt.h partimaged.h
+
+ #partimaged_LDADD = -L/usr/lib -lz -lbz2 -lnewt -lpthread -lcrypt -lslang -lcom_err -lext2fs ../shared/libshared.a
+-partimaged_LDADD = -L/usr/lib -lslang ../shared/libshared.a
++partimaged_LDADD = -L$(libdir) -lslang ../shared/libshared.a
+
+ partimaged_LDFLAGS = @PARTIMAGE_LDFLAGS@
+
+--- partimage-0.6.4/src/server/Makefile.in.chris 2005-03-29 13:34:10.496980472 +0200
++++ partimage-0.6.4/src/server/Makefile.in 2005-03-29 13:34:32.172685264 +0200
+@@ -231,7 +231,7 @@
+
+
+ #partimaged_LDADD = -L/usr/lib -lz -lbz2 -lnewt -lpthread -lcrypt -lslang -lcom_err -lext2fs ../shared/libshared.a
+-partimaged_LDADD = -L/usr/lib -lslang ../shared/libshared.a
++partimaged_LDADD = -L$(libdir) -lslang ../shared/libshared.a
+ partimaged_LDFLAGS = @PARTIMAGE_LDFLAGS@
+ MAINTAINERCLEANFILES = Makefile.in
+ all: all-am
diff --git a/sys-block/partimage/files/partimage-0.6.4-save_all_and_rest_all_actions.patch b/sys-block/partimage/files/partimage-0.6.4-save_all_and_rest_all_actions.patch
new file mode 100644
index 000000000000..581373e8ceaa
--- /dev/null
+++ b/sys-block/partimage/files/partimage-0.6.4-save_all_and_rest_all_actions.patch
@@ -0,0 +1,335 @@
+--- partimage-0.6.4/src/client/main.cpp.pix 2004-02-04 01:57:36.000000000 +0100
++++ partimage-0.6.4/src/client/main.cpp 2005-01-24 13:46:19.388390009 +0100
+@@ -142,6 +142,7 @@
+ int nChoice;
+ char szDevice[MAX_DEVICENAMELEN];
+ char szImageFile[MAXPATHLEN];
++ char szImageDir[MAXPATHLEN];
+ char szTemp[2048];
+ char szTemp2[1024];
+ char szTemp3[1024];
+@@ -505,13 +506,17 @@
+ if (argc - optind == 2) // commands with 1 parameter
+ {
+ showDebug(8, "full cmdline with 1 param\n");
+- strncpy(szImageFile, argv[optind+1], MAXPATHLEN);
+-
+ if (strcmp(argv[optind], "restmbr")==0) // restore an MBR
+ nChoice = OPERATION_RESTMBR;
+ else if (strcmp(argv[optind], "imginfo")==0)
+ // show informations about the imagefile
+ nChoice = OPERATION_IMGINFO;
++ else if (strcmp(argv[optind], "save_all")==0)
++ nChoice = OPERATION_SAVE_ALL;
++ else if (strcmp(argv[optind], "rest_all")==0)
++ nChoice = OPERATION_REST_ALL;
++
++ strncpy(nChoice == OPERATION_REST_ALL || nChoice == OPERATION_SAVE_ALL ? szImageDir : szImageFile, argv[optind+1], MAXPATHLEN);
+ }
+
+ // check options
+@@ -644,6 +649,38 @@
+ nRes = -1;
+ }
+ break;
++
++ case OPERATION_SAVE_ALL:
++ showDebug(1, "action=SAVE_ALL\n");
++ try { save_all(szImageDir, &options); }
++ catch (CExceptions *excep)
++ {
++ showDebug(1, "caught exception: %d\n", excep->GetExcept());
++
++ if (!options.bBatchMode && !excep->getCaught())
++ g_interface -> Error(excep, szImageFile);
++
++ showDebug(1, "\nFINAL ERROR\n\n");
++
++ nRes = -1;
++ }
++ break;
++
++ case OPERATION_REST_ALL:
++ showDebug(1, "action=REST_ALL\n");
++ try { rest_all(szImageDir, &options); }
++ catch (CExceptions *excep)
++ {
++ showDebug(1, "caught exception: %d\n", excep->GetExcept());
++
++ if (!options.bBatchMode && !excep->getCaught())
++ g_interface -> Error(excep, szImageFile);
++
++ showDebug(1, "\nFINAL ERROR\n\n");
++
++ nRes = -1;
++ }
++ break;
+
+ default: // exit
+ if (options.bSync)
+--- partimage-0.6.4/src/client/misc.cpp.pix 2005-01-24 13:46:19.382388046 +0100
++++ partimage-0.6.4/src/client/misc.cpp 2005-01-24 14:39:16.454532386 +0100
+@@ -2274,3 +2274,231 @@
+ strcpy(szFileSystem, "befs");
+ RETURN_int(FS_BEFS);
+ }
++
++static int str_begins_with(const char *s, const char *prefix)
++{
++ return strncmp(s, prefix, strlen(prefix)) == 0;
++}
++
++static char *sfdisk_line_to_disk_device(const char *line)
++{
++ static const char *new_disk_prefix = "# partition table of ";
++ if (str_begins_with(line, new_disk_prefix)) {
++ const char *device = line + strlen(new_disk_prefix);
++ return strndup(device, strlen(device) - 1);
++ } else {
++ return NULL;
++ }
++}
++
++static char *sfdisk_line_to_partition_device(const char *line)
++{
++ if (char *p = strchr(line, ':')) {
++ while (p[-1] == ' ' && p > line) p--;
++ return strndup(line, p - line);
++ } else {
++ return NULL;
++ }
++}
++
++static char *full_device_to_device(char *device)
++{
++ char *p;
++ if (str_begins_with(device, "/dev/")) {
++ p = device + strlen("/dev/");
++ } else {
++ showDebug(2, "full_device_to_device: weird device %s\n", device);
++ p = strrchr(device, '/');
++ p = p ? p + 1 : device;
++ }
++ p = strdup(p);
++ char *q;
++ while (q = strchr(p, '/')) *q = '_';
++
++ return p;
++}
++
++static void my_pclose(FILE *f)
++{
++ int status = pclose(f);
++ if (status != 0) showDebug(1, "ERROR: command failed (%d)\n", status);
++}
++
++static void write_unsigned(CImage *image, unsigned int nb)
++{
++ image->write((char *) &nb, sizeof(nb), true);
++}
++static void write_string(CImage *image, const char *s)
++{
++ unsigned int len = strlen(s);
++ write_unsigned(image, len);
++ image->write((void *) s, len, true);
++}
++static unsigned int read_unsigned(CImage *image)
++{
++ unsigned int nb;
++ image->read((char *) &nb, sizeof(nb), true);
++ return nb;
++}
++static char *read_string(CImage *image)
++{
++ unsigned int len = read_unsigned(image);
++ if (len == 0) return NULL;
++ char *s = (char *) malloc(len + 1);
++ image->read(s, len, true);
++ s[len] = '\0';
++ return s;
++}
++
++void save_all(char *szImageDir, COptions *options)
++{
++ BEGIN;
++
++ char *sfdisk[1024];
++ unsigned int sfdisk_nb_lines = 0;
++ {
++ FILE *f = popen("LC_ALL=C sfdisk -d", "r");
++ char tmp[1024];
++
++ while (1) {
++ if (!fgets(tmp, sizeof(tmp), f)) break;
++ if (sfdisk_nb_lines >= sizeof(sfdisk)) break;
++ sfdisk[sfdisk_nb_lines++] = strdup(tmp);
++ }
++ my_pclose(f);
++ }
++
++ char aux[MAXPATHLEN];
++ CImage image(options);
++ SNPRINTF(aux, "%s/sfdisk.lst", szImageDir);
++ image.set_szImageFilename(aux);
++ image.openWriting();
++
++ write_unsigned(&image, sfdisk_nb_lines);
++
++ for (unsigned int i = 0; i < sfdisk_nb_lines; i++)
++ write_string(&image, sfdisk[i]);
++
++ for (unsigned int i = 0; i < sfdisk_nb_lines; i++)
++ if (char *device = sfdisk_line_to_disk_device(sfdisk[i])) {
++ showDebug(2, "opening %s to get its MBR\n", device);
++ FILE *f = fopen(device, "r");
++ char mbr[512];
++ if (f && fread(mbr, 512, 1, f) == 1) {
++ write_string(&image, device);
++ image.write(mbr, sizeof(mbr), true);
++ } else
++ showDebug(1, "ERROR: can't read MBR of device %s\n", device);
++ if (f) fclose(f);
++ }
++ write_unsigned(&image, 0);
++
++ closeFilesSave(false, *options, &image, NULL);
++
++ COptions save_part_options(*options);
++ save_part_options.qwSplitSize = 0;
++ save_part_options.bAskDesc = false;
++ save_part_options.bBackupMBR = false;
++ save_part_options.bCheckBeforeSaving = false; // checking always find an error, so...
++
++ for (unsigned int i = 0; i < sfdisk_nb_lines; i++) {
++ if (!strstr(sfdisk[i], "Id=83")) continue;
++
++ char *device = sfdisk_line_to_partition_device(sfdisk[i]);
++ if (!device) continue;
++
++ char *short_device = full_device_to_device(device);
++ SNPRINTF(aux, "%s/part_%s", szImageDir, short_device);
++ free(short_device);
++ showDebug(1, "savePartition(%s, %s, ...)\n", device, aux);
++ savePartition(device, aux, &save_part_options);
++
++ free(device);
++ }
++
++ RETURN;
++}
++
++void rest_all(char *szImageDir, COptions *options)
++{
++ BEGIN;
++
++ char **sfdisk;
++ unsigned int sfdisk_nb_lines = 0;
++
++ char aux[MAXPATHLEN];
++ CImage image(options);
++
++ {
++ SNPRINTF(aux, "%s/sfdisk.lst", szImageDir);
++ image.set_szImageFilename(aux);
++ image.openReading();
++
++ sfdisk_nb_lines = read_unsigned(&image);
++ showDebug(2, "rest_all got sfdisk_nb_lines = %d\n", sfdisk_nb_lines);
++ sfdisk = (char **) alloca(sizeof(char *) * sfdisk_nb_lines);
++ for (unsigned int i = 0; i < sfdisk_nb_lines; i++) {
++ sfdisk[i] = read_string(&image);
++ showDebug(2, "rest_all got line = %s\n", sfdisk[i]);
++ }
++ while (1) {
++ char *device = read_string(&image);
++ if (!device) break;
++
++ char mbr[512];
++ image.read(mbr, 512, true);
++
++ FILE *f = fopen(device, "r+b");
++ if (f && fwrite(mbr, 512, 1, f) == 1)
++ showDebug(1, "MBR of %s restored\n", device);
++ else
++ showDebug(1, "ERROR: restoring MBR of device %s failed: %s\n", device, strerror(errno));
++ if (f) fclose(f);
++ }
++
++ // since sfdisk.lst is not really nice to the library, we can't close the thread from procReadBufferFromImage which has already exited
++ image.closeReading(false);
++ }
++
++ {
++ FILE *f = NULL;
++ for (unsigned int i = 0; i < sfdisk_nb_lines; i++) {
++ if (char *device = sfdisk_line_to_disk_device(sfdisk[i])) {
++ if (f) my_pclose(f);
++ SNPRINTF(aux, "sfdisk %s >>" PARTIMAGE_LOG " 2>>" PARTIMAGE_LOG, device);
++ showDebug(1, "calling %s\n", aux);
++ f = popen(aux, "w");
++ free(device);
++ }
++ if (f)
++ fputs(sfdisk[i], f);
++ else
++ showDebug(1, "dropping line: %s", sfdisk[i]);
++ }
++ if (f) my_pclose(f);
++ }
++
++ for (unsigned int i = 0; i < sfdisk_nb_lines; i++) {
++
++ char *device = sfdisk_line_to_partition_device(sfdisk[i]);
++ if (!device) continue;
++
++ if (strstr(sfdisk[i], "Id=83")) {
++ char *short_device = full_device_to_device(device);
++ SNPRINTF(aux, "%s/part_%s", szImageDir, short_device);
++ free(short_device);
++ if (image.getImageDisk()->doesFileExists(aux)) {
++ showDebug(1, "restorePartition(%s, %s, ...)\n", device, aux);
++ restorePartition(device, aux, options);
++ } else
++ showDebug(1, "no such %s image disk, not restoring it\n", aux);
++ } else if (strstr(sfdisk[i], "Id=82")) {
++ SNPRINTF(aux, "mkswap %s >>" PARTIMAGE_LOG, device);
++ showDebug(2, "%s\n", aux);
++ system(aux);
++ }
++ free(device);
++ }
++
++ RETURN;
++}
+--- partimage-0.6.4/src/client/misc.h.pix 2004-02-04 01:57:36.000000000 +0100
++++ partimage-0.6.4/src/client/misc.h 2005-01-24 13:46:19.390390663 +0100
+@@ -47,6 +47,8 @@
+ void savePartition(char *szDevice, char *szImageName, /*char *szFilesystem, */COptions *options);
+ void restorePartition(char *szDevice, char *szImageName, COptions *options);
+ void restoreMbr(char *szImageFile, COptions *options);
++void save_all(char *szImageDir, COptions *options);
++void rest_all(char *szImageDir, COptions *options);
+
+ // =======================================================
+ void closeFilesSave(bool on_error, COptions options, CImage *image, FILE *fDeviceFile);
+--- partimage-0.6.4/src/client/partimage.h.pix 2004-02-04 01:57:36.000000000 +0100
++++ partimage-0.6.4/src/client/partimage.h 2005-01-24 13:46:19.390390663 +0100
+@@ -94,6 +94,8 @@
+ #define OPERATION_RESTMBR 3
+ #define OPERATION_IMGINFO 4
+ #define OPERATION_EXIT 5
++#define OPERATION_SAVE_ALL 6
++#define OPERATION_REST_ALL 7
+
+ // returned by CExceptionsGUI::windowError
+ // user canceled the job
+--- partimage-0.6.4/src/shared/image_disk.cpp.pix 2004-02-04 01:57:36.000000000 +0100
++++ partimage-0.6.4/src/shared/image_disk.cpp 2005-01-24 13:46:19.391390990 +0100
+@@ -526,6 +526,7 @@
+
+ SNPRINTF(szShortName, "pi%.8lx", (DWORD)generateIdentificator());
+ extractFilepathFromFullPath(m_szImageFilename, szPathDir); // filepath without filename
++ if (access(szPathDir, R_OK) == -1) mkdir(szPathDir, 0755);
+ snprintf(m_szSpaceFilename, MAXPATHLEN, "%s/%8s.tmp", szPathDir, szShortName);
+ showDebug(1, "TEMP=[%s]\n", m_szSpaceFilename);
+