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