From f97cb7a173134b0dbc8daedf74de08836dc382f3 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 7 Feb 2008 22:15:13 +0000 Subject: [PATCH] Let the FAT namecheck also look for trailing spaces, fixes FS #8560. Only call the dircache rename function if the actual rename was ok. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16241 a1c6a512-1295-4272-9138-f99709370657 --- firmware/common/file.c | 7 ++++--- firmware/drivers/fat.c | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/firmware/common/file.c b/firmware/common/file.c index f0437f9e6..613eba97d 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c @@ -385,9 +385,6 @@ int rename(const char* path, const char* newpath) return - 5; file = &openfiles[fd]; -#ifdef HAVE_DIRCACHE - dircache_rename(path, newpath); -#endif rc = fat_rename(&file->fatfile, &dir->fatdir, nameptr, file->size, file->attr); @@ -404,6 +401,10 @@ int rename(const char* path, const char* newpath) return rc * 10 - 7; } +#ifdef HAVE_DIRCACHE + dircache_rename(path, newpath); +#endif + rc = close(fd); if (rc<0) { errno = EIO; diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index dd0d4d650..9dd27cf72 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c @@ -1202,6 +1202,10 @@ static int fat_checkname(const unsigned char* newname) return -1; newname++; } + /* check trailing space(s) */ + if(*(--newname) == ' ') + return -1; + return 0; } -- 2.11.4.GIT