Skip to content

[HELP] What is the right format should be used in part_procfs_read? #19424

Description

@wangtao13

Description

I am testing NAND MTD partition in MIPS32 system, and after I created 4 partitions, I ran cat /proc/partitions, and got followings,

Name             Start    Size   MTD
(noname)       34359738368 9230062565109792768
(noname)       274877906944 9230062565109792768
(noname)       274877906944 9230062565109792768
(noname)       274877906944 9230062565109792768

This is wrong, my partition table should be

Name             Start    Size   MTD
(noname)             0       8   tstnand
(noname)             8      64   tstnand
(noname)            72      64   tstnand
(noname)           136      64   tstnand

The info is from following codes of part_procfs_read(),

#ifdef CONFIG_MTD_PARTITION_NAMES
          ptr = attr->nextpart->name;
          for (x = 0; x < sizeof(partname) - 1; x++)
            {
              /* Test for end of partition name */

              if (*ptr == ',' || *ptr == '\0')
                {
                  /* Perform space fill for alignment */

                  partname[x] = ' ';
                }
              else
                {
                  /* Copy next byte of partition name */

                  partname[x] = *ptr++;
                }
            }

          partname[x] = '\0';

          /* Terminate the partition name and add to output buffer */

          ret = snprintf(&buffer[total], buflen - total,
                         "%s%7ju %7ju   %s\n",
                         partname,
                         (uintmax_t)attr->nextpart->firstblock / blkpererase,
                         (uintmax_t)attr->nextpart->geo.neraseblocks,
                         attr->nextpart->parent->name);
#else
          ret = snprintf(&buffer[total], buflen - total, "%7ju %7ju   %s\n",
                         (uintmax_t)attr->nextpart->firstblock / blkpererase,
                         (uintmax_t)attr->nextpart->geo.neraseblocks,
                         attr->nextpart->parent->name);
#endif

What is the right format should be used to print partition info across 32 and 64bit platform?

Verification

  • I have verified before submitting the report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions