summaryrefslogtreecommitdiff
path: root/disk/part.c
Commit message (Collapse)AuthorAgeLines
* cmd, disk: convert CONFIG_PARTITION_UUIDS, CMD_PART and CMD_GPTPatrick Delaunay2017-01-28-4/+4
| | | | | | | | | | | We convert CONFIG_PARTITION_UUIDS to Kconfig first. But in order to cleanly update all of the config files we must also update CMD_PART and CMD_GPT to also be in Kconfig in order to avoid complex logic elsewhere to update all of the config files. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com> Signed-off-by: Tom Rini <trini@konsulko.com>
* disk: convert CONFIG_EFI_PARTITION to KconfigPatrick Delaunay2017-01-28-1/+1
| | | | | Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com>
* disk: convert CONFIG_AMIGA_PARTITION to KconfigPatrick Delaunay2017-01-28-1/+1
| | | | | Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com>
* disk: convert CONFIG_ISO_PARTITION to KconfigPatrick Delaunay2017-01-28-1/+1
| | | | | Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com>
* disk: convert CONFIG_DOS_PARTITION to KconfigPatrick Delaunay2017-01-28-1/+1
| | | | | Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com>
* disk: convert CONFIG_MAC_PARTITION to KconfigPatrick Delaunay2017-01-28-1/+1
| | | | | Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com>
* disk: Fixed capacity messageJean-Jacques Hiblot2016-12-27-2/+2
| | | | | | | | | | With capacities getting bigger, we can see see messages with negative numbers like "Capacity: 1907729.0 MB = 1863.0 GB (-387938128 x 512)". Here the printed LBA is -387938128 when it should have been 3907029168. To fix this, use the right format when displaying the unsigned integers. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reported-by: Yan Liu <yan-liu@ti.com>
* disk: part: refactor generic name creation for DOS and ISOPetr Kulhavy2016-10-01-0/+32
| | | | | | | | | | | | | 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>
* disk: part: implement generic function part_get_info_by_name()Petr Kulhavy2016-10-01-0/+26
| | | | | | | | | | | | | | | | | 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>
* dm: blk: Use the correct error code for blk_get_device_by_str()Simon Glass2016-05-17-3/+3
| | | | | | | Return -EINVAL instead of -1 in this function, to provide a more meaningful error. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: part: Drop the block_drvr tableSimon Glass2016-05-17-53/+14
| | | | | | | 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>
* dm: part: Use the legacy block driver for hardware partition supportSimon Glass2016-05-17-11/+1
| | | | | | Drop use of the table in part.c for this feature. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: sandbox: Drop the host_get_dev() functionSimon Glass2016-05-17-1/+1
| | | | | | This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: systemace: Drop the get_dev() functionSimon Glass2016-05-17-1/+1
| | | | | | This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: sata: Drop the get_dev() functionSimon Glass2016-05-17-1/+1
| | | | | | | | | 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>
* dm: scsi: Drop the get_dev() functionSimon Glass2016-05-17-1/+1
| | | | | | This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: mmc: Drop the get_dev() functionSimon Glass2016-05-17-1/+0
| | | | | | This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: ide: Drop the get_dev() functionSimon Glass2016-05-17-1/+1
| | | | | | This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: usb: Drop the get_dev() functionSimon Glass2016-05-17-1/+1
| | | | | | This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: disk: Use legacy block driver info for block device accessSimon Glass2016-05-17-4/+3
| | | | | | | 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>
* dm: scsi: Rename CONFIG_CMD_SCSI to CONFIG_SCSISimon Glass2016-05-17-1/+1
| | | | | | | | 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>
* dm: part: fix missing driver name in debug printNishanth Menon2016-04-14-1/+2
| | | | | | | | 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>
* drivers: block: add block device cacheEric Nelson2016-04-01-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* disk/part.c: Expose list of available block driversAlexander Graf2016-03-15-7/+1
| | | | | | | | | | | | | | 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>
* dm: block: Rename device number member dev to devnumSimon Glass2016-03-14-6/+2
| | | | | | | | | 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>
* dm: part: Rename some partition functionsSimon Glass2016-03-14-6/+6
| | | | | | | | 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>
* dm: part: Convert partition API use to linker listsSimon Glass2016-03-14-126/+58
| | | | | | | | | | | | | | | | | | | 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>
* dm: blk: Rename get_device_and_partition()Simon Glass2016-03-14-1/+1
| | | | | | | | | | 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>
* dm: blk: Rename get_device() to blk_get_device_by_str()Simon Glass2016-03-14-3/+3
| | | | | | | | | | 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>
* dm: blk: Rename get_dev() to blk_get_dev()Simon Glass2016-03-14-2/+2
| | | | | | | | | 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>
* dm: Drop the block_dev_desc_t typedefSimon Glass2016-03-14-14/+14
| | | | | | | | | 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>
* mmc: emmc and hw partitions partition table id bugfix.Erik Tideman2016-01-20-0/+10
| | | | | | | | | | | | | | | | | 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>
* gpt: add optional parameter type in gpt commandPatrick Delaunay2015-11-12-0/+9
| | | | | | | | | | | | | | | | 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>
* ubifs: Add generic fs supportHans de Goede2015-10-24-0/+27
| | | | | | | | 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>
* disk/part: Only build hostfs special handling when CONFIG_SANDBOX is setHans de Goede2015-10-24-0/+2
| | | | | | | | | 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>
* disk/part.c: make local function staticJeroen Hofstee2014-10-25-1/+1
| | | | Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
* cleanup disk/part.c whitespacePavel Machek2014-09-24-4/+5
| | | | | | Cleanup disk/part.c Signed-off-by: Pavel Machek <pavel@denx.de>
* whitespace cleanupsPavel Machek2014-07-22-4/+4
| | | | | | Whitespace cleanups. Signed-off-by: Pavel Machek <pavel@denx.de>
* sandbox: restore ability to access host fs through standard commandsStephen Warren2014-06-23-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | Commit 95fac6ab4589 "sandbox: Use os functions to read host device tree" removed the ability for get_device_and_partition() to handle the "host" device type, and redirect accesses to it to the host filesystem. This broke some unit tests that use this feature. So, revert that change. The code added back by this patch is slightly different to pacify checkpatch. However, we're then left with "host" being both: - A pseudo device that accesses the hosts real filesystem. - An emulated block device, which accesses "sectors" inside a file stored on the host. In order to resolve this discrepancy, rename the pseudo device from host to hostfs, and adjust the unit-tests for this change. The "help sb" output is modified to reflect this rename, and state where the host and hostfs devices should be used. Signed-off-by: Stephen Warren <swarren@nvidia.com> Tested-by: Josh Wu <josh.wu@atmel.com> Acked-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
* disk: default to HW partition 0 if not specifiedStephen Warren2014-06-12-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, get_device()/get_dev_hwpart() for MMC devices does not select an explicit HW partition unless the user explicitly requests one, i.e. by requesting device "mmc 0.0" rather than just "mmc 0". I think it makes more sense if the default is to select HW partition 0 (main data area) if the user didn't request a specific partition. Otherwise, the following happens, which feels wrong: Select HW partition 1 (boot0): mmc dev 0 1 Attempts to access SW partition 1 on HW partition 1 (boot0), rather than SW partition 1 on HW partition 0 (main data area): ls mmc 0:1 / With this patch, the second command above re-selects the main data area. Many device types don't support HW partitions at all, so if HW partition 0 is selected (either explicitly or as the default) and there's no select_hwpart function, we simply skip attempting to select a HW partition. Some MMC devices (i.e. SD cards) don't support HW partitions. However, this patch still works, since mmc_start_init() sets the current partition number to 0, and mmc_select_hwpart() succeeds if the requested partition is already selected. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
* mmc: provide a select_hwpart implementation for get_device()Stephen Warren2014-05-23-1/+5
| | | | | | | | | This enables specifying which eMMC HW partition to target for any U-Boot command that uses the generic get_partition() function to parse its command-line arguments. Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com> Signed-off-by: Stephen Warren <swarren@nvidia.com>
* disk: support devices with HW partitionsStephen Warren2014-05-23-10/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some device types (e.g. eMMC) have hardware-level partitions (for eMMC, separate boot and user data partitions). This change allows the user to specify the HW partition they wish to access when passing a device ID to U-Boot Commands such as part, ls, load, ums, etc. The syntax allows an optional ".$hwpartid" to be appended to the device name string for those commands. Existing syntax, for MMC device 0, default HW partition ID, SW partition ID 1: ls mmc 0:1 / New syntax, for MMC device 0, HW partition ID 1 (boot0), SW partition ID 2: ls mmc 0.1:2 / For my purposes, this is most useful for the ums (USB mass storage gadget) command, but there's no reason not to allow the new syntax globally. This patch adds the core support infra-structure. The next patch will provide the implementation for MMC. Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com> Signed-off-by: Stephen Warren <swarren@nvidia.com>
* sandbox: Use os functions to read host device treeSimon Glass2014-03-17-17/+0
| | | | | | | | | | At present we use U-Boot's filesystem layer to read the sandbox device tree, but this is problematic since it relies on a temporary feauture added there. Since we plan to implement proper block layer support for sandbox, change this code to use the os layer functions instead. Also use the new fdt_create_empty_tree() instead of our own code. Signed-off-by: Simon Glass <sjg@chromium.org>
* sandbox: block driver using host file/device as backing storeHenrik Nordström2014-01-08-0/+6
| | | | | | | | | | | | | | | | | | | Provide a way to use any host file or device as a block device in U-Boot. This can be used to provide filesystem access within U-Boot to an ext2 image file on the host, for example. The support is plumbed into the filesystem and partition interfaces. We don't want to print a message in the driver every time we find a missing device. Pass the information back to the caller where a message can be printed if desired. Signed-off-by: Henrik Nordström <henrik@henriknordstrom.net> Signed-off-by: Simon Glass <sjg@chromium.org> - Removed change to part.c get_device_and_partition() Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk2013-07-24-17/+1
| | | | | | Signed-off-by: Wolfgang Denk <wd@denx.de> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <trini@ti.com>
* fs/ext4: fix log2blksz un-initialized error, by cacaulating its value from blkszLan Yixun (dlan)2013-07-22-0/+4
| | | | | | | | | | | The problem here is that uboot can't mount ext4 filesystem with commit "50ce4c07df1" applied. We use hard-coded "SECTOR_SIZE"(512) before this commit, now we introduce (block_dev_desc_t *)->log2blksz to replace this macro. And after we calling do_ls()->fs_set_blk_dev(), the variable log2blksz is not initialized, which it's not correct. And this patch try to solve the problem by caculating the value of log2blksz from variable blksz.
* disk: define HAVE_BLOCK_DEVICE in a common placeStephen Warren2013-03-14-10/+0
| | | | | | | | | | This set of ifdefs is used in a number of places. Move its definition somewhere common so it doesn't have to be repeated. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Simon Glass <sjg@chromium.org> Acked-by: Tom Rini <trini@ti.com> Signed-off-by: Tom Warren <twarren@nvidia.com>
* sandbox: Add host filesystemSimon Glass2013-03-04-0/+17
| | | | | | | This allows reading of files from the host filesystem in sandbox. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@ti.com>
* part: check each variable for capability calculationJerry Huang2012-12-06-1/+1
| | | | | | | | | | | In order to calculate the capability, we use the below expression to check: ((dev_desc->lba * dev_desc->blksz)>0L) If the capability is greater than 4GB (e.g. 8GB = 8 * 1024 * 104 * 1024), the result will overflow, the low 32bit may be zero. Therefore, change to check each variable to fix this potential issue. Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
* disk: Make the disk partition code work with no specific partition typesGabe Black2012-10-22-33/+17
| | | | | | | | | | | | | | | Currently, if the disk partition code is compiled with all of the parition types compiled out, it hits an #error which stops the build. This change adjusts that file so that those functions will fall through to their defaults in those cases instead of breaking the build. These functions are needed because other code calls them, and that code is needed because other config options are overly broad and bring in support we don't need along with support we do. Also reduce repetition of the 6-term #ifdef throughout the file. Signed-off-by: Gabe Black <gabeblack@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>