Use source file status

This commit is contained in:
Les De Ridder 2016-10-24 02:27:58 +02:00
parent 5243d77d37
commit 24b869d0f6
No known key found for this signature in database
GPG Key ID: 5EC132DFA85DB372
1 changed files with 11 additions and 16 deletions

View File

@ -20,18 +20,16 @@ class FileSystem : Operations
private string _source;
private TagProvider[] _tagProviders;
private uid_t _uid;
private gid_t _gid;
private string[][string] _tagCache;
private stat_t _sourceStat;
this(string source, TagProvider[] tagProviders)
{
_source = source;
_tagProviders = tagProviders;
_uid = getuid();
_gid = getgid();
lstat(toStringz(source), &_sourceStat);
cacheTags();
}
@ -55,25 +53,22 @@ class FileSystem : Operations
override void getattr(const(char)[] path, ref stat_t stat)
{
stat.st_uid = _uid;
stat.st_gid = _gid;
stat.st_uid = _sourceStat.st_uid;
stat.st_gid = _sourceStat.st_gid;
if(path == "/" || isTag(path.baseName))
{
stat.st_mode = S_IFDIR | octal!555;
stat.st_size = 0;
return;
stat.st_mode = _sourceStat.st_mode;
}
else if(isFile(path.baseName))
{
auto file = findFile(path.baseName);
lstat(toStringz(file), &stat);
stat.st_mode = S_IFREG | octal!444;
return;
}
throw new FuseException(errno.ENOENT);
else
{
throw new FuseException(errno.ENOENT);
}
}
bool isTag(const(char)[] name)
@ -157,7 +152,7 @@ class FileSystem : Operations
override ulong read(const(char)[] path, ubyte[] buf, ulong offset)
{
auto realPath = findFile(path.baseName);
if(realPath == null)
if(realPath is null)
{
throw new FuseException(errno.ENOENT);
}