diff --git a/zfs-win/BlockReader.cpp b/zfs-win/BlockReader.cpp index 0dd462a..69d2423 100644 --- a/zfs-win/BlockReader.cpp +++ b/zfs-win/BlockReader.cpp @@ -174,7 +174,7 @@ namespace ZFS } else { - // FIXME: there may empty pointers in the middle of other valid pointers (???) + // FIXME: there may be empty pointers in the middle of other valid pointers (???) buff.resize(m_indblksize); diff --git a/zfs-win/Compress.h b/zfs-win/Compress.h index 579d9f2..bc30b5d 100644 --- a/zfs-win/Compress.h +++ b/zfs-win/Compress.h @@ -31,5 +31,3 @@ extern size_t gzip_compress(void* s_start, void* d_start, size_t s_len, size_t d extern int gzip_decompress(void* s_start, void* d_start, size_t s_len, size_t d_len); extern size_t zle_compress(void* s_start, void* d_start, size_t s_len, size_t d_len, int n); extern int zle_decompress(void* s_start, void* d_start, size_t s_len, size_t d_len, int n); - -// TODO: gzip, zle diff --git a/zfs-win/DataSet.cpp b/zfs-win/DataSet.cpp index 8218702..74330a6 100644 --- a/zfs-win/DataSet.cpp +++ b/zfs-win/DataSet.cpp @@ -131,6 +131,8 @@ namespace ZFS m_head = NULL; } + + m_cache.clear(); } void DataSet::SetDefaults(DataSet* parent) @@ -238,9 +240,20 @@ namespace ZFS return false; } - if(!m_head->Read("ROOT", &dn, DMU_OT_DIRECTORY_CONTENTS)) + auto it = m_cache.find(L""); + + if(it != m_cache.end()) { - return false; + dn = it->second; + } + else + { + if(!m_head->Read("ROOT", &dn, DMU_OT_DIRECTORY_CONTENTS)) + { + return false; + } + + m_cache[L""] = dn; } if(s == L"/") @@ -263,34 +276,47 @@ namespace ZFS i = j != std::string::npos ? j + 1 : std::string::npos; - ZFS::ZapObject zap(m_pool); + auto it = m_cache.find(s.substr(0, j)); - if(!zap.Init(&dn)) + if(it != m_cache.end()) { - return false; + dn = it->second; } - - std::string name = Util::UTF16To8(dir.c_str()); - - uint64_t index = 0; - - if(!zap.Lookup(name.c_str(), index)) + else { - return false; - } + ZFS::ZapObject zap(m_pool); - if(!m_head->Read((size_t)ZFS_DIRENT_OBJ(index), &dn)) - { - return false; - } + if(!zap.Init(&dn)) + { + return false; + } - if(dn.type != DMU_OT_DIRECTORY_CONTENTS && dn.type != DMU_OT_PLAIN_FILE_CONTENTS) - { - return false; + std::string name = Util::UTF16To8(dir.c_str()); + + uint64_t index = 0; + + if(!zap.Lookup(name.c_str(), index)) + { + return false; + } + + if(!m_head->Read((size_t)ZFS_DIRENT_OBJ(index), &dn)) + { + return false; + } + + if(dn.type != DMU_OT_DIRECTORY_CONTENTS && dn.type != DMU_OT_PLAIN_FILE_CONTENTS) + { + return false; + } + + m_cache[s.substr(0, j)] = dn; } } while(i != std::string::npos); + if(m_cache.size() > 100) m_cache.clear(); // FIXME: keep mru + return true; } } \ No newline at end of file diff --git a/zfs-win/DataSet.h b/zfs-win/DataSet.h index 07ddc66..7198ad0 100644 --- a/zfs-win/DataSet.h +++ b/zfs-win/DataSet.h @@ -29,6 +29,7 @@ namespace ZFS class DataSet { Pool* m_pool; + std::map m_cache; bool Init(ObjectSet& os, const char* name = NULL, size_t root_index = -1); void RemoveAll(); diff --git a/zfs-win/Device.cpp b/zfs-win/Device.cpp index 8953017..f96e691 100644 --- a/zfs-win/Device.cpp +++ b/zfs-win/Device.cpp @@ -59,6 +59,7 @@ namespace ZFS bool VirtualDevice::Read(std::vector& buff, uint64_t size, uint64_t offset) { // TODO: handle chksum errors + // TODO: parallel reads with overlapped i/o buff.resize((size_t)size); diff --git a/zfs-win/Hash.h b/zfs-win/Hash.h index 7b3c45b..c2eb190 100644 --- a/zfs-win/Hash.h +++ b/zfs-win/Hash.h @@ -135,5 +135,3 @@ extern void fletcher_4_byteswap(const void* buf, uint64_t size, cksum_t* zcp); extern void fletcher_4_incremental_native(const void* buf, uint64_t size, cksum_t* zcp); extern void fletcher_4_incremental_byteswap(const void* buf, uint64_t size, cksum_t* zcp); extern void sha256(const void* buf, uint64_t size, cksum_t* zcp); - -// TODO: sha256 \ No newline at end of file diff --git a/zfs-win/main.cpp b/zfs-win/main.cpp index 1bb1cad..5ef2e6e 100644 --- a/zfs-win/main.cpp +++ b/zfs-win/main.cpp @@ -138,11 +138,15 @@ namespace ZFS wprintf(L"%s: %s\n", __FUNCTIONW__, FileName); + std::wstring fn = FileName; + + fn = TrimRight(fn, L"\\"); + dnode_phys_t dn; memset(&dn, 0, sizeof(dn)); - if(!ctx->m_mounted->Find(FileName, dn)) + if(!ctx->m_mounted->Find(fn.c_str(), dn)) { dn.type = 0; } @@ -183,9 +187,13 @@ namespace ZFS wprintf(L"%s: %s\n", __FUNCTIONW__, FileName); + std::wstring fn = FileName; + + fn = TrimRight(fn, L"\\"); + dnode_phys_t dn; - if(!ctx->m_mounted->Find(FileName, dn) || dn.type != DMU_OT_DIRECTORY_CONTENTS) + if(!ctx->m_mounted->Find(fn.c_str(), dn) || dn.type != DMU_OT_DIRECTORY_CONTENTS) { return -ERROR_PATH_NOT_FOUND; } diff --git a/zfs-win/resource.h b/zfs-win/resource.h new file mode 100644 index 0000000..4533838 --- /dev/null +++ b/zfs-win/resource.h @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by zfs-win.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/zfs-win/zfs-win.rc b/zfs-win/zfs-win.rc new file mode 100644 index 0000000..3cb63bc Binary files /dev/null and b/zfs-win/zfs-win.rc differ