1 #include "defs.h"
2
3 #include <fcntl.h>
4 #include <sys/stat.h>
5
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
14 static int
decode_mknod(struct tcb * tcp,int offset)15 decode_mknod(struct tcb *tcp, int offset)
16 {
17 int mode = tcp->u_arg[offset + 1];
18
19 if (entering(tcp)) {
20 printpath(tcp, tcp->u_arg[offset]);
21 tprintf(", %s", sprintmode(mode));
22 switch (mode & S_IFMT) {
23 case S_IFCHR:
24 case S_IFBLK:
25 #if defined(SPARC) || defined(SPARC64)
26 if (current_personality == 1)
27 tprintf(", makedev(%lu, %lu)",
28 (unsigned long) ((tcp->u_arg[offset + 2] >> 18) & 0x3fff),
29 (unsigned long) (tcp->u_arg[offset + 2] & 0x3ffff));
30 else
31 #endif /* SPARC || SPARC64 */
32 tprintf(", makedev(%lu, %lu)",
33 (unsigned long) major(tcp->u_arg[offset + 2]),
34 (unsigned long) minor(tcp->u_arg[offset + 2]));
35 break;
36 default:
37 break;
38 }
39 }
40 return 0;
41 }
42
SYS_FUNC(mknod)43 SYS_FUNC(mknod)
44 {
45 return decode_mknod(tcp, 0);
46 }
47
SYS_FUNC(mknodat)48 SYS_FUNC(mknodat)
49 {
50 if (entering(tcp))
51 print_dirfd(tcp, tcp->u_arg[0]);
52 return decode_mknod(tcp, 1);
53 }
54
55 #if defined(SPARC) || defined(SPARC64)
SYS_FUNC(xmknod)56 SYS_FUNC(xmknod)
57 {
58 int mode = tcp->u_arg[2];
59
60 if (entering(tcp)) {
61 tprintf("%ld, ", tcp->u_arg[0]);
62 printpath(tcp, tcp->u_arg[1]);
63 tprintf(", %s", sprintmode(mode));
64 switch (mode & S_IFMT) {
65 case S_IFCHR:
66 case S_IFBLK:
67 tprintf(", makedev(%lu, %lu)",
68 (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff),
69 (unsigned long) (tcp->u_arg[3] & 0x3ffff));
70 break;
71 default:
72 break;
73 }
74 }
75 return 0;
76 }
77 #endif /* SPARC || SPARC64 */
78