spacepaste

  1.  
  2. diff --git a/linux-user/aarch64/syscall_nr.h b/linux-user/aarch64/syscall_nr.h
  3. index a3c9a3b..b4cb46a 100644
  4. --- a/linux-user/aarch64/syscall_nr.h
  5. +++ b/linux-user/aarch64/syscall_nr.h
  6. @@ -273,4 +273,5 @@
  7. #define TARGET_NR_membarrier 283
  8. #define TARGET_NR_mlock2 284
  9. #define TARGET_NR_copy_file_range 285
  10. +#define TARGET_NR_statx 291
  11. diff --git a/linux-user/syscall.c b/linux-user/syscall.c
  12. index 643b883..6122951 100644
  13. --- a/linux-user/syscall.c
  14. +++ b/linux-user/syscall.c
  15. @@ -313,6 +313,16 @@ _syscall5(int, kcmp, pid_t, pid1, pid_t, pid2, int, type,
  16. unsigned long, idx1, unsigned long, idx2)
  17. #endif
  18. +#if defined(TARGET_NR_pivot_root) && defined(__NR_pivot_root)
  19. +_syscall2(int, pivot_root, const char *, new_root,
  20. + const char *, put_old);
  21. +#endif
  22. +
  23. +#if defined(TARGET_NR_statx) && defined(__NR_statx)
  24. +_syscall5(int, statx, int, dirfd, const char *, pathname,
  25. + int, flags, unsigned int, mask, struct statx *, statxbuf);
  26. +#endif
  27. +
  28. static bitmask_transtbl fcntl_flags_tbl[] = {
  29. { TARGET_O_ACCMODE, TARGET_O_WRONLY, O_ACCMODE, O_WRONLY, },
  30. { TARGET_O_ACCMODE, TARGET_O_RDWR, O_ACCMODE, O_RDWR, },
  31. @@ -9865,6 +9875,45 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
  32. }
  33. }
  34. break;
  35. +#ifdef TARGET_NR_statx
  36. + case TARGET_NR_statx:
  37. + {
  38. + struct statx stx, *target_stx;
  39. + if (!(p = lock_user_string(arg2)))
  40. + goto efault;
  41. + ret = get_errno(statx(arg1, path(p), arg3, arg4, &stx));
  42. + if (!is_error(ret)) {
  43. + if (!lock_user_struct(VERIFY_WRITE, target_stx, arg5, 0))
  44. + goto efault;
  45. + memset(target_stx, 0, sizeof(*target_stx));
  46. + __put_user(stx.stx_mask, &target_stx->stx_mask);
  47. + __put_user(stx.stx_blksize, &target_stx->stx_blksize);
  48. + __put_user(stx.stx_attributes, &target_stx->stx_attributes);
  49. + __put_user(stx.stx_nlink, &target_stx->stx_nlink);
  50. + __put_user(stx.stx_uid, &target_stx->stx_uid);
  51. + __put_user(stx.stx_gid, &target_stx->stx_gid);
  52. + __put_user(stx.stx_mode, &target_stx->stx_mode);
  53. + __put_user(stx.stx_ino, &target_stx->stx_ino);
  54. + __put_user(stx.stx_size, &target_stx->stx_size);
  55. + __put_user(stx.stx_blocks, &target_stx->stx_blocks);
  56. + __put_user(stx.stx_attributes_mask, &target_stx->stx_attributes_mask);
  57. + __put_user(stx.stx_atime.tv_sec, &target_stx->stx_atime.tv_sec);
  58. + __put_user(stx.stx_atime.tv_nsec, &target_stx->stx_atime.tv_nsec);
  59. + __put_user(stx.stx_btime.tv_sec, &target_stx->stx_btime.tv_sec);
  60. + __put_user(stx.stx_btime.tv_nsec, &target_stx->stx_btime.tv_nsec);
  61. + __put_user(stx.stx_mtime.tv_sec, &target_stx->stx_mtime.tv_sec);
  62. + __put_user(stx.stx_mtime.tv_nsec, &target_stx->stx_mtime.tv_nsec);
  63. + __put_user(stx.stx_ctime.tv_sec, &target_stx->stx_ctime.tv_sec);
  64. + __put_user(stx.stx_ctime.tv_nsec, &target_stx->stx_ctime.tv_nsec);
  65. + __put_user(stx.stx_rdev_major, &target_stx->stx_rdev_major);
  66. + __put_user(stx.stx_rdev_minor, &target_stx->stx_rdev_minor);
  67. + __put_user(stx.stx_dev_major, &target_stx->stx_dev_major);
  68. + __put_user(stx.stx_dev_minor, &target_stx->stx_dev_minor);
  69. + unlock_user_struct(target_stx, arg5, 1);
  70. + }
  71. + }
  72. + break;
  73. +#endif
  74. #ifdef TARGET_NR_olduname
  75. case TARGET_NR_olduname:
  76. goto unimplemented;
  77. @@ -11493,9 +11542,18 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
  78. ret = get_errno(setfsgid(arg1));
  79. break;
  80. #endif
  81. -
  82. +#ifdef TARGET_NR_pivot_root
  83. case TARGET_NR_pivot_root:
  84. - goto unimplemented;
  85. + {
  86. + void *p, *n;
  87. + p = lock_user_string(arg1);
  88. + n = lock_user_string(arg2);
  89. + ret = get_errno(pivot_root(p, n));
  90. + unlock_user(p, arg1, 0);
  91. + unlock_user(n, arg2, 0);
  92. + }
  93. + break;
  94. +#endif
  95. #ifdef TARGET_NR_mincore
  96. case TARGET_NR_mincore:
  97. {
  98. diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
  99. index 23f5bcc..d4e4dba 100644
  100. --- a/linux-user/syscall_defs.h
  101. +++ b/linux-user/syscall_defs.h
  102. @@ -1411,6 +1411,35 @@ struct target_winsize {
  103. #define TARGET_MAP_UNINITIALIZED 0x4000000 /* for anonymous mmap, memory could be uninitialized */
  104. #endif
  105. +struct statx_timestamp {
  106. + int64_t tv_sec;
  107. + uint32_t tv_nsec;
  108. + int32_t __reserved;
  109. +};
  110. +
  111. +struct statx {
  112. + uint32_t stx_mask;
  113. + uint32_t stx_blksize;
  114. + uint64_t stx_attributes;
  115. + uint32_t stx_nlink;
  116. + uint32_t stx_uid;
  117. + uint32_t stx_gid;
  118. + uint16_t stx_mode;
  119. + uint16_t __spare0[1];
  120. + uint64_t stx_ino;
  121. + uint64_t stx_size;
  122. + uint64_t stx_blocks;
  123. + uint64_t stx_attributes_mask;
  124. + struct statx_timestamp stx_atime;
  125. + struct statx_timestamp stx_btime;
  126. + struct statx_timestamp stx_ctime;
  127. + struct statx_timestamp stx_mtime;
  128. + uint32_t stx_rdev_major;
  129. + uint32_t stx_rdev_minor;
  130. + uint32_t stx_dev_major;
  131. + uint32_t stx_dev_minor;
  132. + uint64_t __spare2[14];
  133. +};
  134. #if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
  135. || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
  136. || defined(TARGET_CRIS)
  137.