Skip to content
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

Introduce vfcntl() #2194

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion lib/libsys/Symbol.sys.map
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ FBSD_1.7 {
};

FBSD_1.8 {
kcmp;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to upstream this whitespace cleanup but turns out that file does not exist in FreeBSD.

kcmp;
vfcntl;
};

FBSDprivate_1.0 {
Expand Down
3 changes: 3 additions & 0 deletions lib/libsys/fcntl.2
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
.In fcntl.h
.Ft int
.Fn fcntl "int fd" "int cmd" "..."
.In stdarg.h
.Ft int
.Fn vfcntl "int fd" "int cmd" "va_list ap"
.Sh DESCRIPTION
The
.Fn fcntl
Expand Down
18 changes: 14 additions & 4 deletions lib/libsys/fcntl.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@
* CHERI CHANGES END
*/

#include <fcntl.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/syscall.h>

#include <fcntl.h>
#include <stdarg.h>

#include "libc_private.h"

typedef int (*fcntl_func)(int, int, intptr_t);
Expand Down Expand Up @@ -80,16 +82,24 @@ call_fcntl(fcntl_func fn, int fd, int cmd, va_list ap)
return (fn(fd, cmd, arg));
}

#pragma weak fcntl
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/fcntl/vfcntl/?

int
vfcntl(int fd, int cmd, va_list ap)
{
fcntl_func fn = (fcntl_func)*__libsys_interposing_slot(INTERPOS_fcntl);

return (call_fcntl(fn, fd, cmd, ap));
}

#pragma weak fcntl
int
fcntl(int fd, int cmd, ...)
{
va_list args;
int result;
fcntl_func fn = (fcntl_func)*__libsys_interposing_slot(INTERPOS_fcntl);

va_start(args, cmd);
result = call_fcntl(fn, fd, cmd, args);
result = vfcntl(fd, cmd, args);
va_end(args);

return (result);
Expand Down
1 change: 1 addition & 0 deletions sys/sys/fcntl.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,10 @@
int creat(const char *, mode_t);
int fcntl(int, int, ...);
#if __BSD_VISIBLE
int vfcntl(int, int, __va_list);
int flock(int, int);
int fspacectl(int, int, const struct spacectl_range *, int,
struct spacectl_range *);

Check failure on line 382 in sys/sys/fcntl.h

View workflow job for this annotation

GitHub Actions / Style Checker

Missing Signed-off-by: line
#endif
#if __POSIX_VISIBLE >= 200809
int openat(int, const char *, int, ...);
Expand Down
Loading