]> granicus.if.org Git - strace/blob - mount.c
tests: workaround systemd-nspawn habit of disabling unimplemented syscalls
[strace] / mount.c
1 /*
2  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4  * Copyright (c) 1993-1996 Rick Sladkey <jrs@world.std.com>
5  * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6  * Copyright (c) 2005 Roland McGrath <roland@redhat.com>
7  * Copyright (c) 2007-2015 Dmitry V. Levin <ldv@altlinux.org>
8  * Copyright (c) 2014-2018 The strace developers.
9  * All rights reserved.
10  *
11  * SPDX-License-Identifier: LGPL-2.1-or-later
12  */
13
14 #include "defs.h"
15
16 #define MS_MGC_VAL      0xc0ed0000      /* old magic mount flag number */
17 #define MS_MGC_MSK      0xffff0000      /* old magic mount flag mask */
18
19 #include "xlat/mount_flags.h"
20
21 SYS_FUNC(mount)
22 {
23         bool ignore_type = false;
24         bool ignore_data = false;
25         bool old_magic = false;
26         kernel_ulong_t flags = tcp->u_arg[3];
27
28         /* Discard magic */
29         if ((flags & MS_MGC_MSK) == MS_MGC_VAL) {
30                 flags &= ~MS_MGC_MSK;
31                 old_magic = true;
32         }
33
34         if (flags & MS_REMOUNT)
35                 ignore_type = true;
36         else if (flags & (MS_BIND | MS_MOVE | MS_SHARED
37                           | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
38                 ignore_type = ignore_data = true;
39
40         printpath(tcp, tcp->u_arg[0]);
41         tprints(", ");
42
43         printpath(tcp, tcp->u_arg[1]);
44         tprints(", ");
45
46         if (ignore_type)
47                 printaddr(tcp->u_arg[2]);
48         else
49                 printstr(tcp, tcp->u_arg[2]);
50         tprints(", ");
51
52         if (old_magic) {
53                 print_xlat(MS_MGC_VAL);
54                 if (flags)
55                         tprints("|");
56         }
57         if (flags || !old_magic)
58                 printflags64(mount_flags, flags, "MS_???");
59         tprints(", ");
60
61         if (ignore_data)
62                 printaddr(tcp->u_arg[4]);
63         else
64                 printstr(tcp, tcp->u_arg[4]);
65
66         return RVAL_DECODED;
67 }