]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
tools/nolibc/dirent: avoid errno in readdir_r
authorBenjamin Berg <benjamin.berg@intel.com>
Wed, 24 Sep 2025 14:20:51 +0000 (16:20 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 13:02:43 +0000 (14:02 +0100)
[ Upstream commit 4ada5679f18dbbe92d87c37a842c3368e6ab5e4a ]

Using errno is not possible when NOLIBC_IGNORE_ERRNO is set. Use
sys_lseek instead of lseek as that avoids using errno.

Fixes: 665fa8dea90d ("tools/nolibc: add support for directory access")
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/include/nolibc/dirent.h

index 758b95c48e7a4c9779625160f1a60a5641513ddf..61a122a60327d20d54885d32b2640c09b3a355f7 100644 (file)
@@ -86,9 +86,9 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
         * readdir() can only return one entry at a time.
         * Make sure the non-returned ones are not skipped.
         */
-       ret = lseek(fd, ldir->d_off, SEEK_SET);
-       if (ret == -1)
-               return errno;
+       ret = sys_lseek(fd, ldir->d_off, SEEK_SET);
+       if (ret < 0)
+               return -ret;
 
        entry->d_ino = ldir->d_ino;
        /* the destination should always be big enough */