xiaoxiang781216 commented on code in PR #13584:
URL: https://github.com/apache/nuttx/pull/13584#discussion_r1777270663


##########
fs/smartfs/smartfs_smart.c:
##########
@@ -210,13 +212,20 @@ static int smartfs_open(FAR struct file *filep, FAR const 
char *relpath,
 
   /* Locate the directory entry for this path */
 
-  sf = kmm_malloc(sizeof *sf);
+  pathlen = strlen(relpath) + 1;
+  sf = kmm_malloc(sizeof(*sf) + pathlen);

Review Comment:
   ```suggestion
     sf = kmm_malloc(sizeof(*sf) + pathlen - 1);
   ```



##########
fs/smartfs/smartfs_smart.c:
##########
@@ -210,13 +212,20 @@ static int smartfs_open(FAR struct file *filep, FAR const 
char *relpath,
 
   /* Locate the directory entry for this path */
 
-  sf = kmm_malloc(sizeof *sf);
+  pathlen = strlen(relpath) + 1;
+  sf = kmm_malloc(sizeof(*sf) + pathlen);
   if (sf == NULL)
     {
       ret = -ENOMEM;
       goto errout_with_lock;
     }
 
+  /* Save the full path to smartfs_ofile_s stuctrue. This is needed
+   * to FIOC_FILEPATH ioctlc all support.
+   */
+
+  strlcpy(sf->path, relpath, pathlen);

Review Comment:
   memcpy



##########
fs/smartfs/smartfs_smart.c:
##########
@@ -997,9 +1006,45 @@ static off_t smartfs_seek(FAR struct file *filep, off_t 
offset, int whence)
 
 static int smartfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
 {
-  /* We don't use any ioctls */
+  FAR struct smartfs_ofile_s *priv;
+  FAR struct inode *inode;
+  int ret;
+
+  /* Recover our private data from the struct file instance */
+
+  priv  = filep->f_priv;
+  inode = filep->f_inode;
+  ret = nxmutex_lock(&g_lock);

Review Comment:
   don't need lock



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to