From d1b11e8305621d73ff675af940e7f1f28b639b0d Mon Sep 17 00:00:00 2001 From: srs5694 Date: Sun, 18 Sep 2011 21:12:28 -0400 Subject: [PATCH] Fixed bug in reading GPTs with encoded header sizes other than 92 bytes. --- Makefile | 463 +++++++++++++++++++++++++++++++++++++++++++++++++++ NEWS | 17 ++ gpt.cc | 94 +++++++---- gpt.h | 2 +- gptcl.cc | 11 +- gptcl.h | 2 +- gptcurses.cc | 8 +- gptcurses.h | 10 +- support.h | 2 +- 9 files changed, 567 insertions(+), 42 deletions(-) diff --git a/Makefile b/Makefile index f0157c1..93153af 100644 --- a/Makefile +++ b/Makefile @@ -43,3 +43,466 @@ $(OBJS): # DO NOT DELETE +attributes.o: /usr/include/stdint.h /usr/include/features.h +attributes.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h +attributes.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h +attributes.o: /usr/include/bits/wchar.h /usr/include/stdio.h +attributes.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h +attributes.o: /usr/include/libio.h /usr/include/_G_config.h +attributes.o: /usr/include/wchar.h /usr/include/bits/libio-ldbl.h +attributes.o: /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h +attributes.o: /usr/include/bits/stdio-ldbl.h attributes.h support.h +attributes.o: /usr/include/stdlib.h /usr/include/sys/types.h +attributes.o: /usr/include/time.h /usr/include/endian.h +attributes.o: /usr/include/bits/endian.h /usr/include/sys/select.h +attributes.o: /usr/include/bits/select.h /usr/include/bits/sigset.h +attributes.o: /usr/include/bits/time.h /usr/include/sys/sysmacros.h +attributes.o: /usr/include/bits/pthreadtypes.h /usr/include/alloca.h +attributes.o: /usr/include/bits/stdlib-ldbl.h +basicmbr.o: /usr/include/stdio.h /usr/include/features.h +basicmbr.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h +basicmbr.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h +basicmbr.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h +basicmbr.o: /usr/include/libio.h /usr/include/_G_config.h +basicmbr.o: /usr/include/wchar.h /usr/include/bits/libio-ldbl.h +basicmbr.o: /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h +basicmbr.o: /usr/include/bits/stdio-ldbl.h /usr/include/stdlib.h +basicmbr.o: /usr/include/sys/types.h /usr/include/time.h +basicmbr.o: /usr/include/endian.h /usr/include/bits/endian.h +basicmbr.o: /usr/include/sys/select.h /usr/include/bits/select.h +basicmbr.o: /usr/include/bits/sigset.h /usr/include/bits/time.h +basicmbr.o: /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h +basicmbr.o: /usr/include/alloca.h /usr/include/bits/stdlib-ldbl.h +basicmbr.o: /usr/include/stdint.h /usr/include/bits/wchar.h +basicmbr.o: /usr/include/fcntl.h /usr/include/bits/fcntl.h +basicmbr.o: /usr/include/string.h /usr/include/sys/stat.h +basicmbr.o: /usr/include/bits/stat.h /usr/include/errno.h +basicmbr.o: /usr/include/bits/errno.h /usr/include/linux/errno.h +basicmbr.o: /usr/include/asm/errno.h /usr/include/asm-generic/errno.h +basicmbr.o: /usr/include/asm-generic/errno-base.h mbr.h gptpart.h support.h +basicmbr.o: parttypes.h guid.h /usr/include/uuid/uuid.h +basicmbr.o: /usr/include/sys/time.h attributes.h diskio.h +basicmbr.o: /usr/include/sys/ioctl.h /usr/include/bits/ioctls.h +basicmbr.o: /usr/include/asm/ioctls.h /usr/include/asm/ioctl.h +basicmbr.o: /usr/include/bits/ioctl-types.h /usr/include/termios.h +basicmbr.o: /usr/include/bits/termios.h /usr/include/sys/ttydefaults.h +basicmbr.o: basicmbr.h mbrpart.h +bsd.o: /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h +bsd.o: /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h +bsd.o: /usr/include/gnu/stubs-32.h /usr/include/bits/types.h +bsd.o: /usr/include/bits/typesizes.h /usr/include/libio.h +bsd.o: /usr/include/_G_config.h /usr/include/wchar.h +bsd.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h +bsd.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h +bsd.o: /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h +bsd.o: /usr/include/endian.h /usr/include/bits/endian.h +bsd.o: /usr/include/sys/select.h /usr/include/bits/select.h +bsd.o: /usr/include/bits/sigset.h /usr/include/bits/time.h +bsd.o: /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h +bsd.o: /usr/include/alloca.h /usr/include/bits/stdlib-ldbl.h +bsd.o: /usr/include/stdint.h /usr/include/bits/wchar.h /usr/include/fcntl.h +bsd.o: /usr/include/bits/fcntl.h /usr/include/sys/stat.h +bsd.o: /usr/include/bits/stat.h /usr/include/errno.h +bsd.o: /usr/include/bits/errno.h /usr/include/linux/errno.h +bsd.o: /usr/include/asm/errno.h /usr/include/asm-generic/errno.h +bsd.o: /usr/include/asm-generic/errno-base.h support.h bsd.h gptpart.h +bsd.o: parttypes.h guid.h /usr/include/uuid/uuid.h /usr/include/sys/time.h +bsd.o: attributes.h diskio.h /usr/include/sys/ioctl.h +bsd.o: /usr/include/bits/ioctls.h /usr/include/asm/ioctls.h +bsd.o: /usr/include/asm/ioctl.h /usr/include/bits/ioctl-types.h +bsd.o: /usr/include/termios.h /usr/include/bits/termios.h +bsd.o: /usr/include/sys/ttydefaults.h +cgdisk.o: gptcurses.h gptpart.h /usr/include/stdint.h /usr/include/features.h +cgdisk.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h +cgdisk.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h +cgdisk.o: /usr/include/bits/wchar.h /usr/include/sys/types.h +cgdisk.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h +cgdisk.o: /usr/include/time.h /usr/include/endian.h +cgdisk.o: /usr/include/bits/endian.h /usr/include/sys/select.h +cgdisk.o: /usr/include/bits/select.h /usr/include/bits/sigset.h +cgdisk.o: /usr/include/bits/time.h /usr/include/sys/sysmacros.h +cgdisk.o: /usr/include/bits/pthreadtypes.h support.h /usr/include/stdlib.h +cgdisk.o: /usr/include/alloca.h /usr/include/bits/stdlib-ldbl.h parttypes.h +cgdisk.o: guid.h /usr/include/uuid/uuid.h /usr/include/sys/time.h +cgdisk.o: attributes.h gpt.h mbr.h diskio.h /usr/include/sys/ioctl.h +cgdisk.o: /usr/include/bits/ioctls.h /usr/include/asm/ioctls.h +cgdisk.o: /usr/include/asm/ioctl.h /usr/include/bits/ioctl-types.h +cgdisk.o: /usr/include/termios.h /usr/include/bits/termios.h +cgdisk.o: /usr/include/sys/ttydefaults.h basicmbr.h mbrpart.h bsd.h +crc32.o: /usr/include/stdio.h /usr/include/features.h +crc32.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h +crc32.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h +crc32.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h +crc32.o: /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h +crc32.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h +crc32.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h +crc32.o: /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h +crc32.o: /usr/include/endian.h /usr/include/bits/endian.h +crc32.o: /usr/include/sys/select.h /usr/include/bits/select.h +crc32.o: /usr/include/bits/sigset.h /usr/include/bits/time.h +crc32.o: /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h +crc32.o: /usr/include/alloca.h /usr/include/bits/stdlib-ldbl.h crc32.h +crc32.o: /usr/include/stdint.h /usr/include/bits/wchar.h +diskio.o: /usr/include/sys/ioctl.h /usr/include/features.h +diskio.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h +diskio.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h +diskio.o: /usr/include/bits/ioctls.h /usr/include/asm/ioctls.h +diskio.o: /usr/include/asm/ioctl.h /usr/include/bits/ioctl-types.h +diskio.o: /usr/include/termios.h /usr/include/bits/termios.h +diskio.o: /usr/include/sys/ttydefaults.h /usr/include/stdint.h +diskio.o: /usr/include/bits/wchar.h /usr/include/errno.h +diskio.o: /usr/include/bits/errno.h /usr/include/linux/errno.h +diskio.o: /usr/include/asm/errno.h /usr/include/asm-generic/errno.h +diskio.o: /usr/include/asm-generic/errno-base.h /usr/include/fcntl.h +diskio.o: /usr/include/bits/fcntl.h /usr/include/sys/types.h +diskio.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h +diskio.o: /usr/include/time.h /usr/include/endian.h +diskio.o: /usr/include/bits/endian.h /usr/include/sys/select.h +diskio.o: /usr/include/bits/select.h /usr/include/bits/sigset.h +diskio.o: /usr/include/bits/time.h /usr/include/sys/sysmacros.h +diskio.o: /usr/include/bits/pthreadtypes.h /usr/include/sys/stat.h +diskio.o: /usr/include/bits/stat.h support.h /usr/include/stdlib.h +diskio.o: /usr/include/alloca.h /usr/include/bits/stdlib-ldbl.h diskio.h +diskio-unix.o: /usr/include/sys/ioctl.h /usr/include/features.h +diskio-unix.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h +diskio-unix.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h +diskio-unix.o: /usr/include/bits/ioctls.h /usr/include/asm/ioctls.h +diskio-unix.o: /usr/include/asm/ioctl.h /usr/include/bits/ioctl-types.h +diskio-unix.o: /usr/include/termios.h /usr/include/bits/termios.h +diskio-unix.o: /usr/include/sys/ttydefaults.h /usr/include/string.h +diskio-unix.o: /usr/include/stdint.h /usr/include/bits/wchar.h +diskio-unix.o: /usr/include/errno.h /usr/include/bits/errno.h +diskio-unix.o: /usr/include/linux/errno.h /usr/include/asm/errno.h +diskio-unix.o: /usr/include/asm-generic/errno.h +diskio-unix.o: /usr/include/asm-generic/errno-base.h /usr/include/fcntl.h +diskio-unix.o: /usr/include/bits/fcntl.h /usr/include/sys/types.h +diskio-unix.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h +diskio-unix.o: /usr/include/time.h /usr/include/endian.h +diskio-unix.o: /usr/include/bits/endian.h /usr/include/sys/select.h +diskio-unix.o: /usr/include/bits/select.h /usr/include/bits/sigset.h +diskio-unix.o: /usr/include/bits/time.h /usr/include/sys/sysmacros.h +diskio-unix.o: /usr/include/bits/pthreadtypes.h /usr/include/sys/stat.h +diskio-unix.o: /usr/include/bits/stat.h diskio.h support.h +diskio-unix.o: /usr/include/stdlib.h /usr/include/alloca.h +diskio-unix.o: /usr/include/bits/stdlib-ldbl.h +diskio-windows.o: /usr/include/stdio.h /usr/include/features.h +diskio-windows.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h +diskio-windows.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h +diskio-windows.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h +diskio-windows.o: /usr/include/libio.h /usr/include/_G_config.h +diskio-windows.o: /usr/include/wchar.h /usr/include/bits/libio-ldbl.h +diskio-windows.o: /usr/include/bits/stdio_lim.h +diskio-windows.o: /usr/include/bits/sys_errlist.h +diskio-windows.o: /usr/include/bits/stdio-ldbl.h /usr/include/stdint.h +diskio-windows.o: /usr/include/bits/wchar.h /usr/include/errno.h +diskio-windows.o: /usr/include/bits/errno.h /usr/include/linux/errno.h +diskio-windows.o: /usr/include/asm/errno.h /usr/include/asm-generic/errno.h +diskio-windows.o: /usr/include/asm-generic/errno-base.h /usr/include/fcntl.h +diskio-windows.o: /usr/include/bits/fcntl.h /usr/include/sys/types.h +diskio-windows.o: /usr/include/time.h /usr/include/endian.h +diskio-windows.o: /usr/include/bits/endian.h /usr/include/sys/select.h +diskio-windows.o: /usr/include/bits/select.h /usr/include/bits/sigset.h +diskio-windows.o: /usr/include/bits/time.h /usr/include/sys/sysmacros.h +diskio-windows.o: /usr/include/bits/pthreadtypes.h /usr/include/sys/stat.h +diskio-windows.o: /usr/include/bits/stat.h support.h /usr/include/stdlib.h +diskio-windows.o: /usr/include/alloca.h /usr/include/bits/stdlib-ldbl.h +diskio-windows.o: diskio.h /usr/include/sys/ioctl.h +diskio-windows.o: /usr/include/bits/ioctls.h /usr/include/asm/ioctls.h +diskio-windows.o: /usr/include/asm/ioctl.h /usr/include/bits/ioctl-types.h +diskio-windows.o: /usr/include/termios.h /usr/include/bits/termios.h +diskio-windows.o: /usr/include/sys/ttydefaults.h +fixparts.o: /usr/include/stdio.h /usr/include/features.h +fixparts.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h +fixparts.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h +fixparts.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h +fixparts.o: /usr/include/libio.h /usr/include/_G_config.h +fixparts.o: /usr/include/wchar.h /usr/include/bits/libio-ldbl.h +fixparts.o: /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h +fixparts.o: /usr/include/bits/stdio-ldbl.h /usr/include/string.h basicmbr.h +fixparts.o: /usr/include/stdint.h /usr/include/bits/wchar.h +fixparts.o: /usr/include/sys/types.h /usr/include/time.h +fixparts.o: /usr/include/endian.h /usr/include/bits/endian.h +fixparts.o: /usr/include/sys/select.h /usr/include/bits/select.h +fixparts.o: /usr/include/bits/sigset.h /usr/include/bits/time.h +fixparts.o: /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h +fixparts.o: diskio.h /usr/include/sys/ioctl.h /usr/include/bits/ioctls.h +fixparts.o: /usr/include/asm/ioctls.h /usr/include/asm/ioctl.h +fixparts.o: /usr/include/bits/ioctl-types.h /usr/include/termios.h +fixparts.o: /usr/include/bits/termios.h /usr/include/sys/ttydefaults.h +fixparts.o: support.h /usr/include/stdlib.h /usr/include/alloca.h +fixparts.o: /usr/include/bits/stdlib-ldbl.h mbrpart.h +gdisk.o: /usr/include/string.h /usr/include/features.h +gdisk.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h +gdisk.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h gpttext.h gpt.h +gdisk.o: /usr/include/stdint.h /usr/include/bits/wchar.h +gdisk.o: /usr/include/sys/types.h /usr/include/bits/types.h +gdisk.o: /usr/include/bits/typesizes.h /usr/include/time.h +gdisk.o: /usr/include/endian.h /usr/include/bits/endian.h +gdisk.o: /usr/include/sys/select.h /usr/include/bits/select.h +gdisk.o: /usr/include/bits/sigset.h /usr/include/bits/time.h +gdisk.o: /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h +gdisk.o: gptpart.h support.h /usr/include/stdlib.h /usr/include/alloca.h +gdisk.o: /usr/include/bits/stdlib-ldbl.h parttypes.h guid.h +gdisk.o: /usr/include/uuid/uuid.h /usr/include/sys/time.h attributes.h mbr.h +gdisk.o: diskio.h /usr/include/sys/ioctl.h /usr/include/bits/ioctls.h +gdisk.o: /usr/include/asm/ioctls.h /usr/include/asm/ioctl.h +gdisk.o: /usr/include/bits/ioctl-types.h /usr/include/termios.h +gdisk.o: /usr/include/bits/termios.h /usr/include/sys/ttydefaults.h +gdisk.o: basicmbr.h mbrpart.h bsd.h +gpt.o: /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h +gpt.o: /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h +gpt.o: /usr/include/gnu/stubs-32.h /usr/include/bits/types.h +gpt.o: /usr/include/bits/typesizes.h /usr/include/libio.h +gpt.o: /usr/include/_G_config.h /usr/include/wchar.h +gpt.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h +gpt.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h +gpt.o: /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h +gpt.o: /usr/include/endian.h /usr/include/bits/endian.h +gpt.o: /usr/include/sys/select.h /usr/include/bits/select.h +gpt.o: /usr/include/bits/sigset.h /usr/include/bits/time.h +gpt.o: /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h +gpt.o: /usr/include/alloca.h /usr/include/bits/stdlib-ldbl.h +gpt.o: /usr/include/stdint.h /usr/include/bits/wchar.h /usr/include/fcntl.h +gpt.o: /usr/include/bits/fcntl.h /usr/include/string.h /usr/include/math.h +gpt.o: /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h +gpt.o: /usr/include/bits/mathcalls.h /usr/include/sys/stat.h +gpt.o: /usr/include/bits/stat.h /usr/include/errno.h +gpt.o: /usr/include/bits/errno.h /usr/include/linux/errno.h +gpt.o: /usr/include/asm/errno.h /usr/include/asm-generic/errno.h +gpt.o: /usr/include/asm-generic/errno-base.h crc32.h gpt.h gptpart.h +gpt.o: support.h parttypes.h guid.h /usr/include/uuid/uuid.h +gpt.o: /usr/include/sys/time.h attributes.h mbr.h diskio.h +gpt.o: /usr/include/sys/ioctl.h /usr/include/bits/ioctls.h +gpt.o: /usr/include/asm/ioctls.h /usr/include/asm/ioctl.h +gpt.o: /usr/include/bits/ioctl-types.h /usr/include/termios.h +gpt.o: /usr/include/bits/termios.h /usr/include/sys/ttydefaults.h basicmbr.h +gpt.o: mbrpart.h bsd.h +gptcl.o: /usr/include/string.h /usr/include/features.h +gptcl.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h +gptcl.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h +gptcl.o: /usr/include/errno.h /usr/include/bits/errno.h +gptcl.o: /usr/include/linux/errno.h /usr/include/asm/errno.h +gptcl.o: /usr/include/asm-generic/errno.h +gptcl.o: /usr/include/asm-generic/errno-base.h /usr/include/popt.h +gptcl.o: /usr/include/stdio.h /usr/include/bits/types.h +gptcl.o: /usr/include/bits/typesizes.h /usr/include/libio.h +gptcl.o: /usr/include/_G_config.h /usr/include/wchar.h +gptcl.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h +gptcl.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h +gptcl.o: gptcl.h gpt.h /usr/include/stdint.h /usr/include/bits/wchar.h +gptcl.o: /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h +gptcl.o: /usr/include/bits/endian.h /usr/include/sys/select.h +gptcl.o: /usr/include/bits/select.h /usr/include/bits/sigset.h +gptcl.o: /usr/include/bits/time.h /usr/include/sys/sysmacros.h +gptcl.o: /usr/include/bits/pthreadtypes.h gptpart.h support.h +gptcl.o: /usr/include/stdlib.h /usr/include/alloca.h +gptcl.o: /usr/include/bits/stdlib-ldbl.h parttypes.h guid.h +gptcl.o: /usr/include/uuid/uuid.h /usr/include/sys/time.h attributes.h mbr.h +gptcl.o: diskio.h /usr/include/sys/ioctl.h /usr/include/bits/ioctls.h +gptcl.o: /usr/include/asm/ioctls.h /usr/include/asm/ioctl.h +gptcl.o: /usr/include/bits/ioctl-types.h /usr/include/termios.h +gptcl.o: /usr/include/bits/termios.h /usr/include/sys/ttydefaults.h +gptcl.o: basicmbr.h mbrpart.h bsd.h +gptcurses.o: /usr/include/ncurses.h /usr/include/ncurses_dll.h +gptcurses.o: /usr/include/stdio.h /usr/include/features.h +gptcurses.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h +gptcurses.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h +gptcurses.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h +gptcurses.o: /usr/include/libio.h /usr/include/_G_config.h +gptcurses.o: /usr/include/wchar.h /usr/include/bits/libio-ldbl.h +gptcurses.o: /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h +gptcurses.o: /usr/include/bits/stdio-ldbl.h /usr/include/unctrl.h +gptcurses.o: /usr/include/curses.h gptcurses.h gptpart.h +gptcurses.o: /usr/include/stdint.h /usr/include/bits/wchar.h +gptcurses.o: /usr/include/sys/types.h /usr/include/time.h +gptcurses.o: /usr/include/endian.h /usr/include/bits/endian.h +gptcurses.o: /usr/include/sys/select.h /usr/include/bits/select.h +gptcurses.o: /usr/include/bits/sigset.h /usr/include/bits/time.h +gptcurses.o: /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h +gptcurses.o: support.h /usr/include/stdlib.h /usr/include/alloca.h +gptcurses.o: /usr/include/bits/stdlib-ldbl.h parttypes.h guid.h +gptcurses.o: /usr/include/uuid/uuid.h /usr/include/sys/time.h attributes.h +gptcurses.o: gpt.h mbr.h diskio.h /usr/include/sys/ioctl.h +gptcurses.o: /usr/include/bits/ioctls.h /usr/include/asm/ioctls.h +gptcurses.o: /usr/include/asm/ioctl.h /usr/include/bits/ioctl-types.h +gptcurses.o: /usr/include/termios.h /usr/include/bits/termios.h +gptcurses.o: /usr/include/sys/ttydefaults.h basicmbr.h mbrpart.h bsd.h +gptpart.o: /usr/include/string.h /usr/include/features.h +gptpart.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h +gptpart.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h +gptpart.o: /usr/include/stdio.h /usr/include/bits/types.h +gptpart.o: /usr/include/bits/typesizes.h /usr/include/libio.h +gptpart.o: /usr/include/_G_config.h /usr/include/wchar.h +gptpart.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h +gptpart.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h +gptpart.o: gptpart.h /usr/include/stdint.h /usr/include/bits/wchar.h +gptpart.o: /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h +gptpart.o: /usr/include/bits/endian.h /usr/include/sys/select.h +gptpart.o: /usr/include/bits/select.h /usr/include/bits/sigset.h +gptpart.o: /usr/include/bits/time.h /usr/include/sys/sysmacros.h +gptpart.o: /usr/include/bits/pthreadtypes.h support.h /usr/include/stdlib.h +gptpart.o: /usr/include/alloca.h /usr/include/bits/stdlib-ldbl.h parttypes.h +gptpart.o: guid.h /usr/include/uuid/uuid.h /usr/include/sys/time.h +gptpart.o: attributes.h +gpttext.o: /usr/include/string.h /usr/include/features.h +gpttext.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h +gpttext.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h +gpttext.o: /usr/include/errno.h /usr/include/bits/errno.h +gpttext.o: /usr/include/linux/errno.h /usr/include/asm/errno.h +gpttext.o: /usr/include/asm-generic/errno.h +gpttext.o: /usr/include/asm-generic/errno-base.h /usr/include/stdint.h +gpttext.o: /usr/include/bits/wchar.h /usr/include/limits.h +gpttext.o: /usr/include/bits/posix1_lim.h /usr/include/bits/local_lim.h +gpttext.o: /usr/include/linux/limits.h /usr/include/bits/posix2_lim.h +gpttext.o: attributes.h gpttext.h gpt.h /usr/include/sys/types.h +gpttext.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h +gpttext.o: /usr/include/time.h /usr/include/endian.h +gpttext.o: /usr/include/bits/endian.h /usr/include/sys/select.h +gpttext.o: /usr/include/bits/select.h /usr/include/bits/sigset.h +gpttext.o: /usr/include/bits/time.h /usr/include/sys/sysmacros.h +gpttext.o: /usr/include/bits/pthreadtypes.h gptpart.h support.h +gpttext.o: /usr/include/stdlib.h /usr/include/alloca.h +gpttext.o: /usr/include/bits/stdlib-ldbl.h parttypes.h guid.h +gpttext.o: /usr/include/uuid/uuid.h /usr/include/sys/time.h mbr.h diskio.h +gpttext.o: /usr/include/sys/ioctl.h /usr/include/bits/ioctls.h +gpttext.o: /usr/include/asm/ioctls.h /usr/include/asm/ioctl.h +gpttext.o: /usr/include/bits/ioctl-types.h /usr/include/termios.h +gpttext.o: /usr/include/bits/termios.h /usr/include/sys/ttydefaults.h +gpttext.o: basicmbr.h mbrpart.h bsd.h +guid.o: /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h +guid.o: /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h +guid.o: /usr/include/gnu/stubs-32.h /usr/include/bits/types.h +guid.o: /usr/include/bits/typesizes.h /usr/include/libio.h +guid.o: /usr/include/_G_config.h /usr/include/wchar.h +guid.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h +guid.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h +guid.o: /usr/include/time.h /usr/include/string.h guid.h +guid.o: /usr/include/stdint.h /usr/include/bits/wchar.h +guid.o: /usr/include/uuid/uuid.h /usr/include/sys/types.h +guid.o: /usr/include/endian.h /usr/include/bits/endian.h +guid.o: /usr/include/sys/select.h /usr/include/bits/select.h +guid.o: /usr/include/bits/sigset.h /usr/include/bits/time.h +guid.o: /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h +guid.o: /usr/include/sys/time.h support.h /usr/include/stdlib.h +guid.o: /usr/include/alloca.h /usr/include/bits/stdlib-ldbl.h +mbr.o: /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h +mbr.o: /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h +mbr.o: /usr/include/gnu/stubs-32.h /usr/include/bits/types.h +mbr.o: /usr/include/bits/typesizes.h /usr/include/libio.h +mbr.o: /usr/include/_G_config.h /usr/include/wchar.h +mbr.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h +mbr.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h +mbr.o: /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h +mbr.o: /usr/include/endian.h /usr/include/bits/endian.h +mbr.o: /usr/include/sys/select.h /usr/include/bits/select.h +mbr.o: /usr/include/bits/sigset.h /usr/include/bits/time.h +mbr.o: /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h +mbr.o: /usr/include/alloca.h /usr/include/bits/stdlib-ldbl.h +mbr.o: /usr/include/stdint.h /usr/include/bits/wchar.h /usr/include/fcntl.h +mbr.o: /usr/include/bits/fcntl.h /usr/include/string.h +mbr.o: /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/errno.h +mbr.o: /usr/include/bits/errno.h /usr/include/linux/errno.h +mbr.o: /usr/include/asm/errno.h /usr/include/asm-generic/errno.h +mbr.o: /usr/include/asm-generic/errno-base.h mbr.h gptpart.h support.h +mbr.o: parttypes.h guid.h /usr/include/uuid/uuid.h /usr/include/sys/time.h +mbr.o: attributes.h diskio.h /usr/include/sys/ioctl.h +mbr.o: /usr/include/bits/ioctls.h /usr/include/asm/ioctls.h +mbr.o: /usr/include/asm/ioctl.h /usr/include/bits/ioctl-types.h +mbr.o: /usr/include/termios.h /usr/include/bits/termios.h +mbr.o: /usr/include/sys/ttydefaults.h basicmbr.h mbrpart.h +mbrpart.o: /usr/include/stdint.h /usr/include/features.h +mbrpart.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h +mbrpart.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h +mbrpart.o: /usr/include/bits/wchar.h support.h /usr/include/stdlib.h +mbrpart.o: /usr/include/sys/types.h /usr/include/bits/types.h +mbrpart.o: /usr/include/bits/typesizes.h /usr/include/time.h +mbrpart.o: /usr/include/endian.h /usr/include/bits/endian.h +mbrpart.o: /usr/include/sys/select.h /usr/include/bits/select.h +mbrpart.o: /usr/include/bits/sigset.h /usr/include/bits/time.h +mbrpart.o: /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h +mbrpart.o: /usr/include/alloca.h /usr/include/bits/stdlib-ldbl.h mbrpart.h +parttypes.o: /usr/include/string.h /usr/include/features.h +parttypes.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h +parttypes.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h +parttypes.o: /usr/include/stdint.h /usr/include/bits/wchar.h +parttypes.o: /usr/include/stdio.h /usr/include/bits/types.h +parttypes.o: /usr/include/bits/typesizes.h /usr/include/libio.h +parttypes.o: /usr/include/_G_config.h /usr/include/wchar.h +parttypes.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h +parttypes.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h +parttypes.o: parttypes.h /usr/include/stdlib.h /usr/include/sys/types.h +parttypes.o: /usr/include/time.h /usr/include/endian.h +parttypes.o: /usr/include/bits/endian.h /usr/include/sys/select.h +parttypes.o: /usr/include/bits/select.h /usr/include/bits/sigset.h +parttypes.o: /usr/include/bits/time.h /usr/include/sys/sysmacros.h +parttypes.o: /usr/include/bits/pthreadtypes.h /usr/include/alloca.h +parttypes.o: /usr/include/bits/stdlib-ldbl.h support.h guid.h +parttypes.o: /usr/include/uuid/uuid.h /usr/include/sys/time.h +sgdisk.o: gptcl.h gpt.h /usr/include/stdint.h /usr/include/features.h +sgdisk.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h +sgdisk.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h +sgdisk.o: /usr/include/bits/wchar.h /usr/include/sys/types.h +sgdisk.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h +sgdisk.o: /usr/include/time.h /usr/include/endian.h +sgdisk.o: /usr/include/bits/endian.h /usr/include/sys/select.h +sgdisk.o: /usr/include/bits/select.h /usr/include/bits/sigset.h +sgdisk.o: /usr/include/bits/time.h /usr/include/sys/sysmacros.h +sgdisk.o: /usr/include/bits/pthreadtypes.h gptpart.h support.h +sgdisk.o: /usr/include/stdlib.h /usr/include/alloca.h +sgdisk.o: /usr/include/bits/stdlib-ldbl.h parttypes.h guid.h +sgdisk.o: /usr/include/uuid/uuid.h /usr/include/sys/time.h attributes.h mbr.h +sgdisk.o: diskio.h /usr/include/sys/ioctl.h /usr/include/bits/ioctls.h +sgdisk.o: /usr/include/asm/ioctls.h /usr/include/asm/ioctl.h +sgdisk.o: /usr/include/bits/ioctl-types.h /usr/include/termios.h +sgdisk.o: /usr/include/bits/termios.h /usr/include/sys/ttydefaults.h +sgdisk.o: basicmbr.h mbrpart.h bsd.h /usr/include/popt.h /usr/include/stdio.h +sgdisk.o: /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h +sgdisk.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h +sgdisk.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h +support.o: /usr/include/stdio.h /usr/include/features.h +support.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h +support.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h +support.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h +support.o: /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h +support.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h +support.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h +support.o: /usr/include/stdint.h /usr/include/bits/wchar.h +support.o: /usr/include/errno.h /usr/include/bits/errno.h +support.o: /usr/include/linux/errno.h /usr/include/asm/errno.h +support.o: /usr/include/asm-generic/errno.h +support.o: /usr/include/asm-generic/errno-base.h /usr/include/fcntl.h +support.o: /usr/include/bits/fcntl.h /usr/include/sys/types.h +support.o: /usr/include/time.h /usr/include/endian.h +support.o: /usr/include/bits/endian.h /usr/include/sys/select.h +support.o: /usr/include/bits/select.h /usr/include/bits/sigset.h +support.o: /usr/include/bits/time.h /usr/include/sys/sysmacros.h +support.o: /usr/include/bits/pthreadtypes.h /usr/include/string.h +support.o: /usr/include/sys/stat.h /usr/include/bits/stat.h support.h +support.o: /usr/include/stdlib.h /usr/include/alloca.h +support.o: /usr/include/bits/stdlib-ldbl.h +test.o: /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h +test.o: /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h +test.o: /usr/include/gnu/stubs-32.h /usr/include/bits/types.h +test.o: /usr/include/bits/typesizes.h /usr/include/libio.h +test.o: /usr/include/_G_config.h /usr/include/wchar.h +test.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h +test.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h +test.o: support.h /usr/include/stdint.h /usr/include/bits/wchar.h +test.o: /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h +test.o: /usr/include/endian.h /usr/include/bits/endian.h +test.o: /usr/include/sys/select.h /usr/include/bits/select.h +test.o: /usr/include/bits/sigset.h /usr/include/bits/time.h +test.o: /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h +test.o: /usr/include/alloca.h /usr/include/bits/stdlib-ldbl.h +testguid.o: guid.h /usr/include/stdint.h /usr/include/features.h +testguid.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h +testguid.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h +testguid.o: /usr/include/bits/wchar.h /usr/include/uuid/uuid.h +testguid.o: /usr/include/sys/types.h /usr/include/bits/types.h +testguid.o: /usr/include/bits/typesizes.h /usr/include/time.h +testguid.o: /usr/include/endian.h /usr/include/bits/endian.h +testguid.o: /usr/include/sys/select.h /usr/include/bits/select.h +testguid.o: /usr/include/bits/sigset.h /usr/include/bits/time.h +testguid.o: /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h +testguid.o: /usr/include/sys/time.h parttypes.h /usr/include/stdlib.h +testguid.o: /usr/include/alloca.h /usr/include/bits/stdlib-ldbl.h support.h diff --git a/NEWS b/NEWS index 6496a16..40953f8 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,20 @@ +0.8.1 (?/??/2011): +------------------ + +- Changed GPT reading code to use the size encoded in GPT headers to + determine how much of the header to use in computing a CRC, with the + restriction that the size be equal to or less than the disk's sector + size. This should work around problems with libefi in ZFS, which sets the + header size to 512 rather than the standard 92. A caveat: If the disk's + sector size is larger than the GPTHeader data structure size (512 bytes), + then the rest of the sector's contents are ignored and replaced with 0 + values. This could produce false positives on CRC checks on disks with + over-512-byte sector sizes if the header sector is padded with something + other than 0 values. + +- Fixed bug in new (as of 0.8.0) check that main and backup partition + tables are identical on big-endian (PowerPC, etc.) hardware. + 0.8.0 (9/10/2011): ------------------ diff --git a/gpt.cc b/gpt.cc index 25ca53a..767f943 100644 --- a/gpt.cc +++ b/gpt.cc @@ -27,7 +27,6 @@ #include "parttypes.h" #include "attributes.h" #include "diskio.h" -//#include "partnotes.h" using namespace std; @@ -65,6 +64,8 @@ GPTData::GPTData(void) { mainHeader.numParts = 0; numParts = 0; SetGPTSize(NUM_GPT_ENTRIES); + // Initialize CRC functions... + chksum_crc32gentab(); } // GPTData default constructor // The following constructor loads GPT data from a device file @@ -86,6 +87,8 @@ GPTData::GPTData(string filename) { whichWasUsed = use_new; mainHeader.numParts = 0; numParts = 0; + // Initialize CRC functions... + chksum_crc32gentab(); if (!LoadPartitions(filename)) exit(2); } // GPTData(string filename) constructor @@ -129,7 +132,8 @@ GPTData & GPTData::operator=(const GPTData & orig) { } // if for (i = 0; i < numParts; i++) { partitions[i] = orig.partitions[i]; - } + } // for + return *this; } // GPTData::operator=() @@ -353,8 +357,8 @@ int GPTData::CheckGPTSize(void) { // Check the validity of the GPT header. Returns 1 if the main header // is valid, 2 if the backup header is valid, 3 if both are valid, and -// 0 if neither is valid. Note that this function just checks the GPT -// signature and revision numbers, not CRCs or other data. +// 0 if neither is valid. Note that this function checks the GPT signature, +// revision value, and CRCs in both headers. int GPTData::CheckHeaderValidity(void) { int valid = 3; @@ -363,7 +367,7 @@ int GPTData::CheckHeaderValidity(void) { // Note: failed GPT signature checks produce no error message because // a message is displayed in the ReversePartitionBytes() function - if (mainHeader.signature != GPT_SIGNATURE) { + if ((mainHeader.signature != GPT_SIGNATURE) || (!CheckHeaderCRC(&mainHeader, 1))) { valid -= 1; } else if ((mainHeader.revision != 0x00010000) && valid) { valid -= 1; @@ -374,7 +378,7 @@ int GPTData::CheckHeaderValidity(void) { cout << UINT32_C(0x00010000) << dec << "\n"; } // if/else/if - if (secondHeader.signature != GPT_SIGNATURE) { + if ((secondHeader.signature != GPT_SIGNATURE) || (!CheckHeaderCRC(&secondHeader))) { valid -= 2; } else if ((secondHeader.revision != 0x00010000) && valid) { valid -= 2; @@ -396,27 +400,50 @@ int GPTData::CheckHeaderValidity(void) { } // GPTData::CheckHeaderValidity() // Check the header CRC to see if it's OK... -// Note: Must be called with header in LITTLE-ENDIAN -// (x86, x86-64, etc.) byte order. -int GPTData::CheckHeaderCRC(struct GPTHeader* header) { +// Note: Must be called with header in platform-ordered byte order. +// Returns 1 if header's computed CRC matches the stored value, 0 if the +// computed and stored values don't match +int GPTData::CheckHeaderCRC(struct GPTHeader* header, int warn) { uint32_t oldCRC, newCRC, hSize; + uint8_t *temp; // Back up old header CRC and then blank it, since it must be 0 for // computation to be valid oldCRC = header->headerCRC; header->headerCRC = UINT32_C(0); + hSize = header->headerSize; - // If big-endian system, reverse byte order - if (IsLittleEndian() == 0) { - ReverseBytes(&oldCRC, 4); - } // if + if (IsLittleEndian() == 0) + ReverseHeaderBytes(header); - // Initialize CRC functions... - chksum_crc32gentab(); + if ((hSize > blockSize) || (hSize < HEADER_SIZE)) { + if (warn) { + cerr << "\aWarning! Header size is specified as " << hSize << ", which is invalid.\n"; + cerr << "Setting the header size for CRC computation to " << HEADER_SIZE << "\n"; + } // if + hSize = HEADER_SIZE; + } else if ((hSize > sizeof(GPTHeader)) && warn) { + cout << "\aCaution! Header size for CRC check is " << hSize << ", which is greater than " << sizeof(GPTHeader) << ".\n"; + cout << "If stray data exists after the header on the header sector, it will be ignored,\n" + << "which may result in a CRC false alarm.\n"; + } // if/elseif + temp = new uint8_t[hSize]; + if (temp != NULL) { + memset(temp, 0, hSize); + if (hSize < sizeof(GPTHeader)) + memcpy(temp, header, hSize); + else + memcpy(temp, header, sizeof(GPTHeader)); - // Compute CRC, restore original, and return result of comparison - newCRC = chksum_crc32((unsigned char*) header, HEADER_SIZE); + newCRC = chksum_crc32((unsigned char*) temp, hSize); + delete[] temp; + } else { + cerr << "Could not allocate memory in GPTData::CheckHeaderCRC()! Aborting!\n"; + exit(1); + } + if (IsLittleEndian() == 0) + ReverseHeaderBytes(header); header->headerCRC = oldCRC; return (oldCRC == newCRC); } // GPTData::CheckHeaderCRC() @@ -428,11 +455,12 @@ void GPTData::RecomputeCRCs(void) { uint32_t crc, hSize; int littleEndian = 1; - // Initialize CRC functions... - chksum_crc32gentab(); - - // Save some key data from header before reversing byte order.... - hSize = mainHeader.headerSize; + // If the header size is bigger than the GPT header data structure, reset it; + // otherwise, set both header sizes to whatever the main one is.... + if (mainHeader.headerSize > sizeof(GPTHeader)) + hSize = secondHeader.headerSize = mainHeader.headerSize = HEADER_SIZE; + else + hSize = secondHeader.headerSize = mainHeader.headerSize; if ((littleEndian = IsLittleEndian()) == 0) { ReversePartitionBytes(); @@ -449,11 +477,10 @@ void GPTData::RecomputeCRCs(void) { ReverseBytes(&secondHeader.partitionEntriesCRC, 4); } // if - // Zero out GPT tables' own CRCs (required for correct computation) + // Zero out GPT headers' own CRCs (required for correct computation) mainHeader.headerCRC = 0; secondHeader.headerCRC = 0; - // Compute & store CRCs of main & secondary headers... crc = chksum_crc32((unsigned char*) &mainHeader, hSize); if (littleEndian == 0) ReverseBytes(&crc, 4); @@ -463,7 +490,7 @@ void GPTData::RecomputeCRCs(void) { ReverseBytes(&crc, 4); secondHeader.headerCRC = crc; - if ((littleEndian = IsLittleEndian()) == 0) { + if (littleEndian == 0) { ReverseHeaderBytes(&mainHeader); ReverseHeaderBytes(&secondHeader); ReversePartitionBytes(); @@ -524,9 +551,9 @@ int GPTData::FindHybridMismatches(void) { if ((protectiveMBR.GetType(i) != 0xEE) && (protectiveMBR.GetType(i) != 0x00)) { j = 0; found = 0; + mbrFirst = (uint64_t) protectiveMBR.GetFirstSector(i); + mbrLast = mbrFirst + (uint64_t) protectiveMBR.GetLength(i) - UINT64_C(1); do { - mbrFirst = (uint64_t) protectiveMBR.GetFirstSector(i); - mbrLast = mbrFirst + (uint64_t) protectiveMBR.GetLength(i) - UINT64_C(1); if ((partitions[j].GetFirstLBA() == mbrFirst) && (partitions[j].GetLastLBA() == mbrLast)) found = 1; @@ -551,6 +578,7 @@ int GPTData::FindHybridMismatches(void) { // Find overlapping partitions and warn user about them. Returns number of // overlapping partitions. +// Returns number of overlapping segments found. int GPTData::FindOverlaps(void) { int problems = 0; uint32_t i, j; @@ -574,6 +602,7 @@ int GPTData::FindOverlaps(void) { // big for the disk. (The latter should duplicate detection of overlaps // with GPT backup data structures, but better to err on the side of // redundant tests than to miss something....) +// Returns number of problems found. int GPTData::FindInsanePartitions(void) { uint32_t i; int problems = 0; @@ -841,12 +870,12 @@ int GPTData::LoadHeader(struct GPTHeader *header, DiskIO & disk, uint64_t sector cerr << "Warning! Read error " << errno << "; strange behavior now likely!\n"; allOK = 0; } // if - *crcOk = CheckHeaderCRC(&tempHeader); // Reverse byte order, if necessary if (IsLittleEndian() == 0) { ReverseHeaderBytes(&tempHeader); } // if + *crcOk = CheckHeaderCRC(&tempHeader); if (allOK && (numParts != tempHeader.numParts) && *crcOk) { allOK = SetGPTSize(tempHeader.numParts); @@ -904,6 +933,7 @@ int GPTData::LoadPartitionTable(const struct GPTHeader & header, DiskIO & disk, int GPTData::CheckTable(struct GPTHeader *header) { uint32_t sizeOfParts, newCRC; GPTPart *partsToCheck; + GPTHeader *otherHeader; int allOK = 0; // Load partition table into temporary storage to check @@ -919,9 +949,13 @@ int GPTData::CheckTable(struct GPTHeader *header) { if (myDisk.Read(partsToCheck, sizeOfParts) != (int) sizeOfParts) { cerr << "Warning! Error " << errno << " reading partition table for CRC check!\n"; } else { - newCRC = chksum_crc32((unsigned char*) partsToCheck, sizeOfParts); + newCRC = chksum_crc32((unsigned char*) partsToCheck, sizeOfParts); allOK = (newCRC == header->partitionEntriesCRC); - if (memcmp(partitions, partsToCheck, sizeOfParts) != 0) { + if (header == &mainHeader) + otherHeader = &secondHeader; + else + otherHeader = &mainHeader; + if (newCRC != otherHeader->partitionEntriesCRC) { cerr << "Warning! Main and backup partition tables differ! Use the 'c' and 'e' options\n" << "on the recovery & transformation menu to examine the two tables.\n\n"; allOK = 0; diff --git a/gpt.h b/gpt.h index d8c2a43..eb2c747 100644 --- a/gpt.h +++ b/gpt.h @@ -98,7 +98,7 @@ class GPTData { int Verify(void); int CheckGPTSize(void); int CheckHeaderValidity(void); - int CheckHeaderCRC(struct GPTHeader* header); + int CheckHeaderCRC(struct GPTHeader* header, int warn = 0); void RecomputeCRCs(void); void RebuildMainHeader(void); void RebuildSecondHeader(void); diff --git a/gptcl.cc b/gptcl.cc index 92aa601..f6ab05a 100644 --- a/gptcl.cc +++ b/gptcl.cc @@ -51,6 +51,15 @@ void GPTDataCL::LoadBackupFile(string backupFile, int &saveData, int &neverSaveD } // else } // +// Perform the actions specified on the command line. This is necessarily one +// monster of a function! +// Returns values: +// 0 = success +// 1 = too few arguments +// 2 = error when reading partition table +// 3 = non-GPT disk and no -g option +// 4 = unable to save changes +// 8 = disk replication operation (-R) failed int GPTDataCL::DoOptions(int argc, char* argv[]) { GPTData secondDevice; int opt, numOptions = 0, saveData = 0, neverSaveData = 0; @@ -109,7 +118,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { if (argc < 2) { poptPrintUsage(poptCon, stderr, 0); - exit(1); + return 1; } // Do one loop through the options to find the device filename and deal diff --git a/gptcl.h b/gptcl.h index 1e6148d..1abf746 100644 --- a/gptcl.h +++ b/gptcl.h @@ -35,8 +35,8 @@ class GPTDataCL : public GPTData { char *partGUID, *diskGUID; int alignment, deletePartNum, infoPartNum, largestPartNum, bsdPartNum; uint32_t tableSize; - poptContext poptCon; + int BuildMBR(char* argument, int isHybrid); public: GPTDataCL(void); diff --git a/gptcurses.cc b/gptcurses.cc index b8a0371..7fd6e55 100644 --- a/gptcurses.cc +++ b/gptcurses.cc @@ -2,21 +2,21 @@ * Implementation of GPTData class derivative with curses-based text-mode * interaction * Copyright (C) 2011 Roderick W. Smith - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * + * */ #include diff --git a/gptcurses.h b/gptcurses.h index 14f43ad..4a9987e 100644 --- a/gptcurses.h +++ b/gptcurses.h @@ -2,21 +2,21 @@ * Implementation of GPTData class derivative with curses-based text-mode * interaction * Copyright (C) 2011 Roderick W. Smith - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * + * */ #include @@ -81,6 +81,7 @@ class GPTDataCurses : public GPTData { string whichOptions; char currentKey; int numSpaces; + // Functions relating to Spaces data structures void EmptySpaces(void); int MakeSpacesFromParts(void); @@ -90,6 +91,7 @@ class GPTDataCurses : public GPTData { void LinkToEnd(Space *theSpace); void SortSpaces(void); void IdentifySpaces(void); + // Data display functions Space* ShowSpace(int spaceNum, int lineNum); int DisplayParts(int selected); diff --git a/support.h b/support.h index 998c5b4..2562f36 100644 --- a/support.h +++ b/support.h @@ -8,7 +8,7 @@ #ifndef __GPTSUPPORT #define __GPTSUPPORT -#define GPTFDISK_VERSION "0.8.0" +#define GPTFDISK_VERSION "0.8.0.1" #if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__) // Darwin (Mac OS) & FreeBSD: disk IOCTLs are different, and there is no lseek64