gustavonihei commented on a change in pull request #4248:
URL: https://github.com/apache/incubator-nuttx/pull/4248#discussion_r680116455



##########
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:
       > Redundancy like that should not be tolerated in an OS and has never 
been tolerated in the past.
   
   There has always been at least two methods for retrieving information from 
MTD:
   - `ioctl` commands from the `MTDIOC_*`;
   - `procfs`;
   
   Currently neither approach provides the `firstblock` information.
   
   So, consider an application that already owns the path to the MTD character 
device (via BCH and FTL) and already manipulates the MTD partition via file 
descriptors. So this is not one particular use case, it is a fairly common one.
   Linux also provides this information via `ioctl` calls.
   
   `procfs` requires `CONFIG_FS_PROCFS`, which is an optional feature. Adding 
`CONFIG_FS_PROCFS`, even after disabling all `procfs` entries except for the 
**partitions**, this imposes a footprint overhead of 2460 bytes to the binary 
file. There is also the runtime execution overhead of the two-way string 
conversion.
   
   Do you really think it is worth paying the price for this coupling to 
`procfs`?
   




-- 
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


Reply via email to