Merge lp:~psusi/ubuntu/precise/parted/fix-dmsync into lp:ubuntu/precise/parted

Proposed by Phillip Susi
Status: Merged
Merge reported by: Stéphane Graber
Merged at revision: not available
Proposed branch: lp:~psusi/ubuntu/precise/parted/fix-dmsync
Merge into: lp:ubuntu/precise/parted
Diff against target: 221 lines (+97/-16)
3 files modified
debian/changelog (+7/-0)
debian/patches/dm-part-sync.patch (+88/-12)
debian/patches/udevadm-settle.patch (+2/-4)
To merge this branch: bzr merge lp:~psusi/ubuntu/precise/parted/fix-dmsync
Reviewer Review Type Date Requested Status
Bryce Harrington Approve
Ubuntu branches Pending
Review via email: mp+111995@code.launchpad.net
To post a comment you must log in.
111. By Phillip Susi

Fix dm-part-sync.patch to canonicalize the dm name when constructing
the partition device path (LP: #1012946)

Revision history for this message
Bryce Harrington (bryce) wrote :

Looks good, uploaded.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-03-20 20:24:21 +0000
3+++ debian/changelog 2012-07-17 14:36:20 +0000
4@@ -1,3 +1,10 @@
5+parted (2.3-8ubuntu5.1) precise; urgency=low
6+
7+ * Fix dm-part-sync.patch to canonicalize the dm name when constructing
8+ the partition device path (LP: #1012946)
9+
10+ -- Phillip Susi <psusi@ubuntu.com> Sat, 16 Jun 2012 21:26:34 -0400
11+
12 parted (2.3-8ubuntu5) precise; urgency=low
13
14 * Backport from upstream:
15
16=== modified file 'debian/patches/dm-part-sync.patch'
17--- debian/patches/dm-part-sync.patch 2012-01-13 19:49:30 +0000
18+++ debian/patches/dm-part-sync.patch 2012-07-17 14:36:20 +0000
19@@ -5,8 +5,6 @@
20 all partitions, then add new partitions method. Refactor to use the same
21 algorithm as regular disks: try to remove all, and ignore any that could not
22 be removed but have not changed.
23-Index: b/libparted/arch/linux.c
24-===================================================================
25 --- a/libparted/arch/linux.c
26 +++ b/libparted/arch/linux.c
27 @@ -270,6 +270,16 @@
28@@ -26,7 +24,83 @@
29
30
31 static int
32-@@ -2579,6 +2589,23 @@
33+@@ -2230,10 +2240,39 @@
34+ _probe_proc_partitions ();
35+ }
36+
37++static char *dm_canonical_path (PedDevice *dev)
38++{
39++ char* dev_name = NULL;
40++ LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
41++
42++ /* Get map name from devicemapper */
43++ struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
44++ if (!task)
45++ goto err;
46++ if (!dm_task_set_major_minor (task, arch_specific->major,
47++ arch_specific->minor, 0))
48++ goto err;
49++ if (!dm_task_run(task))
50++ goto err;
51++ dev_name = ped_malloc (strlen (dm_task_get_name (task)) +
52++ strlen ("/dev/mapper/") + 1);
53++ strcpy (dev_name, "/dev/mapper/");
54++ strcat (dev_name, dm_task_get_name (task));
55++ /* Caution: dm_task_destroy frees dev_name. */
56++ dm_task_destroy (task);
57++ return dev_name;
58++err:
59++ return NULL;
60++}
61++
62+ static char*
63+ _device_get_part_path (PedDevice* dev, int num)
64+ {
65+- int path_len = strlen (dev->path);
66++ char* devpath;
67++ if (dev->type == PED_DEVICE_DM)
68++ devpath = dm_canonical_path (dev);
69++ else devpath = dev->path;
70++ int path_len = strlen (devpath);
71+ int result_len = path_len + 16;
72+ char* result;
73+
74+@@ -2244,18 +2283,19 @@
75+ /* Check for devfs-style /disc => /partN transformation
76+ unconditionally; the system might be using udev with devfs rules,
77+ and if not the test is harmless. */
78+- if (!strcmp (dev->path + path_len - 5, "/disc")) {
79++ if (!strcmp (devpath + path_len - 5, "/disc")) {
80+ /* replace /disc with /path%d */
81+- strcpy (result, dev->path);
82++ strcpy (result, devpath);
83+ snprintf (result + path_len - 5, 16, "/part%d", num);
84+ } else if (dev->type == PED_DEVICE_DAC960
85+ || dev->type == PED_DEVICE_CPQARRAY
86+ || dev->type == PED_DEVICE_ATARAID
87+- || isdigit (dev->path[path_len - 1]))
88+- snprintf (result, result_len, "%sp%d", dev->path, num);
89++ || isdigit (devpath[path_len - 1]))
90++ snprintf (result, result_len, "%sp%d", devpath, num);
91+ else
92+- snprintf (result, result_len, "%s%d", dev->path, num);
93+-
94++ snprintf (result, result_len, "%s%d", devpath, num);
95++ if (dev->type == PED_DEVICE_DM)
96++ free (devpath);
97+ return result;
98+ }
99+
100+@@ -2542,6 +2582,8 @@
101+ FILE* fp;
102+ bool ok;
103+
104++ if (dev->type == PED_DEVICE_DM)
105++ return MAX_NUM_PARTS;
106+ r = snprintf(path, sizeof(path), "/sys/block/%s/ext_range",
107+ last_component(dev->path));
108+ if (r < 0 || r >= sizeof(path))
109+@@ -2579,6 +2621,23 @@
110 PED_ASSERT(disk->dev != NULL, return 0);
111 int lpn;
112
113@@ -50,7 +124,7 @@
114 /* lpn = largest partition number. */
115 if (ped_disk_get_max_supported_partition_count(disk, &lpn))
116 lpn = PED_MIN(lpn, _device_get_partition_range(disk->dev));
117-@@ -2612,7 +2639,7 @@
118+@@ -2612,7 +2671,7 @@
119 int j;
120 for (j = 0; j < lpn; j++) {
121 if (!ok[j]) {
122@@ -59,18 +133,20 @@
123 errnums[j] = errno;
124 if (!ok[j] && errnums[j] == EBUSY)
125 busy = true;
126-@@ -2629,8 +2656,8 @@
127+@@ -2629,9 +2688,9 @@
128 unsigned long long length;
129 unsigned long long start;
130 /* get start and length of existing partition */
131 - if (!_kernel_get_partition_start_and_length(part,
132 - &start, &length))
133+- goto cleanup;
134 + if (!get_partition_start_and_length(part,
135 + &start, &length))
136- goto cleanup;
137++ goto cleanup;
138 if (start == part->geom.start
139 && length == part->geom.length)
140-@@ -2643,7 +2670,7 @@
141+ ok[i - 1] = 1;
142+@@ -2643,7 +2702,7 @@
143 }
144
145 /* add the (possibly modified or new) partition */
146@@ -79,7 +155,7 @@
147 ped_exception_throw (
148 PED_EXCEPTION_ERROR,
149 PED_EXCEPTION_RETRY_CANCEL,
150-@@ -2691,24 +2718,34 @@
151+@@ -2691,24 +2750,34 @@
152
153 #ifdef ENABLE_DEVICE_MAPPER
154 static int
155@@ -122,7 +198,7 @@
156 }
157
158 /* We consider a dm device that is a linear mapping with a *
159-@@ -2762,65 +2799,38 @@
160+@@ -2762,65 +2831,38 @@
161 return rc;
162 }
163
164@@ -211,7 +287,7 @@
165 {
166 char* vol_name = NULL;
167 const char* dev_name = NULL;
168-@@ -2873,7 +2883,7 @@
169+@@ -2873,7 +2915,7 @@
170 free(vol_name);
171 return 1;
172 } else {
173@@ -220,7 +296,7 @@
174 }
175 err:
176 dm_task_update_nodes();
177-@@ -2883,34 +2893,6 @@
178+@@ -2883,34 +2925,6 @@
179 free (vol_name);
180 return 0;
181 }
182@@ -255,7 +331,7 @@
183 #endif
184
185 static int
186-@@ -2933,10 +2915,6 @@
187+@@ -2933,10 +2947,6 @@
188 if (!_has_partitions (disk))
189 return 1;
190
191
192=== modified file 'debian/patches/udevadm-settle.patch'
193--- debian/patches/udevadm-settle.patch 2012-01-13 19:49:30 +0000
194+++ debian/patches/udevadm-settle.patch 2012-07-17 14:36:20 +0000
195@@ -7,8 +7,6 @@
196 This should be replaced by a proper completion-notification mechanism
197 between the kernel and udev.
198
199-Index: b/libparted/arch/linux.c
200-===================================================================
201 --- a/libparted/arch/linux.c
202 +++ b/libparted/arch/linux.c
203 @@ -26,6 +26,7 @@
204@@ -19,7 +17,7 @@
205 #include <ctype.h>
206 #include <errno.h>
207 #include <fcntl.h>
208-@@ -2908,13 +2909,55 @@
209+@@ -2940,13 +2941,55 @@
210 return have_blkpg = kver >= KERNEL_VERSION (2,4,0) ? 1 : 0;
211 }
212
213@@ -75,7 +73,7 @@
214 if (disk->dev->type != PED_DEVICE_FILE) {
215
216 /* We now require BLKPG support. If this assertion fails,
217-@@ -2924,10 +2967,20 @@
218+@@ -2956,10 +2999,20 @@
219 assert (_have_blkpg ());
220
221 if (!_disk_sync_part_table (disk))

Subscribers

People subscribed via source and target branches

to all changes: