summaryrefslogtreecommitdiff
path: root/cgpt/cgpt.h
Commit message (Collapse)AuthorAgeFilesLines
* vboot: fix up some headers, includes, comments, spacingJoel Kitching2019-08-281-6/+7
| | | | | | | | | | | | | BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: Id97f544da845f7070555e5e8cc6e782b2d45c300 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1758151 Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org>
* Makefile: Enable more warnings for host utilities / testsJulius Werner2019-05-141-13/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds a bunch of more warnings that are already enabled in coreboot and thus already enabled for firmware builds anyway (because coreboot just passes its CFLAGS through). Enabling it in the vboot Makefile means they also apply to host utilities and tests, which sounds desirable for consistency. Fix enough of the cruft and bad coding practices that accumulated over the years of not having warnings enabled to get it to build again (this includes making functions static, removing dead code, cleaning up prototypes, etc.). Also remove -fno-strict-aliasing from the x86 firmware build options, because it's not clear why it's there (coreboot isn't doing this, so presumably it's not needed). BRANCH=None BUG=None TEST=make runtests Change-Id: Ie4a42083c4770a4eca133b22725be9ba85b24184 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1598721 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
* cgpt: add edit commandstabilize-nocturne-10986.Bstabilize-11021.84.Bstabilize-11020.Bstabilize-11005.Bstabilize-10985.Brelease-R70-11021.Bfirmware-servo-11011.Bfirmware-nocturne-10984.Bfactory-nocturne-10984.BMatt Delco2018-08-151-0/+1
| | | | | | | | | | | | | | | | This change adds a command to cgpt to change the GUID of the drive. BRANCH=none BUG=None TEST=Compiled and ran utility to verify that GUID changes. Also verified that the new and existing tests completed successfully. Change-Id: Ia8a815447509626312e2b06c6f293901290c73c3 Signed-off-by: Matt Delco <delco@google.com> Reviewed-on: https://chromium-review.googlesource.com/1171834 Reviewed-by: Julius Werner <jwerner@chromium.org>
* cgpt: add support for managing GPT platform required partition bitBen Chan2018-02-061-0/+3
| | | | | | | | | | | | | | | | Bit 0 in the GPT partition attributes is defined to indicate whether a partition is required by the platform. This CL adds the support for managing this bit to cgpt. BUG=b:70807006 BRANCH=None TEST=Run unit tests. Change-Id: Iaf87c828438b3df6730de502ae420fcf4c61277b Reviewed-on: https://chromium-review.googlesource.com/902196 Commit-Ready: Ben Chan <benchan@chromium.org> Tested-by: Ben Chan <benchan@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* cgpt: add support for managing the legacy boot gpt bitstabilize-kevin-8785.94.BMike Frysinger2016-09-081-0/+3
| | | | | | | | | | | | | | | | | | | | | | | Bit 2 in the GPT partition attributes has been allocated as the legacy bios boot (equivalent to the "active" or "boot" flag in MBR). If we try to boot images on newer x86 systems, syslinux dies because it can't find any GPT partition marked bootable. Update the various parts of cgpt add & show to manage this bit. Now we can run: cgpt add -i 12 -B 1 chromiumos_image.bin And the EFI partition will be marked bootable. BUG=chromium:644845 TEST=vboot_reference unittests pass TEST=booted an amd64-generic disk image via USB on a generic laptop BRANCH=None Change-Id: I78e17b8df5b0c61e9e2d8a3c703e6d5ad230fe92 Reviewed-on: https://chromium-review.googlesource.com/382411 Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* cgpt: unify cli int parsing error checkingMike Frysinger2016-09-081-0/+2
| | | | | | | | | | | | | | | | Most of the cmd funcs had the same logic copied & pasted multiple times over. Unify them into a common header. BUG=chromium:644845 TEST=precq passes TEST=passing invalid args to some funcs is caught BRANCH=None Change-Id: Ib7212bcbb17da1135b2508a52910aac37ee8e6cd Reviewed-on: https://chromium-review.googlesource.com/382691 Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Changes to compile signing tools on darwinDavid Riley2015-02-111-0/+2
| | | | | | | | | | | | | | | | | | | The following works from a Mac with these changes: make Q= ARCH=arm HAVE_MACOS=1 `pwd`/build/futility/futility Only vbutil_keyblock and vbutil_kernel have been exercised. BUG=none TEST='make Q= ARCH=arm HAVE_MACOS=1 `pwd`/build/futility/futility' BRANCH=none Signed-off-by: David Riley <davidriley@chromium.org> Change-Id: Ie69cfee0c650d4ff96be6322083a2fea1543ee39 Reviewed-on: https://chromium-review.googlesource.com/246773 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Tested-by: David Riley <davidriley@chromium.org> Commit-Queue: David Riley <davidriley@chromium.org>
* vboot: Remove FTS codeNam T. Nguyen2014-11-261-17/+0
| | | | | | | | | | | | | | | flash_ts driver (from Android) was pulled to support Sonic. But now we go a different route, this CL is to drop the FTS code. BUG=chromium:436597 BRANCH=none TEST=unittest Change-Id: I86d6273f9f5f642b504ccb6a76e005cda12d0e78 Reviewed-on: https://chromium-review.googlesource.com/231896 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@chromium.org> Tested-by: Nam Nguyen <namnguyen@chromium.org>
* vboot: cgpt: Treat drive_path as the GPT storageNam T. Nguyen2014-11-141-26/+9
| | | | | | | | | | | | | | | | | | | | | | Previously, "cgpt" called out to "flashrom" directly to read and write NOR area. This CL removes that dependency and always treats "drive_path" as the storage of GPT structs. This makes it consistent that whatever device that cgpt reads from or writes to is always the device that stores GPT structs. We only need to pass in the size of the drive that contains the partitions, but we do not need to access to that drive. More information is in the bug. BUG=chromium:432611 BRANCH=none TEST=unittest CQ-DEPEND=CL:228942 Change-Id: Id0139adf70463cec4f2924de8b9a4725dbec822b Reviewed-on: https://chromium-review.googlesource.com/229736 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@chromium.org> Tested-by: Nam Nguyen <namnguyen@chromium.org>
* vboot: cgpt: Support writing GPT structs to NOR flashNam T. Nguyen2014-11-131-3/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL allows the GPT headers and partition entry arrays to be stored in a NOR flash device. Instead of treating both the NOR and NAND devices as one (in a sandwich way), this CL writes and reads the GPT structs independently of the actual device that houses the partitions. Therefore, the first usable LBA of the partitions will be at 0, and the last usable LBA is at the end of the NAND. +------------------------+ | NOR houses GPT structs | +------------------------+ | 0 | Index into v v +------------------------+ | NAND houses partitions | +------------------------+ Note that the "my_lba", "alternate_lba", "entries_lba" in the GPT headers are no longer meaningful. Consumers of cgptlib will have to set "stored_on_device" to either GPT_STORED_ON_DEVICE or GPT_STORED_OFF_DEVICE, and "gpt_drive_sectors" to the number of 512-byte sectors available to store GPT structs. The NOR read and write operations are done by "flashrom". BUG=chromium:425677 BRANCH=none TEST=unittest TEST=build with DEBUG, cgpt create/add/show on a stumpy-moblab Change-Id: I083b3c94da3b0bb3da1a7b10c6969774080a2afd Reviewed-on: https://chromium-review.googlesource.com/226800 Reviewed-by: Nam Nguyen <namnguyen@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@chromium.org> Tested-by: Nam Nguyen <namnguyen@chromium.org>
* Remove cgpt app-specific symbols from libvboot_host.aBill Richardson2014-06-261-13/+12
| | | | | | | | | | | | | | | | | | | | | | Three symbols used by the standalone cgpt executable were being referenced in the files used to create the external libvboot_host.a needed by non-vboot userspace applications. This cleans things up so those symbols don't have to be explictly defined by other repos just to link with that library. BUG=chromium:318536 BRANCH=ToT TEST=manual No new functionality, just code cleanup. Tested with make runtests runfutiltests runlongtests Change-Id: Ibc77fb9800c89d7109ebf38d4d6729f52665722f Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/205667 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Don't always enable MTD mode unless MTD device is specifiedfactory-4455.Bfactory-4455.228.BAlbert Chaulk2013-07-241-2/+3
| | | | | | | | | | | | | | | | On MTD devices, don't always enable MTD mode - the installer needs to be able to access both the GPT disk and the MTD disk, so only enable it if we install to /dev/fts BRANCH=none BUG=chromium:221745 TEST=make runtests Change-Id: I7688e6bc758ef47cfb9d468c1224ef43b2043d02 Reviewed-on: https://gerrit.chromium.org/gerrit/62662 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org>
* MTD: When running on the host (as during install) use the host FTS if possible.Albert Chaulk2013-07-161-0/+3
| | | | | | | | | | | | BUG=chromium:252331 TEST='make runtests' still passes BRANCH=none Change-Id: I1deb70766b811b070f0f412cb5cfa583250dd687 Reviewed-on: https://gerrit.chromium.org/gerrit/61328 Commit-Queue: Albert Chaulk <achaulk@chromium.org> Reviewed-by: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org>
* Bugfixes & MTD create commandAlbert Chaulk2013-06-241-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Fix some bugs in the cgpt implementation of the flash I/O functions & load logic, it was validating too much at load time. Implement the create command for MTD BUG=chromium:221745 TEST=MTD version of run_cgpt_tests.sh passes BRANCH=none Original-Change-Id: I2f52637d82962f4d805aa827c5c37685f10e76ea Reviewed-on: https://gerrit.chromium.org/gerrit/47172 Tested-by: Albert Chaulk <achaulk@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Albert Chaulk <achaulk@chromium.org> (cherry picked from commit 931544744ba410dad267064b87d504b0b4c24772) Change-Id: If9364155fb2c030645adc6ee6f3fbe5373bcc153 Reviewed-on: https://gerrit.chromium.org/gerrit/49793 Commit-Queue: Albert Chaulk <achaulk@chromium.org> Reviewed-by: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org>
* Enables MTD mode via command line option.Albert Chaulk2013-06-211-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Enables MTD mode with a command line option of -N=<write page bytes>,<write pages per erase block>, <erase block offset to fts partition>,<erase block size of fts partition> The problem is that we need to know exactly where the fts store partition is and what the layout of the flash chip is in order to be able to use it properly. This will vary per-device however, so for flexibility and testing purposes, this command line option allows specification of arbitrary layouts. BUG=chromium:221745 BRANCH=none TEST=verified during development via prints Original-Change-Id: I88640e777d5ccd4ffd3b39e1f131dc1d362c6b2c Reviewed-on: https://gerrit.chromium.org/gerrit/46920 Commit-Queue: Albert Chaulk <achaulk@chromium.org> Reviewed-by: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org> (cherry picked from commit 2b768f99d246823f3711bbe4cf50ea9ab4588a06) Change-Id: I35591d4fbec13c3887beef11fdefc84fc90b8e05 Reviewed-on: https://gerrit.chromium.org/gerrit/49792 Reviewed-by: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org> Commit-Queue: Albert Chaulk <achaulk@chromium.org>
* Provide MTD version of common functionsfactory-4290.BAlbert Chaulk2013-06-181-0/+3
| | | | | | | | | | | | | | | | | | | | | Provide an MTD implementation of several common functions in cgpt_common.c BUG=chromium:221745 BRANCH=none TEST=none Original-Change-Id: Ib3248c283ca31e33a91b9ea0c14b2f72ea7c5850 Reviewed-on: https://gerrit.chromium.org/gerrit/47029 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org> (cherry picked from commit b0bd7e4cf8dd15cc3c371dac157093c7e7c7a874) Change-Id: I243c2bf98a88d0019c332b274868459b5f1b8ea1 Reviewed-on: https://gerrit.chromium.org/gerrit/49791 Reviewed-by: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org> Commit-Queue: Albert Chaulk <achaulk@chromium.org>
* Integrate the flash key-value store code into cgpt.stabilize-4255.BAlbert Chaulk2013-06-101-0/+49
| | | | | | | | | | | | | | | | | | | | | | Integrates the FTS driver into cgpt. This driver is binary-format compatible with the linux driver for interoperabiilty. The cgpt changes load & store a hex-encoded mtd partition table in the FTS; we need some sort of encoding because FTS only stores NUL-terminated strings. Currently, the mtd code paths aren't executed in cgpt, only in the tests. It's also not hooked up to the vboot code yet, we will need to do that eventually. BUG=chromium:221745 TEST=new unit test added BRANCH=none Change-Id: I94eb0389d29aca0beb9d9a644465c7d86161b3c2 Original-Change-Id: I9fe2fa91b666572563426adb8fa9d426f9b60bbf Reviewed-on: https://gerrit.chromium.org/gerrit/46796 Commit-Queue: Albert Chaulk <achaulk@chromium.org> Reviewed-by: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/49789
* Refactor CgptAdd and CgptPrioitize to remove gpt-specific codeAlbert Chaulk2013-05-061-7/+16
| | | | | | | | | | | | | | | | | | | | - Refactor cgpt_prioitize.c to completely remove gpt-specific code. - Refactor cgpt_add.c to isolate gpt-dependence to one helper function and the backup/restore logic - Change several common apis to take a struct drive* rather than a GptData*, this provides a path to cleanly implement mtd versions BUG=chromium:221745 TEST=no functional changes, existing tests cover this BRANCH=none Change-Id: I27ed166aae390aa5dc83062f62939e45122edc76 Original-Change-Id: I1b0a73509efbf22411c4ae5cf044feede0a49a33 Reviewed-on: https://gerrit.chromium.org/gerrit/46548 Tested-by: Albert Chaulk <achaulk@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Albert Chaulk <achaulk@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/49788
* Massive refactoring of external header files.Bill Richardson2013-04-021-25/+0
| | | | | | | | | | | | | | | | | | | | | | | | This reduces the number of exported header files to the minimum needed by the existing userspace utilities and firmware implementations. BUG=chromium:221544 BRANCH=none TEST=manual, trybots CQ-DEPEND=CL:47019,CL:47022,CL:47023 sudo FEATURES=test emerge vboot_reference FEATURES=test emerge-$BOARD \ vboot_reference \ chromeos-cryptohome \ chromeos-installer \ chromeos-u-boot \ peach-u-boot \ depthcharge Change-Id: I2946cc2dbaf5459a6c5eca92ca57d546498e6d85 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/47021 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Apply consistent naming scheme for hostlib functions.Bill Richardson2013-03-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The chromeos-installer uses several functions from the vboot_reference userspace library, but the names of those functions are inconsistent: IsZero MapFile VbGetSystemPropertyString cgpt_add cgpt_boot cgpt_create cgpt_get_boot_partition_number cgpt_get_num_non_empty_partitions cgpt_get_partition_details cgpt_prioritize cgpt_set_attributes find_kernel_config The Google C++ style guide says types and functions should use CamelCase, while variables use lower_case_with_underscores. Kernel style (which vboot_reference tries to be more-or-less compatible with) uses lower_case_with_underscores for everything, but that really only has to apply to firmware stuff. For userspace, we can use the Google style. BUG=chromium:221544 BRANCH=none TEST=buildbot CQ-DEPEND=CL:46045 Renaming/cleanup only; no functional changes. Change-Id: I9c82c9ff8909be88586194c8ffdb435fc771195f Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/46044
* Support alternative GPT header signatureStefan Reinauer2012-09-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | In order to dual boot Windows and ChromeOS, Windows must not find a GPT partition table on the disk. So change ChromeOS to cope with an alternative signature "CHROMEOS" instead of the standard "EFI PART" BUG=chrome-os-partner:6108 TEST=rebuild chromeos, install it, run cgpt legacy /dev/sda dd if=/dev/sda of=/tmp/x bs=1k hexdump -C /tmp/X see the string CHROMEOS BRANCH=link Signed-off-by: Stefan Reinauer <reinauer@chromium.org> Change-Id: Ia88eff33b9880bd73a78c1b8e026c1f8298c4557 Reviewed-on: https://gerrit.chromium.org/gerrit/31264 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Ready: Stefan Reinauer <reinauer@chromium.org> Tested-by: Stefan Reinauer <reinauer@chromium.org>
* Let cgpt open devices in read-only mode when possible.Bill Richardson2012-05-021-1/+3
| | | | | | | | | | | | | | | | BUG=chromium-os:12430 TEST=manual Running "make; make runtests" in src/platform/vboot_refererence will test this change. Tests for use on a Chromebook are described in the bug report, but will require a USB or SD card that has a physical write-protect switch. Change-Id: I16a67bad3b59bec0981f4064f51fb1a29da65a90 Reviewed-on: https://gerrit.chromium.org/gerrit/21474 Tested-by: Bill Richardson <wfrichar@chromium.org> Commit-Ready: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Richard Barnette <jrbarnette@chromium.org> Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
* Enable building of Cgpt C++ Library for 32-bit.Jay Srinivasan2012-02-231-0/+7
| | | | | | | | | | | | | | | | | | | The existing library had a bunch of dependencies which are too many to build for the 32-bit platform. So this checkin prunes the dependency list by building only things that are absolutely required for the functionality used in 32-bit Post-Installer. Made the use of libuuid restricted only to cgpt and unit tests so that libcgpt-cc.a doesn't depend on it. BUG=chromium-os:25374 TEST=Built 32-bit and 64-bit. Tested 32-bit post-install. Change-Id: Idd0826fdf507a95728fee8adac9520e26f05d469 Reviewed-on: https://gerrit.chromium.org/gerrit/16433 Reviewed-by: Don Garrett <dgarrett@chromium.org> Reviewed-by: Sonny Rao <sonnyrao@chromium.org> Commit-Ready: Jay Srinivasan <jaysri@chromium.org> Tested-by: Jay Srinivasan <jaysri@chromium.org>
* Implementation of CgptManager C++ library and unit tests.Jay Srinivasan2012-02-161-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | CgptManager exposes the cgpt commands via a C++ library so that the post-installer for 32- to 64-bit upgrade can link directly against a library and thus avoid any shell dependency. The default make target will not build libcgpt-cc.a since it requires some dependencies that are available only in chroot. A separate follow-up checkin to the vboot_reference ebuild will enable emerging the libcgpt-cc.a by default. BUG=chromium-os:25374 TEST=Tested with the new unit tests for CgptManager, ran existing cgpt unit tests, as well as running the cgpt commands manually. Built on both amd64 and x86. Tested that vboot_reference is also buildable outside of chroot. Tested that vboot_reference-firmware and vboot_reference-tests also build fine with these changes. CQ-DEPEND=I99f6c321e09c2425eaa8171d78685d2d731954c8 Change-Id: I59a896255b8ea2fc8b1b2150ae7c4ff9d0769699 Reviewed-on: https://gerrit.chromium.org/gerrit/15730 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Gaurav Shah <gauravsh@chromium.org> Commit-Ready: Jay Srinivasan <jaysri@chromium.org> Tested-by: Jay Srinivasan <jaysri@chromium.org>
* Introduce GUID type for Chrome OS read/write firmware.Gabe Black2011-07-071-0/+1
| | | | | | | | | | | | | | | | | | This change teaches cgpt a new GUID type to be used for the Chrome OS read/write firmware. The GUID is CAB6E88E-ABF3-4102-A07A-D4BB9BE3C1D3. BUG=chrome-os-partner:4843 TEST=Built and installed on my host, used a separate change to repurpose partition 11 for the R/W firmware using cgpt and the "firmware" type, inspected the image using cgpt. Built and installed an image and used cgpt on the device to inspect it's GPT. Signed-off-by: Gabe Black <gabeblack@google.com> Change-Id: I3b2801b2e1f71b3275bbddbc45fb63bde5bce5a7 Reviewed-on: http://gerrit.chromium.org/gerrit/3763 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Tested-by: Gabe Black <gabeblack@chromium.org>
* Add 'prioritize' command to cgpt tool.Bill Richardson2010-11-291-1/+9
| | | | | | | | | | | | | | | | | | | | | | This lets us reorder the priority of all the kernel partitions with a single command, instead of a bunch of complicated and error-prone shell script logic. Change-Id: I21d39763ec5a748488d5319a987bcfe7c34ce4d0 BUG=chromium-os:9167 TEST=manual In the chroot, do this: cd ~/trunk/src/platform/vboot_reference make make runtests make clean Everything should pass. Review URL: http://codereview.chromium.org/5352005
* Fix for un-initialized code point variable.Louis Yung-Chieh Lo2010-11-221-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The original CL is http://codereview.chromium.org/5025003/, but it was reverted because the compiler complains code_point variable is not initialized. This CL just initializes it. This CL also adds few lines of code to make code more robust. Change-Id: Ib1329bcaeb4a1bd9abfe9e766b61bd0e52d2c260 BUG=chromium-os:7542 TEST=RUNTESTS=1 emerge-x86-generic vboot_reference Manually tested the following commands (intentionally mix Chinese and ASCII): export C=.../cgpt export D=/tmp/hda $C add $D -i 1 -l 批P踢T踢T許C夕C餐 $C find $D -l 批P踢T踢T許C夕C餐 $C show $D $C add $D -i 1 -l abc012 $C add $D -i 1 -l 是否看過坊間常見的許茹芸淚海慶功宴吃蓋飯第四集 $C add $D -i 1 -l 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ # ok and truncated $C add $D -i 1 -l `printf "\xf4\x91\x81\x81"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf4\x8f\xbf\xbf"` $C add $D -i 1 -l `printf "\xf4\x8f\x44\x44"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf4\x8f\xbf"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\xbf\xbf\xbf"` $C add $D -i 1 -l `printf "\xf0\xbf\xbf\x44"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x80\x80\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x80\x84\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x80\x90\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x88\x80\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xed\x80\x80"` $C add $D -i 1 -l `printf "\xed\xa0\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\xbf\xbf"` $C add $D -i 1 -l `printf "\xe0\xbf\x44"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\x80\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\x90\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\xbf"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xd0\x80"` $C add $D -i 1 -l `printf "\xd0\x11"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xd0"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xc0\xaf"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\x80"` # (EXPECT: failed) Review URL: http://codereview.chromium.org/5104009
* Revert "The right implementation of CGPT label conversion between UTF8 and ↵Chris Sosa2010-11-191-13/+5
| | | | | | | | | | UTF16." This reverts commit 6965cbfed3352754f0ff9a270e3b330223b7154c. TBR=Change broke tree Change-Id: I5323799bf0bc2f9a1f2815f0c44fc90ca9a7bd77
* The right implementation of CGPT label conversion between UTF8 and UTF16.Louis Yung-Chieh Lo2010-11-191-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For security quick fix, the original UTF8/UTF16 conversion only supports ASCII area. This CL extends the library to support multiple code units conversion between UTF8 and UTF16. The UTF8/UTF16 encoded byte(s) would be decoded to code point first, then be encoded to UTF16/UTF8 correspondingly. Bill, please kindly review the UTF8/UTF16 conversion. Peter, please kindly comment if any security concern. Thanks. Change-Id: I99c558ff27556e0b8635ba2b8d9925d042e75cb2 BUG=chromium-os:7542 TEST=RUNTESTS=1 emerge-x86-generic vboot_reference Manually tested the following commands (intentionally mix Chinese and ASCII): export C=.../cgpt export D=/tmp/hda $C add $D -i 1 -l 批P踢T踢T許C夕C餐 $C find $D -l 批P踢T踢T許C夕C餐 $C show $D $C add $D -i 1 -l 批P踢T踢T許C夕C餐 $C find $D -l 批P踢T踢T許C夕C餐 $C add $D -i 1 -l abc012 $C add $D -i 1 -l 是否看過坊間常見的許茹芸淚海慶功宴吃蓋飯第四集 $C add $D -i 1 -l 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ # ok and truncated $C add $D -i 1 -l `printf "\xf4\x91\x81\x81"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf4\x8f\xbf\xbf"` $C add $D -i 1 -l `printf "\xf4\x8f\x44\x44"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf4\x8f\xbf"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\xbf\xbf\xbf"` $C add $D -i 1 -l `printf "\xf0\xbf\xbf\x44"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x80\x80\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x80\x84\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x80\x90\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x88\x80\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xed\x80\x80"` $C add $D -i 1 -l `printf "\xed\xa0\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\xbf\xbf"` $C add $D -i 1 -l `printf "\xe0\xbf\x44"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\x80\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\x90\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\xbf"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xd0\x80"` $C add $D -i 1 -l `printf "\xd0\x11"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xd0"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xc0\xaf"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\x80"` # (EXPECT: failed) Review URL: http://codereview.chromium.org/5025003
* Address some security concerns in the cgpt tool.Bill Richardson2010-10-121-20/+33
| | | | | | | | | | | | | | | | | | | | | | 1. Check for potential integer overflow in sector_bytes * sector_count. 2. Added O_NOFOLLOW to open() call - Is this enough? 3. Passing buffer length to GuidToStr(), PMBRToStr(). 4. Use unsigned int in GetEntry() to determine stride. 5. Address conversion between UTF16 and UTF8. Note: The UTF conversion is complex and troublesome, and needs careful consideration to get right. For now, I've just forced the interpretation of the partition name to 7-bit ASCII. That's sufficient for the needs of Chrome OS, and I can file a new issue to handle UTF correctly. BUG=chrome-os-partner:705 TEST=manual Running "make runtests" invokes the tests/run_cgpt_tests.sh script, which checks the behavior and output of the cgpt tool. Review URL: http://codereview.chromium.org/3594010 Change-Id: I5fd29796d8c929527e0cfbc6d5ccbcdc77502c6b
* Add 'find' command to cgpt, to search for partitions by UUID.Bill Richardson2010-07-021-0/+1
| | | | Review URL: http://codereview.chromium.org/2849040
* Nearly complete rewrite of cgpt tool.Bill Richardson2010-06-111-0/+130
This fixes a number of bugs, adds a bunch of commands, and essentially makes cgpt ready to use as a replacement for gpt. Still to do is to add commands and options that will let it generated intentionally bad partitions, for use in testing. Review URL: http://codereview.chromium.org/2719008