Merge lp:~psusi/ubuntu/raring/grub2/fix-ldm into lp:ubuntu/raring/grub2

Proposed by Phillip Susi
Status: Work in progress
Proposed branch: lp:~psusi/ubuntu/raring/grub2/fix-ldm
Merge into: lp:ubuntu/raring/grub2
Diff against target: 2237 lines (+2103/-3)
10 files modified
.pc/applied-patches (+1/-0)
.pc/ldm-require-sfs-partition.patch/Makefile.util.def (+783/-0)
.pc/ldm-require-sfs-partition.patch/grub-core/disk/ldm.c (+1010/-0)
.pc/ldm-require-sfs-partition.patch/include/grub/msdos_partition.h (+126/-0)
Makefile.util.def (+1/-1)
debian/changelog (+7/-0)
debian/patches/ldm-require-sfs-partition.patch (+136/-0)
debian/patches/series (+1/-0)
grub-core/disk/ldm.c (+37/-2)
include/grub/msdos_partition.h (+1/-0)
To merge this branch: bzr merge lp:~psusi/ubuntu/raring/grub2/fix-ldm
Reviewer Review Type Date Requested Status
Colin Watson Pending
Review via email: mp+137588@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

I'll look at this, but this belongs at least in Debian rather than landing directly in Ubuntu, and I want to look at its upstream status first. Please could other sponsors leave this one alone for now?

Revision history for this message
Stéphane Graber (stgraber) wrote :

Hi Colin,

I assigned the review to you and marked the branch as Work in progress, this should make it disappear from the sponsoring report, that way no sponsor will touch it and it should avoid having people read through it over and over again.

Unmerged revisions

163. By Phillip Susi

