Commit Graph

194 Commits

Author SHA1 Message Date
Xiang Xiao 6a3c2aded6 Fix wait loop and void cast (#24)
* 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
2020-01-02 10:54:43 -06:00
Gregory Nutt d2af57169b tools/nxstyle.c: Fix a rare false alarm that could occur if a variable or function name begins with the sub-string 'union' or 'struct'. misc fixes under fs/ and sched/ from application of current version of nxstyle. 2019-12-01 13:01:16 -06:00
Gregory Nutt bd3cc792ff fs/: Run all .c files under fs/ through tools/nxstyle. 2019-10-27 11:48:14 -06:00
Xiang Xiao 3bc62f1ccc Change space to tab and help to ---help--- in Kconfig files. 2019-10-05 21:39:12 -06:00
Juha Niskanen 5c853cd1dc libs/libc/unistd/lib_getcwd.c: remove stray sched_unlock(). Also fixes several typos. 2019-09-20 06:23:48 -06:00
Gregory Nutt be3dd0bac6 fs/: Fix various coding standard issues found while testing tools/nxstyle.c 2019-03-01 15:01:04 -06:00
Gregory Nutt 15688c4331 Revert "fs/fat/fs_fat32.c: Fixes issue when seeking to end of file where we move one too many clusters ahead due to < vs <= logic. This causes us to move past the last cluster in the file."
This reverts commit 7ffe023766.

This change is reverted because it introduces other problems when seeking around the file.
2019-01-05 16:43:47 -06:00
Anthony Merlino 7ffe023766 fs/fat/fs_fat32.c: Fixes issue when seeking to end of file where we move one too many clusters ahead due to < vs <= logic. This causes us to move past the last cluster in the file. 2019-01-05 14:55:59 -06:00
Gregory Nutt 97b0235d77 s/dirent: Corrects a problem with opendir() noted by Petteri Aimonen in Bitbucket Issue 132: "opendir() fails for FAT filesystem with trailing slash in path":
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.
2018-11-16 11:45:18 -06:00
Gregory Nutt 31485356b8 Updates based on coding style review of PR 755 2018-11-09 07:51:43 -06:00
Petteri Aimonen 96da659c0b Merged in paimonen/nuttx/pullreq_FAT_improvements (pull request #755)
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>
2018-11-09 13:46:16 +00:00
Gregory Nutt d77df925a3 Trivial FATFS cleanup
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_).
2018-07-22 08:42:15 -06:00
Boris Astardzhiev ae6b80f8b6 fs/fat: Avoid caculating the bogus directory entry address for the FAT root directory (since it has no directory entry). This change should have no effect, other than making the logic clearer. 2018-05-24 06:18:15 -06:00
Gregory Nutt b3f20f8c5b fs/fat: In fs_stat(), when stat'ing the root directory, avoid calculating the address of the root directory entry. The calculation is bogus (but not harmful) because the root directory does not have a directory entry. Noted by Boris Astardzhiev. 2018-05-23 08:14:22 -06:00
Gregory Nutt 1567b82429 Make sure that labeling is used consistently in all function headers (part 2). 2018-02-01 12:03:55 -06:00
Gregory Nutt 7cf88d7dbd Make sure that labeling is used consistently in all function headers. 2018-02-01 10:00:02 -06:00
Aleksandr Vyhovanec 8b97ea95c7 Merged in AVyhovanec/nuttx (pull request #564)
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>
2018-01-05 20:52:53 +00:00
Gregory Nutt 49775ea801 fs/fat: Fix a bug in the FAT ftruncate logic. 2018-01-05 11:56:39 -06:00
Gregory Nutt 376e30dab4 net/route: Fix a couple of compile-related issues that have crept in sense the last time the file-based routing table was used. 2018-01-05 08:57:22 -06:00
Gregory Nutt fb73006a4b These changes implemnt FAT file shrinkage as needed to fully support ftruncate().
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.
2018-01-04 19:08:43 -06:00
Gregory Nutt 5d1a91fd8e configs/lpcxpresso-lpc5428/fb: Should disable pixel depths that are not being used. 2018-01-04 16:40:31 -06:00
Gregory Nutt 39fe6a0dff Squashed commit of the following:
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.
2018-01-04 10:54:54 -06:00
Gregory Nutt e4652bd3dc Squashed commit of the following:
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.
2018-01-03 16:03:56 -06:00
Gregory Nutt 91f48701ae arch/arm/src/sam34: Fix some compile warnings that I introduced with a possibly overzealous recent change. 2017-12-17 17:43:20 -06:00
Gregory Nutt 8057af6724 fs/fat: Still trying to eliminate warnings in all configurations. 2017-12-17 17:10:37 -06:00
Gregory Nutt cf8a7bebf6 Eliminate another warning. 2017-12-17 16:47:49 -06:00
Gregory Nutt f96478bb99 fs/fat: Don't warn about the CONFIG_FAT_MAXFNAME being too large if long file name support is not implemented. 2017-12-17 16:41:26 -06:00
Gregory Nutt 9638f3f065 fs/fat: CONFIG_FAT_MAXFNAME may not exceed NAME_MAX (CONFIG_NAME_MAX) 2017-12-15 06:19:14 -06:00
Gregory Nutt 9b31a81b00 Squashed commit of the following:
fs/fat:  Remove mkfatfs from the OS.  This is a user-space application and belongs in apps, not in the OS.
2017-10-20 12:36:25 -06:00
Jussi Kivilinna d02c0c05ae FS FAT: Fix hard-fault when listing contents of FAT root 2017-10-13 07:54:40 -06:00
Gregory Nutt 9568600ab1 Squashed commit of the following:
This commit backs out most of commit b4747286b1.  That change was added because sem_wait() would sometimes cause cancellation points inappropriated.  But with these recent changes, nxsem_wait() is used instead and it is not a cancellation point.

    In the OS, all calls to sem_wait() changed to nxsem_wait().  nxsem_wait() does not return errors via errno so each place where nxsem_wait() is now called must not examine the errno variable.

    In all OS functions (not libraries), change sem_wait() to nxsem_wait().  This will prevent the OS from creating bogus cancellation points and from modifying the per-task errno variable.

    sched/semaphore:  Add the function nxsem_wait().  This is a new internal OS interface.  It is functionally equivalent to sem_wait() except that (1) it is not a cancellation point, and (2) it does not set the per-thread errno value on return.
2017-10-04 15:22:27 -06:00
Gregory Nutt 42a0796615 Squashed commit of the following:
sched/semaphore:  Add nxsem_post() which is identical to sem_post() except that it never modifies the errno variable.  Changed all references to sem_post in the OS to nxsem_post().

    sched/semaphore:  Add nxsem_destroy() which is identical to sem_destroy() except that it never modifies the errno variable.  Changed all references to sem_destroy() in the OS to nxsem_destroy().

    libc/semaphore and sched/semaphore:  Add nxsem_getprotocol() and nxsem_setprotocola which are identical to sem_getprotocol() and set_setprotocol() except that they never modifies the errno variable.  Changed all references to sem_setprotocol in the OS to nxsem_setprotocol().  sem_getprotocol() was not used in the OS
2017-10-03 15:35:24 -06:00
Gregory Nutt 83cdb0c552 Squashed commit of the following:
libc/semaphore:  Add nxsem_getvalue() which is identical to sem_getvalue() except that it never modifies the errno variable.  Changed all references to sem_getvalue in the OS to nxsem_getvalue().

    sched/semaphore:  Rename all internal private functions from sem_xyz to nxsem_xyz.  The sem_ prefix is (will be) reserved only for the application semaphore interfaces.

    libc/semaphore:  Add nxsem_init() which is identical to sem_init() except that it never modifies the errno variable.  Changed all references to sem_init in the OS to nxsem_init().

    sched/semaphore:  Rename sem_tickwait() to nxsem_tickwait() so that it is clear this is an internal OS function.

    sched/semaphoate:  Rename sem_reset() to nxsem_reset() so that it is clear this is an internal OS function.
2017-10-03 12:52:31 -06:00
Masayuki Ishikawa 99bdab3ac3 FAT: Fix 'Missing unlock' in fs_fat32.c
Jira: PDFW15IS-265
Coverity-ID: 10590 10589
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2017-05-22 14:44:24 +09:00
Gregory Nutt 40f8e8b41f Fix some backward DEBUGASSERT tests in ROMFS and FAT. 2017-02-13 14:06:39 -06:00
Gregory Nutt 34f1b333b1 FAT: Fix some errors that I introduced in my review of Alan's patch. My screw-up, not Alan's. Sorry. 2017-02-13 12:43:35 -06:00
Alan Carvalho de Assis a73651c8ca fstat: Add fstat() support to FAT. 2017-02-13 12:21:06 -06:00
Gregory Nutt 7d91fabf01 fstat: Add skeleton implmentations of fstat() in all file systems. 2017-02-12 13:42:27 -06:00
Gregory Nutt bd7d3a92f5 Add logic to VFS rename: If target of rename exists and is a directory, then the source file should be moved 'under' the target directory. POSIX also requires that if the target is a file, then that old file must be deleted. 2017-02-11 11:18:30 -06:00
Gregory Nutt 45fd98da88 Add macros support that will eventually allow dynamic allocation of strings need to support soft links. 2017-02-05 14:25:45 -06:00
Gregory Nutt 8f2c7198ed inode_find: Now takes struct inode_desc_s type as input. This was necessary before that structure includes some data storage. It was used within inode_find(), but that means that the life of the data was the life of inode_find(). That data must persist longer. It is now provided by the caller so that the life of the data persists for the entire life of the caller. 2017-02-05 09:51:42 -06:00
Gregory Nutt 0c9935f8ac FS: Remove inode_find_nofollow. Instead provide a bool nofollow argument to inode_find. 2017-02-04 11:46:54 -06:00
Gregory Nutt 610afe9cd9 FAT performance improvement. In large files, seeking to a position fromt he beginning of the file can be very time consuming. ftell does lssek(fd, 0, SET_CURR). In that case, that is wasted time since we are going to seek to the same position. This fix short-circutes fat_seek() in all cases where we attempt to seek to curren position. Suggested by Nate Weibley 2016-08-03 13:32:52 -06:00
Gregory Nutt ad2f7b0119 fs/: Change some *err() message to *info() messages if what was a *dbg() message does not indicate and error condition. 2016-06-11 17:14:02 -06:00
Gregory Nutt a1469a3e95 Add CONFIG_DEBUG_ERROR. Change names of *dbg() * *err() 2016-06-11 15:50:49 -06:00
Gregory Nutt 1cdc746726 Rename CONFIG_DEBUG to CONFIG_DEBUG_FEATURES 2016-06-11 14:14:08 -06:00
Gregory Nutt fc3540cffe Replace all occurrences of vdbg with vinfo 2016-06-11 11:59:51 -06:00
Gregory Nutt 9008308b64 Remove some block comments before empty code sections 2016-04-11 18:16:04 -06:00
Gregory Nutt b6f5ffa9a8 CDC/AC: too man right parentheses if IFLOW_CONTROL enabled 2016-02-24 11:54:02 -06:00
Gregory Nutt 0682671ffe Update Kconfig help comments 2016-02-23 06:38:51 -06:00