Skip to content

Commit

Permalink
DAOS-17059 client: fcntl 3rd parameter should be void * (#15856)
Browse files Browse the repository at this point in the history
Third argument is "void *" type in libc source code. "va_arg(arg, int);" leads to wrong argument retrieved. also need to return ENOTSUP for flock when compatible mode is not enabled.

Signed-off-by: Lei Huang <[email protected]>
  • Loading branch information
wiliamhuang authored Feb 8, 2025
1 parent 76f0e11 commit 01406c9
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/client/dfuse/pil4dfs/int_dfs.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* (C) Copyright 2022-2024 Intel Corporation.
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -6129,14 +6130,18 @@ futimens(int fd, const struct timespec times[2])
static int
new_fcntl(int fd, int cmd, ...)
{
int fd_directed, param, OrgFunc = 1;
int fd_directed, OrgFunc = 1;
int next_dirfd, next_fd, rc;
void *param;
va_list arg;

va_start(arg, cmd);
param = va_arg(arg, int);
param = va_arg(arg, void *);
va_end(arg);

if (!d_hook_enabled)
return libc_fcntl(fd, cmd, param);

if (fd < FD_FILE_BASE && d_compatible_mode)
return libc_fcntl(fd, cmd, param);

Expand All @@ -6155,9 +6160,6 @@ new_fcntl(int fd, int cmd, ...)
case F_ADD_SEALS:
fd_directed = d_get_fd_redirected(fd);

if (!d_hook_enabled)
return libc_fcntl(fd, cmd, param);

if (cmd == F_GETFL) {
if (fd_directed >= FD_DIR_BASE)
return dir_list[fd_directed - FD_DIR_BASE]->open_flag;
Expand Down Expand Up @@ -6206,12 +6208,15 @@ new_fcntl(int fd, int cmd, ...)
case F_OFD_GETLK:
case F_GETOWN_EX:
case F_SETOWN_EX:
if (!d_hook_enabled)
fd_directed = d_get_fd_redirected(fd);
if (fd_directed >= FD_FILE_BASE) {
errno = ENOTSUP;
return (-1);
} else {
return libc_fcntl(fd, cmd, param);

return libc_fcntl(fd, cmd, param);
}
default:
return libc_fcntl(fd, cmd);
return libc_fcntl(fd, cmd, param);
}
}

Expand Down

0 comments on commit 01406c9

Please sign in to comment.