file_systems & Tracker: Do not assume sizeof(dirent) contains 1 byte for the name.
At present, it does, but that is an oddity we have preserved from BeOS that the next commit is going to remove. (This commit thus wastes 1 byte without the following one.) Most changes are pretty straightforward: only a +1 is needed, and a few removed from sizing calculations. Some filesystems like UDF originally passed back the length with the \0 included, so they have been adjusted further. UFS2 had some other sizing problems which are also corrected in this commit.
This commit is contained in:
@@ -1737,7 +1737,7 @@ bfs_read_dir(fs_volume* _volume, fs_vnode* _node, void* _cookie,
|
||||
while (count < maxCount && bufferSize > sizeof(struct dirent)) {
|
||||
ino_t id;
|
||||
uint16 length;
|
||||
size_t nameBufferSize = bufferSize - sizeof(struct dirent) + 1;
|
||||
size_t nameBufferSize = bufferSize - sizeof(struct dirent);
|
||||
|
||||
status_t status = iterator->GetNextEntry(dirent->d_name, &length,
|
||||
nameBufferSize, &id);
|
||||
@@ -1759,7 +1759,7 @@ bfs_read_dir(fs_volume* _volume, fs_vnode* _node, void* _cookie,
|
||||
|
||||
dirent->d_dev = volume->ID();
|
||||
dirent->d_ino = id;
|
||||
dirent->d_reclen = sizeof(struct dirent) + length;
|
||||
dirent->d_reclen = sizeof(struct dirent) + length + 1;
|
||||
|
||||
bufferSize -= dirent->d_reclen;
|
||||
dirent = (struct dirent*)((uint8*)dirent + dirent->d_reclen);
|
||||
@@ -1867,7 +1867,7 @@ bfs_read_attr_dir(fs_volume* _volume, fs_vnode* node, void* _cookie,
|
||||
Volume* volume = (Volume*)_volume->private_volume;
|
||||
|
||||
dirent->d_dev = volume->ID();
|
||||
dirent->d_reclen = sizeof(struct dirent) + length;
|
||||
dirent->d_reclen = sizeof(struct dirent) + length + 1;
|
||||
|
||||
*_num = 1;
|
||||
return B_OK;
|
||||
|
||||
Reference in New Issue
Block a user