From 44609129ea116deaf8b49fd11f40f8e52d97cb66 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 21 Apr 2015 17:46:52 +0000 Subject: [PATCH] Add support for LL_IOC_PATH2FID and LL_IOC_GETPARENT Lustre ioctls From: Frank Zago git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15123 --- coregrind/m_syswrap/syswrap-linux.c | 42 +++++++++++++++++++++++++++++++------ include/vki/vki-linux.h | 20 ++++++++++++++++++ 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index def5aee2c..f15c909e4 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -7321,11 +7321,28 @@ PRE(sys_ioctl) break; #endif - /* To do: figure out which software layer extends the sign of 'request' */ - case VKI_OBD_IOC_FID2PATH: - PRE_MEM_READ("VKI_OBD_IOC_FID2PATH(args)", ARG3, - sizeof(struct vki_getinfo_fid2path)); + /* Lustre */ + case VKI_OBD_IOC_FID2PATH: { + struct vki_getinfo_fid2path *gf = (struct vki_getinfo_fid2path *)ARG3; + PRE_MEM_READ("VKI_OBD_IOC_FID2PATH(args)", ARG3, sizeof(struct vki_getinfo_fid2path)); + PRE_FIELD_WRITE("VKI_OBD_IOC_FID2PATH(args).gf_recno", gf->gf_recno); + PRE_FIELD_WRITE("VKI_OBD_IOC_FID2PATH(args).gf_linkno", gf->gf_linkno); + PRE_MEM_WRITE("VKI_OBD_IOC_FID2PATH(args)", (Addr)gf->gf_path, gf->gf_pathlen); + break; + } + + case VKI_LL_IOC_PATH2FID: + PRE_MEM_WRITE("ioctl(VKI_LL_IOC_PATH2FID)", ARG3, sizeof(struct vki_lu_fid)); + break; + + case VKI_LL_IOC_GETPARENT: { + struct vki_getparent *gp = (struct vki_getparent *)ARG3; + PRE_FIELD_READ("ioctl(VKI_LL_IOC_GETPARENT).gp_linkno", gp->gp_linkno); + PRE_FIELD_READ("ioctl(VKI_LL_IOC_GETPARENT).gp_name_size", gp->gp_name_size); + PRE_FIELD_WRITE("ioctl(VKI_LL_IOC_GETPARENT).gp_fid", gp->gp_fid); + PRE_MEM_WRITE("ioctl(VKI_LL_IOC_GETPARENT).gp_name", (Addr)gp->gp_name, gp->gp_name_size); break; + } /* V4L2 */ case VKI_V4L2_QUERYCAP: { @@ -9636,13 +9653,26 @@ POST(sys_ioctl) break; #endif - /* To do: figure out which software layer extends the sign of 'request' */ + /* Lustre */ case VKI_OBD_IOC_FID2PATH: { struct vki_getinfo_fid2path *args = (void *)(ARG3); - POST_MEM_WRITE((Addr)args->gf_path, args->gf_pathlen); + POST_FIELD_WRITE(args->gf_recno); + POST_FIELD_WRITE(args->gf_linkno); + POST_MEM_WRITE((Addr)args->gf_path, VG_(strlen)(args->gf_path)+1); + break; } + + case VKI_LL_IOC_PATH2FID: + POST_MEM_WRITE(ARG3, sizeof(struct vki_lu_fid)); break; + case VKI_LL_IOC_GETPARENT: { + struct vki_getparent *gp = (struct vki_getparent *)ARG3; + POST_FIELD_WRITE(gp->gp_fid); + POST_MEM_WRITE((Addr)gp->gp_name, VG_(strlen)(gp->gp_name)+1); + break; + } + /* V4L2 */ case VKI_V4L2_S_FMT: case VKI_V4L2_TRY_FMT: diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h index 808c1d88c..6db92dc89 100644 --- a/include/vki/vki-linux.h +++ b/include/vki/vki-linux.h @@ -3658,6 +3658,26 @@ struct vki_getinfo_fid2path { #define VKI_OBD_IOC_FID2PATH \ _VKI_IOWR ('f', 150, VKI_OBD_IOC_DATA_TYPE) +#define VKI_LL_IOC_PATH2FID \ + _VKI_IOR ('f', 173, long) + +//---------------------------------------------------------------------- +// From lustre/include/lustre/lustre_idl.h +//---------------------------------------------------------------------- + +struct vki_getparent { + struct vki_lu_fid gp_fid; + __vki_u32 gp_linkno; + __vki_u32 gp_name_size; + char gp_name[0]; +} __attribute__((packed)); + +//---------------------------------------------------------------------- +// From Lustre's lustre/include/lustre/lustre_user.h +//---------------------------------------------------------------------- +#define VKI_LL_IOC_GETPARENT \ + _VKI_IOWR('f', 249, struct vki_getparent) + struct vki_v4l2_rect { __vki_s32 left; -- 2.11.4.GIT