-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
6 changed files
with
153 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) 2024 Meta Platforms | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#ifndef ZEPHYR_INCLUDE_POSIX_GRP_H_ | ||
#define ZEPHYR_INCLUDE_POSIX_GRP_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include <zephyr/types.h> | ||
|
||
typedef unsigned int gid_t; | ||
|
||
struct group { | ||
/* the name of the group */ | ||
char *gr_name; | ||
/* numerical group ID */ | ||
gid_t gr_gid; | ||
/* pointer to a null-terminated array of character pointers to member names */ | ||
char **gr_mem; | ||
}; | ||
|
||
int getgrnam_r(const char *name, struct group *grp, char *buffer, size_t bufsize, | ||
struct group **result); | ||
int getgrgid_r(gid_t gid, struct group *grp, char *buffer, size_t bufsize, struct group **result); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* ZEPHYR_INCLUDE_POSIX_GRP_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2024 Meta Platforms | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#ifndef ZEPHYR_INCLUDE_POSIX_PWD_H_ | ||
#define ZEPHYR_INCLUDE_POSIX_PWD_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include <zephyr/types.h> | ||
|
||
typedef unsigned int uid_t; | ||
typedef unsigned int gid_t; | ||
|
||
struct passwd { | ||
/* user's login name */ | ||
char *pw_name; | ||
/* numerical user ID */ | ||
uid_t pw_uid; | ||
/* numerical group ID */ | ||
gid_t pw_gid; | ||
/* initial working directory */ | ||
char *pw_dir; | ||
/* program to use as shell */ | ||
char *pw_shell; | ||
}; | ||
|
||
int getpwnam_r(const char *nam, struct passwd *pwd, char *buffer, size_t bufsize, | ||
struct passwd **result); | ||
int getpwuid_r(uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* ZEPHYR_INCLUDE_POSIX_PWD_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2024 Meta Platforms | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <errno.h> | ||
|
||
#include <zephyr/sys/util.h> | ||
#include <zephyr/posix/grp.h> | ||
|
||
#ifdef CONFIG_POSIX_THREAD_SAFE_FUNCTIONS | ||
|
||
int getgrnam_r(const char *name, struct group *grp, char *buffer, size_t bufsize, | ||
struct group **result) | ||
{ | ||
ARG_UNUSED(name); | ||
ARG_UNUSED(grp); | ||
ARG_UNUSED(buffer); | ||
ARG_UNUSED(bufsize); | ||
ARG_UNUSED(result); | ||
|
||
return -ENOSYS; | ||
} | ||
|
||
int getgrgid_r(gid_t gid, struct group *grp, char *buffer, size_t bufsize, struct group **result) | ||
{ | ||
ARG_UNUSED(gid); | ||
ARG_UNUSED(grp); | ||
ARG_UNUSED(buffer); | ||
ARG_UNUSED(bufsize); | ||
ARG_UNUSED(result); | ||
|
||
return -ENOSYS; | ||
} | ||
|
||
#endif /* CONFIG_POSIX_THREAD_SAFE_FUNCTIONS */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2024 Meta Platforms | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <errno.h> | ||
|
||
#include <zephyr/sys/util.h> | ||
#include <zephyr/posix/pwd.h> | ||
|
||
#ifdef CONFIG_POSIX_THREAD_SAFE_FUNCTIONS | ||
|
||
int getpwnam_r(const char *nam, struct passwd *pwd, char *buffer, size_t bufsize, | ||
struct passwd **result) | ||
{ | ||
ARG_UNUSED(nam); | ||
ARG_UNUSED(pwd); | ||
ARG_UNUSED(buffer); | ||
ARG_UNUSED(bufsize); | ||
ARG_UNUSED(result); | ||
|
||
return -ENOSYS; | ||
} | ||
|
||
int getpwuid_r(uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result) | ||
{ | ||
ARG_UNUSED(uid); | ||
ARG_UNUSED(pwd); | ||
ARG_UNUSED(buffer); | ||
ARG_UNUSED(bufsize); | ||
ARG_UNUSED(result); | ||
|
||
return -ENOSYS; | ||
} | ||
|
||
#endif /* CONFIG_POSIX_THREAD_SAFE_FUNCTIONS */ |