File: fcntl.c

package info (click to toggle)
strace 4.26-0.2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 35,988 kB
  • sloc: ansic: 95,598; sh: 7,155; makefile: 2,489; awk: 335; perl: 267; sed: 6
file content (56 lines) | stat: -rw-r--r-- 1,300 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
 * Copyright (c) 2015-2018 The strace developers.
 * All rights reserved.
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include "tests.h"
#include <asm/unistd.h>

#ifdef __NR_fcntl

# define TEST_SYSCALL_NR __NR_fcntl
# define TEST_SYSCALL_STR "fcntl"
# include "fcntl-common.c"

static void
test_flock64_undecoded(const int cmd, const char *name)
{
	struct_kernel_flock64 fl = {
		.l_type = F_RDLCK,
		.l_start = 0xdefaced1facefeedULL,
		.l_len = 0xdefaced2cafef00dULL
	};
	invoke_test_syscall(0, cmd, &fl);
	printf("%s(0, %s, %p) = %s\n",
	       TEST_SYSCALL_STR, name, &fl, errstr);
}

#define TEST_FLOCK64_UNDECODED(cmd) test_flock64_undecoded(cmd, #cmd)

static void
test_flock64_lk64(void)
{
/*
 * F_[GS]ETOWN_EX had conflicting values with F_[GS]ETLK64
 * in kernel revisions v2.6.32-rc1~96..v2.6.32-rc7~23.
 */
# if !defined(F_GETOWN_EX) || F_GETOWN_EX != F_SETLK64
	TEST_FLOCK64_UNDECODED(F_SETLK64);
# endif
/* F_GETLK and F_SETLKW64 have conflicting values on mips64 */
# if !defined(__mips64) || F_GETLK != F_SETLKW64
	TEST_FLOCK64_UNDECODED(F_SETLKW64);
# endif
# if !defined(F_SETOWN_EX) || F_SETOWN_EX != F_GETLK64
	TEST_FLOCK64_UNDECODED(F_GETLK64);
# endif
}

#else

SKIP_MAIN_UNDEFINED("__NR_fcntl")

#endif