Skip to content

Commit fad222a

Browse files
committed
libbe_build: Use getdents64
1 parent c600860 commit fad222a

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/build/libroot/fs3.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -608,21 +608,22 @@ _kern_read_dir(int fd, struct dirent* buffer, size_t bufferSize, uint32 maxCount
608608
if (fd < 0)
609609
return B_FILE_ERROR;
610610

611-
struct linux_dirent {
612-
long d_ino;
613-
off_t d_off;
611+
struct linux_dirent64 {
612+
ino64_t d_ino;
613+
off64_t d_off;
614614
unsigned short d_reclen;
615-
char d_name[255];
615+
unsigned char d_type;
616+
char d_name[256];
616617
};
617618

618-
size_t bufSize = sizeof(struct linux_dirent) * maxCount;
619-
struct linux_dirent* direntBuffer = malloc(bufSize);
619+
size_t bufSize = sizeof(struct linux_dirent64) * maxCount;
620+
struct linux_dirent64* direntBuffer = (struct linux_dirent64*)malloc(bufSize);
620621
if (direntBuffer == NULL)
621622
return B_NO_MEMORY;
622623

623624
off_t seekOffset = _kern_seek(fd, 0, SEEK_CUR);
624625

625-
ssize_t ret = syscall(SYS_getdents, fd, direntBuffer, bufSize);
626+
ssize_t ret = syscall(SYS_getdents64, fd, direntBuffer, bufSize);
626627
if (ret < 0) {
627628
free(direntBuffer);
628629
return BKernelPrivate::posixError(errno);
@@ -631,7 +632,7 @@ _kern_read_dir(int fd, struct dirent* buffer, size_t bufferSize, uint32 maxCount
631632
int i = 0;
632633
int pos = 0;
633634
while (pos < ret && i < maxCount) {
634-
struct linux_dirent* dir = (struct linux_dirent *) (direntBuffer + pos);
635+
struct linux_dirent64* dir = (struct linux_dirent64 *) ((char*)direntBuffer + pos);
635636
buffer[i].d_ino = dir->d_ino;
636637
buffer[i].d_off = dir->d_off;
637638
buffer[i].d_reclen = dir->d_reclen;

0 commit comments

Comments
 (0)