Squashed a few minor TODOs.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20205 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2007-02-23 02:10:51 +00:00
parent e696418178
commit 36ca5d166c
3 changed files with 24 additions and 17 deletions
@@ -244,7 +244,6 @@ NameIndexEntryIterator::GetCurrent(uint8 *buffer, size_t *keyLength)
Entry *entry = GetCurrent(); Entry *entry = GetCurrent();
if (entry) { if (entry) {
strncpy((char*)buffer, entry->GetName(), kMaxIndexKeyLength); strncpy((char*)buffer, entry->GetName(), kMaxIndexKeyLength);
// TODO: + 1 ?
*keyLength = strlen(entry->GetName()); *keyLength = strlen(entry->GetName());
} }
return entry; return entry;
@@ -67,8 +67,9 @@ IndexWrapper::Type() const
off_t off_t
IndexWrapper::GetSize() const IndexWrapper::GetSize() const
{ {
// TODO: That's not exactly what should be returned. // Compute a fake "index size" based on the number of entries
return (fIndex ? fIndex->CountEntries() + 1 : 0); // (1024 + 16 * entry count), so we don't need to adjust the code using it.
return 1024LL + (fIndex ? fIndex->CountEntries() : 0) * 16LL;
} }
// KeySize // KeySize
@@ -1126,7 +1127,7 @@ Equation::PrepareQuery(Volume */*volume*/, IndexWrapper &index, IndexIterator **
status_t status_t
Equation::GetNextMatching(Volume *volume, IndexIterator *iterator, Equation::GetNextMatching(Volume *volume, IndexIterator *iterator,
struct dirent *dirent, size_t /*bufferSize*/) struct dirent *dirent, size_t bufferSize)
{ {
while (true) { while (true) {
union value indexValue; union value indexValue;
@@ -1195,15 +1196,22 @@ Equation::GetNextMatching(Volume *volume, IndexIterator *iterator,
} }
if (status == MATCH_OK) { if (status == MATCH_OK) {
size_t nameLen = strlen(entry->GetName());
// check, whether the entry fits into the buffer,
// and fill it in
size_t length = (dirent->d_name + nameLen + 1) - (char*)dirent;
if (length > bufferSize)
RETURN_ERROR(B_BUFFER_OVERFLOW);
dirent->d_dev = volume->GetID(); dirent->d_dev = volume->GetID();
dirent->d_ino = entry->GetNode()->GetID(); dirent->d_ino = entry->GetNode()->GetID();
dirent->d_pdev = volume->GetID(); dirent->d_pdev = volume->GetID();
dirent->d_pino = entry->GetParent()->GetID(); dirent->d_pino = entry->GetParent()->GetID();
// TODO: Check the buffer size. memcpy(dirent->d_name, entry->GetName(), nameLen);
strncpy(dirent->d_name, entry->GetName(), B_FILE_NAME_LENGTH); dirent->d_name[nameLen] = '\0';
dirent->d_name[B_FILE_NAME_LENGTH - 1] = '\0'; dirent->d_reclen = length;
dirent->d_reclen = sizeof(struct dirent) + strlen(dirent->d_name);
} }
if (status == MATCH_OK) if (status == MATCH_OK)
@@ -1324,8 +1324,7 @@ PRINT((" entry: `%s'\n", name));
#endif #endif
*count = 1; *count = 1;
} else { } else {
// TODO: Check, if that's the correct behavior. SET_ERROR(error, B_BUFFER_OVERFLOW);
SET_ERROR(error, B_BAD_VALUE);
} }
} else } else
*count = 0; *count = 0;
@@ -1616,8 +1615,7 @@ ramfs_read_attrdir(void *ns, void */*_node*/, void *cookie, long *count,
#endif #endif
*count = 1; *count = 1;
} else { } else {
// TODO: Check, if that's the correct behavior. SET_ERROR(error, B_BUFFER_OVERFLOW);
SET_ERROR(error, B_BAD_VALUE);
} }
} else } else
*count = 0; *count = 0;
@@ -1858,8 +1856,7 @@ ramfs_read_indexdir(void *ns, void *_cookie, long *count,
#endif #endif
*count = 1; *count = 1;
} else { } else {
// TODO: Check, if that's the correct behavior. SET_ERROR(error, B_BUFFER_OVERFLOW);
SET_ERROR(error, B_BAD_VALUE);
} }
} else } else
*count = 0; *count = 0;
@@ -1951,9 +1948,12 @@ ramfs_stat_index(void *ns, const char *name, struct index_info *indexInfo)
// find the index // find the index
if (Index *index = indexDir->FindIndex(name)) { if (Index *index = indexDir->FindIndex(name)) {
indexInfo->type = index->GetType(); indexInfo->type = index->GetType();
indexInfo->size = 0; // TODO if (index->HasFixedKeyLength())
indexInfo->modification_time = 0; // TODO indexInfo->size = index->GetKeyLength();
indexInfo->creation_time = 0; // TODO else
indexInfo->size = kMaxIndexKeyLength;
indexInfo->modification_time = 0; // TODO: index times
indexInfo->creation_time = 0; // ...
indexInfo->uid = 0; // root owns the indices indexInfo->uid = 0; // root owns the indices
indexInfo->gid = 0; // indexInfo->gid = 0; //
} else } else