mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 16:33:02 -05:00
tst: passthrough-fuse: BSD flags support
This commit is contained in:
parent
895bf67691
commit
fd662ee848
@ -212,6 +212,10 @@ static void *ptfs_init(struct fuse_conn_info *conn)
|
|||||||
conn->want |= (conn->capable & FSP_FUSE_CAP_READDIR_PLUS);
|
conn->want |= (conn->capable & FSP_FUSE_CAP_READDIR_PLUS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSP_FUSE_USE_STAT_EX) && defined(FSP_FUSE_CAP_STAT_EX)
|
||||||
|
conn->want |= (conn->capable & FSP_FUSE_CAP_STAT_EX);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(FSP_FUSE_CAP_CASE_INSENSITIVE)
|
#if defined(FSP_FUSE_CAP_CASE_INSENSITIVE)
|
||||||
conn->want |= (conn->capable & FSP_FUSE_CAP_CASE_INSENSITIVE);
|
conn->want |= (conn->capable & FSP_FUSE_CAP_CASE_INSENSITIVE);
|
||||||
#endif
|
#endif
|
||||||
@ -242,43 +246,42 @@ static int ptfs_fgetattr(const char *path, struct fuse_stat *stbuf, struct fuse_
|
|||||||
return -1 != fstat(fd, stbuf) ? 0 : -errno;
|
return -1 != fstat(fd, stbuf) ? 0 : -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(FSP_FUSE_USE_STAT_EX)
|
||||||
|
static int ptfs_chflags(const char *path, uint32_t flags)
|
||||||
|
{
|
||||||
|
ptfs_impl_fullpath(path);
|
||||||
|
|
||||||
|
return -1 != lchflags(path, flags) ? 0 : -errno;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static struct fuse_operations ptfs_ops =
|
static struct fuse_operations ptfs_ops =
|
||||||
{
|
{
|
||||||
ptfs_getattr,
|
.getattr = ptfs_getattr,
|
||||||
0, //getdir
|
.mkdir = ptfs_mkdir,
|
||||||
0, //readlink
|
.unlink = ptfs_unlink,
|
||||||
0, //mknod
|
.rmdir = ptfs_rmdir,
|
||||||
ptfs_mkdir,
|
.rename = ptfs_rename,
|
||||||
ptfs_unlink,
|
.chmod = ptfs_chmod,
|
||||||
ptfs_rmdir,
|
.chown = ptfs_chown,
|
||||||
0, //symlink
|
.truncate = ptfs_truncate,
|
||||||
ptfs_rename,
|
.utime = ptfs_utime,
|
||||||
0, //link
|
.open = ptfs_open,
|
||||||
ptfs_chmod,
|
.read = ptfs_read,
|
||||||
ptfs_chown,
|
.write = ptfs_write,
|
||||||
ptfs_truncate,
|
.statfs = ptfs_statfs,
|
||||||
ptfs_utime,
|
.release = ptfs_release,
|
||||||
ptfs_open,
|
.fsync = ptfs_fsync,
|
||||||
ptfs_read,
|
.opendir = ptfs_opendir,
|
||||||
ptfs_write,
|
.readdir = ptfs_readdir,
|
||||||
ptfs_statfs,
|
.releasedir = ptfs_releasedir,
|
||||||
0, //flush
|
.init = ptfs_init,
|
||||||
ptfs_release,
|
.create = ptfs_create,
|
||||||
ptfs_fsync,
|
.ftruncate = ptfs_ftruncate,
|
||||||
0, //setxattr
|
.fgetattr = ptfs_fgetattr,
|
||||||
0, //getxattr
|
#if defined(FSP_FUSE_USE_STAT_EX)
|
||||||
0, //listxattr
|
.chflags = ptfs_chflags,
|
||||||
0, //removexattr
|
#endif
|
||||||
ptfs_opendir,
|
|
||||||
ptfs_readdir,
|
|
||||||
ptfs_releasedir,
|
|
||||||
0, //fsyncdir
|
|
||||||
ptfs_init,
|
|
||||||
0, //destroy
|
|
||||||
0, //access
|
|
||||||
ptfs_create,
|
|
||||||
ptfs_ftruncate,
|
|
||||||
ptfs_fgetattr,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void usage(void)
|
static void usage(void)
|
||||||
|
@ -99,7 +99,7 @@
|
|||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>FSP_FUSE_USE_STAT_EX;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\WinFsp\inc\fuse;$(MSBuildProgramFiles32)\WinFsp\inc</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\WinFsp\inc\fuse;$(MSBuildProgramFiles32)\WinFsp\inc</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
@ -118,7 +118,7 @@
|
|||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>FSP_FUSE_USE_STAT_EX;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\WinFsp\inc\fuse;$(MSBuildProgramFiles32)\WinFsp\inc</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\WinFsp\inc\fuse;$(MSBuildProgramFiles32)\WinFsp\inc</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
@ -139,7 +139,7 @@
|
|||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>FSP_FUSE_USE_STAT_EX;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\WinFsp\inc\fuse;$(MSBuildProgramFiles32)\WinFsp\inc</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\WinFsp\inc\fuse;$(MSBuildProgramFiles32)\WinFsp\inc</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
@ -162,7 +162,7 @@
|
|||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>FSP_FUSE_USE_STAT_EX;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\WinFsp\inc\fuse;$(MSBuildProgramFiles32)\WinFsp\inc</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\WinFsp\inc\fuse;$(MSBuildProgramFiles32)\WinFsp\inc</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @file passthrough-fuse.c
|
* @file winposix.c
|
||||||
*
|
*
|
||||||
* @copyright 2015-2017 Bill Zissimopoulos
|
* @copyright 2015-2017 Bill Zissimopoulos
|
||||||
*/
|
*/
|
||||||
@ -36,6 +36,40 @@ struct _DIR
|
|||||||
char path[];
|
char path[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(FSP_FUSE_USE_STAT_EX)
|
||||||
|
static inline uint32_t MapFileAttributesToFlags(UINT32 FileAttributes)
|
||||||
|
{
|
||||||
|
uint32_t flags = 0;
|
||||||
|
|
||||||
|
if (FileAttributes & FILE_ATTRIBUTE_READONLY)
|
||||||
|
flags |= FSP_FUSE_UF_READONLY;
|
||||||
|
if (FileAttributes & FILE_ATTRIBUTE_HIDDEN)
|
||||||
|
flags |= FSP_FUSE_UF_HIDDEN;
|
||||||
|
if (FileAttributes & FILE_ATTRIBUTE_SYSTEM)
|
||||||
|
flags |= FSP_FUSE_UF_SYSTEM;
|
||||||
|
if (FileAttributes & FILE_ATTRIBUTE_ARCHIVE)
|
||||||
|
flags |= FSP_FUSE_UF_ARCHIVE;
|
||||||
|
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline UINT32 MapFlagsToFileAttributes(uint32_t flags)
|
||||||
|
{
|
||||||
|
UINT32 FileAttributes = 0;
|
||||||
|
|
||||||
|
if (flags & FSP_FUSE_UF_READONLY)
|
||||||
|
FileAttributes |= FILE_ATTRIBUTE_READONLY;
|
||||||
|
if (flags & FSP_FUSE_UF_HIDDEN)
|
||||||
|
FileAttributes |= FILE_ATTRIBUTE_HIDDEN;
|
||||||
|
if (flags & FSP_FUSE_UF_SYSTEM)
|
||||||
|
FileAttributes |= FILE_ATTRIBUTE_SYSTEM;
|
||||||
|
if (flags & FSP_FUSE_UF_ARCHIVE)
|
||||||
|
FileAttributes |= FILE_ATTRIBUTE_ARCHIVE;
|
||||||
|
|
||||||
|
return FileAttributes;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int maperror(int winerrno);
|
static int maperror(int winerrno);
|
||||||
|
|
||||||
static inline void *error0(void)
|
static inline void *error0(void)
|
||||||
@ -173,6 +207,9 @@ int fstat(int fd, struct fuse_stat *stbuf)
|
|||||||
stbuf->st_ctim.tv_nsec = LastWriteTime % 10000000 * 100;
|
stbuf->st_ctim.tv_nsec = LastWriteTime % 10000000 * 100;
|
||||||
stbuf->st_birthtim.tv_sec = CreationTime / 10000000;
|
stbuf->st_birthtim.tv_sec = CreationTime / 10000000;
|
||||||
stbuf->st_birthtim.tv_nsec = CreationTime % 10000000 * 100;
|
stbuf->st_birthtim.tv_nsec = CreationTime % 10000000 * 100;
|
||||||
|
#if defined(FSP_FUSE_USE_STAT_EX)
|
||||||
|
stbuf->st_flags = MapFileAttributesToFlags(FileInfo.dwFileAttributes);
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -272,6 +309,21 @@ int lchown(const char *path, fuse_uid_t uid, fuse_gid_t gid)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int lchflags(const char *path, uint32_t flags)
|
||||||
|
{
|
||||||
|
#if defined(FSP_FUSE_USE_STAT_EX)
|
||||||
|
UINT32 FileAttributes = MapFlagsToFileAttributes(flags);
|
||||||
|
|
||||||
|
if (0 == FileAttributes)
|
||||||
|
FileAttributes = FILE_ATTRIBUTE_NORMAL;
|
||||||
|
|
||||||
|
if (!SetFileAttributesA(path, FileAttributes))
|
||||||
|
return error();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int truncate(const char *path, fuse_off_t size)
|
int truncate(const char *path, fuse_off_t size)
|
||||||
{
|
{
|
||||||
HANDLE h = CreateFileA(path,
|
HANDLE h = CreateFileA(path,
|
||||||
@ -424,6 +476,9 @@ struct dirent *readdir(DIR *dirp)
|
|||||||
stbuf->st_ctim.tv_nsec = LastWriteTime % 10000000 * 100;
|
stbuf->st_ctim.tv_nsec = LastWriteTime % 10000000 * 100;
|
||||||
stbuf->st_birthtim.tv_sec = CreationTime / 10000000;
|
stbuf->st_birthtim.tv_sec = CreationTime / 10000000;
|
||||||
stbuf->st_birthtim.tv_nsec = CreationTime % 10000000 * 100;
|
stbuf->st_birthtim.tv_nsec = CreationTime % 10000000 * 100;
|
||||||
|
#if defined(FSP_FUSE_USE_STAT_EX)
|
||||||
|
stbuf->st_flags = MapFileAttributesToFlags(FindData.dwFileAttributes);
|
||||||
|
#endif
|
||||||
|
|
||||||
strcpy(dirp->de.d_name, FindData.cFileName);
|
strcpy(dirp->de.d_name, FindData.cFileName);
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ int close(int fd);
|
|||||||
int lstat(const char *path, struct fuse_stat *stbuf);
|
int lstat(const char *path, struct fuse_stat *stbuf);
|
||||||
int chmod(const char *path, fuse_mode_t mode);
|
int chmod(const char *path, fuse_mode_t mode);
|
||||||
int lchown(const char *path, fuse_uid_t uid, fuse_gid_t gid);
|
int lchown(const char *path, fuse_uid_t uid, fuse_gid_t gid);
|
||||||
|
int lchflags(const char *path, uint32_t flags);
|
||||||
int truncate(const char *path, fuse_off_t size);
|
int truncate(const char *path, fuse_off_t size);
|
||||||
int utime(const char *path, const struct fuse_utimbuf *timbuf);
|
int utime(const char *path, const struct fuse_utimbuf *timbuf);
|
||||||
int unlink(const char *path);
|
int unlink(const char *path);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user