blob: a7aa774678c3d0aa6a05138f2c7f7398cc840ea3 [file] [log] [blame]
Dmitry V. Levindb23b342014-12-06 03:53:16 +00001#include "defs.h"
2
3#include <fcntl.h>
Felix Jandad34e00b2015-03-28 18:21:09 +01004#include <sys/stat.h>
Dmitry V. Levindb23b342014-12-06 03:53:16 +00005
6#ifdef MAJOR_IN_SYSMACROS
7# include <sys/sysmacros.h>
8#endif
9
10#ifdef MAJOR_IN_MKDEV
11# include <sys/mkdev.h>
12#endif
13
Dmitry V. Levinc15dd412015-07-19 23:07:17 +000014static void
Dmitry V. Levindb23b342014-12-06 03:53:16 +000015decode_mknod(struct tcb *tcp, int offset)
16{
17 int mode = tcp->u_arg[offset + 1];
18
Dmitry V. Levinc15dd412015-07-19 23:07:17 +000019 printpath(tcp, tcp->u_arg[offset]);
20 tprintf(", %s", sprintmode(mode));
21 switch (mode & S_IFMT) {
22 case S_IFCHR:
23 case S_IFBLK:
Dmitry V. Levindb23b342014-12-06 03:53:16 +000024#if defined(SPARC) || defined(SPARC64)
Dmitry V. Levinc15dd412015-07-19 23:07:17 +000025 if (current_personality == 1)
26 tprintf(", makedev(%lu, %lu)",
27 (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff),
28 (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff));
29 else
Dmitry V. Levindb23b342014-12-06 03:53:16 +000030#endif /* SPARC || SPARC64 */
Dmitry V. Levinc15dd412015-07-19 23:07:17 +000031 tprintf(", makedev(%lu, %lu)",
32 (unsigned long) major(tcp->u_arg[offset + 2]),
33 (unsigned long) minor(tcp->u_arg[offset + 2]));
34 break;
Dmitry V. Levindb23b342014-12-06 03:53:16 +000035 }
Dmitry V. Levindb23b342014-12-06 03:53:16 +000036}
37
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000038SYS_FUNC(mknod)
Dmitry V. Levindb23b342014-12-06 03:53:16 +000039{
Dmitry V. Levinc15dd412015-07-19 23:07:17 +000040 decode_mknod(tcp, 0);
41
42 return RVAL_DECODED;
Dmitry V. Levindb23b342014-12-06 03:53:16 +000043}
44
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000045SYS_FUNC(mknodat)
Dmitry V. Levindb23b342014-12-06 03:53:16 +000046{
Dmitry V. Levinc15dd412015-07-19 23:07:17 +000047 print_dirfd(tcp, tcp->u_arg[0]);
48 decode_mknod(tcp, 1);
49
50 return RVAL_DECODED;
Dmitry V. Levindb23b342014-12-06 03:53:16 +000051}
52
53#if defined(SPARC) || defined(SPARC64)
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000054SYS_FUNC(xmknod)
Dmitry V. Levindb23b342014-12-06 03:53:16 +000055{
56 int mode = tcp->u_arg[2];
57
Dmitry V. Levinc15dd412015-07-19 23:07:17 +000058 tprintf("%ld, ", tcp->u_arg[0]);
59 printpath(tcp, tcp->u_arg[1]);
60 tprintf(", %s", sprintmode(mode));
61 switch (mode & S_IFMT) {
62 case S_IFCHR:
63 case S_IFBLK:
64 tprintf(", makedev(%lu, %lu)",
65 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
66 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
67 break;
68 default:
69 break;
Dmitry V. Levindb23b342014-12-06 03:53:16 +000070 }
Dmitry V. Levinc15dd412015-07-19 23:07:17 +000071
72 return RVAL_DECODED;
Dmitry V. Levindb23b342014-12-06 03:53:16 +000073}
74#endif /* SPARC || SPARC64 */