Skip to content

posix: implement fattach() and fdetach() #68464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/services/portability/posix/option_groups/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,8 @@ _XOPEN_STREAMS
:header: API, Supported
:widths: 50,10

fattach(),
fdetach(),
fattach(),yes (will fail with ``ENOSYS``:ref:`†<posix_undefined_behaviour>`)
fdetach(),yes (will fail with ``ENOSYS``:ref:`†<posix_undefined_behaviour>`)
getmsg(),
getpmsg(),
ioctl(),yes
Expand Down
2 changes: 2 additions & 0 deletions include/zephyr/posix/stropts.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ struct strbuf {
};

int putmsg(int fildes, const struct strbuf *ctlptr, const struct strbuf *dataptr, int flags);
int fdetach(const char *path);
int fattach(int fildes, const char *path);

#ifdef __cplusplus
}
Expand Down
17 changes: 17 additions & 0 deletions lib/posix/options/stropts.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,20 @@ int putmsg(int fildes, const struct strbuf *ctlptr, const struct strbuf *dataptr
errno = ENOSYS;
return -1;
}

int fdetach(const char *path)
{
ARG_UNUSED(path);

errno = ENOSYS;
return -1;
}

int fattach(int fildes, const char *path)
{
ARG_UNUSED(fildes);
ARG_UNUSED(path);

errno = ENOSYS;
return -1;
}
19 changes: 19 additions & 0 deletions tests/posix/common/src/stropts.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,23 @@ ZTEST(stropts, test_putmsg)
zassert_equal(errno, ENOSYS, "Expected errno ENOSYS, got %d", errno);
}

ZTEST(stropts, test_fdetach)
{
char *path = NULL;
int ret = fdetach(path);

zassert_equal(ret, -1, "Expected return value -1, got %d", ret);
zassert_equal(errno, ENOSYS, "Expected errno ENOSYS, got %d", errno);
}

ZTEST(stropts, test_fattach)
{
char *path = NULL;
int fd = -1;
int ret = fattach(fd, path);

zassert_equal(ret, -1, "Expected return value -1, got %d", ret);
zassert_equal(errno, ENOSYS, "Expected errno ENOSYS, got %d", errno);
}

ZTEST_SUITE(stropts, NULL, NULL, NULL, NULL, NULL);
2 changes: 2 additions & 0 deletions tests/posix/headers/src/stropts_h.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ ZTEST(posix_headers, test_stropts_h)
{
#ifdef CONFIG_POSIX_API
zassert_not_null((void *)putmsg, "putmsg is null");
zassert_not_null((void *)fdetach, "fdetach is null");
zassert_not_null((void *)fattach, "fattach is null");

zassert_true(sizeof(((struct strbuf *)0)->maxlen) > 0, "maxlen size is 0");
zassert_true(sizeof(((struct strbuf *)0)->len) > 0, "len size is 0");
Expand Down