From owner-p4-projects@FreeBSD.ORG Fri Aug 21 22:56:58 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 69AC41065690; Fri, 21 Aug 2009 22:56:58 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2D3C0106568D for ; Fri, 21 Aug 2009 22:56:58 +0000 (UTC) (envelope-from stas@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 033E58FC18 for ; Fri, 21 Aug 2009 22:56:58 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n7LMuvMi004898 for ; Fri, 21 Aug 2009 22:56:57 GMT (envelope-from stas@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n7LMuvGK004896 for perforce@freebsd.org; Fri, 21 Aug 2009 22:56:57 GMT (envelope-from stas@freebsd.org) Date: Fri, 21 Aug 2009 22:56:57 GMT Message-Id: <200908212256.n7LMuvGK004896@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to stas@freebsd.org using -f From: Stanislav Sedov To: Perforce Change Reviews Cc: Subject: PERFORCE change 167593 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Aug 2009 22:56:58 -0000 http://perforce.freebsd.org/chv.cgi?CH=167593 Change 167593 by stas@stas_orion on 2009/08/21 22:56:07 - Implement fcntl wrapper. Affected files ... .. //depot/projects/valgrind/coregrind/m_syswrap/syswrap-freebsd.c#36 edit Differences ... ==== //depot/projects/valgrind/coregrind/m_syswrap/syswrap-freebsd.c#36 (text+ko) ==== @@ -3048,6 +3048,60 @@ POST_MEM_WRITE( ARG1, sizeof(struct vki_ucontext) ); } +PRE(sys_fcntl) +{ + switch (ARG2) { + // These ones ignore ARG3. + case VKI_F_GETFD: + case VKI_F_GETFL: + case VKI_F_GETOWN: + PRINT("sys_fcntl ( %ld, %ld )", ARG1,ARG2); + PRE_REG_READ2(long, "fcntl", unsigned int, fd, unsigned int, cmd); + break; + + // These ones use ARG3 as "arg". + case VKI_F_DUPFD: + case VKI_F_SETFD: + case VKI_F_SETFL: + case VKI_F_SETOWN: + PRINT("sys_fcntl[ARG3=='arg'] ( %ld, %ld, %ld )", ARG1,ARG2,ARG3); + PRE_REG_READ3(long, "fcntl", + unsigned int, fd, unsigned int, cmd, unsigned long, arg); + break; + + // These ones use ARG3 as "lock". + case VKI_F_GETLK: + case VKI_F_SETLK: + case VKI_F_SETLKW: + PRINT("sys_fcntl[ARG3=='lock'] ( %ld, %ld, %#lx )", ARG1,ARG2,ARG3); + PRE_REG_READ3(long, "fcntl", + unsigned int, fd, unsigned int, cmd, + struct flock64 *, lock); + break; + + default: + PRINT("sys_fcntl[UNKNOWN] ( %ld, %ld, %ld )", ARG1,ARG2,ARG3); + I_die_here; + break; + } + if (ARG2 == VKI_F_SETLKW) + *flags |= SfMayBlock; +} + +POST(sys_fcntl) +{ + vg_assert(SUCCESS); + if (ARG2 == VKI_F_DUPFD) { + if (!ML_(fd_allowed)(RES, "fcntl(DUPFD)", tid, True)) { + VG_(close)(RES); + SET_STATUS_Failure( VKI_EMFILE ); + } else { + if (VG_(clo_track_fds)) + ML_(record_fd_open_named)(tid, RES); + } + } +} + #undef PRE #undef POST @@ -3167,7 +3221,7 @@ GENXY(__NR_dup2, sys_dup2), // 90 // unimpl getdopt 91 -// GENXY(__NR_fcntl, sys_fcntl), // 92 + BSDXY(__NR_fcntl, sys_fcntl), // 92 GENX_(__NR_select, sys_select), // 93 // unimpl setdopt 94 GENX_(__NR_fsync, sys_fsync), // 95