patacongo commented on a change in pull request #4248: URL: https://github.com/apache/incubator-nuttx/pull/4248#discussion_r682806497
########## File path: drivers/mtd/mtd_partition.c ########## @@ -413,6 +413,25 @@ static int part_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg) } break; + case MTDIOC_PARTINFO: + { + FAR struct partition_info_s *info = + (FAR struct partition_info_s *)arg; + if (info != NULL) + { + info->magic = 0; + info->numsectors = priv->neraseblocks * priv->blkpererase; + info->length = info->numsectors * priv->blocksize; + info->sectorsize = priv->blocksize; + info->startsector = priv->firstblock; + info->endsector = priv->firstblock + info->numsectors; + info->parent = priv->parent->name; + + ret = OK; + } + } + break; + Review comment: > 1. Linux MTD character device driver implements similar `ioctl` commands (**MEMGETREGIONINFO** and **MEMGETINFO**) for providing MTD info to the application: That argument has value if the solution is 100% compatible with Linux. ########## File path: drivers/mtd/mtd_partition.c ########## @@ -413,6 +413,25 @@ static int part_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg) } break; + case MTDIOC_PARTINFO: + { + FAR struct partition_info_s *info = + (FAR struct partition_info_s *)arg; + if (info != NULL) + { + info->magic = 0; + info->numsectors = priv->neraseblocks * priv->blkpererase; + info->length = info->numsectors * priv->blocksize; + info->sectorsize = priv->blocksize; + info->startsector = priv->firstblock; + info->endsector = priv->firstblock + info->numsectors; + info->parent = priv->parent->name; + + ret = OK; + } + } + break; + Review comment: > So 100% compatibility with Linux is not possible at the moment. > But, the approach via `ioctl` is the most compatible to Linux. That makes no sense to me. That is like saying I need a whale, but I don't have a whale. But a whale is mammal so I can use a bat instead. ########## File path: drivers/mtd/mtd_partition.c ########## @@ -413,6 +413,25 @@ static int part_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg) } break; + case MTDIOC_PARTINFO: + { + FAR struct partition_info_s *info = + (FAR struct partition_info_s *)arg; + if (info != NULL) + { + info->magic = 0; + info->numsectors = priv->neraseblocks * priv->blkpererase; + info->length = info->numsectors * priv->blocksize; + info->sectorsize = priv->blocksize; + info->startsector = priv->firstblock; + info->endsector = priv->firstblock + info->numsectors; + info->parent = priv->parent->name; + + ret = OK; + } + } + break; + Review comment: > So 100% compatibility with Linux is not possible at the moment. > But, the approach via `ioctl` is the most compatible to Linux. That makes no sense to me. That is like saying I need a whale, but I don't have a whale. But a whale is mammal so I can use a bat instead because it is also a mammal. ########## File path: drivers/mtd/mtd_partition.c ########## @@ -413,6 +413,25 @@ static int part_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg) } break; + case MTDIOC_PARTINFO: + { + FAR struct partition_info_s *info = + (FAR struct partition_info_s *)arg; + if (info != NULL) + { + info->magic = 0; + info->numsectors = priv->neraseblocks * priv->blkpererase; + info->length = info->numsectors * priv->blocksize; + info->sectorsize = priv->blocksize; + info->startsector = priv->firstblock; + info->endsector = priv->firstblock + info->numsectors; + info->parent = priv->parent->name; + + ret = OK; + } + } + break; + Review comment: > I really hope that you have a better proposal than the string parsing approach via `procfs`. I would prefer in this order: A 100% Linux compatible solution, string parsing via procfs. I personally will not merge a non-standard, redundant solution. But others may. ########## File path: drivers/mtd/mtd_partition.c ########## @@ -413,6 +413,25 @@ static int part_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg) } break; + case MTDIOC_PARTINFO: + { + FAR struct partition_info_s *info = + (FAR struct partition_info_s *)arg; + if (info != NULL) + { + info->magic = 0; + info->numsectors = priv->neraseblocks * priv->blkpererase; + info->length = info->numsectors * priv->blocksize; + info->sectorsize = priv->blocksize; + info->startsector = priv->firstblock; + info->endsector = priv->firstblock + info->numsectors; + info->parent = priv->parent->name; + + ret = OK; + } + } + break; + Review comment: > I really hope that you have a better proposal than the string parsing approach via `procfs`. I would prefer in this order: A 100% Linux compatible solution, string parsing via procfs. I personally will not merge a non-standard, incompatible, redundant solution. But others may. ########## File path: drivers/mtd/mtd_partition.c ########## @@ -413,6 +413,25 @@ static int part_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg) } break; + case MTDIOC_PARTINFO: + { + FAR struct partition_info_s *info = + (FAR struct partition_info_s *)arg; + if (info != NULL) + { + info->magic = 0; + info->numsectors = priv->neraseblocks * priv->blkpererase; + info->length = info->numsectors * priv->blocksize; + info->sectorsize = priv->blocksize; + info->startsector = priv->firstblock; + info->endsector = priv->firstblock + info->numsectors; + info->parent = priv->parent->name; + + ret = OK; + } + } + break; + Review comment: > I really hope that you have a better proposal than the string parsing approach via `procfs`. I would prefer in this order: A 100% Linux compatible solution, string parsing via procfs. I personally will not merge a non-standard, incompatible, redundant solution. But others may. I am going to get out of the loop on this one. So I will not be commenting further. ########## File path: drivers/mtd/mtd_partition.c ########## @@ -413,6 +413,25 @@ static int part_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg) } break; + case MTDIOC_PARTINFO: + { + FAR struct partition_info_s *info = + (FAR struct partition_info_s *)arg; + if (info != NULL) + { + info->magic = 0; + info->numsectors = priv->neraseblocks * priv->blkpererase; + info->length = info->numsectors * priv->blocksize; + info->sectorsize = priv->blocksize; + info->startsector = priv->firstblock; + info->endsector = priv->firstblock + info->numsectors; + info->parent = priv->parent->name; + + ret = OK; + } + } + break; + Review comment: > I really hope that you have a better proposal than the string parsing approach via `procfs`. I would prefer in this order: A 100% Linux compatible solution, string parsing via procfs. I personally will not merge a non-standard, incompatible, redundant user solution. But others may. I am going to get out of the loop on this one. So I will not be commenting further. ########## File path: drivers/mtd/mtd_partition.c ########## @@ -413,6 +413,25 @@ static int part_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg) } break; + case MTDIOC_PARTINFO: + { + FAR struct partition_info_s *info = + (FAR struct partition_info_s *)arg; + if (info != NULL) + { + info->magic = 0; + info->numsectors = priv->neraseblocks * priv->blkpererase; + info->length = info->numsectors * priv->blocksize; + info->sectorsize = priv->blocksize; + info->startsector = priv->firstblock; + info->endsector = priv->firstblock + info->numsectors; + info->parent = priv->parent->name; + + ret = OK; + } + } + break; + Review comment: > I really hope that you have a better proposal than the string parsing approach via `procfs`. I would prefer in this order: A 100% Linux compatible solution then string parsing via the existing procfs. I personally will not merge a non-standard, incompatible, redundant user solution. But others may. I am going to get out of the loop on this one. So I will not be commenting further. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org