Dmitry V. Levin | db23b34 | 2014-12-06 03:53:16 +0000 | [diff] [blame] | 1 | #include "defs.h" |
| 2 | |
| 3 | #include <fcntl.h> |
| 4 | |
| 5 | #ifdef MAJOR_IN_SYSMACROS |
| 6 | # include <sys/sysmacros.h> |
| 7 | #endif |
| 8 | |
| 9 | #ifdef MAJOR_IN_MKDEV |
| 10 | # include <sys/mkdev.h> |
| 11 | #endif |
| 12 | |
| 13 | static int |
| 14 | decode_mknod(struct tcb *tcp, int offset) |
| 15 | { |
| 16 | int mode = tcp->u_arg[offset + 1]; |
| 17 | |
| 18 | if (entering(tcp)) { |
| 19 | printpath(tcp, tcp->u_arg[offset]); |
| 20 | tprintf(", %s", sprintmode(mode)); |
| 21 | switch (mode & S_IFMT) { |
| 22 | case S_IFCHR: |
| 23 | case S_IFBLK: |
| 24 | #if defined(SPARC) || defined(SPARC64) |
| 25 | 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 |
| 30 | #endif /* SPARC || SPARC64 */ |
| 31 | tprintf(", makedev(%lu, %lu)", |
| 32 | (unsigned long) major(tcp->u_arg[offset + 2]), |
| 33 | (unsigned long) minor(tcp->u_arg[offset + 2])); |
| 34 | break; |
| 35 | default: |
| 36 | break; |
| 37 | } |
| 38 | } |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | int |
| 43 | sys_mknod(struct tcb *tcp) |
| 44 | { |
| 45 | return decode_mknod(tcp, 0); |
| 46 | } |
| 47 | |
| 48 | int |
| 49 | sys_mknodat(struct tcb *tcp) |
| 50 | { |
| 51 | if (entering(tcp)) |
| 52 | print_dirfd(tcp, tcp->u_arg[0]); |
| 53 | return decode_mknod(tcp, 1); |
| 54 | } |
| 55 | |
| 56 | #if defined(SPARC) || defined(SPARC64) |
| 57 | int |
| 58 | sys_xmknod(struct tcb *tcp) |
| 59 | { |
| 60 | int mode = tcp->u_arg[2]; |
| 61 | |
| 62 | if (entering(tcp)) { |
| 63 | tprintf("%ld, ", tcp->u_arg[0]); |
| 64 | printpath(tcp, tcp->u_arg[1]); |
| 65 | tprintf(", %s", sprintmode(mode)); |
| 66 | switch (mode & S_IFMT) { |
| 67 | case S_IFCHR: |
| 68 | case S_IFBLK: |
| 69 | tprintf(", makedev(%lu, %lu)", |
| 70 | (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff), |
| 71 | (unsigned long) (tcp->u_arg[3] & 0x3ffff)); |
| 72 | break; |
| 73 | default: |
| 74 | break; |
| 75 | } |
| 76 | } |
| 77 | return 0; |
| 78 | } |
| 79 | #endif /* SPARC || SPARC64 */ |