lib: posix: add stubs for thread-safe grp & pwd functions

Create stubs for getpwnam_r, getpwuid_r, getgrgid_r
& getgrnam_r.

These functions are in the _POSIX_THREAD_SAFE_FUNCTIONS
option group.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
This commit is contained in:
Yong Cong Sin 2024-06-14 17:18:22 +08:00 committed by Carles Cufí
commit 2ccfe8202d
8 changed files with 187 additions and 4 deletions

View file

@ -0,0 +1,18 @@
/*
* Copyright (c) 2024 Meta Platforms
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <errno.h>
#include <grp.h>
#include <zephyr/ztest.h>
ZTEST(grp, test_grp_stubs)
{
zassert_equal(getgrnam_r(NULL, NULL, NULL, 42, NULL), ENOSYS);
zassert_equal(getgrgid_r(42, NULL, NULL, 42, NULL), ENOSYS);
}
ZTEST_SUITE(grp, NULL, NULL, NULL, NULL, NULL);

View file

@ -0,0 +1,18 @@
/*
* Copyright (c) 2024 Meta Platforms
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <errno.h>
#include <pwd.h>
#include <zephyr/ztest.h>
ZTEST(pwd, test_pwd_stubs)
{
zassert_equal(getpwnam_r(NULL, NULL, NULL, 42, NULL), ENOSYS);
zassert_equal(getpwuid_r(42, NULL, NULL, 42, NULL), ENOSYS);
}
ZTEST_SUITE(pwd, NULL, NULL, NULL, NULL, NULL);