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@strace.io>
8 * Copyright (c) 2014-2022 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 /* source */
41 printpath(tcp, tcp->u_arg[0]);
42 tprint_arg_next();
43
44 /* target */
45 printpath(tcp, tcp->u_arg[1]);
46 tprint_arg_next();
47
48 /* filesystemtype */
49 if (ignore_type)
50 printaddr(tcp->u_arg[2]);
51 else
52 printstr(tcp, tcp->u_arg[2]);
53 tprint_arg_next();
54
55 /* mountflags */
56 tprint_flags_begin();
57 if (old_magic) {
58 print_xlat(MS_MGC_VAL);
59 if (flags)
60 tprint_flags_or();
61 }
62 if (flags || !old_magic)
63 printflags64_in(mount_flags, flags, "MS_???");
64 tprint_flags_end();
65 tprint_arg_next();
66
67 /* data */
68 if (ignore_data)
69 printaddr(tcp->u_arg[4]);
70 else
71 printstr(tcp, tcp->u_arg[4]);
72
73 return RVAL_DECODED;
74 }