mirror of
https://github.com/dominicusin/zfs-win
synced 2025-08-30 22:05:35 +00:00
missing files and minor changes
This commit is contained in:
@@ -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);
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -29,6 +29,7 @@ namespace ZFS
|
||||
class DataSet
|
||||
{
|
||||
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);
|
||||
void RemoveAll();
|
||||
|
@@ -59,6 +59,7 @@ namespace ZFS
|
||||
bool VirtualDevice::Read(std::vector<uint8_t>& buff, uint64_t size, uint64_t offset)
|
||||
{
|
||||
// TODO: handle chksum errors
|
||||
// TODO: parallel reads with overlapped i/o
|
||||
|
||||
buff.resize((size_t)size);
|
||||
|
||||
|
@@ -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
|
@@ -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;
|
||||
}
|
||||
|
14
zfs-win/resource.h
Normal file
14
zfs-win/resource.h
Normal 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
BIN
zfs-win/zfs-win.rc
Normal file
Binary file not shown.
Reference in New Issue
Block a user