From b3a8adf419bfef2c062796210996b8986e89bf5e Mon Sep 17 00:00:00 2001 From: gabest11 Date: Sun, 25 Jul 2010 17:38:22 +0000 Subject: [PATCH] missing files and minor changes --- zfs-win/BlockReader.cpp | 2 +- zfs-win/Compress.h | 2 -- zfs-win/DataSet.cpp | 66 ++++++++++++++++++++++++++++------------ zfs-win/DataSet.h | 1 + zfs-win/Device.cpp | 1 + zfs-win/Hash.h | 2 -- zfs-win/main.cpp | 12 ++++++-- zfs-win/resource.h | 14 +++++++++ zfs-win/zfs-win.rc | Bin 0 -> 4600 bytes 9 files changed, 73 insertions(+), 27 deletions(-) create mode 100644 zfs-win/resource.h create mode 100644 zfs-win/zfs-win.rc 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 0000000000000000000000000000000000000000..3cb63bc1bc7a2351da16ec7f652c25dcbaa7f339 GIT binary patch literal 4600 zcmd6rTTdE66vxkVlYWOSzSPumQD53OFGxvIj9hw&i9r!Hv0wnBHvQ~vfBzZA-G#+g zd?A}*cFxSXU*;@-eiy7@k?q@+o!QU^He&Q_46F@oWVhC_YgRkCEecJ|7<2~?~49oWf>B1aY1-ne!xQCSn_5=OL zSVwkfqV-pPt7yH0p0Y<7_&Q_SBmee62e02x@Y42QK8pp3e01DmD@9Tdy%&p(VEI6I zx#l2UWS_{HJ{j1-Pgnf*(fDl&`e3UW-XA4$>B`yZO)96lP}#CQqRHn{gS=^xRXfDf z2~kz!5#3)r(Ok?XG>(Yf6C`R8ldFzv4d?;T7IVeLXMlur6^B=K=hmR#;OsUWJ)ZcN zk!=fTjcAuOyx*nCe7`Fz+UW5a>|KYkTwYB|6FeN|dAS|-HEWcx*1Rg9{cUuwxcZ<~ zGs}wB@c@4WxMqzunR&u*nJjO(oA-dVG~Xl7 zgq_?8aA8KAsFJ0CzGDXrJ^`C{U{ZYOa~W7Lt))80fzJ)0Ap zSc)cH%pq1w%MkDTN|`S`Uk$}%}57`vN9cgh|zUZYnP&-d_uIvca8g{(+Z zl_o{|;50hrH%%$V$*N6ZH_UDPsLn<<$RW2npc{AdJrH*tR_DNVYvk}@$4*&~&?=i} zHr1f{uEUM{R-Xld`XyAy@c!sB`V2{Q_vEqMfak*5E>B-82@9Mn*iY;@viEj}W&5lb zktv;#L6#DHi;v?ubmd)j?L%hu_0u*?%be%rJ>xkXYMfVxa_zizV-GIEF6de174Iqe zF}u6SDs0&`qpY;hxSzU4j|7w+tmzV2$2q(qCEq))**z!A^mE+2$A@dg( z2VGWo#Km)Ln&z{3OvE>P$b?x)I+xqnZ1`xwMQTGjgPTxO-#WrC`hHC2m@2ie9Ey?> zorkKTubN)oSlaka`}1$=mvzj`bzdi?k=DuK@3p7CgJwIFB)#Q&mu8YE%rE^SR>%1C e7jdxVa@ip%jU=2O=Y6V*{7$IW- literal 0 HcmV?d00001