1. 02 Nov, 2017 1 commit
  2. 05 Apr, 2017 1 commit
  3. 08 Feb, 2017 1 commit
  4. 28 Jan, 2017 2 commits
  5. 02 Oct, 2016 1 commit
    • Petr Kulhavy's avatar
      disk: part: implement generic function part_get_info_by_name() · 87b8530f
      Petr Kulhavy authored
      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: default avatarPetr Kulhavy <brain@jikos.cz>
      Reviewed-by: default avatarTom Rini <trini@konsulko.com>
      Acked-by: default avatarSteve Rae <steve.rae@raedomain.com>
      87b8530f
  6. 06 Aug, 2016 1 commit
  7. 25 Jul, 2016 1 commit
  8. 27 May, 2016 1 commit
    • Patrick Delaunay's avatar
      disk: part_efi: fix check of the max partition size · a5653867
      Patrick Delaunay authored
      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: default avatarPatrick Delaunay <patrick.delaunay73@gmail.com>
      a5653867
  9. 22 Mar, 2016 2 commits
  10. 14 Mar, 2016 7 commits
  11. 15 Jan, 2016 1 commit
  12. 14 Jan, 2016 1 commit
  13. 23 Nov, 2015 2 commits
    • Patrick Delaunay's avatar
      part:efi: add bootable parameter in gpt command · cfdaf4ca
      Patrick Delaunay authored
      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: default avatarPatrick Delaunay <patrick.delaunay73@gmail.com>
      cfdaf4ca
    • Lukasz Majewski's avatar
      gpt: part: Definition and declaration of GPT verification functions · cef68bf9
      Lukasz Majewski authored
      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: default avatarLukasz Majewski <l.majewski@majess.pl>
      Reviewed-by: default avatarTom Rini <trini@konsulko.com>
      Reviewed-by: default avatarPrzemyslaw Marczak <p.marczak@samsung.com>
      cef68bf9
  14. 12 Nov, 2015 2 commits
    • Patrick Delaunay's avatar
      uuid: add selection by string for known partition type GUID · bcb41dca
      Patrick Delaunay authored
      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: default avatarPatrick Delaunay <patrick.delaunay73@gmail.com>
      bcb41dca
    • Patrick Delaunay's avatar
      gpt: add optional parameter type in gpt command · 7561b258
      Patrick Delaunay authored
      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: default avatarPatrick Delaunay <patrick.delaunay73@gmail.com>
      7561b258
  15. 11 Sep, 2015 1 commit
  16. 08 Jan, 2015 1 commit
    • Maxime Ripard's avatar
      gpt: Fix the protective MBR partition size · b349abbf
      Maxime Ripard authored
      According to the UEFI Spec (Table 16, section 5.2.3 of the version 2.4 Errata
      B), the protective MBR partition record size must be set to the size of the
      disk minus one, in LBAs.
      
      However, the current code was setting the size as the total number of LBAs on
      the disk, resulting in an off-by-one error.
      
      This confused the AM335x ROM code, and will probably confuse other tools as
      well.
      Signed-off-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
      b349abbf
  17. 18 Dec, 2014 2 commits
  18. 27 Nov, 2014 1 commit
  19. 05 Jun, 2014 3 commits
  20. 12 May, 2014 1 commit
  21. 02 Apr, 2014 2 commits
    • Przemyslaw Marczak's avatar
      lib: uuid: code refactor for proper maintain between uuid bin and string · d718ded0
      Przemyslaw Marczak authored
      Changes in lib/uuid.c to:
      - uuid_str_to_bin()
      - uuid_bin_to_str()
      
      New parameter is added to specify input/output string format in listed functions
      This change allows easy recognize which UUID type is or should be stored in given
      string array. Binary data of UUID and GUID is always stored in big endian, only
      string representations are different as follows.
      
      String byte: 0                                  36
      String char: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
      string UUID:    be     be   be   be       be
      string GUID:    le     le   le   be       be
      
      This patch also updates functions calls and declarations in a whole code.
      Signed-off-by: default avatarPrzemyslaw Marczak <p.marczak@samsung.com>
      Cc: Stephen Warren <swarren@nvidia.com>
      Cc: Lukasz Majewski <l.majewski@samsung.com>
      Cc: trini@ti.com
      d718ded0
    • Przemyslaw Marczak's avatar
      part_efi: move uuid<->string conversion functions into lib/uuid.c · a96a0e61
      Przemyslaw Marczak authored
      This commit introduces cleanup for uuid library.
      Changes:
      - move uuid<->string conversion functions into lib/uuid.c so they can be
        used by code outside part_efi.c.
      - rename uuid_string() to uuid_bin_to_str() for consistency with existing
        uuid_str_to_bin()
      - add an error return code to uuid_str_to_bin()
      - update existing code to the new library functions.
      Signed-off-by: default avatarPrzemyslaw Marczak <p.marczak@samsung.com>
      Cc: Stephen Warren <swarren@nvidia.com>
      Cc: Lukasz Majewski <l.majewski@samsung.com>
      Cc: trini@ti.com
      a96a0e61
  22. 24 Feb, 2014 1 commit
  23. 20 Sep, 2013 1 commit
    • Mark Langsdorf's avatar
      part_efi: make sure the gpt_pte is freed · 6d2ee5a3
      Mark Langsdorf authored
      the gpt_pte wasn't being freed if it was checked against an invalid
      partition. The resulting memory leakage could make it impossible
      to repeatedly attempt to load non-existent files in a script.
      
      Also, downgrade the message for not finding an invalid partition
      from a printf() to a debug() so as to minimize message spam in
      perfectly normal situations.
      Signed-off-by: default avatarMark Langsdorf <mark.langsdorf@calxeda.com>
      6d2ee5a3
  24. 24 Jul, 2013 1 commit
  25. 15 Jul, 2013 1 commit
    • Frederic Leroy's avatar
      Fix ext2/ext4 filesystem accesses beyond 2TiB · 04735e9c
      Frederic Leroy authored
      With CONFIG_SYS_64BIT_LBA, lbaint_t gets defined as a 64-bit type,
      which is required to represent block numbers for storage devices that
      exceed 2TiB (the block size usually is 512B), e.g. recent hard drives
      
      We now use lbaint_t for partition offset to reflect the lbaint_t change,
      and access partitions beyond or crossing the 2.1TiB limit.
      This required changes to signature of ext4fs_devread(), and type of all
      variables relatives to block sector.
      
      ext2/ext4 fs uses logical block represented by a 32 bit value. Logical
      block is a multiple of device block sector. To avoid overflow problem
      when calling ext4fs_devread(), we need to cast the sector parameter.
      Signed-off-by: default avatarFrédéric Leroy <fredo@starox.org>
      04735e9c
  26. 04 Jun, 2013 1 commit
    • Marek Vasut's avatar
      disk: Fix possible out-of-bounds access in part_efi.c · 67cd4a63
      Marek Vasut authored
      Make sure to never access beyond bounds of either EFI partition name
      or DOS partition name. This situation is happening:
      
      part.h:     disk_partition_t->name is 32-byte long
      part_efi.h: gpt_entry->partition_name is 36-bytes long
      
      The loop in part_efi.c copies over 36 bytes and thus accesses beyond
      the disk_partition_t->name .
      
      Fix this by picking the shortest of source and destination arrays and
      make sure the destination array is cleared so the trailing bytes are
      zeroed-out and don't cause issues with string manipulation.
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Cc: Tom Rini <trini@ti.com>
      Cc: Simon Glass <sjg@chromium.org>
      67cd4a63