2
0
mirror of https://github.com/dominicusin/zfs-win synced 2025-08-31 14:25:45 +00:00

missing files and minor changes

This commit is contained in:
gabest11
2010-07-25 17:38:22 +00:00
parent 548f2f8ab6
commit b3a8adf419
9 changed files with 73 additions and 27 deletions

View File

@@ -174,7 +174,7 @@ namespace ZFS
} }
else 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); buff.resize(m_indblksize);

View File

@@ -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 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 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); extern int zle_decompress(void* s_start, void* d_start, size_t s_len, size_t d_len, int n);
// TODO: gzip, zle

View File

@@ -131,6 +131,8 @@ namespace ZFS
m_head = NULL; m_head = NULL;
} }
m_cache.clear();
} }
void DataSet::SetDefaults(DataSet* parent) void DataSet::SetDefaults(DataSet* parent)
@@ -238,9 +240,20 @@ namespace ZFS
return false; 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"/") if(s == L"/")
@@ -263,34 +276,47 @@ namespace ZFS
i = j != std::string::npos ? j + 1 : std::string::npos; 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;
} }
else
std::string name = Util::UTF16To8(dir.c_str());
uint64_t index = 0;
if(!zap.Lookup(name.c_str(), index))
{ {
return false; ZFS::ZapObject zap(m_pool);
}
if(!m_head->Read((size_t)ZFS_DIRENT_OBJ(index), &dn)) if(!zap.Init(&dn))
{ {
return false; return false;
} }
if(dn.type != DMU_OT_DIRECTORY_CONTENTS && dn.type != DMU_OT_PLAIN_FILE_CONTENTS) std::string name = Util::UTF16To8(dir.c_str());
{
return false; 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); while(i != std::string::npos);
if(m_cache.size() > 100) m_cache.clear(); // FIXME: keep mru
return true; return true;
} }
} }

View File

@@ -29,6 +29,7 @@ namespace ZFS
class DataSet class DataSet
{ {
Pool* m_pool; Pool* m_pool;
std::map<std::wstring, dnode_phys_t> m_cache;
bool Init(ObjectSet& os, const char* name = NULL, size_t root_index = -1); bool Init(ObjectSet& os, const char* name = NULL, size_t root_index = -1);
void RemoveAll(); void RemoveAll();

View File

@@ -59,6 +59,7 @@ namespace ZFS
bool VirtualDevice::Read(std::vector<uint8_t>& buff, uint64_t size, uint64_t offset) bool VirtualDevice::Read(std::vector<uint8_t>& buff, uint64_t size, uint64_t offset)
{ {
// TODO: handle chksum errors // TODO: handle chksum errors
// TODO: parallel reads with overlapped i/o
buff.resize((size_t)size); buff.resize((size_t)size);

View File

@@ -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_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 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); extern void sha256(const void* buf, uint64_t size, cksum_t* zcp);
// TODO: sha256

View File

@@ -138,11 +138,15 @@ namespace ZFS
wprintf(L"%s: %s\n", __FUNCTIONW__, FileName); wprintf(L"%s: %s\n", __FUNCTIONW__, FileName);
std::wstring fn = FileName;
fn = TrimRight(fn, L"\\");
dnode_phys_t dn; dnode_phys_t dn;
memset(&dn, 0, sizeof(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; dn.type = 0;
} }
@@ -183,9 +187,13 @@ namespace ZFS
wprintf(L"%s: %s\n", __FUNCTIONW__, FileName); wprintf(L"%s: %s\n", __FUNCTIONW__, FileName);
std::wstring fn = FileName;
fn = TrimRight(fn, L"\\");
dnode_phys_t dn; 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; return -ERROR_PATH_NOT_FOUND;
} }

14
zfs-win/resource.h Normal file
View File

@@ -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

BIN
zfs-win/zfs-win.rc Normal file

Binary file not shown.