Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37795661
en ru br
ALT Linux repos
S:0.2.2-alt11
5.0: 0.2.2-alt2
4.1: 0.2.2-alt1
4.0: 0.2.0-alt6.1
3.0: 0.2.0-alt6

Group :: System/Kernel and hardware
RPM: e2fsimage

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: e2fsimage-0.2.2-symlinks-rootpath.patch
Download


diff -urN e2fsimage-0.2.2.orig/src/e2fsimage.h e2fsimage-0.2.2/src/e2fsimage.h
--- e2fsimage-0.2.2.orig/src/e2fsimage.h	2006-01-12 00:08:58 +0200
+++ e2fsimage-0.2.2/src/e2fsimage.h	2008-02-21 00:34:21 +0200
@@ -113,6 +113,7 @@
 	ext2_filsys fs;
 	ext2_ino_t curr_e2dir;
 	const char *curr_path;
+	const char *root_path;
 
 	inodb_t *ino_db;
 	uiddb_t *uid_db;
diff -urN e2fsimage-0.2.2.orig/src/main.c e2fsimage-0.2.2/src/main.c
--- e2fsimage-0.2.2.orig/src/main.c	2006-01-11 23:57:27 +0200
+++ e2fsimage-0.2.2/src/main.c	2008-02-21 00:33:31 +0200
@@ -129,7 +129,7 @@
 			case 'u': e2c.default_uid = atoi(optarg); break;
 			case 'g': e2c.default_gid = atoi(optarg); break;
 			case 'f': e2fsfile = optarg; break;
-			case 'd': e2c.curr_path = optarg; break;
+			case 'd': e2c.root_path = e2c.curr_path = optarg; break;
 			case 'h': usage(argv[0]); return 0;
 			case 'n': create = 0; break;
 			case 's': ksize = getsize(optarg); break;
diff -urN e2fsimage-0.2.2.orig/src/symlink.c e2fsimage-0.2.2/src/symlink.c
--- e2fsimage-0.2.2.orig/src/symlink.c	2005-05-25 21:06:52 +0300
+++ e2fsimage-0.2.2/src/symlink.c	2008-02-21 00:37:06 +0200
@@ -56,6 +56,8 @@
 	struct ext2_inode inode;
 	int ret, written;
 	char buf[SYM_BUF_SIZE];
+	char * root_ptr;
+	char *tmpptr;
 	off_t size = 0;
 	struct stat s;
 	
@@ -74,6 +76,30 @@
 	
 	/* populate the new inode */
 	ext2fs_inode_alloc_stats(e2c->fs, e2ino, 1);
+
+	/* open the source file */
+	size = readlink(e2c->curr_path, buf, SYM_BUF_SIZE);
+	if (size < 0 || size >= SYM_BUF_SIZE) {
+		fprintf(stderr, "Error reading symlink '%s': %s\n", e2c->curr_path, strerror(errno));
+		return -1;
+	}
+	
+	e2c->cnt->softln++;
+
+	if (e2c->root_path != NULL) { 
+	    root_ptr = strstr(buf, e2c->root_path);
+    	    if (root_ptr != buf) {
+		tmpptr = buf;
+	    } else {
+		tmpptr = buf + strlen(e2c->root_path);
+	    }
+	    strcpy(buf, tmpptr);
+	}
+
+	if (e2c->verbose)
+		printf("Copying symlink %s -> %s\n",e2c->curr_path,buf);
+	
+	s.st_size = strlen(buf);	
 	
 	init_inode(e2c, &inode, &s);
 
@@ -91,12 +117,23 @@
 		return -1;
 	}
 	
+	e2c->cnt->softln++;
+
+	if (e2c->root_path != NULL) { 
+	    root_ptr = strstr(buf, e2c->root_path);
+    	    if (root_ptr != buf) {
+		tmpptr = buf;
+	    } else {
+		tmpptr = buf + strlen(e2c->root_path);
+	    }
+	    strcpy(buf, tmpptr);
+	}
+
 	if (e2c->verbose)
-		printf("Copying symlink %s\n",e2c->curr_path);
+		printf("Copying symlink %i %i %s -> %s\n",strlen(buf), size, e2c->curr_path,buf);
 	
-	e2c->cnt->softln++;
 	
-	ret = ext2fs_file_write(e2file, buf, size, &written);
+	ret = ext2fs_file_write(e2file, buf, strlen(buf), &written);
 	if (ret) {
 		fprintf(stderr, "Error writing ext2 symlink (%s)\n", error_message(ret));
 		ext2fs_file_close(e2file);
@@ -106,7 +143,7 @@
 	ext2fs_file_close(e2file);
 	
 	/* if this sizes differ its an inconsistency in the base filesystem */
-	if (size != written) {
+	if (strlen(buf) != written) {
 		fprintf(stderr, "Error 'size matters' Size:%ld, Written:%d\n", size, written);
 		return -1;
 	}
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin