summaryrefslogtreecommitdiffstats
path: root/disk/part.c
Commit message (Collapse)AuthorAgeFilesLines
* dm: blk: Use the correct error code for blk_get_device_by_str()Simon Glass2016-05-171-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-171-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-171-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-171-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-171-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-171-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-171-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-171-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-171-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-171-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-171-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-171-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-141-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-011-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-151-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-141-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-141-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-141-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-141-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-141-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-141-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-141-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-201-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-121-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-241-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-241-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-251-1/+1
| | | | Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
* cleanup disk/part.c whitespacePavel Machek2014-09-241-4/+5
| | | | | | Cleanup disk/part.c Signed-off-by: Pavel Machek <pavel@denx.de>
* whitespace cleanupsPavel Machek2014-07-221-4/+4
| | | | | | Whitespace cleanups. Signed-off-by: Pavel Machek <pavel@denx.de>
* sandbox: restore ability to access host fs through standard commandsStephen Warren2014-06-231-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-121-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-231-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-231-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-171-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-081-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-241-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-221-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-141-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-041-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-061-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-221-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>
* disk: initialize name/part fields when returning a whole diskStephen Warren2012-10-191-0/+2
| | | | | | | | | | | | | | | | | | When get_device_and_partition() finds a disk without a partition table, under some conditions, it "returns" a disk_partition_t that describes the entire raw disk. Make sure to initialize all fields in the partition descriptor in that case. The value chosen for name is just some arbitrary descriptive string. The value chosen for info matches the check at the end of get_device_and_partition(). However, it's probably not that important; it's not obvious that the value is really used. Reported-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com> Signed-off-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com> Signed-off-by: Tom Rini <trini@ti.com>
* disk: get_device_and_partition() return value fixesStephen Warren2012-10-171-1/+1
| | | | | | | | | | | When no valid partitions are found, guarantee that we return -1. This most likely already happens, since the most recent get_partition_info() will have returned an error. However, it's best to be explicit. Remove an unnecessary assignment of ret=0 in the success case; this value is over-written with the processed partition ID later. Signed-off-by: Stephen Warren <swarren@nvidia.com>
* disk: allow - or empty string to fall back to $bootdeviceStephen Warren2012-09-281-1/+2
| | | | | | | | | | | | | | | | Commit 10a37fd "disk: get_device_and_partition() "auto" partition" prevented the use of "-" on the command-line to request fallback to the $bootdevice environment variable instead. This patch allows that, or an empty string "" to be used. Tested: setenv bootfile /boot/zImage setenv bootdevice 0:1 ext2load mmc 0:1 ext2load mmc - ext2load mmc "" Signed-off-by: Stephen Warren <swarren@nvidia.com>
* disk: part_efi: parse and store partition UUIDStephen Warren2012-09-251-0/+5
| | | | | | | | | | | Each EFI partition table entry contains a UUID. Extend U-Boot's struct disk_partition to be able to store this information, and modify get_partition_info_efi() to fill it in. The implementation of uuid_string() was derived from the Linux kernel, tag v3.6-rc4 file lib/vsprintf.c function uuid_string(). Signed-off-by: Stephen Warren <swarren@nvidia.com>
* disk: get_device_and_partition() "auto" partition and cleanupStephen Warren2012-09-251-43/+154
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rework get_device_and_partition() to: a) Implement a new partition ID of "auto", which requests that U-Boot search for the first "bootable" partition, and fall back to the first valid partition if none is found. This way, users don't need to specify an explicit partition in their commands. b) Make use of get_device(). c) Add parameter to indicate whether returning a whole device is acceptable, or whether a partition is mandatory. d) Make error-checking of the user's device-/partition-specification more complete. In particular, if strtoul() doesn't convert all characters, it's an error rather than just ignored. The resultant device/partition returned by the function will be as follows, based on whether the disk has a partition table (ptable) or not, and whether the calling command allows the whole device to be returned or not. (D and P are integers, P >= 1) D D: No ptable: !allow_whole_dev: error allow_whole_dev: device D ptable: device D partition 1 D:0 !allow_whole_dev: error allow_whole_dev: device D D:P No ptable: error ptable: device D partition P D:auto No ptable: !allow_whole_dev: error allow_whole_dev: device D ptable: first partition in device D with bootable flag set. If none, first valid paratition in device D. Note: In order to review this patch, it's probably easiest to simply look at the file contents post-application, rather than reading the patch itself. Signed-off-by: Rob Herring <rob.herring@calxeda.com> [swarren: Rob implemented scanning for bootable partitions. I fixed a couple of issues there, switched the syntax to ":auto", added the error-checking rework, and ":0" syntax for the whole device] Signed-off-by: Stephen Warren <swarren@nvidia.com>
* disk: introduce get_device()Stephen Warren2012-09-251-0/+22
| | | | | | | | | This patch introduces function get_device(). This looks up a block_dev_desc_t from an interface name (e.g. mmc) and device number (e.g. 0). This function is essentially the non-partition-specific prefix of get_device_and_partition(). Signed-off-by: Stephen Warren <swarren@nvidia.com>
* disk/part: introduce get_device_and_partitionRob Herring2012-09-251-2/+67
| | | | | | | | | | | | All block device related commands (scsiboot, fatload, ext2ls, etc.) have simliar duplicated device and partition parsing and selection code. This adds a common function to replace various implementations. The new function has an enhancement over current versions. If no device or partition is specified on the command line, the bootdevice env variable will be used (scsiboot does this). Signed-off-by: Rob Herring <rob.herring@calxeda.com>
* disk: make get_partition_info() always available to disk.cStephen Warren2012-09-251-55/+63
| | | | | | | | | | | | | | | | | | | | | | | | Now that get_device_and_partition() always calls get_partition_info() when disk.c is compiled, we must always compile the function, rather than ifdef it away. The implementation must be conditional based on CONFIG_CMD_* etc., since that's what e.g. part_dos.c uses to ifdef out get_partition_info_dos(); CONFIG_DOS_PARTITION can be enabled even without those commands being enabled. Technically, this change is required before Rob's "disk/part: introduce get_device_and_partition" patch. However, at least when the compiler optimizer is turned on, it isn't required before then in practice, since get_device_and_partition() calls get_dev(), which is stubbed out in disk.c under exactly the same conditions that get_partition_info() is not compiled, and hence the compiler never generates code for the call to the missing function. However, in my later patch "disk: get_device_and_partition() "auto" partition and cleanup", the optimizer doesn't succeed at this, and may attempt to reference the undefined function. Signed-off-by: Stephen Warren <swarren@nvidia.com>
* Block: Remove MG DISK supportMarek Vasut2012-06-211-6/+0
| | | | | | | | This driver is unused and obsolete. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Wolfgang Denk <wd@denx.de> Cc: unsik Kim <donari75@gmail.com>
OpenPOWER on IntegriCloud