Browse Source

renameat2: add decoding support

* file.c (decode_renameat, sys_renameat2): New functions.
(sys_renameat): Use decode_renameat.
* pathtrace.c (pathtrace_match): Handle sys_renameat2.
* linux/syscall.h (sys_renameat2): New prototype.
* xlat/rename_flags.in: New file.
Mike Frysinger 5 years ago
parent
commit
5b677ab904
4 changed files with 27 additions and 4 deletions
  1. 23
    4
      file.c
  2. 1
    0
      linux/syscall.h
  3. 1
    0
      pathtrace.c
  4. 2
    0
      xlat/rename_flags.in

+ 23
- 4
file.c View File

@@ -1767,15 +1767,34 @@ sys_readlinkat(struct tcb *tcp)
1767 1767
 	return decode_readlink(tcp, 1);
1768 1768
 }
1769 1769
 
1770
+static void
1771
+decode_renameat(struct tcb *tcp)
1772
+{
1773
+	print_dirfd(tcp, tcp->u_arg[0]);
1774
+	printpath(tcp, tcp->u_arg[1]);
1775
+	tprints(", ");
1776
+	print_dirfd(tcp, tcp->u_arg[2]);
1777
+	printpath(tcp, tcp->u_arg[3]);
1778
+}
1779
+
1770 1780
 int
1771 1781
 sys_renameat(struct tcb *tcp)
1772 1782
 {
1773 1783
 	if (entering(tcp)) {
1774
-		print_dirfd(tcp, tcp->u_arg[0]);
1775
-		printpath(tcp, tcp->u_arg[1]);
1784
+		decode_renameat(tcp);
1785
+	}
1786
+	return 0;
1787
+}
1788
+
1789
+#include "xlat/rename_flags.h"
1790
+
1791
+int
1792
+sys_renameat2(struct tcb *tcp)
1793
+{
1794
+	if (entering(tcp)) {
1795
+		decode_renameat(tcp);
1776 1796
 		tprints(", ");
1777
-		print_dirfd(tcp, tcp->u_arg[2]);
1778
-		printpath(tcp, tcp->u_arg[3]);
1797
+		printflags(rename_flags, tcp->u_arg[4], "RENAME_??");
1779 1798
 	}
1780 1799
 	return 0;
1781 1800
 }

+ 1
- 0
linux/syscall.h View File

@@ -207,6 +207,7 @@ int sys_recvmsg();
207 207
 int sys_remap_file_pages();
208 208
 int sys_removexattr();
209 209
 int sys_renameat();
210
+int sys_renameat2();
210 211
 int sys_request_key();
211 212
 int sys_restart_syscall();
212 213
 int sys_rt_sigaction();

+ 1
- 0
pathtrace.c View File

@@ -211,6 +211,7 @@ pathtrace_match(struct tcb *tcp)
211 211
 	}
212 212
 
213 213
 	if (s->sys_func == sys_renameat ||
214
+	    s->sys_func == sys_renameat2 ||
214 215
 	    s->sys_func == sys_linkat)
215 216
 	{
216 217
 		/* fd, path, fd, path */

+ 2
- 0
xlat/rename_flags.in View File

@@ -0,0 +1,2 @@
1
+RENAME_NOREPLACE
2
+RENAME_EXCHANGE

Loading…
Cancel
Save