summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/update_to_1.95.patch
blob: ea2b16ccf9c8fd98bdcecb8e55660cf622e69b1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
See http://genext2fs.cvs.sourceforge.net/viewvc/genext2fs/genext2fs/genext2fs.c?view=log

The latest version of genext2fs.c is the v1.95 in the cvs repo:
http://genext2fs.cvs.sourceforge.net/viewvc/genext2fs/genext2fs/genext2fs.c?revision=1.95

First let's upgrade to the version.

Upstream-Status: inappropriate

Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>

--- a/genext2fs.c	2007-03-26 22:19:59.000000000 +0800
+++ b/genext2fs.c	2012-03-28 22:15:03.678856820 +0800
@@ -286,7 +286,9 @@
 // older solaris. Note that this is still not very portable, in that
 // the return value cannot be trusted.
 
-#if SCANF_CAN_MALLOC
+#if 0 // SCANF_CAN_MALLOC
+// C99 define "a" for floating point, so you can have runtime surprise
+// according the library versions
 # define SCANF_PREFIX "a"
 # define SCANF_STRING(s) (&s)
 #else
@@ -778,7 +780,7 @@
 		if(hdlinks.hdl[i].src_inode == inode)
 			return i;
 	}
-	return -1;		
+	return -1;
 }
 
 // printf helper macro
@@ -1356,20 +1358,23 @@
 	return nod;
 }
 
+// chmod an inode
+void
+chmod_fs(filesystem *fs, uint32 nod, uint16 mode, uint16 uid, uint16 gid)
+{
+	inode *node;
+	node = get_nod(fs, nod);
+	node->i_mode = (node->i_mode & ~FM_IMASK) | (mode & FM_IMASK);
+	node->i_uid = uid;
+	node->i_gid = gid;
+}
+
 // create a simple inode
 static uint32
 mknod_fs(filesystem *fs, uint32 parent_nod, const char *name, uint16 mode, uint16 uid, uint16 gid, uint8 major, uint8 minor, uint32 ctime, uint32 mtime)
 {
 	uint32 nod;
 	inode *node;
-	if((nod = find_dir(fs, parent_nod, name)))
-	{
-		node = get_nod(fs, nod);
-		if((node->i_mode & FM_IFMT) != (mode & FM_IFMT))
-			error_msg_and_die("node '%s' already exists and isn't of the same type", name);
-		node->i_mode = mode;
-	}
-	else
 	{
 		nod = alloc_nod(fs);
 		node = get_nod(fs, nod);
@@ -1591,13 +1596,24 @@
 				dname = malloc(len + 1);
 				for(i = start; i < count; i++)
 				{
+					uint32 oldnod;
 					SNPRINTF(dname, len, "%s%lu", name, i);
-					mknod_fs(fs, nod, dname, mode, uid, gid, major, minor + (i * increment - start), ctime, mtime);
+					oldnod = find_dir(fs, nod, dname);
+					if(oldnod)
+						chmod_fs(fs, oldnod, mode, uid, gid);
+					else
+						mknod_fs(fs, nod, dname, mode, uid, gid, major, minor + (i * increment - start), ctime, mtime);
 				}
 				free(dname);
 			}
 			else
-				mknod_fs(fs, nod, name, mode, uid, gid, major, minor, ctime, mtime);
+			{
+				uint32 oldnod = find_dir(fs, nod, name);
+				if(oldnod)
+					chmod_fs(fs, oldnod, mode, uid, gid);
+				else
+					mknod_fs(fs, nod, name, mode, uid, gid, major, minor, ctime, mtime);
+			}
 		}
 	}
 	if (line)
@@ -1664,6 +1680,17 @@
 			}
 		else
 		{
+			if((nod = find_dir(fs, this_nod, name)))
+			{
+				error_msg("ignoring duplicate entry %s", name);
+				if(S_ISDIR(st.st_mode)) {
+					if(chdir(dent->d_name) < 0)
+						perror_msg_and_die(name);
+					add2fs_from_dir(fs, nod, squash_uids, squash_perms, fs_timestamp, stats);
+					chdir("..");
+				}
+				continue;
+			}
 			save_nod = 0;
 			/* Check for hardlinks */
 			if (!S_ISDIR(st.st_mode) && !S_ISLNK(st.st_mode) && st.st_nlink > 1) {
@@ -1994,7 +2021,7 @@
 		//system blocks
 		for(j = 1; j <= overhead_per_group; j++)
 			allocate(bbm, j); 
-		
+
 		/* Inode bitmap */
 		ibm = get_blk(fs,fs->gd[i].bg_inode_bitmap);	
 		//non-filesystem inodes