New CONFIG_FAT_LFN_UTF8: UTF8 strings are converted to UCS2-LFN
Bugfix in fat_createalias: space is now also converted to underbar.
Change (bugfix) in fat_getlfname: init characters (0xff) and '\0' are rewound as well.
* Simplify EINTR/ECANCEL error handling
1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx
* Unify the void cast usage
1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
I see the following behaviour on NuttX 7.26, where I have SD card mounted on /flash and a directory called "frm" on it:
opendir("/flash") returns (DIR *) 0x1000c580
opendir("/flash/") returns (DIR *) 0x1000c5d0
opendir("/flash/frm") returns (DIR *) 0x1000c620
opendir("/flash/frm/") returns (DIR *) 0x0
From POSIX specs for opendir(): "A pathname ... that ends with one or more trailing slashes shall be resolved as if a single dot character ( '.' ) were appended to the pathname."
So for mount points, opendir() works correctly, but for FAT32 filesystem it fails to open directory if the path has a trailing slash. I'm not quite sure how to cleanly fix this. Stripping the trailing slash in opendir() would require allocating a separate buffer, while fixing it in the FAT32 code seems somewhat complex due to the short/long filename logic.
It is not a big issue for me, I'm just going to fix it on the application side. But still a small portability and standards compliance issue.
NOTE: You would not see this problem if you call opendir() indirectly in NSH (like 'ls -R /') because NSH contains logic to remove trailing '/' characters from paths.
Pullreq FAT improvements
* NuttX: Add CONFIG_FAT_LFN_ALIAS_HASH to speed up creating long filenames.
Long filenames on FAT filesystems have associated 8.3 character alias
short filenames. The traditional form of these is FILENA~1.EXT with
a running count of the number of similar names. However creating this
unique count can take several seconds if there are many similarly named
files in the directory. Enabling FAT_LFN_ALIAS_HASH uses an alternative
format of FI0123~1.TXT where the four digits are a hash of the original
filename. This method is similar to what is used by Windows 2000 and
later.
* NuttX: Add CONFIG_FAT_LFN_ALIAS_TRAILCHARS alternative format for 8.3 filenames.
Traditional format for long filename 8.3 aliases takes first 6
characters of long filename. If this option is set to N > 0,
NuttX will instead take first 6-N and last N characters to form
the short name. This is useful for filenames like "datafile12.txt"
where the first characters would always remain the same.
* NuttX: FAT32: Fix file date corruption in fat_truncate().
* NuttX: if SD card wait seems to be a long one, give time for other threads to run.
Approved-by: GregoryN <gnutt@nuttx.org>
Squashed commit of the following:
fs/fat/fs_fat32util.c: Most costmetic naming MBR to FBR in numerous locations. Change some ferr macros to fwarn. Use FBR macros insteac of MBR macros.
Add definitions for the FAT boot record (FBR).
fs/fat: Clean up some name BS_ and MBR_ refer to the same record and should use the same naming (MBR_).
FAT. Effectively handles the situation when a new file position is within the current sector.
* Find begin of the next token
* EOL
* revert
* Accelerates the work of the FS with a multitude of operations to write small pieces of data within the current sector.
Approved-by: Gregory Nutt <gnutt@nuttx.org>
Squashed commit of the following:
fs/fat: Resolves issues with truncating the cluster chain when shrinking files via ftruncate().
fs/fat: First cut at implementation file shrinkage logic needed to support ftruncate(). Certainly shrinks the file size but it does not appear to correctly disconnect the cluster chains.
fs/fat: Restructure some functions in files to better support forthcoming file shrinkage logic. Put framework for file shrinkage in place. That logic is incomplete on initial commit.
fs/nxffs: Add partial implementation of the truncate method: It extend files, but cannot yet shrink them.
fs/smartfs: Add partial implementation of the truncate method: It extend files, but cannot yet shrink them.
fs/fat: Add partial implementation of the truncate method: It extend files, but no yet shrink them.
fs/nfs: Add support for the truncate method to the NFS file system.
fs: Add truncate() support for userfs
fs/unionfs: Add truncate() support to the unionfs
fs/tmpfs: Add ftruncate() support to tmpfs
syscall/: Add system call support for ftruncate()
net/route: Adding ftruncate() support eliminates an issue in file-based routing table management.
fs: Add basic framework to support truncate() and ftruncate(). The infrastructure is complete. Now, however, the actual implementation of ftruncate() will have to be done for each file system.