From 634081197460dd2051dcf156d02caf051273d02e Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Wed, 21 Oct 2020 15:45:07 -0700 Subject: [PATCH] dll: fuse: fsp_fuse_notify: handle case-insensitive file systems --- inc/winfsp/winfsp.h | 12 ++++++++++++ src/dll/fuse/fuse.c | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/inc/winfsp/winfsp.h b/inc/winfsp/winfsp.h index deb94fb3..06f77227 100644 --- a/inc/winfsp/winfsp.h +++ b/inc/winfsp/winfsp.h @@ -1229,6 +1229,18 @@ FSP_API NTSTATUS FspFileSystemNotifyEnd(FSP_FILE_SYSTEM *FileSystem); * first issue an FspFileSystemBegin call, followed by 0 or more * FspFileSystemNotify calls, followed by an FspFileSystemNotifyEnd call. * + * Note that FspFileSystemNotify requires file names to be normalized. A + * normalized file name is one that contains the correct case of all characters + * in the file name. + * + * For case-sensitive file systems all file names are normalized by definition. + * For case-insensitive file systems that implement file name normalization, + * a normalized file name is the one that the file system specifies in the + * response to Create or Open (see also FspFileSystemGetOpenFileInfo). For + * case-insensitive file systems that do not implement file name normalization + * a normalized file name is the upper case version of the file name used + * to open the file. + * * @param FileSystem * The file system object. * @param NotifyInfo diff --git a/src/dll/fuse/fuse.c b/src/dll/fuse/fuse.c index dca5c8c2..e54f3e01 100644 --- a/src/dll/fuse/fuse.c +++ b/src/dll/fuse/fuse.c @@ -642,6 +642,18 @@ FSP_FUSE_API int fsp_fuse_notify(struct fsp_fuse_env *env, NotifyInfo.V.Action = 0; memcpy(NotifyInfo.V.FileNameBuf, Path, NotifyInfo.V.Size - sizeof(FSP_FSCTL_NOTIFY_INFO)); + if (!f->VolumeParams.CaseSensitiveSearch) + { + /* + * Case-insensitive FUSE file systems do not normalize open file names, which means + * that the FSD automatically normalizes file names internally by uppercasing them. + * + * The FspFileSystemNotify API requires normalized names, so upper case the file name + * here in the case of case-insensitive file systems. + */ + CharUpperBuffW(NotifyInfo.V.FileNameBuf, PathLength); + } + if (action & FSP_FUSE_NOTIFY_MKDIR) { NotifyInfo.V.Filter = FILE_NOTIFY_CHANGE_DIR_NAME;