From 8beb534340fd0232129aff6553530d1baee8731f Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Mon, 15 Apr 2019 16:30:00 -0700 Subject: [PATCH] dll: fuse: dot_hidden option adds hidden file attribute on dot files --- src/dll/fuse/fuse.c | 5 +++++ src/dll/fuse/fuse_intf.c | 11 ++++++++++- src/dll/fuse/library.h | 4 +++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/dll/fuse/fuse.c b/src/dll/fuse/fuse.c index 437a2f9f..55745328 100644 --- a/src/dll/fuse/fuse.c +++ b/src/dll/fuse/fuse.c @@ -71,6 +71,9 @@ static struct fuse_opt fsp_fuse_core_opts[] = FSP_FUSE_CORE_OPT("rellinks", rellinks, 1), FSP_FUSE_CORE_OPT("norellinks", rellinks, 0), + FSP_FUSE_CORE_OPT("dot_hidden", dot_hidden, 1), + FSP_FUSE_CORE_OPT("nodot_hidden", dot_hidden, 0), + FUSE_OPT_KEY("fstypename=", 'F'), FUSE_OPT_KEY("volname=", 'v'), @@ -244,6 +247,7 @@ static int fsp_fuse_core_opt_proc(void *opt_data0, const char *arg, int key, " -o uid=N set file owner (-1 for mounting user id)\n" " -o gid=N set file group (-1 for mounting user group)\n" " -o rellinks interpret absolute symlinks as volume relative\n" + " -o dot_hidden dot files have the Windows hidden file attrib\n" " -o volname=NAME set volume label\n" " -o VolumePrefix=UNC set UNC prefix (/Server/Share)\n" " --VolumePrefix=UNC set UNC prefix (\\Server\\Share)\n" @@ -425,6 +429,7 @@ FSP_FUSE_API struct fuse *fsp_fuse_new(struct fsp_fuse_env *env, f->set_uid = opt_data.set_uid; f->uid = opt_data.uid; f->set_gid = opt_data.set_gid; f->gid = opt_data.gid; f->rellinks = opt_data.rellinks; + f->dot_hidden = opt_data.dot_hidden; f->ThreadCount = opt_data.ThreadCount; memcpy(&f->ops, ops, opsize); f->data = data; diff --git a/src/dll/fuse/fuse_intf.c b/src/dll/fuse/fuse_intf.c index a88a66e4..3aac551a 100644 --- a/src/dll/fuse/fuse_intf.c +++ b/src/dll/fuse/fuse_intf.c @@ -429,6 +429,15 @@ static NTSTATUS fsp_fuse_intf_GetFileInfoFunnel(FSP_FILE_SYSTEM *FileSystem, } if (StatEx) FileInfo->FileAttributes |= fsp_fuse_intf_MapFlagsToFileAttributes(stbuf.st_flags); + if (f->dot_hidden) + { + const char *basename = PosixPath; + for (const char *p = PosixPath; '\0' != *p; p++) + if ('/' == *p) + basename = p + 1; + if ('.' == basename[0]) + FileInfo->FileAttributes |= FILE_ATTRIBUTE_HIDDEN; + } FileInfo->FileSize = stbuf.st_size; FileInfo->AllocationSize = (FileInfo->FileSize + AllocationUnit - 1) / AllocationUnit * AllocationUnit; @@ -1712,7 +1721,7 @@ int fsp_fuse_intf_AddDirInfo(void *buf, const char *name, UINT32 Uid, Gid, Mode; NTSTATUS Result0; - Result0 = fsp_fuse_intf_GetFileInfoFunnel(dh->FileSystem, 0, 0, stbuf, + Result0 = fsp_fuse_intf_GetFileInfoFunnel(dh->FileSystem, name, 0, stbuf, &Uid, &Gid, &Mode, 0, &DirInfo->FileInfo); if (NT_SUCCESS(Result0)) DirInfo->Padding[0] = 1; /* HACK: remember that the FileInfo is valid */ diff --git a/src/dll/fuse/library.h b/src/dll/fuse/library.h index fb18d15c..dfbb4e7f 100644 --- a/src/dll/fuse/library.h +++ b/src/dll/fuse/library.h @@ -53,6 +53,7 @@ struct fuse int set_uid, uid; int set_gid, gid; int rellinks; + int dot_hidden; unsigned ThreadCount; struct fuse_operations ops; void *data; @@ -140,7 +141,8 @@ struct fsp_fuse_core_opt_data set_uid, uid, set_gid, gid, set_attr_timeout, attr_timeout, - rellinks; + rellinks, + dot_hidden; int set_FileInfoTimeout, set_DirInfoTimeout, set_EaTimeout,