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


##########
fs/fat/fs_fat32dirent.c:
##########
@@ -1121,17 +1138,35 @@ static int fat_path2dirname(FAR const char **path,
   /* Assume no long file name */
 
   dirinfo->fd_lfname[0] = '\0';
+  dirinfo->fd_name[0] = '\0';
 
-  /* Then parse the (assumed) 8+3 short file name */
+  /* Parse long file name */
 
-  ret = fat_parsesfname(path, dirinfo, terminator);
+  ret = fat_parselfname(path, dirinfo, terminator);
   if (ret < 0)
     {
-      /* No, the name is not a valid short 8+3 file name. Try parsing
-       * the long file name.
+      return ret;
+    }
+  else
+    {
+      /* Does the long file name fit into short file name? This means
+       * this is actually a short file name.
+       *
+       * There are following possibilities:
+       *   - file was created on Linux and is written as long file name
+       *   - file was created on Windows and is written as short file name
+       *   - we are creating file on NuttX -> write it as short file name
        */
 
-      ret = fat_parselfname(path, dirinfo, terminator);
+      if (strlen((FAR const char *)dirinfo->fd_lfname) <= DIR_MAXFNAME)
+        {
+          /* Get short file name for given path */
+
+          char *name = kmm_zalloc(DIR_MAXFNAME);

Review Comment:
   why not pass fd_lfname directly



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