summaryrefslogtreecommitdiff
path: root/disk
AgeCommit message (Collapse)Author
2016-10-02disk: part: refactor generic name creation for DOS and ISOPetr Kulhavy
In both DOS and ISO partition tables the same code to create partition name like "hda1" was repeated. Code moved to into a new function part_set_generic_name() in part.c and optimized. Added recognition of MMC and SD types, name is like "mmcsda1". Signed-off-by: Petr Kulhavy <brain@jikos.cz> Reviewed-by: Tom Rini <trini@konsulko.com> Acked-by: Steve Rae <steve.rae@raedomain.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2016-10-02fastboot: add support for writing MBRPetr Kulhavy
Add special target "mbr" (otherwise configurable via CONFIG_FASTBOOT_MBR_NAME) to write MBR partition table. Partitions are now searched using the generic function which finds any partiiton by name. For MBR the partition names hda1, sda1, etc. are used. Signed-off-by: Petr Kulhavy <brain@jikos.cz> Reviewed-by: Tom Rini <trini@konsulko.com> Acked-by: Steve Rae <steve.rae@raedomain.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2016-10-02disk: part: implement generic function part_get_info_by_name()Petr Kulhavy
So far partition search by name has been supported only on the EFI partition table. This patch extends the search to all partition tables. Rename part_get_info_efi_by_name() to part_get_info_by_name(), move it from part_efi.c into part.c and make it a generic function which traverses all part drivers and searches all partitions (in the order given by the linked list). For this a new variable struct part_driver.max_entries is added, which limits the number of partitions searched. For EFI this was GPT_ENTRY_NUMBERS. Similarly the limit is defined for DOS, ISO, MAC and AMIGA partition tables. Signed-off-by: Petr Kulhavy <brain@jikos.cz> Reviewed-by: Tom Rini <trini@konsulko.com> Acked-by: Steve Rae <steve.rae@raedomain.com>
2016-08-06cmd: gpt: fix the wrong size parse for the last partitionKever Yang
The calculation of "dev_desc->lba - 34 - 1 - offset" is not correct for size '-', because both fist_usable_lba and last_usable_lba will remain 34 sectors. We can simply use 0 for size '-' because the part_efi module will decode the size and auto extend the size to maximum available size. Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2016-07-25part_efi: Fix compiler warning on 32-bit sandboxSimon Glass
This fixes a mismatch between the %zu format and the type used on sandbox. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2016-07-22iso: Fix part info commandAlexander Graf
Partitions on the iso el torito partition table interpreter only start from partition 1. So when printing out the tables, let's also start counting at 1. Signed-off-by: Alexander Graf <agraf@suse.de>
2016-05-27disk: part_efi: fix check of the max partition sizePatrick Delaunay
the last value acceptable value for offset is last_usable_lba + 1 and not last_usable_lba - 1 issue found with SDCARD partition commands on u-boot 2015.10 but this part of code don't change 1- create GPT partion on all the card > gpt write mmc 0 name=test,start=0,size=0 > part list mmc 0 Partition Map for MMC device 0 -- Partition Type: EFI Part Start LBA End LBA Name Attributes Type GUID Partition GUID 1 0x00000022 0x003a9fde "test" attrs: 0x0000000000000000 type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 type: data guid: b710eb04-45b9-e94a-8d0b-21458d596f54 => Start = 0x22*512 = 0x4400 => Size = (0x003a9fde-0x22+1) * 512 = 0x753F7A00 2- try to recreate the same partition with the next command (block size:512 bytes = 0x200) > gpt write mmc 0 name=test,start=0x4400,size=0x753F7A00 Writing GPT: Partitions layout exceds disk size > gpt write mmc 0 name=test,start=0x4400,size=0x753F7800 Writing GPT: Partitions layout exceds disk size > gpt write mmc 0 name=test,start=0x4400,size=0x753F7600 Writing GPT: success! Partition Map for MMC device 0 -- Partition Type: EFI Part Start LBA End LBA Name Attributes Type GUID Partition GUID 1 0x00000022 0x003a9fdc "test" attrs: 0x0000000000000000 type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 type: data guid: 36ec30ef-7ca4-cd48-97cd-ea9fb95185d0 the max LBA when the size is indicated (0x003a9fdc) is lower than when u-boot compute the max allowed value with size=0 (0x003a9fde) in the code : /* partition ending lba */ if ((i == parts - 1) && (partitions[i].size == 0)) /* extend the last partition to maximuim */ gpt_e[i].ending_lba = gpt_h->last_usable_lba; else gpt_e[i].ending_lba = cpu_to_le64(offset - 1); so offset = gpt_h->last_usable_lba + 1 is acceptable ! but the test (offset >= last_usable_lba) cause the error END Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com>disk: part_efi: fix check of the max partition size the last value acceptable value for offset is (last_usable_lba + 1) and not (last_usable_lba - 1) issue found with SDCARD partition commands on u-boot 2015.10 but this part of code don't change 1- I create GPT partion on all the card (start and size undefined) > gpt write mmc 0 name=test,start=0,size=0 > part list mmc 0 Partition Map for MMC device 0 -- Partition Type: EFI Part Start LBA End LBA Name Attributes Type GUID Partition GUID 1 0x00000022 0x003a9fde "test" attrs: 0x0000000000000000 type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 type: data guid: b710eb04-45b9-e94a-8d0b-21458d596f54 => Start = 0x22*512 = 0x4400 => Size = (0x003a9fde-0x22+1) * 512 = 0x753F7A00 2- I try to recreate the same partition with the command gpt write and with start and size values (block size:512 bytes = 0x200) > gpt write mmc 0 name=test,start=0x4400,size=0x753F7A00 Writing GPT: Partitions layout exceds disk size > gpt write mmc 0 name=test,start=0x4400,size=0x753F7800 Writing GPT: Partitions layout exceds disk size > gpt write mmc 0 name=test,start=0x4400,size=0x753F7600 Writing GPT: success! I check the partition created : > part list mmc 0 Partition Map for MMC device 0 -- Partition Type: EFI Part Start LBA End LBA Name Attributes Type GUID Partition GUID 1 0x00000022 0x003a9fdc "test" attrs: 0x0000000000000000 type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 type: data guid: 36ec30ef-7ca4-cd48-97cd-ea9fb95185d0 => but the max LBA when the size is indicated (0x003a9fdc) is lower than when u-boot compute the max allowed value with size=0 (0x003a9fde) 3- in the code, just after my patch, line 446 /* partition ending lba */ if ((i == parts - 1) && (partitions[i].size == 0)) /* extend the last partition to maximuim */ gpt_e[i].ending_lba = gpt_h->last_usable_lba; else gpt_e[i].ending_lba = cpu_to_le64(offset - 1); so offset = gpt_h->last_usable_lba + 1 is acceptable ! (it the value used when size is 0) but today the test (offset >= last_usable_lba) cause the error my patch only solve this issue END Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com>
2016-05-17dm: blk: Use the correct error code for blk_get_device_by_str()Simon Glass
Return -EINVAL instead of -1 in this function, to provide a more meaningful error. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-05-17dm: part: Drop the block_drvr tableSimon Glass
This is not needed since we can use the functions provided by the legacy block device support. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-05-17dm: part: Use the legacy block driver for hardware partition supportSimon Glass
Drop use of the table in part.c for this feature. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-05-17dm: sandbox: Drop the host_get_dev() functionSimon Glass
This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-05-17dm: systemace: Drop the get_dev() functionSimon Glass
This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-05-17dm: sata: Drop the get_dev() functionSimon Glass
This function is implemented by the legacy block functions now. Drop it. We cannot yet make sata_dev_desc[] private to common/sata.c as it is used by the SATA drivers. This will require the SATA interface to be reworked. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-05-17dm: scsi: Drop the get_dev() functionSimon Glass
This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-05-17dm: mmc: Drop the get_dev() functionSimon Glass
This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-05-17dm: ide: Drop the get_dev() functionSimon Glass
This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-05-17dm: usb: Drop the get_dev() functionSimon Glass
This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-05-17dm: disk: Use legacy block driver info for block device accessSimon Glass
Instead of calling xx_get_dev() functions for each interface type, use the new legacy block driver which can provide the device through its interface. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-05-17dm: scsi: Rename CONFIG_CMD_SCSI to CONFIG_SCSISimon Glass
This option currently enables both the command and the SCSI functionality. Rename the existing option to CONFIG_SCSI since most of the code relates to the feature. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-04-18iso: Allow 512 byte sector sizeAlexander Graf
Real CD-ROMs are pretty obsolete these days. Usually people still keep iso files around, but just put them on USB sticks or SD cards and expect them to "just work". To support this use case with El Torito images, add support for 512 byte sector size to the iso parsing code. Signed-off-by: Alexander Graf <agraf@suse.de>
2016-04-18iso: Start with partition 1Alexander Graf
The generic partition code treats partition 0 as "whole disk". So we should start with partition 1 as the first partition in the iso partition table. Signed-off-by: Alexander Graf <agraf@suse.de>
2016-04-18iso: Make little endian and 64bit safeAlexander Graf
The iso partition table implementation has a few endian and 64bit problems. Clean it up a bit to become endian and bitness safe. Signed-off-by: Alexander Graf <agraf@suse.de>
2016-04-14dm: part: fix missing driver name in debug printNishanth Menon
Fixes the following warning with PART_DEBUG enabled: disk/part.c: In function ‘get_partition_info’: disk/part.c:372:3: warning: format ‘%s’ expects a matching ‘char *’ argument [-Wformat] Signed-off-by: Nishanth Menon <nm@ti.com>
2016-04-01drivers: block: add block device cacheEric Nelson
Add a block device cache to speed up repeated reads of block devices by various filesystems. This small amount of cache can dramatically speed up filesystem operations by skipping repeated reads of common areas of a block device (typically directory structures). This has shown to have some benefit on FAT filesystem operations of loading a kernel and RAM disk, but more dramatic benefits on ext4 filesystems when the kernel and/or RAM disk are spread across multiple extent header structures as described in commit fc0fc50. The cache is implemented through a minimal list (block_cache) maintained in most-recently-used order and count of the current number of entries (cache_count). It uses a maximum block count setting to prevent copies of large block reads and an upper bound on the number of cached areas. The maximum number of entries in the cache defaults to 32 and the maximum number of blocks per cache entry has a default of 2, which has shown to produce the best results on testing of ext4 and FAT filesystems. The 'blkcache' command (enabled through CONFIG_CMD_BLOCK_CACHE) allows changing these values and can be used to tune for a particular filesystem layout. Signed-off-by: Eric Nelson <eric@nelint.com>
2016-03-22part_efi: Drop NULL check in part_get_info_efi()Simon Glass
This cannot be NULL since part_get_info() calls this function and requires it to be non-NULL. Reported-by: Coverity (CID: 138497) Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2016-03-22part_efi: Drop the NULL check on dev_desc in part_print_efi()Simon Glass
This cannot be NULL since part_print() calls this function and requires it to be non-NULL. Reported-by: Coverity (CID: 138498) Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2016-03-22part_iso: Drop the customer unaligned access functionsSimon Glass
One of these is causing a coverity warning. Drop these functions and use the standard U-Boot ones instead. Reported-by: Coverity (CID: 138499) Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2016-03-15disk/part.c: Expose list of available block driversAlexander Graf
We have a pretty nice and generic interface to ask for a specific block device. However, that one is still based around the magic notion that we know the driver name. In order to be able to write fully generic disk access code, expose the currently internal list to other source files so that they can scan through all available block drivers. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
2016-03-14part: Rename test_part_xx() and print_part_xx()Simon Glass
Rename these functions so that part_ is at the start. This more clearly identifies these functions as partition functions. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-03-14dm: block: Adjust device calls to go through helpers functionSimon Glass
To ease conversion to driver model, add helper functions which deal with calling each block device method. With driver model we can reimplement these functions with the same arguments. Use inline functions to avoid increasing code size on some boards. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
2016-03-14dm: block: Rename device number member dev to devnumSimon Glass
This is a device number, and we want to use 'dev' to mean a driver model device. Rename the member. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
2016-03-14dm: part: Rename some partition functionsSimon Glass
Rename three partition functions so that they start with part_. This makes it clear what they relate to. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Stephen Warren <swarren@nvidia.com>
2016-03-14dm: part: Convert partition API use to linker listsSimon Glass
We can use linker lists instead of explicitly declaring each function. This makes the code shorter by avoiding switch() statements and lots of header file declarations. While this does clean up the code it introduces a few code issues with SPL. SPL never needs to print partition information since this all happens from commands. SPL mostly doesn't need to obtain information about a partition either, except in a few cases. Add these cases so that the code will be dropped from each partition driver when not needed. This avoids code bloat. I think this is still a win, since it is not a bad thing to be explicit about which features are used in SPL. But others may like to weigh in. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com> Tested-by: Stephen Warren <swarren@nvidia.com>
2016-03-14dm: part: Add a cast to avoid a compiler warningSimon Glass
In part_amiga.c the name is unsigned but bcpl_strcpy() requires a signed pointer. Add a cast to fix the warning. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
2016-03-14dm: blk: Rename get_device_and_partition()Simon Glass
Rename this function to blk_get_device_part_str(). This is a better name because it makes it clear that the function returns a block device and parses a string. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
2016-03-14dm: blk: Rename get_device() to blk_get_device_by_str()Simon Glass
The current name is too generic. The function returns a block device based on a provided string. Rename it to aid searching and make its purpose clearer. Also add a few comments. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
2016-03-14dm: blk: Rename get_dev() to blk_get_dev()Simon Glass
The current name is too generic. Add a 'blk_' prefix to aid searching and make its purpose clearer. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
2016-03-14dm: part: Correct a sandbox build warningSimon Glass
Adjust the cast to avoid a warning when stdint.h is used. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Stephen Warren <swarren@nvidia.com>
2016-03-14dm: Drop the block_dev_desc_t typedefSimon Glass
Use 'struct' instead of a typdef. Also since 'struct block_dev_desc' is long and causes 80-column violations, rename it to struct blk_desc. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
2016-01-20mmc: emmc and hw partitions partition table id bugfix.Erik Tideman
On bootup the emmc's hw partition is always set to 0 and the partition table is read from it. When switching to another hw partition the partition table's id is not updated but instead the old one from hw partition 0 is used. If there is no partition table on hw partition 0 then the code will terminate and return error even if the desired hw partition contains a perfectly fine partition table. This fix updates the partition table struct to correspond to the specified hw partition before testing if the partition table is valid or not. Signed-off-by: Erik Tideman <erik.tideman@faltcom.se> Reviewed-by: Tom Rini <trini@konsulko.com> [trini: Squash the patch that corrected whitespace in the original into this one, wrap with HAVE_BLOCK_DEVICE test] Signed-off-by: Tom Rini <trini@konsulko.com>
2016-01-15Fix GCC format-security errors and convert sprintfs.Ben Whitten
With format-security errors turned on, GCC picks up the use of sprintf with a format parameter not being a string literal. Simple uses of sprintf are also converted to use strcpy. Signed-off-by: Ben Whitten <ben.whitten@gmail.com> Acked-by: Wolfgang Denk <wd@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
2016-01-14block: pass block dev not num to read/write/erase()Stephen Warren
This will allow the implementation to make use of data in the block_dev structure beyond the base device number. This will be useful so that eMMC block devices can encompass the HW partition ID rather than treating this out-of-band. Equally, the existence of the priv field is crying out for this patch to exist. Signed-off-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2016-01-13part_dos.c: Don't wrap to negative after 2G sectorsStefan Monnier
In order to support large IDE disks we need to make certain types be lbaint_t now. Reviewed-by: Tom Rini <trini@konsulko.com> Signed-off-by: Stefan Monnier <monnier@iro.umontreal.ca>
2015-11-23part:efi: add bootable parameter in gpt commandPatrick Delaunay
The optional parameter bootable is added in gpt command to set the partition attribute flag "Legacy BIOS bootable" This flag is used in extlinux and so in with distro to select the boot partition where is located the configuration file (please check out doc/README.distro for details). With this parameter, U-Boot can be used to create the boot partition needed for device using distro. example of use: setenv partitions "name=u-boot,size=60MiB;name=boot,size=60Mib,bootable;\ name=rootfs,size=0" > gpt write mmc 0 $partitions > part list mmc 0 Partition Map for MMC device 0 -- Partition Type: EFI Part Start LBA End LBA Name Attributes Type GUID Partition GUID 1 0x00000022 0x0001e021 "u-boot" attrs: 0x0000000000000000 type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 guid: cceb0b18-39cb-d547-9db7-03b405fa77d4 2 0x0001e022 0x0003c021 "boot" attrs: 0x0000000000000004 type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 guid: d4981a2b-0478-544e-9607-7fd3c651068d 3 0x0003c022 0x003a9fde "rootfs" attrs: 0x0000000000000000 type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 guid: 6d6c9a36-e919-264d-a9ee-bd00379686c7 > part list mmc 0 -bootable devplist > printenv devplist devplist=2 Then the distro scripts will search extlinux in partition 2 and not in the first partition. Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com>
2015-11-23gpt: part: Definition and declaration of GPT verification functionsLukasz Majewski
This commit provides definition and declaration of GPT verification functions - namely gpt_verify_headers() and gpt_verify_partitions(). The former is used to only check CRC32 of GPT's header and PTEs. The latter examines each partition entry and compare attributes such as: name, start offset and size with ones provided at '$partitions' env variable. Signed-off-by: Lukasz Majewski <l.majewski@majess.pl> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Przemyslaw Marczak <p.marczak@samsung.com>
2015-11-12uuid: add selection by string for known partition type GUIDPatrick Delaunay
short strings can be used in type parameter of gpt command to replace the guid string for the types known by u-boot partitions = name=boot,size=0x6bc00,type=data; \ name=root,size=0x7538ba00,type=linux; gpt write mmc 0 $partitions and they are also used to display the type of partition in "part list" command Partition Map for MMC device 0 -- Partition Type: EFI Part Start LBA End LBA Name Attributes Type GUID Partition GUID 1 0x00000022 0x0000037f "boot" attrs: 0x0000000000000000 type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 type: data guid: d117f98e-6f2c-d04b-a5b2-331a19f91cb2 2 0x00000380 0x003a9fdc "root" attrs: 0x0000000000000000 type: 0fc63daf-8483-4772-8e79-3d69d8477de4 type: linux guid: 25718777-d0ad-7443-9e60-02cb591c9737 Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com>
2015-11-12gpt: add optional parameter type in gpt commandPatrick Delaunay
code under flag CONFIG_PARTITION_TYPE_GUID add parameter "type" to select partition type guid example of use with gpt command : partitions = uuid_disk=${uuid_gpt_disk}; \ name=boot,size=0x6bc00,uuid=${uuid_gpt_boot}; \ name=root,size=0x7538ba00,uuid=${uuid_gpt_root}, \ type=0fc63daf-8483-4772-8e79-3d69d8477de4; gpt write mmc 0 $partitions Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com>
2015-10-24ubifs: Add generic fs supportHans de Goede
Add generic fs support, so that commands like ls, load and test -e can be used on ubifs. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Heiko Schocher <hs@denx.de>
2015-10-24disk/part: Only build hostfs special handling when CONFIG_SANDBOX is setHans de Goede
This is not necessary / useful when not building with CONFIG_SANDBOX and with the addition of ubifs support to the generic fs commands it actually gets in the way, since both operate on a fake / NULL blkdev. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Stephen Warren <swarren@nvidia.com>
2015-09-11Move ALLOC_CACHE_ALIGN_BUFFER() to the new memalign.h headerSimon Glass
Now that we have a new header file for cache-aligned allocation, we should move the stack-based allocation macro there also. Signed-off-by: Simon Glass <sjg@chromium.org>