michallenc commented on PR #18697:
URL: https://github.com/apache/nuttx/pull/18697#issuecomment-4216077923
> I can check on FreeBSD.. what are test steps? I assume this is about FAT
on the NuttX side? :-)
Yes, it's about FAT on the NuttX side. Testing is pretty simple
1. create a file with short name on FAT on your computer (I used
`config.ini`)
2. rename the file to `config_12345678.ini` on NuttX
3. rename it back to `config.ini` on your computer
4. rename it again to `config_12345678.ini` on NuttX
5. you should see `CONFIG~1.INI` instead of `config_12345678.ini`
I have this simple C code that does the rename on NuttX for you.
```c
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <syslog.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
openlog("sdcard", LOG_PERROR, LOG_USER);
int fd = open("/sdcard/config.ini", O_RDWR | O_CREAT, S_IRUSR |
S_IWUSR);
if (fd < 0) {
syslog(LOG_ERR, "Failed to create SD card %d\n", errno);
return -1;
}
close(fd);
char newpath[64];
uint32_t rnd = argc > 1 ? atol(argv[1]) : 0x12345678;
sprintf(newpath, "%s_%08" PRIx32 ".ini", "/sdcard/config", rnd);
rename("sdcard/config.ini", newpath);
return 0;
}
```
This happens ONLY IF your computer creates the initial `config.ini` as a
long file name entry - which is a case of Linux (at least my Debian 12).
Windows creates it as short file name entry and there it's fine. The main issue
on NuttX is that we expect there is short file name entry only if the name fits
into 8+3 format, which is not if the file is created on Linux.
But I am more concerned whether I break anything on NuttX FAT side -
hopefully not, I tested file creation, rename, delete and it all seems to work
without issues.
--
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]