debian/ldm-require-sfs-partition.patch: Only recognize ldm partition
table if there is an SFS partition listed in the DOS MBR (LP: #1061255)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.pc/applied-patches'
2--- .pc/applied-patches 2012-10-31 10:36:57 +0000
3+++ .pc/applied-patches 2012-12-03 15:02:19 +0000
4@@ -56,3 +56,4 @@
5 ubuntu_mount_readdir_symlink_failures.patch
6 ubuntu_initrd_addr_min.patch
7 ubuntu_gnulib_gets.patch
8+ldm-require-sfs-partition.patch
9
10=== added directory '.pc/ldm-require-sfs-partition.patch'
11=== added file '.pc/ldm-require-sfs-partition.patch/.timestamp'
12=== added file '.pc/ldm-require-sfs-partition.patch/Makefile.util.def'
13--- .pc/ldm-require-sfs-partition.patch/Makefile.util.def 1970-01-01 00:00:00 +0000
14+++ .pc/ldm-require-sfs-partition.patch/Makefile.util.def 2012-12-03 15:02:19 +0000
15@@ -0,0 +1,783 @@
16+AutoGen definitions Makefile.tpl;
17+
18+library = {
19+ name = libgrubkern.a;
20+ cflags = '$(CFLAGS_GNULIB)';
21+ cppflags = '$(CPPFLAGS_GNULIB)';
22+
23+ common = util/misc.c;
24+ common = grub-core/kern/command.c;
25+ common = grub-core/kern/device.c;
26+ common = grub-core/kern/disk.c;
27+ common = util/getroot.c;
28+ common = util/raid.c;
29+ common = grub-core/kern/emu/hostdisk.c;
30+ common = grub-core/kern/emu/misc.c;
31+ common = grub-core/kern/emu/mm.c;
32+ common = grub-core/kern/env.c;
33+ common = grub-core/kern/err.c;
34+ common = grub-core/kern/file.c;
35+ common = grub-core/kern/fs.c;
36+ common = grub-core/kern/list.c;
37+ common = grub-core/kern/misc.c;
38+ common = grub-core/kern/partition.c;
39+ common = grub-core/lib/crypto.c;
40+ common = grub-core/disk/luks.c;
41+ common = grub-core/disk/geli.c;
42+ common = grub-core/disk/cryptodisk.c;
43+ common = grub-core/disk/AFSplitter.c;
44+ common = grub-core/lib/pbkdf2.c;
45+ common = grub-core/commands/extcmd.c;
46+ common = grub-core/lib/arg.c;
47+ common = grub-core/disk/ldm.c;
48+ common = grub-core/disk/diskfilter.c;
49+ common = grub-core/partmap/gpt.c;
50+};
51+
52+library = {
53+ name = libgrubmods.a;
54+ cflags = '$(CFLAGS_POSIX) -Wno-undef -Wno-error=missing-noreturn';
55+ cppflags = '-I$(top_srcdir)/grub-core/lib/minilzo -I$(srcdir)/grub-core/lib/xzembed -DMINILZO_HAVE_CONFIG_H';
56+
57+ common_nodist = grub_script.tab.c;
58+ common_nodist = grub_script.yy.c;
59+ common_nodist = libgrub_a_init.c;
60+ common_nodist = grub_script.yy.h;
61+ common_nodist = grub_script.tab.h;
62+
63+ common = grub-core/commands/blocklist.c;
64+ common = grub-core/commands/xnu_uuid.c;
65+ common = grub-core/commands/testload.c;
66+ common = grub-core/commands/ls.c;
67+ common = grub-core/disk/dmraid_nvidia.c;
68+ common = grub-core/disk/loopback.c;
69+ common = grub-core/disk/lvm.c;
70+ common = grub-core/disk/mdraid_linux.c;
71+ common = grub-core/disk/mdraid_linux_be.c;
72+ common = grub-core/disk/mdraid1x_linux.c;
73+ common = grub-core/disk/raid5_recover.c;
74+ common = grub-core/disk/raid6_recover.c;
75+ common = grub-core/fs/affs.c;
76+ common = grub-core/fs/afs.c;
77+ common = grub-core/fs/bfs.c;
78+ common = grub-core/fs/btrfs.c;
79+ common = grub-core/fs/cpio.c;
80+ common = grub-core/fs/cpio_be.c;
81+ common = grub-core/fs/odc.c;
82+ common = grub-core/fs/newc.c;
83+ common = grub-core/fs/ext2.c;
84+ common = grub-core/fs/fat.c;
85+ common = grub-core/fs/exfat.c;
86+ common = grub-core/fs/fshelp.c;
87+ common = grub-core/fs/hfs.c;
88+ common = grub-core/fs/hfsplus.c;
89+ common = grub-core/fs/iso9660.c;
90+ common = grub-core/fs/jfs.c;
91+ common = grub-core/fs/minix.c;
92+ common = grub-core/fs/minix2.c;
93+ common = grub-core/fs/minix3.c;
94+ common = grub-core/fs/minix_be.c;
95+ common = grub-core/fs/minix2_be.c;
96+ common = grub-core/fs/minix3_be.c;
97+ common = grub-core/fs/nilfs2.c;
98+ common = grub-core/fs/ntfs.c;
99+ common = grub-core/fs/ntfscomp.c;
100+ common = grub-core/fs/reiserfs.c;
101+ common = grub-core/fs/romfs.c;
102+ common = grub-core/fs/sfs.c;
103+ common = grub-core/fs/squash4.c;
104+ common = grub-core/fs/tar.c;
105+ common = grub-core/fs/udf.c;
106+ common = grub-core/fs/ufs2.c;
107+ common = grub-core/fs/ufs.c;
108+ common = grub-core/fs/xfs.c;
109+ common = grub-core/fs/zfs/zfscrypt.c;
110+ common = grub-core/fs/zfs/zfs.c;
111+ common = grub-core/fs/zfs/zfsinfo.c;
112+ common = grub-core/fs/zfs/zfs_lzjb.c;
113+ common = grub-core/fs/zfs/zfs_sha256.c;
114+ common = grub-core/fs/zfs/zfs_fletcher.c;
115+ common = grub-core/lib/envblk.c;
116+ common = grub-core/lib/hexdump.c;
117+ common = grub-core/lib/LzFind.c;
118+ common = grub-core/lib/LzmaEnc.c;
119+ common = grub-core/lib/crc.c;
120+ common = grub-core/lib/adler32.c;
121+ common = grub-core/lib/crc64.c;
122+ common = grub-core/normal/datetime.c;
123+ common = grub-core/normal/misc.c;
124+ common = grub-core/partmap/acorn.c;
125+ common = grub-core/partmap/amiga.c;
126+ common = grub-core/partmap/apple.c;
127+ common = grub-core/partmap/msdos.c;
128+ common = grub-core/partmap/sun.c;
129+ common = grub-core/partmap/plan.c;
130+ common = grub-core/partmap/dvh.c;
131+ common = grub-core/partmap/sunpc.c;
132+ common = grub-core/partmap/bsdlabel.c;
133+ common = grub-core/script/function.c;
134+ common = grub-core/script/lexer.c;
135+ common = grub-core/script/main.c;
136+ common = grub-core/script/script.c;
137+ common = grub-core/script/argv.c;
138+ common = grub-core/io/gzio.c;
139+ common = grub-core/io/lzopio.c;
140+ common = grub-core/kern/ia64/dl_helper.c;
141+ common = grub-core/lib/minilzo/minilzo.c;
142+ common = grub-core/lib/xzembed/xz_dec_bcj.c;
143+ common = grub-core/lib/xzembed/xz_dec_lzma2.c;
144+ common = grub-core/lib/xzembed/xz_dec_stream.c;
145+};
146+
147+program = {
148+ name = grub-bin2h;
149+ common = util/bin2h.c;
150+ ldadd = libgrubmods.a;
151+ ldadd = libgrubgcry.a;
152+ ldadd = libgrubkern.a;
153+ ldadd = grub-core/gnulib/libgnu.a;
154+ ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
155+ installdir = noinst;
156+};
157+
158+program = {
159+ name = grub-mkimage;
160+ mansection = 1;
161+
162+ common = util/grub-mkimage.c;
163+ common = util/resolve.c;
164+ common = grub-core/kern/emu/argp_common.c;
165+
166+ extra_dist = util/grub-mkimagexx.c;
167+
168+ ldadd = libgrubmods.a;
169+ ldadd = libgrubgcry.a;
170+ ldadd = libgrubkern.a;
171+ ldadd = grub-core/gnulib/libgnu.a;
172+ ldadd = '$(LIBLZMA)';
173+ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
174+ cppflags = '-DGRUB_PKGLIBDIR=\"$(pkglibdir)\"';
175+};
176+
177+program = {
178+ name = grub-mkrelpath;
179+ mansection = 1;
180+
181+ common = util/grub-mkrelpath.c;
182+ common = grub-core/kern/emu/argp_common.c;
183+
184+ ldadd = libgrubmods.a;
185+ ldadd = libgrubgcry.a;
186+ ldadd = libgrubkern.a;
187+ ldadd = grub-core/gnulib/libgnu.a;
188+ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
189+};
190+
191+program = {
192+ name = grub-script-check;
193+ mansection = 1;
194+
195+ common = util/grub-script-check.c;
196+ common = grub-core/kern/emu/argp_common.c;
197+
198+ ldadd = libgrubmods.a;
199+ ldadd = libgrubgcry.a;
200+ ldadd = libgrubkern.a;
201+ ldadd = grub-core/gnulib/libgnu.a;
202+ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
203+};
204+
205+program = {
206+ name = grub-editenv;
207+ mansection = 1;
208+
209+ common = util/grub-editenv.c;
210+
211+ ldadd = libgrubmods.a;
212+ ldadd = libgrubgcry.a;
213+ ldadd = libgrubkern.a;
214+ ldadd = grub-core/gnulib/libgnu.a;
215+ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
216+};
217+
218+program = {
219+ name = grub-mkpasswd-pbkdf2;
220+ mansection = 1;
221+
222+ common = util/grub-mkpasswd-pbkdf2.c;
223+ common = grub-core/kern/emu/argp_common.c;
224+
225+ ldadd = libgrubmods.a;
226+ ldadd = libgrubgcry.a;
227+ ldadd = libgrubkern.a;
228+ ldadd = grub-core/gnulib/libgnu.a;
229+ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
230+ cflags = '$(CFLAGS_GCRY)';
231+ cppflags = '$(CPPFLAGS_GCRY)';
232+};
233+
234+program = {
235+ name = grub-macho2img;
236+ mansection = 1;
237+ common = util/grub-macho2img.c;
238+ condition = COND_APPLE_CC;
239+};
240+
241+program = {
242+ name = grub-pe2elf;
243+ mansection = 1;
244+ common = util/grub-pe2elf.c;
245+
246+ ldadd = libgrubmods.a;
247+ ldadd = libgrubgcry.a;
248+ ldadd = libgrubkern.a;
249+ ldadd = grub-core/gnulib/libgnu.a;
250+ ldadd = '$(LIBINTL)';
251+ condition = COND_GRUB_PE2ELF;
252+};
253+
254+program = {
255+ name = grub-fstest;
256+ mansection = 1;
257+ common_nodist = grub_fstest_init.c;
258+ common = util/grub-fstest.c;
259+ common = grub-core/kern/emu/hostfs.c;
260+ common = grub-core/disk/host.c;
261+
262+ cflags = '$(CFLAGS_GCRY)';
263+ cppflags = '$(CPPFLAGS_GCRY)';
264+
265+ ldadd = libgrubmods.a;
266+ ldadd = libgrubgcry.a;
267+ ldadd = libgrubkern.a;
268+ ldadd = grub-core/gnulib/libgnu.a;
269+ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
270+};
271+
272+program = {
273+ name = grub-mount;
274+ mansection = 1;
275+ common_nodist = grub_fstest_init.c;
276+ common = util/grub-mount.c;
277+ common = grub-core/kern/emu/hostfs.c;
278+ common = grub-core/disk/host.c;
279+
280+ ldadd = libgrubmods.a;
281+ ldadd = libgrubgcry.a;
282+ ldadd = libgrubkern.a;
283+ ldadd = grub-core/gnulib/libgnu.a;
284+ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM) -lfuse';
285+ condition = COND_GRUB_MOUNT;
286+};
287+
288+program = {
289+ name = grub-mkfont;
290+ mansection = 1;
291+ common = util/grub-mkfont.c;
292+ common = grub-core/unidata.c;
293+ common = grub-core/kern/emu/argp_common.c;
294+
295+ cflags = '$(freetype_cflags)';
296+
297+ ldadd = libgrubmods.a;
298+ ldadd = libgrubgcry.a;
299+ ldadd = libgrubkern.a;
300+ ldadd = grub-core/gnulib/libgnu.a;
301+ ldadd = '$(freetype_libs)';
302+ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
303+ condition = COND_GRUB_MKFONT;
304+};
305+
306+program = {
307+ name = grub-mkdevicemap;
308+ installdir = sbin;
309+ mansection = 8;
310+
311+ common = util/grub-mkdevicemap.c;
312+ common = util/deviceiter.c;
313+ common = util/devicemap.c;
314+
315+ ldadd = libgrubmods.a;
316+ ldadd = libgrubgcry.a;
317+ ldadd = libgrubkern.a;
318+ ldadd = grub-core/gnulib/libgnu.a;
319+ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
320+};
321+
322+program = {
323+ name = grub-probe;
324+ installdir = sbin;
325+ mansection = 8;
326+ common = util/grub-probe.c;
327+ common = util/ieee1275/ofpath.c;
328+ common = grub-core/kern/emu/argp_common.c;
329+
330+ ldadd = libgrubmods.a;
331+ ldadd = libgrubgcry.a;
332+ ldadd = libgrubkern.a;
333+ ldadd = grub-core/gnulib/libgnu.a;
334+ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
335+};
336+
337+program = {
338+ name = grub-bios-setup;
339+ installdir = sbin;
340+ mansection = 8;
341+ common = util/grub-setup.c;
342+ common = util/lvm.c;
343+ common = grub-core/kern/emu/argp_common.c;
344+ common = grub-core/lib/reed_solomon.c;
345+
346+ ldadd = libgrubmods.a;
347+ ldadd = libgrubkern.a;
348+ ldadd = libgrubgcry.a;
349+ ldadd = grub-core/gnulib/libgnu.a;
350+ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
351+ cppflags = '-DGRUB_SETUP_BIOS=1';
352+};
353+
354+program = {
355+ name = grub-sparc64-setup;
356+ installdir = sbin;
357+ mansection = 8;
358+ common = util/grub-setup.c;
359+ common = util/lvm.c;
360+ common = grub-core/kern/emu/argp_common.c;
361+ common = grub-core/lib/reed_solomon.c;
362+ common = util/ieee1275/ofpath.c;
363+
364+ ldadd = libgrubmods.a;
365+ ldadd = libgrubkern.a;
366+ ldadd = libgrubgcry.a;
367+ ldadd = grub-core/gnulib/libgnu.a;
368+ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
369+ cppflags = '-DGRUB_SETUP_SPARC64=1';
370+};
371+
372+program = {
373+ name = grub-ofpathname;
374+ installdir = sbin;
375+ mansection = 8;
376+ common = util/ieee1275/grub-ofpathname.c;
377+ common = util/ieee1275/ofpath.c;
378+
379+ ldadd = libgrubmods.a;
380+ ldadd = libgrubgcry.a;
381+ ldadd = libgrubkern.a;
382+ ldadd = grub-core/gnulib/libgnu.a;
383+ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBGEOM)';
384+};
385+
386+program = {
387+ name = grub-mklayout;
388+ mansection = 1;
389+
390+ common = util/grub-mklayout.c;
391+ common = grub-core/kern/emu/argp_common.c;
392+
393+ ldadd = libgrubmods.a;
394+ ldadd = libgrubgcry.a;
395+ ldadd = libgrubkern.a;
396+ ldadd = grub-core/gnulib/libgnu.a;
397+ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
398+};
399+
400+data = {
401+ common = util/grub.d/README;
402+ installdir = grubconf;
403+};
404+
405+script = {
406+ name = '00_header';
407+ common = util/grub.d/00_header.in;
408+ installdir = grubconf;
409+};
410+
411+script = {
412+ name = '10_windows';
413+ common = util/grub.d/10_windows.in;
414+ installdir = grubconf;
415+ condition = COND_HOST_WINDOWS;
416+};
417+
418+script = {
419+ name = '10_hurd';
420+ common = util/grub.d/10_hurd.in;
421+ installdir = grubconf;
422+ condition = COND_HOST_HURD;
423+};
424+
425+script = {
426+ name = '10_kfreebsd';
427+ common = util/grub.d/10_kfreebsd.in;
428+ installdir = grubconf;
429+ condition = COND_HOST_KFREEBSD;
430+};
431+
432+script = {
433+ name = '10_illumos';
434+ common = util/grub.d/10_illumos.in;
435+ installdir = grubconf;
436+ condition = COND_HOST_ILLUMOS;
437+};
438+
439+script = {
440+ name = '10_netbsd';
441+ common = util/grub.d/10_netbsd.in;
442+ installdir = grubconf;
443+ condition = COND_HOST_NETBSD;
444+};
445+
446+script = {
447+ name = '10_linux';
448+ common = util/grub.d/10_linux.in;
449+ installdir = grubconf;
450+ condition = COND_HOST_LINUX;
451+};
452+
453+script = {
454+ name = '10_xnu';
455+ common = util/grub.d/10_xnu.in;
456+ installdir = grubconf;
457+ condition = COND_HOST_XNU;
458+};
459+
460+script = {
461+ name = '20_linux_xen';
462+ common = util/grub.d/20_linux_xen.in;
463+ installdir = grubconf;
464+ condition = COND_HOST_LINUX;
465+};
466+
467+script = {
468+ name = '30_os-prober';
469+ common = util/grub.d/30_os-prober.in;
470+ installdir = grubconf;
471+};
472+
473+script = {
474+ name = '30_uefi-firmware';
475+ common = util/grub.d/30_uefi-firmware.in;
476+ installdir = grubconf;
477+};
478+
479+script = {
480+ name = '40_custom';
481+ common = util/grub.d/40_custom.in;
482+ installdir = grubconf;
483+};
484+
485+script = {
486+ name = '41_custom';
487+ common = util/grub.d/41_custom.in;
488+ installdir = grubconf;
489+};
490+
491+script = {
492+ mansection = 1;
493+ name = grub-mkrescue;
494+ x86 = util/grub-mkrescue.in;
495+ mips_qemu_mips = util/grub-mkrescue.in;
496+ mips_loongson = util/grub-mkrescue.in;
497+ ia64_efi = util/grub-mkrescue.in;
498+ powerpc_ieee1275 = util/powerpc/ieee1275/grub-mkrescue.in;
499+ enable = i386_pc;
500+ enable = i386_efi;
501+ enable = x86_64_efi;
502+ enable = i386_qemu;
503+ enable = i386_multiboot;
504+ enable = i386_coreboot;
505+ enable = mips_qemu_mips;
506+ enable = mips_loongson;
507+ enable = ia64_efi;
508+ enable = powerpc_ieee1275;
509+};
510+
511+script = {
512+ mansection = 1;
513+ name = grub-mkstandalone;
514+ common = util/grub-mkstandalone.in;
515+};
516+
517+script = {
518+ mansection = 8;
519+ installdir = sbin;
520+ name = grub-install;
521+
522+ common = util/grub-install.in;
523+ enable = noemu;
524+};
525+
526+script = {
527+ mansection = 8;
528+ installdir = sbin;
529+ name = grub-mknetdir;
530+
531+ common = util/grub-mknetdir.in;
532+};
533+
534+script = {
535+ name = grub-mkconfig;
536+ common = util/grub-mkconfig.in;
537+ mansection = 8;
538+ installdir = sbin;
539+};
540+
541+script = {
542+ name = grub-set-default;
543+ common = util/grub-set-default.in;
544+ mansection = 8;
545+ installdir = sbin;
546+};
547+
548+script = {
549+ name = grub-reboot;
550+ common = util/grub-reboot.in;
551+ mansection = 8;
552+ installdir = sbin;
553+};
554+
555+script = {
556+ name = grub-mkconfig_lib;
557+ common = util/grub-mkconfig_lib.in;
558+ installdir = noinst;
559+};
560+
561+script = {
562+ name = grub-kbdcomp;
563+ common = util/grub-kbdcomp.in;
564+ mansection = 1;
565+};
566+
567+script = {
568+ name = grub-shell;
569+ common = tests/util/grub-shell.in;
570+ installdir = noinst;
571+};
572+
573+script = {
574+ name = grub-shell-tester;
575+ common = tests/util/grub-shell-tester.in;
576+ installdir = noinst;
577+};
578+
579+script = {
580+ testcase;
581+ name = example_scripted_test;
582+ common = tests/example_scripted_test.in;
583+};
584+
585+script = {
586+ testcase;
587+ name = example_grub_script_test;
588+ common = tests/example_grub_script_test.in;
589+};
590+
591+script = {
592+ testcase;
593+ name = grub_script_echo1;
594+ common = tests/grub_script_echo1.in;
595+};
596+
597+script = {
598+ testcase;
599+ name = grub_script_leading_whitespace;
600+ common = tests/grub_script_leading_whitespace.in;
601+};
602+
603+script = {
604+ testcase;
605+ name = grub_script_echo_keywords;
606+ common = tests/grub_script_echo_keywords.in;
607+};
608+
609+script = {
610+ testcase;
611+ name = grub_script_vars1;
612+ common = tests/grub_script_vars1.in;
613+};
614+
615+script = {
616+ testcase;
617+ name = grub_script_for1;
618+ common = tests/grub_script_for1.in;
619+};
620+
621+script = {
622+ testcase;
623+ name = grub_script_while1;
624+ common = tests/grub_script_while1.in;
625+};
626+
627+script = {
628+ testcase;
629+ name = grub_script_if;
630+ common = tests/grub_script_if.in;
631+};
632+
633+script = {
634+ testcase;
635+ name = grub_script_blanklines;
636+ common = tests/grub_script_blanklines.in;
637+};
638+
639+script = {
640+ testcase;
641+ name = grub_script_final_semicolon;
642+ common = tests/grub_script_final_semicolon.in;
643+};
644+
645+script = {
646+ testcase;
647+ name = grub_script_dollar;
648+ common = tests/grub_script_dollar.in;
649+};
650+
651+script = {
652+ testcase;
653+ name = grub_script_comments;
654+ common = tests/grub_script_comments.in;
655+};
656+
657+script = {
658+ testcase;
659+ name = grub_script_functions;
660+ common = tests/grub_script_functions.in;
661+};
662+
663+script = {
664+ testcase;
665+ name = grub_script_break;
666+ common = tests/grub_script_break.in;
667+};
668+
669+script = {
670+ testcase;
671+ name = grub_script_continue;
672+ common = tests/grub_script_continue.in;
673+};
674+
675+script = {
676+ testcase;
677+ name = grub_script_shift;
678+ common = tests/grub_script_shift.in;
679+};
680+
681+script = {
682+ testcase;
683+ name = grub_script_blockarg;
684+ common = tests/grub_script_blockarg.in;
685+};
686+
687+script = {
688+ testcase;
689+ name = grub_script_setparams;
690+ common = tests/grub_script_setparams.in;
691+};
692+
693+script = {
694+ testcase;
695+ name = grub_script_return;
696+ common = tests/grub_script_return.in;
697+};
698+
699+script = {
700+ testcase;
701+ name = grub_cmd_regexp;
702+ common = tests/grub_cmd_regexp.in;
703+};
704+
705+script = {
706+ testcase;
707+ name = grub_script_expansion;
708+ common = tests/grub_script_expansion.in;
709+};
710+
711+script = {
712+ testcase;
713+ name = grub_script_not;
714+ common = tests/grub_script_not.in;
715+};
716+
717+script = {
718+ testcase;
719+ name = partmap_test;
720+ common = tests/partmap_test.in;
721+};
722+
723+script = {
724+ testcase;
725+ name = grub_cmd_echo;
726+ common = tests/grub_cmd_echo.in;
727+};
728+
729+script = {
730+ testcase;
731+ name = grub_script_gettext;
732+ common = tests/grub_script_gettext.in;
733+};
734+
735+script = {
736+ testcase;
737+ name = grub_script_strcmp;
738+ common = tests/grub_script_strcmp.in;
739+};
740+
741+program = {
742+ testcase;
743+ name = example_unit_test;
744+ common = tests/example_unit_test.c;
745+ common = tests/lib/unit_test.c;
746+ common = grub-core/kern/list.c;
747+ common = grub-core/kern/misc.c;
748+ common = grub-core/tests/lib/test.c;
749+ ldadd = libgrubmods.a;
750+ ldadd = libgrubgcry.a;
751+ ldadd = libgrubkern.a;
752+ ldadd = grub-core/gnulib/libgnu.a;
753+ ldadd = '$(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
754+};
755+
756+program = {
757+ testcase;
758+ name = printf_test;
759+ common = tests/printf_unit_test.c;
760+ common = tests/lib/unit_test.c;
761+ common = grub-core/kern/list.c;
762+ common = grub-core/kern/misc.c;
763+ common = grub-core/tests/lib/test.c;
764+ ldadd = libgrubmods.a;
765+ ldadd = libgrubgcry.a;
766+ ldadd = libgrubkern.a;
767+ ldadd = grub-core/gnulib/libgnu.a;
768+ ldadd = '$(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
769+};
770+
771+program = {
772+ testcase;
773+ name = cmp_test;
774+ common = tests/cmp_unit_test.c;
775+ common = tests/lib/unit_test.c;
776+ common = grub-core/kern/list.c;
777+ common = grub-core/kern/misc.c;
778+ common = grub-core/tests/lib/test.c;
779+ ldadd = libgrubmods.a;
780+ ldadd = libgrubgcry.a;
781+ ldadd = libgrubkern.a;
782+ ldadd = grub-core/gnulib/libgnu.a;
783+ ldadd = '$(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
784+};
785+
786+program = {
787+ name = grub-menulst2cfg;
788+ mansection = 1;
789+ common = util/grub-menulst2cfg.c;
790+ common = grub-core/lib/legacy_parse.c;
791+ common = grub-core/lib/i386/pc/vesa_modes_table.c;
792+
793+ ldadd = libgrubmods.a;
794+ ldadd = libgrubgcry.a;
795+ ldadd = libgrubkern.a;
796+ ldadd = grub-core/gnulib/libgnu.a;
797+ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
798+};
799
800=== added directory '.pc/ldm-require-sfs-partition.patch/grub-core'
801=== added directory '.pc/ldm-require-sfs-partition.patch/grub-core/disk'
802=== added file '.pc/ldm-require-sfs-partition.patch/grub-core/disk/ldm.c'
803--- .pc/ldm-require-sfs-partition.patch/grub-core/disk/ldm.c 1970-01-01 00:00:00 +0000
804+++ .pc/ldm-require-sfs-partition.patch/grub-core/disk/ldm.c 2012-12-03 15:02:19 +0000
805@@ -0,0 +1,1010 @@
806+/*
807+ * GRUB -- GRand Unified Bootloader
808+ * Copyright (C) 2006,2007,2008,2009,2011 Free Software Foundation, Inc.
809+ *
810+ * GRUB is free software: you can redistribute it and/or modify
811+ * it under the terms of the GNU General Public License as published by
812+ * the Free Software Foundation, either version 3 of the License, or
813+ * (at your option) any later version.
814+ *
815+ * GRUB is distributed in the hope that it will be useful,
816+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
817+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
818+ * GNU General Public License for more details.
819+ *
820+ * You should have received a copy of the GNU General Public License
821+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
822+ */
823+
824+#include <grub/dl.h>
825+#include <grub/disk.h>
826+#include <grub/mm.h>
827+#include <grub/err.h>
828+#include <grub/misc.h>
829+#include <grub/diskfilter.h>
830+#include <grub/gpt_partition.h>
831+#include <grub/i18n.h>
832+
833+#ifdef GRUB_UTIL
834+#include <grub/emu/misc.h>
835+#include <grub/emu/hostdisk.h>
836+#endif
837+
838+GRUB_MOD_LICENSE ("GPLv3+");
839+
840+#define LDM_GUID_STRLEN 64
841+#define LDM_NAME_STRLEN 32
842+
843+typedef grub_uint8_t *grub_ldm_id_t;
844+
845+enum { STRIPE = 1, SPANNED = 2, RAID5 = 3 };
846+
847+#define LDM_LABEL_SECTOR 6
848+struct grub_ldm_vblk {
849+ char magic[4];
850+ grub_uint8_t unused1[12];
851+ grub_uint16_t update_status;
852+ grub_uint8_t flags;
853+ grub_uint8_t type;
854+ grub_uint32_t unused2;
855+ grub_uint8_t dynamic[104];
856+} __attribute__ ((packed));
857+#define LDM_VBLK_MAGIC "VBLK"
858+
859+enum
860+ {
861+ STATUS_CONSISTENT = 0,
862+ STATUS_STILL_ACTIVE = 1,
863+ STATUS_NOT_ACTIVE_YET = 2
864+ };
865+
866+enum
867+ {
868+ ENTRY_COMPONENT = 0x32,
869+ ENTRY_PARTITION = 0x33,
870+ ENTRY_DISK = 0x34,
871+ ENTRY_VOLUME = 0x51,
872+ };
873+
874+struct grub_ldm_label
875+{
876+ char magic[8];
877+ grub_uint32_t unused1;
878+ grub_uint16_t ver_major;
879+ grub_uint16_t ver_minor;
880+ grub_uint8_t unused2[32];
881+ char disk_guid[LDM_GUID_STRLEN];
882+ char host_guid[LDM_GUID_STRLEN];
883+ char group_guid[LDM_GUID_STRLEN];
884+ char group_name[LDM_NAME_STRLEN];
885+ grub_uint8_t unused3[11];
886+ grub_uint64_t pv_start;
887+ grub_uint64_t pv_size;
888+ grub_uint64_t config_start;
889+ grub_uint64_t config_size;
890+} __attribute__ ((packed));
891+
892+
893+#define LDM_MAGIC "PRIVHEAD"
894+
895+
896
897+
898+static inline grub_uint64_t
899+read_int (grub_uint8_t *in, grub_size_t s)
900+{
901+ grub_uint8_t *ptr2;
902+ grub_uint64_t ret;
903+ ret = 0;
904+ for (ptr2 = in; ptr2 < in + s; ptr2++)
905+ {
906+ ret <<= 8;
907+ ret |= *ptr2;
908+ }
909+ return ret;
910+}
911+
912+static const grub_gpt_part_type_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM;
913+
914+static grub_disk_addr_t
915+gpt_ldm_sector (grub_disk_t dsk)
916+{
917+ grub_disk_addr_t sector = 0;
918+ grub_err_t err;
919+ auto int hook (grub_disk_t disk, const grub_partition_t p);
920+ int hook (grub_disk_t disk, const grub_partition_t p)
921+ {
922+ struct grub_gpt_partentry gptdata;
923+ grub_partition_t p2;
924+
925+ p2 = disk->partition;
926+ disk->partition = p->parent;
927+ if (grub_disk_read (disk, p->offset, p->index,
928+ sizeof (gptdata), &gptdata))
929+ {
930+ disk->partition = p2;
931+ return 0;
932+ }
933+ disk->partition = p2;
934+
935+ if (! grub_memcmp (&gptdata.type, &ldm_type, 16))
936+ {
937+ sector = p->start + p->len - 1;
938+ return 1;
939+ }
940+ return 0;
941+ }
942+ err = grub_gpt_partition_map_iterate (dsk, hook);
943+ if (err)
944+ {
945+ grub_errno = GRUB_ERR_NONE;
946+ return 0;
947+ }
948+ return sector;
949+}
950+
951+static struct grub_diskfilter_vg *
952+make_vg (grub_disk_t disk,
953+ const struct grub_ldm_label *label)
954+{
955+ grub_disk_addr_t startsec, endsec, cursec;
956+ struct grub_diskfilter_vg *vg;
957+ grub_err_t err;
958+
959+ /* First time we see this volume group. We've to create the
960+ whole volume group structure. */
961+ vg = grub_malloc (sizeof (*vg));
962+ if (! vg)
963+ return NULL;
964+ vg->extent_size = 1;
965+ vg->name = grub_malloc (LDM_NAME_STRLEN + 1);
966+ vg->uuid = grub_malloc (LDM_GUID_STRLEN + 1);
967+ if (! vg->uuid || !vg->name)
968+ {
969+ grub_free (vg->uuid);
970+ grub_free (vg->name);
971+ return NULL;
972+ }
973+ grub_memcpy (vg->uuid, label->group_guid, LDM_GUID_STRLEN);
974+ grub_memcpy (vg->name, label->group_name, LDM_NAME_STRLEN);
975+ vg->name[LDM_NAME_STRLEN] = 0;
976+ vg->uuid[LDM_GUID_STRLEN] = 0;
977+ vg->uuid_len = grub_strlen (vg->uuid);
978+
979+ vg->lvs = NULL;
980+ vg->pvs = NULL;
981+
982+ startsec = grub_be_to_cpu64 (label->config_start);
983+ endsec = startsec + grub_be_to_cpu64 (label->config_size);
984+
985+ /* First find disks. */
986+ for (cursec = startsec + 0x12; cursec < endsec; cursec++)
987+ {
988+ struct grub_ldm_vblk vblk[GRUB_DISK_SECTOR_SIZE
989+ / sizeof (struct grub_ldm_vblk)];
990+ unsigned i;
991+ err = grub_disk_read (disk, cursec, 0,
992+ sizeof(vblk), &vblk);
993+ if (err)
994+ goto fail2;
995+
996+ for (i = 0; i < ARRAY_SIZE (vblk); i++)
997+ {
998+ struct grub_diskfilter_pv *pv;
999+ grub_uint8_t *ptr;
1000+ if (grub_memcmp (vblk[i].magic, LDM_VBLK_MAGIC,
1001+ sizeof (vblk[i].magic)) != 0)
1002+ continue;
1003+ if (grub_be_to_cpu16 (vblk[i].update_status)
1004+ != STATUS_CONSISTENT
1005+ && grub_be_to_cpu16 (vblk[i].update_status)
1006+ != STATUS_STILL_ACTIVE)
1007+ continue;
1008+ if (vblk[i].type != ENTRY_DISK)
1009+ continue;
1010+ pv = grub_zalloc (sizeof (*pv));
1011+ if (!pv)
1012+ goto fail2;
1013+
1014+ pv->disk = 0;
1015+ ptr = vblk[i].dynamic;
1016+ if (ptr + *ptr + 1 >= vblk[i].dynamic
1017+ + sizeof (vblk[i].dynamic))
1018+ {
1019+ grub_free (pv);
1020+ goto fail2;
1021+ }
1022+ pv->internal_id = grub_malloc (ptr[0] + 2);
1023+ if (!pv->internal_id)
1024+ {
1025+ grub_free (pv);
1026+ goto fail2;
1027+ }
1028+ grub_memcpy (pv->internal_id, ptr, (grub_size_t) ptr[0] + 1);
1029+ pv->internal_id[(grub_size_t) ptr[0] + 1] = 0;
1030+
1031+ ptr += *ptr + 1;
1032+ if (ptr + *ptr + 1 >= vblk[i].dynamic
1033+ + sizeof (vblk[i].dynamic))
1034+ {
1035+ grub_free (pv);
1036+ goto fail2;
1037+ }
1038+ /* ptr = name. */
1039+ ptr += *ptr + 1;
1040+ if (ptr + *ptr + 1
1041+ >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
1042+ {
1043+ grub_free (pv);
1044+ goto fail2;
1045+ }
1046+ pv->id.uuidlen = *ptr;
1047+ pv->id.uuid = grub_malloc (pv->id.uuidlen + 1);
1048+ grub_memcpy (pv->id.uuid, ptr + 1, pv->id.uuidlen);
1049+ pv->id.uuid[pv->id.uuidlen] = 0;
1050+
1051+ pv->next = vg->pvs;
1052+ vg->pvs = pv;
1053+ }
1054+ }
1055+
1056+ /* Then find LVs. */
1057+ for (cursec = startsec + 0x12; cursec < endsec; cursec++)
1058+ {
1059+ struct grub_ldm_vblk vblk[GRUB_DISK_SECTOR_SIZE
1060+ / sizeof (struct grub_ldm_vblk)];
1061+ unsigned i;
1062+ err = grub_disk_read (disk, cursec, 0,
1063+ sizeof(vblk), &vblk);
1064+ if (err)
1065+ goto fail2;
1066+
1067+ for (i = 0; i < ARRAY_SIZE (vblk); i++)
1068+ {
1069+ struct grub_diskfilter_lv *lv;
1070+ grub_uint8_t *ptr;
1071+ if (grub_memcmp (vblk[i].magic, LDM_VBLK_MAGIC,
1072+ sizeof (vblk[i].magic)) != 0)
1073+ continue;
1074+ if (grub_be_to_cpu16 (vblk[i].update_status)
1075+ != STATUS_CONSISTENT
1076+ && grub_be_to_cpu16 (vblk[i].update_status)
1077+ != STATUS_STILL_ACTIVE)
1078+ continue;
1079+ if (vblk[i].type != ENTRY_VOLUME)
1080+ continue;
1081+ lv = grub_zalloc (sizeof (*lv));
1082+ if (!lv)
1083+ goto fail2;
1084+
1085+ lv->vg = vg;
1086+ lv->segment_count = 1;
1087+ lv->segment_alloc = 1;
1088+ lv->visible = 1;
1089+ lv->segments = grub_zalloc (sizeof (*lv->segments));
1090+ if (!lv->segments)
1091+ goto fail2;
1092+ lv->segments->start_extent = 0;
1093+ lv->segments->type = GRUB_DISKFILTER_MIRROR;
1094+ lv->segments->node_count = 0;
1095+ lv->segments->node_alloc = 8;
1096+ lv->segments->nodes = grub_zalloc (sizeof (*lv->segments->nodes)
1097+ * lv->segments->node_alloc);
1098+ if (!lv->segments->nodes)
1099+ goto fail2;
1100+ ptr = vblk[i].dynamic;
1101+ if (ptr + *ptr + 1 >= vblk[i].dynamic
1102+ + sizeof (vblk[i].dynamic))
1103+ {
1104+ grub_free (lv);
1105+ goto fail2;
1106+ }
1107+ lv->internal_id = grub_malloc ((grub_size_t) ptr[0] + 2);
1108+ if (!lv->internal_id)
1109+ {
1110+ grub_free (lv);
1111+ goto fail2;
1112+ }
1113+ grub_memcpy (lv->internal_id, ptr, ptr[0] + 1);
1114+ lv->internal_id[ptr[0] + 1] = 0;
1115+
1116+ ptr += *ptr + 1;
1117+ if (ptr + *ptr + 1 >= vblk[i].dynamic
1118+ + sizeof (vblk[i].dynamic))
1119+ {
1120+ grub_free (lv);
1121+ goto fail2;
1122+ }
1123+ lv->name = grub_malloc (*ptr + 1);
1124+ if (!lv->name)
1125+ {
1126+ grub_free (lv->internal_id);
1127+ grub_free (lv);
1128+ goto fail2;
1129+ }
1130+ grub_memcpy (lv->name, ptr + 1, *ptr);
1131+ lv->name[*ptr] = 0;
1132+ lv->fullname = grub_xasprintf ("ldm/%s/%s",
1133+ vg->uuid, lv->name);
1134+ if (!lv->fullname)
1135+ {
1136+ grub_free (lv->internal_id);
1137+ grub_free (lv->name);
1138+ grub_free (lv);
1139+ goto fail2;
1140+ }
1141+ ptr += *ptr + 1;
1142+ if (ptr + *ptr + 1
1143+ >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
1144+ {
1145+ grub_free (lv->internal_id);
1146+ grub_free (lv->name);
1147+ grub_free (lv);
1148+ goto fail2;
1149+ }
1150+ /* ptr = volume type. */
1151+ ptr += *ptr + 1;
1152+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
1153+ {
1154+ grub_free (lv->internal_id);
1155+ grub_free (lv->name);
1156+ grub_free (lv);
1157+ goto fail2;
1158+ }
1159+ /* ptr = flags. */
1160+ ptr += *ptr + 1;
1161+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
1162+ {
1163+ grub_free (lv->internal_id);
1164+ grub_free (lv->name);
1165+ grub_free (lv);
1166+ goto fail2;
1167+ }
1168+
1169+ /* Skip state, type, unknown, volume number, zeros, flags. */
1170+ ptr += 14 + 1 + 1 + 1 + 3 + 1;
1171+ /* ptr = number of children. */
1172+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
1173+ {
1174+ grub_free (lv->internal_id);
1175+ grub_free (lv->name);
1176+ grub_free (lv);
1177+ goto fail2;
1178+ }
1179+ ptr += *ptr + 1;
1180+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
1181+ {
1182+ grub_free (lv->internal_id);
1183+ grub_free (lv->name);
1184+ grub_free (lv);
1185+ goto fail2;
1186+ }
1187+
1188+ /* Skip 2 more fields. */
1189+ ptr += 8 + 8;
1190+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic)
1191+ || ptr + *ptr + 1>= vblk[i].dynamic
1192+ + sizeof (vblk[i].dynamic))
1193+ {
1194+ grub_free (lv->internal_id);
1195+ grub_free (lv->name);
1196+ grub_free (lv);
1197+ goto fail2;
1198+ }
1199+ lv->size = read_int (ptr + 1, *ptr);
1200+ lv->segments->extent_count = lv->size;
1201+
1202+ lv->next = vg->lvs;
1203+ vg->lvs = lv;
1204+ }
1205+ }
1206+
1207+ /* Now the components. */
1208+ for (cursec = startsec + 0x12; cursec < endsec; cursec++)
1209+ {
1210+ struct grub_ldm_vblk vblk[GRUB_DISK_SECTOR_SIZE
1211+ / sizeof (struct grub_ldm_vblk)];
1212+ unsigned i;
1213+ err = grub_disk_read (disk, cursec, 0,
1214+ sizeof(vblk), &vblk);
1215+ if (err)
1216+ goto fail2;
1217+
1218+ for (i = 0; i < ARRAY_SIZE (vblk); i++)
1219+ {
1220+ struct grub_diskfilter_lv *comp;
1221+ struct grub_diskfilter_lv *lv;
1222+ grub_uint8_t type;
1223+
1224+ grub_uint8_t *ptr;
1225+ if (grub_memcmp (vblk[i].magic, LDM_VBLK_MAGIC,
1226+ sizeof (vblk[i].magic)) != 0)
1227+ continue;
1228+ if (grub_be_to_cpu16 (vblk[i].update_status)
1229+ != STATUS_CONSISTENT
1230+ && grub_be_to_cpu16 (vblk[i].update_status)
1231+ != STATUS_STILL_ACTIVE)
1232+ continue;
1233+ if (vblk[i].type != ENTRY_COMPONENT)
1234+ continue;
1235+ comp = grub_zalloc (sizeof (*comp));
1236+ if (!comp)
1237+ goto fail2;
1238+ comp->visible = 0;
1239+ comp->name = 0;
1240+ comp->fullname = 0;
1241+
1242+ ptr = vblk[i].dynamic;
1243+ if (ptr + *ptr + 1 >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
1244+ {
1245+ goto fail2;
1246+ }
1247+ comp->internal_id = grub_malloc ((grub_size_t) ptr[0] + 2);
1248+ if (!comp->internal_id)
1249+ {
1250+ grub_free (comp);
1251+ goto fail2;
1252+ }
1253+ grub_memcpy (comp->internal_id, ptr, ptr[0] + 1);
1254+ comp->internal_id[ptr[0] + 1] = 0;
1255+
1256+ ptr += *ptr + 1;
1257+ if (ptr + *ptr + 1 >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
1258+ {
1259+ grub_free (comp->internal_id);
1260+ grub_free (comp);
1261+ goto fail2;
1262+ }
1263+ /* ptr = name. */
1264+ ptr += *ptr + 1;
1265+ if (ptr + *ptr + 1 >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
1266+ {
1267+ grub_free (comp->internal_id);
1268+ grub_free (comp);
1269+ goto fail2;
1270+ }
1271+ /* ptr = state. */
1272+ ptr += *ptr + 1;
1273+ type = *ptr++;
1274+ /* skip zeros. */
1275+ ptr += 4;
1276+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
1277+ {
1278+ grub_free (comp->internal_id);
1279+ grub_free (comp);
1280+ goto fail2;
1281+ }
1282+
1283+ /* ptr = number of children. */
1284+ ptr += *ptr + 1;
1285+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
1286+ {
1287+ grub_free (comp->internal_id);
1288+ grub_free (comp);
1289+ goto fail2;
1290+ }
1291+ ptr += 8 + 8;
1292+ if (ptr + *ptr + 1 >= vblk[i].dynamic
1293+ + sizeof (vblk[i].dynamic))
1294+ {
1295+ grub_free (comp->internal_id);
1296+ grub_free (comp);
1297+ goto fail2;
1298+ }
1299+ for (lv = vg->lvs; lv; lv = lv->next)
1300+ {
1301+ if (lv->internal_id[0] == ptr[0]
1302+ && grub_memcmp (lv->internal_id + 1, ptr + 1, ptr[0]) == 0)
1303+ break;
1304+ }
1305+ if (!lv)
1306+ {
1307+ grub_free (comp->internal_id);
1308+ grub_free (comp);
1309+ continue;
1310+ }
1311+ comp->size = lv->size;
1312+ if (type == SPANNED)
1313+ {
1314+ comp->segment_alloc = 8;
1315+ comp->segment_count = 0;
1316+ comp->segments = grub_malloc (sizeof (*comp->segments)
1317+ * comp->segment_alloc);
1318+ if (!comp->segments)
1319+ goto fail2;
1320+ }
1321+ else
1322+ {
1323+ comp->segment_alloc = 1;
1324+ comp->segment_count = 1;
1325+ comp->segments = grub_malloc (sizeof (*comp->segments));
1326+ if (!comp->segments)
1327+ goto fail2;
1328+ comp->segments->start_extent = 0;
1329+ comp->segments->extent_count = lv->size;
1330+ comp->segments->layout = 0;
1331+ if (type == STRIPE)
1332+ comp->segments->type = GRUB_DISKFILTER_STRIPED;
1333+ else if (type == RAID5)
1334+ {
1335+ comp->segments->type = GRUB_DISKFILTER_RAID5;
1336+ comp->segments->layout = GRUB_RAID_LAYOUT_SYMMETRIC_MASK;
1337+ }
1338+ else
1339+ goto fail2;
1340+ ptr += *ptr + 1;
1341+ ptr++;
1342+ if (!(vblk[i].flags & 0x10))
1343+ goto fail2;
1344+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic)
1345+ || ptr + *ptr + 1 >= vblk[i].dynamic
1346+ + sizeof (vblk[i].dynamic))
1347+ {
1348+ grub_free (comp->internal_id);
1349+ grub_free (comp);
1350+ goto fail2;
1351+ }
1352+ comp->segments->stripe_size = read_int (ptr + 1, *ptr);
1353+ ptr += *ptr + 1;
1354+ if (ptr + *ptr + 1 >= vblk[i].dynamic
1355+ + sizeof (vblk[i].dynamic))
1356+ {
1357+ grub_free (comp->internal_id);
1358+ grub_free (comp);
1359+ goto fail2;
1360+ }
1361+ comp->segments->node_count = read_int (ptr + 1, *ptr);
1362+ comp->segments->node_alloc = comp->segments->node_count;
1363+ comp->segments->nodes = grub_zalloc (sizeof (*comp->segments->nodes)
1364+ * comp->segments->node_alloc);
1365+ if (!lv->segments->nodes)
1366+ goto fail2;
1367+ }
1368+
1369+ if (lv->segments->node_alloc == lv->segments->node_count)
1370+ {
1371+ void *t;
1372+ lv->segments->node_alloc *= 2;
1373+ t = grub_realloc (lv->segments->nodes,
1374+ sizeof (*lv->segments->nodes)
1375+ * lv->segments->node_alloc);
1376+ if (!t)
1377+ goto fail2;
1378+ lv->segments->nodes = t;
1379+ }
1380+ lv->segments->nodes[lv->segments->node_count].pv = 0;
1381+ lv->segments->nodes[lv->segments->node_count].start = 0;
1382+ lv->segments->nodes[lv->segments->node_count++].lv = comp;
1383+ comp->next = vg->lvs;
1384+ vg->lvs = comp;
1385+ }
1386+ }
1387+ /* Partitions. */
1388+ for (cursec = startsec + 0x12; cursec < endsec; cursec++)
1389+ {
1390+ struct grub_ldm_vblk vblk[GRUB_DISK_SECTOR_SIZE
1391+ / sizeof (struct grub_ldm_vblk)];
1392+ unsigned i;
1393+ err = grub_disk_read (disk, cursec, 0,
1394+ sizeof(vblk), &vblk);
1395+ if (err)
1396+ goto fail2;
1397+
1398+ for (i = 0; i < ARRAY_SIZE (vblk); i++)
1399+ {
1400+ struct grub_diskfilter_lv *comp;
1401+ struct grub_diskfilter_node part;
1402+ grub_disk_addr_t start, size;
1403+
1404+ grub_uint8_t *ptr;
1405+ part.name = 0;
1406+ if (grub_memcmp (vblk[i].magic, LDM_VBLK_MAGIC,
1407+ sizeof (vblk[i].magic)) != 0)
1408+ continue;
1409+ if (grub_be_to_cpu16 (vblk[i].update_status)
1410+ != STATUS_CONSISTENT
1411+ && grub_be_to_cpu16 (vblk[i].update_status)
1412+ != STATUS_STILL_ACTIVE)
1413+ continue;
1414+ if (vblk[i].type != ENTRY_PARTITION)
1415+ continue;
1416+ part.lv = 0;
1417+ part.pv = 0;
1418+
1419+ ptr = vblk[i].dynamic;
1420+ if (ptr + *ptr + 1 >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
1421+ {
1422+ goto fail2;
1423+ }
1424+ /* ID */
1425+ ptr += *ptr + 1;
1426+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
1427+ {
1428+ goto fail2;
1429+ }
1430+ /* ptr = name. */
1431+ ptr += *ptr + 1;
1432+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
1433+ {
1434+ goto fail2;
1435+ }
1436+
1437+ /* skip zeros and logcommit id. */
1438+ ptr += 4 + 8;
1439+ if (ptr + 16 >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
1440+ {
1441+ goto fail2;
1442+ }
1443+ part.start = read_int (ptr, 8);
1444+ start = read_int (ptr + 8, 8);
1445+ ptr += 16;
1446+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic)
1447+ || ptr + *ptr + 1 >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
1448+ {
1449+ goto fail2;
1450+ }
1451+ size = read_int (ptr + 1, *ptr);
1452+ ptr += *ptr + 1;
1453+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic)
1454+ || ptr + *ptr + 1 >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
1455+ {
1456+ goto fail2;
1457+ }
1458+
1459+ for (comp = vg->lvs; comp; comp = comp->next)
1460+ if (comp->internal_id[0] == ptr[0]
1461+ && grub_memcmp (ptr + 1, comp->internal_id + 1,
1462+ comp->internal_id[0]) == 0)
1463+ goto out;
1464+ continue;
1465+ out:
1466+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic)
1467+ || ptr + *ptr + 1 >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
1468+ {
1469+ goto fail2;
1470+ }
1471+ ptr += *ptr + 1;
1472+ struct grub_diskfilter_pv *pv;
1473+ for (pv = vg->pvs; pv; pv = pv->next)
1474+ if (pv->internal_id[0] == ptr[0]
1475+ && grub_memcmp (pv->internal_id + 1, ptr + 1, ptr[0]) == 0)
1476+ part.pv = pv;
1477+
1478+ if (comp->segment_alloc == 1)
1479+ {
1480+ unsigned index;
1481+ ptr += *ptr + 1;
1482+ if (ptr + *ptr + 1 >= vblk[i].dynamic
1483+ + sizeof (vblk[i].dynamic))
1484+ {
1485+ goto fail2;
1486+ }
1487+ index = read_int (ptr + 1, *ptr);
1488+ if (index < comp->segments->node_count)
1489+ comp->segments->nodes[index] = part;
1490+ }
1491+ else
1492+ {
1493+ if (comp->segment_alloc == comp->segment_count)
1494+ {
1495+ void *t;
1496+ comp->segment_alloc *= 2;
1497+ t = grub_realloc (comp->segments,
1498+ comp->segment_alloc
1499+ * sizeof (*comp->segments));
1500+ if (!t)
1501+ goto fail2;
1502+ comp->segments = t;
1503+ }
1504+ comp->segments[comp->segment_count].start_extent = start;
1505+ comp->segments[comp->segment_count].extent_count = size;
1506+ comp->segments[comp->segment_count].type = GRUB_DISKFILTER_STRIPED;
1507+ comp->segments[comp->segment_count].node_count = 1;
1508+ comp->segments[comp->segment_count].node_alloc = 1;
1509+ comp->segments[comp->segment_count].nodes
1510+ = grub_malloc (sizeof (*comp->segments[comp->segment_count].nodes));
1511+ if (!comp->segments[comp->segment_count].nodes)
1512+ goto fail2;
1513+ comp->segments[comp->segment_count].nodes[0] = part;
1514+ comp->segment_count++;
1515+ }
1516+ }
1517+ }
1518+ if (grub_diskfilter_vg_register (vg))
1519+ goto fail2;
1520+ return vg;
1521+ fail2:
1522+ {
1523+ struct grub_diskfilter_lv *lv, *next_lv;
1524+ struct grub_diskfilter_pv *pv, *next_pv;
1525+ for (lv = vg->lvs; lv; lv = next_lv)
1526+ {
1527+ unsigned i;
1528+ for (i = 0; i < lv->segment_count; i++)
1529+ grub_free (lv->segments[i].nodes);
1530+
1531+ next_lv = lv->next;
1532+ grub_free (lv->segments);
1533+ grub_free (lv->internal_id);
1534+ grub_free (lv->name);
1535+ grub_free (lv->fullname);
1536+ grub_free (lv);
1537+ }
1538+ for (pv = vg->pvs; pv; pv = next_pv)
1539+ {
1540+ next_pv = pv->next;
1541+ grub_free (pv->id.uuid);
1542+ grub_free (pv);
1543+ }
1544+ }
1545+ grub_free (vg->uuid);
1546+ grub_free (vg);
1547+ return NULL;
1548+}
1549+
1550+static struct grub_diskfilter_vg *
1551+grub_ldm_detect (grub_disk_t disk,
1552+ struct grub_diskfilter_pv_id *id,
1553+ grub_disk_addr_t *start_sector)
1554+{
1555+ grub_err_t err;
1556+ struct grub_ldm_label label;
1557+ struct grub_diskfilter_vg *vg;
1558+
1559+#ifdef GRUB_UTIL
1560+ grub_util_info ("scanning %s for LDM", disk->name);
1561+#endif
1562+
1563+ {
1564+ int i;
1565+ for (i = 0; i < 3; i++)
1566+ {
1567+ grub_disk_addr_t sector = LDM_LABEL_SECTOR;
1568+ switch (i)
1569+ {
1570+ case 0:
1571+ sector = LDM_LABEL_SECTOR;
1572+ break;
1573+ case 1:
1574+ /* LDM is never inside a partition. */
1575+ if (disk->partition)
1576+ continue;
1577+ sector = grub_disk_get_size (disk);
1578+ if (sector == GRUB_DISK_SIZE_UNKNOWN)
1579+ continue;
1580+ sector--;
1581+ break;
1582+ /* FIXME: try the third copy. */
1583+ case 2:
1584+ sector = gpt_ldm_sector (disk);
1585+ if (!sector)
1586+ continue;
1587+ break;
1588+ }
1589+ err = grub_disk_read (disk, sector, 0,
1590+ sizeof(label), &label);
1591+ if (err)
1592+ return NULL;
1593+ if (grub_memcmp (label.magic, LDM_MAGIC, sizeof (label.magic)) == 0
1594+ && grub_be_to_cpu16 (label.ver_major) == 0x02
1595+ && grub_be_to_cpu16 (label.ver_minor) >= 0x0b
1596+ && grub_be_to_cpu16 (label.ver_minor) <= 0x0c)
1597+ break;
1598+ }
1599+
1600+ /* Return if we didn't find a label. */
1601+ if (i == 3)
1602+ {
1603+#ifdef GRUB_UTIL
1604+ grub_util_info ("no LDM signature found");
1605+#endif
1606+ return NULL;
1607+ }
1608+ }
1609+
1610+ id->uuid = grub_malloc (LDM_GUID_STRLEN + 1);
1611+ if (!id->uuid)
1612+ return NULL;
1613+ grub_memcpy (id->uuid, label.disk_guid, LDM_GUID_STRLEN);
1614+ id->uuid[LDM_GUID_STRLEN] = 0;
1615+ id->uuidlen = grub_strlen ((char *) id->uuid);
1616+ *start_sector = grub_be_to_cpu64 (label.pv_start);
1617+
1618+ {
1619+ grub_size_t s;
1620+ for (s = 0; s < LDM_GUID_STRLEN && label.group_guid[s]; s++);
1621+ vg = grub_diskfilter_get_vg_by_uuid (s, label.group_guid);
1622+ if (! vg)
1623+ vg = make_vg (disk, &label);
1624+ }
1625+
1626+ if (!vg)
1627+ {
1628+ grub_free (id->uuid);
1629+ return NULL;
1630+ }
1631+ return vg;
1632+}
1633+
1634+#ifdef GRUB_UTIL
1635+
1636+char *
1637+grub_util_get_ldm (grub_disk_t disk, grub_disk_addr_t start)
1638+{
1639+ struct grub_diskfilter_pv *pv = NULL;
1640+ struct grub_diskfilter_vg *vg = NULL;
1641+ struct grub_diskfilter_lv *res = 0, *lv, *res_lv = 0;
1642+
1643+ pv = grub_diskfilter_get_pv_from_disk (disk, &vg);
1644+
1645+ if (!pv)
1646+ return NULL;
1647+
1648+ for (lv = vg->lvs; lv; lv = lv->next)
1649+ if (lv->segment_count == 1 && lv->segments->node_count == 1
1650+ && lv->segments->type == GRUB_DISKFILTER_STRIPED
1651+ && lv->segments->nodes->pv == pv
1652+ && lv->segments->nodes->start + pv->start_sector == start)
1653+ {
1654+ res_lv = lv;
1655+ break;
1656+ }
1657+ if (!res_lv)
1658+ return NULL;
1659+ for (lv = vg->lvs; lv; lv = lv->next)
1660+ if (lv->segment_count == 1 && lv->segments->node_count == 1
1661+ && lv->segments->type == GRUB_DISKFILTER_MIRROR
1662+ && lv->segments->nodes->lv == res_lv)
1663+ {
1664+ res = lv;
1665+ break;
1666+ }
1667+ if (res && res->fullname)
1668+ return grub_strdup (res->fullname);
1669+ return NULL;
1670+}
1671+
1672+int
1673+grub_util_is_ldm (grub_disk_t disk)
1674+{
1675+ int i;
1676+ for (i = 0; i < 3; i++)
1677+ {
1678+ grub_disk_addr_t sector = LDM_LABEL_SECTOR;
1679+ grub_err_t err;
1680+ struct grub_ldm_label label;
1681+
1682+ switch (i)
1683+ {
1684+ case 0:
1685+ sector = LDM_LABEL_SECTOR;
1686+ break;
1687+ case 1:
1688+ /* LDM is never inside a partition. */
1689+ if (disk->partition)
1690+ continue;
1691+ sector = grub_disk_get_size (disk);
1692+ if (sector == GRUB_DISK_SIZE_UNKNOWN)
1693+ continue;
1694+ sector--;
1695+ break;
1696+ /* FIXME: try the third copy. */
1697+ case 2:
1698+ sector = gpt_ldm_sector (disk);
1699+ if (!sector)
1700+ continue;
1701+ break;
1702+ }
1703+ err = grub_disk_read (disk, sector, 0, sizeof(label), &label);
1704+ if (err)
1705+ {
1706+ grub_errno = GRUB_ERR_NONE;
1707+ return 0;
1708+ }
1709+ /* This check is more relaxed on purpose. */
1710+ if (grub_memcmp (label.magic, LDM_MAGIC, sizeof (label.magic)) == 0)
1711+ return 1;
1712+ }
1713+
1714+ return 0;
1715+}
1716+
1717+grub_err_t
1718+grub_util_ldm_embed (struct grub_disk *disk, unsigned int *nsectors,
1719+ unsigned int max_nsectors,
1720+ grub_embed_type_t embed_type,
1721+ grub_disk_addr_t **sectors)
1722+{
1723+ struct grub_diskfilter_pv *pv = NULL;
1724+ struct grub_diskfilter_vg *vg;
1725+ struct grub_diskfilter_lv *lv;
1726+ unsigned i;
1727+
1728+ if (embed_type != GRUB_EMBED_PCBIOS)
1729+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
1730+ "LDM curently supports only PC-BIOS embedding");
1731+ if (disk->partition)
1732+ return grub_error (GRUB_ERR_BUG, "disk isn't LDM");
1733+ pv = grub_diskfilter_get_pv_from_disk (disk, &vg);
1734+ if (!pv)
1735+ return grub_error (GRUB_ERR_BUG, "disk isn't LDM");
1736+ for (lv = vg->lvs; lv; lv = lv->next)
1737+ {
1738+ struct grub_diskfilter_lv *comp;
1739+
1740+ if (!lv->visible || !lv->fullname)
1741+ continue;
1742+
1743+ if (lv->segment_count != 1)
1744+ continue;
1745+ if (lv->segments->type != GRUB_DISKFILTER_MIRROR
1746+ || lv->segments->node_count != 1
1747+ || lv->segments->start_extent != 0
1748+ || lv->segments->extent_count != lv->size)
1749+ continue;
1750+
1751+ comp = lv->segments->nodes->lv;
1752+ if (!comp)
1753+ continue;
1754+
1755+ if (comp->segment_count != 1 || comp->size != lv->size)
1756+ continue;
1757+ if (comp->segments->type != GRUB_DISKFILTER_STRIPED
1758+ || comp->segments->node_count != 1
1759+ || comp->segments->start_extent != 0
1760+ || comp->segments->extent_count != lv->size)
1761+ continue;
1762+
1763+ /* How to implement proper check is to be discussed. */
1764+#if 1
1765+ if (1)
1766+ continue;
1767+#else
1768+ if (grub_strcmp (lv->name, "Volume5") != 0)
1769+ continue;
1770+#endif
1771+ if (lv->size < *nsectors)
1772+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
1773+ /* TRANSLATORS: it's a partition for embedding,
1774+ not a partition embed into something. GRUB
1775+ install tools put core.img into a place
1776+ usable for bootloaders (called generically
1777+ "embedding zone") and this operation is
1778+ called "embedding". */
1779+ N_("your LDM embedding Partition is too small;"
1780+ " embedding won't be possible"));
1781+ *nsectors = lv->size;
1782+ if (*nsectors > max_nsectors)
1783+ *nsectors = max_nsectors;
1784+ *sectors = grub_malloc (*nsectors * sizeof (**sectors));
1785+ if (!*sectors)
1786+ return grub_errno;
1787+ for (i = 0; i < *nsectors; i++)
1788+ (*sectors)[i] = (lv->segments->nodes->start
1789+ + comp->segments->nodes->start
1790+ + comp->segments->nodes->pv->start_sector + i);
1791+ return GRUB_ERR_NONE;
1792+ }
1793+
1794+ return grub_error (GRUB_ERR_FILE_NOT_FOUND,
1795+ /* TRANSLATORS: it's a partition for embedding,
1796+ not a partition embed into something. */
1797+ N_("this LDM has no Embedding Partition;"
1798+ " embedding won't be possible"));
1799+}
1800+#endif
1801+
1802+static struct grub_diskfilter grub_ldm_dev = {
1803+ .name = "ldm",
1804+ .detect = grub_ldm_detect,
1805+ .next = 0
1806+};
1807+
1808+GRUB_MOD_INIT (ldm)
1809+{
1810+ grub_diskfilter_register_back (&grub_ldm_dev);
1811+}
1812+
1813+GRUB_MOD_FINI (ldm)
1814+{
1815+ grub_diskfilter_unregister (&grub_ldm_dev);
1816+}
1817
1818=== added directory '.pc/ldm-require-sfs-partition.patch/include'
1819=== added directory '.pc/ldm-require-sfs-partition.patch/include/grub'
1820=== added file '.pc/ldm-require-sfs-partition.patch/include/grub/msdos_partition.h'
1821--- .pc/ldm-require-sfs-partition.patch/include/grub/msdos_partition.h 1970-01-01 00:00:00 +0000
1822+++ .pc/ldm-require-sfs-partition.patch/include/grub/msdos_partition.h 2012-12-03 15:02:19 +0000
1823@@ -0,0 +1,126 @@
1824+/*
1825+ * GRUB -- GRand Unified Bootloader
1826+ * Copyright (C) 1999,2000,2001,2002,2004,2007 Free Software Foundation, Inc.
1827+ *
1828+ * GRUB is free software: you can redistribute it and/or modify
1829+ * it under the terms of the GNU General Public License as published by
1830+ * the Free Software Foundation, either version 3 of the License, or
1831+ * (at your option) any later version.
1832+ *
1833+ * GRUB is distributed in the hope that it will be useful,
1834+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1835+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1836+ * GNU General Public License for more details.
1837+ *
1838+ * You should have received a copy of the GNU General Public License
1839+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
1840+ */
1841+
1842+#ifndef GRUB_PC_PARTITION_HEADER
1843+#define GRUB_PC_PARTITION_HEADER 1
1844+
1845+#include <grub/symbol.h>
1846+#include <grub/types.h>
1847+#include <grub/err.h>
1848+#include <grub/disk.h>
1849+#include <grub/partition.h>
1850+
1851+/* The signature. */
1852+#define GRUB_PC_PARTITION_SIGNATURE 0xaa55
1853+
1854+/* This is not a flag actually, but used as if it were a flag. */
1855+#define GRUB_PC_PARTITION_TYPE_HIDDEN_FLAG 0x10
1856+
1857+/* DOS partition types. */
1858+#define GRUB_PC_PARTITION_TYPE_NONE 0
1859+#define GRUB_PC_PARTITION_TYPE_FAT12 1
1860+#define GRUB_PC_PARTITION_TYPE_FAT16_LT32M 4
1861+#define GRUB_PC_PARTITION_TYPE_EXTENDED 5
1862+#define GRUB_PC_PARTITION_TYPE_FAT16_GT32M 6
1863+#define GRUB_PC_PARTITION_TYPE_NTFS 7
1864+#define GRUB_PC_PARTITION_TYPE_FAT32 0xb
1865+#define GRUB_PC_PARTITION_TYPE_FAT32_LBA 0xc
1866+#define GRUB_PC_PARTITION_TYPE_FAT16_LBA 0xe
1867+#define GRUB_PC_PARTITION_TYPE_WIN95_EXTENDED 0xf
1868+#define GRUB_PC_PARTITION_TYPE_PLAN9 0x39
1869+#define GRUB_PC_PARTITION_TYPE_EZD 0x55
1870+#define GRUB_PC_PARTITION_TYPE_MINIX 0x80
1871+#define GRUB_PC_PARTITION_TYPE_LINUX_MINIX 0x81
1872+#define GRUB_PC_PARTITION_TYPE_LINUX_SWAP 0x82
1873+#define GRUB_PC_PARTITION_TYPE_EXT2FS 0x83
1874+#define GRUB_PC_PARTITION_TYPE_LINUX_EXTENDED 0x85
1875+#define GRUB_PC_PARTITION_TYPE_VSTAFS 0x9e
1876+#define GRUB_PC_PARTITION_TYPE_FREEBSD 0xa5
1877+#define GRUB_PC_PARTITION_TYPE_OPENBSD 0xa6
1878+#define GRUB_PC_PARTITION_TYPE_NETBSD 0xa9
1879+#define GRUB_PC_PARTITION_TYPE_HFS 0xaf
1880+#define GRUB_PC_PARTITION_TYPE_GPT_DISK 0xee
1881+#define GRUB_PC_PARTITION_TYPE_LINUX_RAID 0xfd
1882+
1883+/* The partition entry. */
1884+struct grub_msdos_partition_entry
1885+{
1886+ /* If active, 0x80, otherwise, 0x00. */
1887+ grub_uint8_t flag;
1888+
1889+ /* The head of the start. */
1890+ grub_uint8_t start_head;
1891+
1892+ /* (S | ((C >> 2) & 0xC0)) where S is the sector of the start and C
1893+ is the cylinder of the start. Note that S is counted from one. */
1894+ grub_uint8_t start_sector;
1895+
1896+ /* (C & 0xFF) where C is the cylinder of the start. */
1897+ grub_uint8_t start_cylinder;
1898+
1899+ /* The partition type. */
1900+ grub_uint8_t type;
1901+
1902+ /* The end versions of start_head, start_sector and start_cylinder,
1903+ respectively. */
1904+ grub_uint8_t end_head;
1905+ grub_uint8_t end_sector;
1906+ grub_uint8_t end_cylinder;
1907+
1908+ /* The start sector. Note that this is counted from zero. */
1909+ grub_uint32_t start;
1910+
1911+ /* The length in sector units. */
1912+ grub_uint32_t length;
1913+} __attribute__ ((packed));
1914+
1915+/* The structure of MBR. */
1916+struct grub_msdos_partition_mbr
1917+{
1918+ /* The code area (actually, including BPB). */
1919+ grub_uint8_t code[446];
1920+
1921+ /* Four partition entries. */
1922+ struct grub_msdos_partition_entry entries[4];
1923+
1924+ /* The signature 0xaa55. */
1925+ grub_uint16_t signature;
1926+} __attribute__ ((packed));
1927+
1928+
1929
1930+
1931+static inline int
1932+grub_msdos_partition_is_empty (int type)
1933+{
1934+ return (type == GRUB_PC_PARTITION_TYPE_NONE);
1935+}
1936+
1937+static inline int
1938+grub_msdos_partition_is_extended (int type)
1939+{
1940+ return (type == GRUB_PC_PARTITION_TYPE_EXTENDED
1941+ || type == GRUB_PC_PARTITION_TYPE_WIN95_EXTENDED
1942+ || type == GRUB_PC_PARTITION_TYPE_LINUX_EXTENDED);
1943+}
1944+
1945+grub_err_t
1946+grub_partition_msdos_iterate (grub_disk_t disk,
1947+ int (*hook) (grub_disk_t disk,
1948+ const grub_partition_t partition));
1949+
1950+#endif /* ! GRUB_PC_PARTITION_HEADER */
1951
1952=== modified file 'Makefile.util.def'
1953--- Makefile.util.def 2012-10-08 12:16:40 +0000
1954+++ Makefile.util.def 2012-12-03 15:02:19 +0000
1955@@ -32,6 +32,7 @@
1956 common = grub-core/disk/ldm.c;
1957 common = grub-core/disk/diskfilter.c;
1958 common = grub-core/partmap/gpt.c;
1959+ common = grub-core/partmap/msdos.c;
1960 };
1961
1962 library = {
1963@@ -109,7 +110,6 @@
1964 common = grub-core/partmap/acorn.c;
1965 common = grub-core/partmap/amiga.c;
1966 common = grub-core/partmap/apple.c;
1967- common = grub-core/partmap/msdos.c;
1968 common = grub-core/partmap/sun.c;
1969 common = grub-core/partmap/plan.c;
1970 common = grub-core/partmap/dvh.c;
1971
1972=== modified file 'debian/changelog'
1973--- debian/changelog 2012-10-31 10:36:57 +0000
1974+++ debian/changelog 2012-12-03 15:02:19 +0000
1975@@ -1,3 +1,10 @@
1976+grub2 (2.00-7ubuntu14) raring; urgency=low
1977+
1978+ * debian/ldm-require-sfs-partition.patch: Only recognize ldm partition
1979+ table if there is an SFS partition listed in the DOS MBR (LP: #1061255)
1980+
1981+ -- Phillip Susi <psusi@Ubuntu.com> Wed, 28 Nov 2012 15:08:45 -0500
1982+
1983 grub2 (2.00-7ubuntu13) raring; urgency=low
1984
1985 * Avoid assuming that gets is declared.
1986
1987=== added file 'debian/patches/ldm-require-sfs-partition.patch'
1988--- debian/patches/ldm-require-sfs-partition.patch 1970-01-01 00:00:00 +0000
1989+++ debian/patches/ldm-require-sfs-partition.patch 2012-12-03 15:02:19 +0000
1990@@ -0,0 +1,136 @@
1991+Author: Andrey Borzenkov <arvidjaar@gmail.com>
1992+Origin: grub-devel@gnu.org
1993+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1061255
1994+Description: There are multiple reports of GRUB2 refusing to install on
1995+ disk which was used for LDM in the past. Example is:
1996+ https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1061255
1997+
1998+ I tested behavior of Windows and Linux on a disk with valid LDM
1999+ signature but manually modified partition table. Both ignore LDM labels
2000+ if disk does not contain SFS partition (0x42) and treat is as pure MBR
2001+ disk. This differs from GRUB2 behavior which always checks for LDM
2002+ label whether SFS partition exists or not.
2003+
2004+ Would the following be appropriate? It adds additional check for
2005+ partition 0x42 before checking for LDM labels.
2006+
2007+ -andrey
2008+
2009+--- a/grub-core/disk/ldm.c
2010++++ b/grub-core/disk/ldm.c
2011+@@ -22,6 +22,7 @@
2012+ #include <grub/err.h>
2013+ #include <grub/misc.h>
2014+ #include <grub/diskfilter.h>
2015++#include <grub/msdos_partition.h>
2016+ #include <grub/gpt_partition.h>
2017+ #include <grub/i18n.h>
2018+
2019+@@ -103,6 +104,34 @@
2020+ return ret;
2021+ }
2022+
2023++static int
2024++msdos_has_ldm_partition (grub_disk_t dsk)
2025++{
2026++ grub_err_t err;
2027++ int has_sfs = 0;
2028++ auto int hook (grub_disk_t disk, const grub_partition_t p);
2029++ int hook (grub_disk_t disk __attribute__ ((unused)), const grub_partition_t p)
2030++ {
2031++ if (p->number >= 4)
2032++ return 1;
2033++ if (p->msdostype == GRUB_PC_PARTITION_TYPE_SFS)
2034++ {
2035++ has_sfs = 1;
2036++ return 1;
2037++ }
2038++ return 0;
2039++ }
2040++
2041++ err = grub_partition_msdos_iterate (dsk, hook);
2042++ if (err)
2043++ {
2044++ grub_errno = GRUB_ERR_NONE;
2045++ return 0;
2046++ }
2047++
2048++ return has_sfs;
2049++}
2050++
2051+ static const grub_gpt_part_type_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM;
2052+
2053+ static grub_disk_addr_t
2054+@@ -756,17 +785,20 @@
2055+
2056+ {
2057+ int i;
2058++ int has_sfs = msdos_has_ldm_partition (disk);
2059+ for (i = 0; i < 3; i++)
2060+ {
2061+ grub_disk_addr_t sector = LDM_LABEL_SECTOR;
2062+ switch (i)
2063+ {
2064+ case 0:
2065++ if (!has_sfs)
2066++ continue;
2067+ sector = LDM_LABEL_SECTOR;
2068+ break;
2069+ case 1:
2070+ /* LDM is never inside a partition. */
2071+- if (disk->partition)
2072++ if (!has_sfs || disk->partition)
2073+ continue;
2074+ sector = grub_disk_get_size (disk);
2075+ if (sector == GRUB_DISK_SIZE_UNKNOWN)
2076+@@ -867,6 +899,7 @@
2077+ grub_util_is_ldm (grub_disk_t disk)
2078+ {
2079+ int i;
2080++ int has_sfs = msdos_has_ldm_partition (disk);
2081+ for (i = 0; i < 3; i++)
2082+ {
2083+ grub_disk_addr_t sector = LDM_LABEL_SECTOR;
2084+@@ -876,11 +909,13 @@
2085+ switch (i)
2086+ {
2087+ case 0:
2088++ if (!has_sfs)
2089++ continue;
2090+ sector = LDM_LABEL_SECTOR;
2091+ break;
2092+ case 1:
2093+ /* LDM is never inside a partition. */
2094+- if (disk->partition)
2095++ if (!has_sfs || disk->partition)
2096+ continue;
2097+ sector = grub_disk_get_size (disk);
2098+ if (sector == GRUB_DISK_SIZE_UNKNOWN)
2099+--- a/include/grub/msdos_partition.h
2100++++ b/include/grub/msdos_partition.h
2101+@@ -43,6 +43,7 @@
2102+ #define GRUB_PC_PARTITION_TYPE_FAT16_LBA 0xe
2103+ #define GRUB_PC_PARTITION_TYPE_WIN95_EXTENDED 0xf
2104+ #define GRUB_PC_PARTITION_TYPE_PLAN9 0x39
2105++#define GRUB_PC_PARTITION_TYPE_SFS 0x42
2106+ #define GRUB_PC_PARTITION_TYPE_EZD 0x55
2107+ #define GRUB_PC_PARTITION_TYPE_MINIX 0x80
2108+ #define GRUB_PC_PARTITION_TYPE_LINUX_MINIX 0x81
2109+--- a/Makefile.util.def
2110++++ b/Makefile.util.def
2111+@@ -32,6 +32,7 @@
2112+ common = grub-core/disk/ldm.c;
2113+ common = grub-core/disk/diskfilter.c;
2114+ common = grub-core/partmap/gpt.c;
2115++ common = grub-core/partmap/msdos.c;
2116+ };
2117+
2118+ library = {
2119+@@ -109,7 +110,6 @@
2120+ common = grub-core/partmap/acorn.c;
2121+ common = grub-core/partmap/amiga.c;
2122+ common = grub-core/partmap/apple.c;
2123+- common = grub-core/partmap/msdos.c;
2124+ common = grub-core/partmap/sun.c;
2125+ common = grub-core/partmap/plan.c;
2126+ common = grub-core/partmap/dvh.c;
2127
2128=== modified file 'debian/patches/series'
2129--- debian/patches/series 2012-10-31 10:36:57 +0000
2130+++ debian/patches/series 2012-12-03 15:02:19 +0000
2131@@ -56,3 +56,4 @@
2132 ubuntu_mount_readdir_symlink_failures.patch
2133 ubuntu_initrd_addr_min.patch
2134 ubuntu_gnulib_gets.patch
2135+ldm-require-sfs-partition.patch
2136
2137=== modified file 'grub-core/disk/ldm.c'
2138--- grub-core/disk/ldm.c 2012-09-13 18:02:04 +0000
2139+++ grub-core/disk/ldm.c 2012-12-03 15:02:19 +0000
2140@@ -22,6 +22,7 @@
2141 #include <grub/err.h>
2142 #include <grub/misc.h>
2143 #include <grub/diskfilter.h>
2144+#include <grub/msdos_partition.h>
2145 #include <grub/gpt_partition.h>
2146 #include <grub/i18n.h>
2147
2148@@ -103,6 +104,34 @@
2149 return ret;
2150 }
2151
2152+static int
2153+msdos_has_ldm_partition (grub_disk_t dsk)
2154+{
2155+ grub_err_t err;
2156+ int has_sfs = 0;
2157+ auto int hook (grub_disk_t disk, const grub_partition_t p);
2158+ int hook (grub_disk_t disk __attribute__ ((unused)), const grub_partition_t p)
2159+ {
2160+ if (p->number >= 4)
2161+ return 1;
2162+ if (p->msdostype == GRUB_PC_PARTITION_TYPE_SFS)
2163+ {
2164+ has_sfs = 1;
2165+ return 1;
2166+ }
2167+ return 0;
2168+ }
2169+
2170+ err = grub_partition_msdos_iterate (dsk, hook);
2171+ if (err)
2172+ {
2173+ grub_errno = GRUB_ERR_NONE;
2174+ return 0;
2175+ }
2176+
2177+ return has_sfs;
2178+}
2179+
2180 static const grub_gpt_part_type_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM;
2181
2182 static grub_disk_addr_t
2183@@ -756,17 +785,20 @@
2184
2185 {
2186 int i;
2187+ int has_sfs = msdos_has_ldm_partition (disk);
2188 for (i = 0; i < 3; i++)
2189 {
2190 grub_disk_addr_t sector = LDM_LABEL_SECTOR;
2191 switch (i)
2192 {
2193 case 0:
2194+ if (!has_sfs)
2195+ continue;
2196 sector = LDM_LABEL_SECTOR;
2197 break;
2198 case 1:
2199 /* LDM is never inside a partition. */
2200- if (disk->partition)
2201+ if (!has_sfs || disk->partition)
2202 continue;
2203 sector = grub_disk_get_size (disk);
2204 if (sector == GRUB_DISK_SIZE_UNKNOWN)
2205@@ -867,6 +899,7 @@
2206 grub_util_is_ldm (grub_disk_t disk)
2207 {
2208 int i;
2209+ int has_sfs = msdos_has_ldm_partition (disk);
2210 for (i = 0; i < 3; i++)
2211 {
2212 grub_disk_addr_t sector = LDM_LABEL_SECTOR;
2213@@ -876,11 +909,13 @@
2214 switch (i)
2215 {
2216 case 0:
2217+ if (!has_sfs)
2218+ continue;
2219 sector = LDM_LABEL_SECTOR;
2220 break;
2221 case 1:
2222 /* LDM is never inside a partition. */
2223- if (disk->partition)
2224+ if (!has_sfs || disk->partition)
2225 continue;
2226 sector = grub_disk_get_size (disk);
2227 if (sector == GRUB_DISK_SIZE_UNKNOWN)
2228
2229=== modified file 'include/grub/msdos_partition.h'
2230--- include/grub/msdos_partition.h 2012-09-13 18:02:04 +0000
2231+++ include/grub/msdos_partition.h 2012-12-03 15:02:19 +0000
2232@@ -43,6 +43,7 @@
2233 #define GRUB_PC_PARTITION_TYPE_FAT16_LBA 0xe
2234 #define GRUB_PC_PARTITION_TYPE_WIN95_EXTENDED 0xf
2235 #define GRUB_PC_PARTITION_TYPE_PLAN9 0x39
2236+#define GRUB_PC_PARTITION_TYPE_SFS 0x42
2237 #define GRUB_PC_PARTITION_TYPE_EZD 0x55
2238 #define GRUB_PC_PARTITION_TYPE_MINIX 0x80
2239 #define GRUB_PC_PARTITION_TYPE_LINUX_MINIX 0x81

Subscribers

People subscribed via source and target branches

to all changes: