Mark Wielaard 099bdc
commit 1c49351424f04ee29a5efc054cb08ab3ad22b978
Mark Wielaard 099bdc
Author: Laurent Bonnans <laurent.bonnans@here.com>
Mark Wielaard 099bdc
Date:   Fri Nov 16 15:22:18 2018 +0100
Mark Wielaard 099bdc
Mark Wielaard 099bdc
    Fix 397605 - Add support for Linux FICLONE ioctl
Mark Wielaard 099bdc
Mark Wielaard 099bdc
diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
Mark Wielaard 099bdc
index 41849873e..328e02a98 100644
Mark Wielaard 099bdc
--- a/coregrind/m_syswrap/syswrap-linux.c
Mark Wielaard 099bdc
+++ b/coregrind/m_syswrap/syswrap-linux.c
Mark Wielaard 099bdc
@@ -7961,6 +7961,11 @@ PRE(sys_ioctl)
Mark Wielaard 099bdc
    case VKI_FIBMAP:
Mark Wielaard 099bdc
       PRE_MEM_READ( "ioctl(FIBMAP)", ARG3, sizeof(int));
Mark Wielaard 099bdc
       break;
Mark Wielaard 099bdc
+   case VKI_FICLONE:
Mark Wielaard 099bdc
+      /* The direction of FICLONE (W) is incorrectly specified
Mark Wielaard 099bdc
+       * as it expects a file descriptor and not a pointer to
Mark Wielaard 099bdc
+       * user data */
Mark Wielaard 099bdc
+      break;
Mark Wielaard 099bdc
 
Mark Wielaard 099bdc
    case VKI_FBIOGET_VSCREENINFO: /* 0x4600 */
Mark Wielaard 099bdc
       PRE_MEM_WRITE( "ioctl(FBIOGET_VSCREENINFO)", ARG3,
Mark Wielaard 099bdc
@@ -10898,6 +10903,8 @@ POST(sys_ioctl)
Mark Wielaard 099bdc
    case VKI_FIBMAP:
Mark Wielaard 099bdc
       POST_MEM_WRITE(ARG3, sizeof(int));
Mark Wielaard 099bdc
       break;
Mark Wielaard 099bdc
+   case VKI_FICLONE:
Mark Wielaard 099bdc
+      break;
Mark Wielaard 099bdc
 
Mark Wielaard 099bdc
    case VKI_FBIOGET_VSCREENINFO: //0x4600
Mark Wielaard 099bdc
       POST_MEM_WRITE(ARG3, sizeof(struct vki_fb_var_screeninfo));
Mark Wielaard 099bdc
diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h
Mark Wielaard 099bdc
index ef93b9258..3b9dc3779 100644
Mark Wielaard 099bdc
--- a/include/vki/vki-linux.h
Mark Wielaard 099bdc
+++ b/include/vki/vki-linux.h
Mark Wielaard 099bdc
@@ -1888,6 +1888,7 @@ struct vki_ppdev_frob_struct {
Mark Wielaard 099bdc
 
Mark Wielaard 099bdc
 #define VKI_FIBMAP	_VKI_IO(0x00,1)	/* bmap access */
Mark Wielaard 099bdc
 #define VKI_FIGETBSZ    _VKI_IO(0x00,2)	/* get the block size used for bmap */
Mark Wielaard 099bdc
+#define VKI_FICLONE     _VKI_IOW(0x94, 9, int)
Mark Wielaard 099bdc
 
Mark Wielaard 099bdc
 //----------------------------------------------------------------------
Mark Wielaard 099bdc
 // From linux-2.6.8.1/include/scsi/sg.h