Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Mar 2022 17:50:44 GMT
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 099fa2feb36f - main - linux(4): Fixup miscalculation of d_off of struct dirent in getdents() syscalls.
Message-ID:  <202203311750.22VHoinC038802@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=099fa2feb36fe6a68a87dfdb0f290b882139a88d

commit 099fa2feb36fe6a68a87dfdb0f290b882139a88d
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2022-03-31 17:50:09 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2022-03-31 17:50:09 +0000

    linux(4): Fixup miscalculation of d_off of struct dirent in getdents() syscalls.
    
    Avoid calculating d_off value as it is specific to the underlying filesystem
    and can be used by others API, like lseek(), seekdir() as input offset.
    
    Differential revision:  https://reviews.freebsd.org/D31551
    MFC after:              2 weeks
---
 sys/compat/linux/linux_file.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c
index 285faaf8927b..6a1402c09456 100644
--- a/sys/compat/linux/linux_file.c
+++ b/sys/compat/linux/linux_file.c
@@ -497,7 +497,7 @@ linux_getdents(struct thread *td, struct linux_getdents_args *args)
 
 		linux_dirent = (struct l_dirent*)lbuf;
 		linux_dirent->d_ino = bdp->d_fileno;
-		linux_dirent->d_off = base + reclen;
+		linux_dirent->d_off = bdp->d_off;
 		linux_dirent->d_reclen = linuxreclen;
 		/*
 		 * Copy d_type to last byte of l_dirent buffer
@@ -574,7 +574,7 @@ linux_getdents64(struct thread *td, struct linux_getdents64_args *args)
 
 		linux_dirent64 = (struct l_dirent64*)lbuf;
 		linux_dirent64->d_ino = bdp->d_fileno;
-		linux_dirent64->d_off = base + reclen;
+		linux_dirent64->d_off = bdp->d_off;
 		linux_dirent64->d_reclen = linuxreclen;
 		linux_dirent64->d_type = bdp->d_type;
 		strlcpy(linux_dirent64->d_name, bdp->d_name,
@@ -631,7 +631,7 @@ linux_readdir(struct thread *td, struct linux_readdir_args *args)
 
 	linux_dirent = (struct l_dirent*)lbuf;
 	linux_dirent->d_ino = bdp->d_fileno;
-	linux_dirent->d_off = linuxreclen;
+	linux_dirent->d_off = bdp->d_off;
 	linux_dirent->d_reclen = bdp->d_namlen;
 	strlcpy(linux_dirent->d_name, bdp->d_name,
 	    linuxreclen - offsetof(struct l_dirent, d_name));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202203311750.22VHoinC038802>