aboutsummaryrefslogtreecommitdiff
path: root/disk/part.c
AgeCommit message (Collapse)AuthorFilesLines
2023-10-24rockchip: dm: prepare rkmtd UCLASSJohan Jonker1-0/+4
Prepare a rkmtd UCLASS in use for writing Rockchip boot blocks in combination with existing userspace tools and rockusb command. Signed-off-by: Johan Jonker <jbx6244@gmail.com> Reviewed-by: Kever Yang <kever.yang@rock-chips.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-10-10disk: part: Handle blkmap device in print_part_header()WIP/2023-10-10-blk-sandbox-support-binding-a-device-with-a-given-logical-block-sizeBin Meng1-0/+3
Print out the blkmap device type when showing partition header for a blkmap device. Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-10-10disk: part: Print out the unknown device uclass idBin Meng1-1/+1
It's helpful to output the device uclass id for unknown devices during the debugging process. Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-25part: Add accessors for struct disk_partition type_uuidSimon Glass1-6/+2
This field is only present when a CONFIG is set. To avoid annoying #ifdefs in the source code, add accessors. Update all code to use it. Note that the accessor is optional. It can be omitted if it is known that the option is enabled. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-25part: Add accessors for struct disk_partition uuidSimon Glass1-6/+2
This field is only present when a CONFIG is set. To avoid annoying #ifdefs in the source code, add accessors. Update all code to use it. Note that the accessor is optional. It can be omitted if it is known that the option is enabled. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-25part: Add comments for static functionsSimon Glass1-0/+32
Some internal functions could do with a few comments, to explain what they do. Add these, to make the code easier to follow. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-25part: Use desc instead of dev_descSimon Glass1-92/+86
The dev_ prefix is a hangover from the pre-driver model days. The device is now a different thing, with driver model. Update the partition code to just use 'desc', as is done with driver model. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-07-30part: check CONFIG_IS_ENABLED(ENV_SUPPORT)Heinrich Schuchardt1-3/+5
In SPL environment variables may not be enabled. Suggested-by: Tom Rini <trini@konsulko.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-07-25part: eliminate part_get_info_by_name_type()Heinrich Schuchardt1-8/+2
Since commit 56670d6fb83f ("disk: part: use common api to lookup part driver") part_get_info_by_name_type() ignores the part_type parameter used to restrict the partition table type. omap_mmc_get_part_size() and part_get_info_by_name() are the only consumers. omap_mmc_get_part_size() calls with part_type = PART_TYPE_EFI because at the time of implementation a speed up could be gained by passing the partition table type. After 5 years experience without this restriction it looks safe to keep it that way. part_get_info_by_name() uses PART_TYPE_ALL. Move the logic of part_get_info_by_name_type() to part_get_info_by_name() and replace the function in omap_mmc_get_part_size(). Fixes: 56670d6fb83f ("disk: part: use common api to lookup part driver") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-07-17disk: part: Add API to get partitions with specific driverJoshua Watt1-7/+31
Adds part_driver_get_type() API which can be used to force a specific driver to be used when getting partition information instead of relying on auto detection. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-07-17part: Allow setting the partition-table typeSimon Glass1-0/+16
Some devices have multiple partition types available on the same media. It is sometimes useful to see these to check that everything is working correctly. Provide a way to manually set the partition-table type, avoiding the auto-detection process. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2023-04-05cmd: blkmap: Add blkmap commandTobias Waldekranz1-0/+1
Add a frontend for the blkmap subsystem. In addition to the common block device operations, this allows users to create and destroy devices, and map in memory and slices of other block devices. With that we support two primary use-cases: - Being able to "distro boot" from a RAM disk. I.e., from an image where the kernel is stored in /boot of some filesystem supported by U-Boot. - Accessing filesystems not located on exact partition boundaries, e.g. when a filesystem image is wrapped in an FIT image and stored in a disk partition. Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-23part: Add a function to find the first bootable partitionSimon Glass1-0/+16
If a disk has a bootable partition we are expected to use it to locate the boot files. Add a function to find it. To test this, update mmc1 to have two paritions, fixing up other tests accordingly. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-12-02disk: fix blk_get_device_part_str()Heinrich Schuchardt1-18/+5
blk_get_device_part_str() should always initialize all info fields including sys_ind. As a side effect the code is simplified. Replace '(0 ==' by '(!' to conform with Linux coding style. Fixes: 4d907025d6a5 ("sandbox: restore ability to access host fs through standard commands") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Heiko Schocher <hs@denx.de>
2022-11-07dm: sandbox: Switch over to using the new host uclassSimon Glass1-2/+2
Update the sandbox implementation to use UCLASS_HOST and adjust all the pieces to continue to work: - Update the 'host' command to use the new API - Replace various uses of UCLASS_ROOT with UCLASS_HOST - Disable test_eficonfig since it doesn't work (this should have a unit test to allow this to be debugged) - Update the blk test to use the new API - Drop the old header file Unfortunately it does not seem to be possible to split this change up further. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-25blk: Rename if_type to uclass_idSimon Glass1-7/+7
Use the word 'uclass' instead of 'if_type' to complete the conversion. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-19Merge branch 'master' into nextTom Rini1-1/+1
Signed-off-by: Tom Rini <trini@konsulko.com>
2022-09-16disk: Handle UCLASS_EFI_MEDIA in dev_print()Simon Glass1-1/+4
This is currently missing. Add it. Fix the code style for the function while we are here. Suggested-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Switch over to using uclass IDsSimon Glass1-26/+26
We currently have an if_type (interface type) and a uclass id. These are closely related and we don't need to have both. Drop the if_type values and use the uclass ones instead. Maintain the existing, subtle, one-way conversion between UCLASS_USB and UCLASS_MASS_STORAGE for now, and add a comment. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Drop IF_TYPE_SDSimon Glass1-2/+0
This is not really needed since it does the same things as MMC. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Drop IF_TYPE_ATAPISimon Glass1-5/+0
This is not really needed since it does the same things as IDE. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Drop IF_TYPE_DOCSimon Glass1-9/+0
This doesn't seem to be used for anything and it isn't clear what it is. It dates from the first U-Boot commit. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-16blk: Use a function for whether block devices are availableSimon Glass1-47/+33
At present we use HAVE_BLOCK_DEVICE to indicate when block devices are available. This is a very strange option, since it partially duplicates the BLK option used by driver model. It also covers both U-Boot proper and SPL, even though one might have block devices and another not. As a first step towards correcting this, create a new inline function called blk_enabled() which indicates if block devices are available. This cannot be used in Makefiles, or #if clauses, but can be used in C code. A function is useful because we cannot use CONFIG_IS_ENABLED(BLK) to decide if block devices are needed, since we must consider the legacy block interface, enabled by HAVE_BLOCK_DEVICE Update a few places where it can be used and drop some unnecessary #if checks around some functions in disk/part.c - rely on the compiler's dead-code elimination instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-26disk: part: remove dependency to ubifs for splStefan Herbrechtsmeier1-1/+1
The spl doesn't support ubifs and thereby doesn't provide the ubifs_is_mounted function. Remove the dependency to ubifs for the spl. Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
2022-04-12disk: part: add the device search failed log msgOleksii Bidnichenko1-0/+2
Add missing error message to blk_get_device_part_str. Signed-off-by: Oleksii Bidnichenko <oleksii.bidnichenko@toradex.com> Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
2022-04-01fs: Add semihosting filesystemSean Anderson1-2/+2
This adds a filesystem which is backed by the host's filesystem. It is modeled off of sandboxfs, which has very similar aims. Semihosting doesn't support listing directories (except with SYS_SYSTEM), so neither do we. it's possible to optimize a bit for the common case of reading a whole file by omitting a call to smh_seek, but this is left as a future optimization. Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2022-01-19doc: replace @return by Return:Heinrich Schuchardt1-1/+1
Sphinx expects Return: and not @return to indicate a return value. find . -name '*.c' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; find . -name '*.h' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-12-18part: call part_init() in blk_get_device_by_str() only for MMCAKASHI Takahiro1-1/+2
In blk_get_device_by_str(), the comment says: "Updates the partition table for the specified hw partition." Since hw partition is supported only on MMC, it makes no sense to do so for other devices. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-12-09efi: Add uclass for devices provided by UEFI firmwareSimon Glass1-1/+4
UCLASS_EFI_LOADER is used for devices created by applications and drivers loaded by U-Boots UEFI implementation. This patch provides a new uclass (UCLASS_EFI_MEDIA) to be used for devices that provided by a UEFI firmware calling U-Boot as an EFI application. If the two uclasses can be unified, is left to future redesign. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-11-18part: return -ENOSYS when get_info not valid.schspa1-0/+7
In some case, get_info() interface can be NULL, add this check to stop from crash. Signed-off-by: schspa <schspa@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-08-02global: Convert simple_strtoul() with hex to hextoul()Simon Glass1-3/+3
It is a pain to have to specify the value 16 in each call. Add a new hextoul() function and update the code to use it. Add a proper comment to simple_strtoul() while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-05-26part: Add check for NULL dev_part_strSean Anderson1-1/+5
Some callers (e.g. cmd/fs.c) of fs_set_blk_dev may use a NULL dev_part_str. While blk_get_device_part_str handles this fine, part_get_info_by_dev_and_name does not. This fixes commands crashing when implicitly using bootdevice. The unit test has also been updated to set bootdevice to a known value and to restore it after we are done. Fixes: 7194527b6a ("cmd: fs: Use part_get_info_by_dev_and_name_or_num to parse partitions") Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-22part: Fix bogus return from part_get_info_by_dev_and_nameSean Anderson1-1/+1
blk_get_device_by_str returns the device number on success. So we must check if the return was negative to determine an error. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-02-26part: Support string block devices in part_get_info_by_dev_and_nameSean Anderson1-19/+22
This adds support for things like "#partname" and "0.1#partname". The block device parsing is done like in blk_get_device_part_str. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-02-26part: Support getting whole disk from part_get_info_by_dev_and_name_or_numSean Anderson1-2/+3
This adds an option to part_get_info_by_dev_and_name_or_num to allow callers to specify whether whole-disk partitions are fine. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-02-26part: Give several functions more useful return valuesSean Anderson1-22/+28
Several functions in disk/part.c just return -1 on error. This makes them return different errnos for different failures. This helps callers differentiate between failures, even if they cannot read stdout. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-30disk: part: sandbox support in dev_print()Heinrich Schuchardt1-0/+1
Commands like 'fatinfo' call dev_print() to print device information. If the block device is created via 'host bind', we should print accurate information. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-14xen: pvblock: Add initial support for para-virtualized block driverAnastasiia Lukianenko1-0/+4
Add initial infrastructure for Xen para-virtualized block device. This includes compile-time configuration and the skeleton for the future driver implementation. Add new class UCLASS_PVBLOCK which is going to be a parent for virtual block devices. Add new interface type IF_TYPE_PVBLOCK. Implement basic driver setup by reading XenStore configuration. Signed-off-by: Andrii Anisov <andrii_anisov@epam.com> Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
2020-05-18common: Drop log.h from common headerSimon Glass1-0/+1
Move this header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop part.h from common headerSimon Glass1-0/+1
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18part: Drop disk_partition_t typedefSimon Glass1-8/+9
We should not be using typedefs and these make it harder to use forward declarations (to reduce header file inclusions). Drop the typedef. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-23disk: part: rename parameter of lba512_muldiv()Heinrich Schuchardt1-6/+7
div_by is a misleading parameter name, when we are doing >> div_by. Rename it to right_shift. Reported-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-08-11env: Move env_get() to env.hSimon Glass1-0/+1
Move env_get() over to the new header file. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24disk: part: Extend API to get partition infoRuslan Trofymenko1-0/+68
This patch adds part_get_info_by_dev_and_name_or_num() function which allows us to get partition info from its number or name. Partition of interest is specified by string like "device_num:partition_number" or "device_num#partition_name". The patch was extracted from [1]. [1] https://android-review.googlesource.com/c/platform/external/u-boot/+/729880/2 Signed-off-by: Ruslan Trofymenko <ruslan.trofymenko@linaro.org> Signed-off-by: Igor Opaniuk <igor.opaniuk@gmail.com> Reviewed-by: Alistair Strachan <astrachan@google.com> Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-06-21disk: part: Don't skip partition initRobert Hancock1-4/+3
blk_get_device_by_str was skipping part_init when hw partition 0 was selected because it is the default. However, this caused issues when switching to a non-zero partition and then back to partition zero, as stale data from the wrong partition was returned. Remove this optimization and call part_init regardless of the selected partition. Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
2019-06-14disk: part: avoid undefined reference to `__udivmoddi4'Heinrich Schuchardt1-6/+6
When compiling with FTRACE=1 an error ld.bfd: disk/built-in.o: in function `lba512_muldiv': disk/part.c:114: undefined reference to `__udivmoddi4 occurred. Use '>> 11' instead of '/ 2048' to avoid the division. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-26disk: part: fix typoHeinrich Schuchardt1-1/+1
%g/rathen then/rather than/ Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2018-11-14blk: Introduce IF_TYPE_VIRTIOTuomas Tynkkynen1-0/+6
This adds a new block interface type for VirtIO block devices. Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi> Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-08-10disk: part: Don't show redundant error messageSam Protsenko1-1/+1
Underlying API should already print some meaningful error message, so this one is just brings more noise. E.g. we can see log like this: MMC: no card present ** Bad device mmc 0 ** Obviously, second error message is unwanted. Let's only print it in case when DEBUG is defined to keep log short and clear. Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini1-2/+1
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>