From patchwork Wed Jul 6 12:38:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Boca X-Patchwork-Id: 645271 X-Patchwork-Delegate: guru@ovn.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3rl0h92qfzz9sRZ for ; Wed, 6 Jul 2016 22:39:53 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id A3A6E109FC; Wed, 6 Jul 2016 05:39:52 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e3.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 3F99D109DA for ; Wed, 6 Jul 2016 05:39:51 -0700 (PDT) Received: from bar5.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id C3FA94202B4 for ; Wed, 6 Jul 2016 06:39:50 -0600 (MDT) X-ASG-Debug-ID: 1467808789-09eadd1b18105c40001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar5.cudamail.com with ESMTP id n9zp4PYcf6lSvNbC (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 06 Jul 2016 06:39:49 -0600 (MDT) X-Barracuda-Envelope-From: pboca@cloudbasesolutions.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO cbssmtp1.cloudbase.local) (91.232.152.5) by mx1-pf2.cudamail.com with SMTP; 6 Jul 2016 12:39:48 -0000 Received-SPF: pass (mx1-pf2.cudamail.com: SPF record at cloudbasesolutions.com designates 91.232.152.5 as permitted sender) X-Barracuda-Apparent-Source-IP: 91.232.152.5 X-Barracuda-RBL-IP: 91.232.152.5 Received: from localhost (localhost [127.0.0.1]) by cbssmtp1.cloudbase.local (Postfix) with ESMTP id DA400404DF for ; Wed, 6 Jul 2016 15:39:46 +0300 (EEST) X-Virus-Scanned: amavisd-new at cloudbasesolutions.com Received: from cbssmtp1.cloudbase.local ([127.0.0.1]) by localhost (cbssmtp1.cloudbase.local [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GUSrYIfbY05K for ; Wed, 6 Jul 2016 15:39:26 +0300 (EEST) Received: from CBSEX1.cloudbase.local (unknown [10.77.78.3]) by cbssmtp1.cloudbase.local (Postfix) with ESMTP id 983664010C for ; Wed, 6 Jul 2016 15:38:27 +0300 (EEST) Received: from CBSEX1.cloudbase.local ([10.77.78.3]) by CBSEX1.cloudbase.local ([10.77.78.3]) with mapi id 14.03.0301.000; Wed, 6 Jul 2016 14:38:27 +0200 X-CudaMail-Envelope-Sender: pboca@cloudbasesolutions.com From: Paul Boca To: "dev@openvswitch.org" X-CudaMail-MID: CM-E2-705012039 X-CudaMail-DTE: 070616 X-CudaMail-Originating-IP: 91.232.152.5 Thread-Topic: [PATCH V6 05/17] python tests: Added fcntl module for Windows X-ASG-Orig-Subj: [##CM-E2-705012039##][PATCH V6 05/17] python tests: Added fcntl module for Windows Thread-Index: AQHR14NKqQRQOPzfPkGjDByt9j/BYQ== Date: Wed, 6 Jul 2016 12:38:26 +0000 Message-ID: <1467808691-17280-6-git-send-email-pboca@cloudbasesolutions.com> References: <1467808691-17280-1-git-send-email-pboca@cloudbasesolutions.com> In-Reply-To: <1467808691-17280-1-git-send-email-pboca@cloudbasesolutions.com> Accept-Language: en-US, it-IT Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.77.78.1] MIME-Version: 1.0 X-GBUdb-Analysis: 0, 91.232.152.5, Ugly c=0.237282 p=-0.6 Source Normal X-MessageSniffer-Rules: 0-0-0-6163-c X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1467808789 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 1.60 X-Barracuda-Spam-Status: No, SCORE=1.60 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC0_MV0713, BSF_SC0_MV0713_3, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.31058 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC0_MV0713 Custom rule MV0713 1.00 BSF_SC0_MV0713_3 BSF_SC0_MV0713_3 Subject: [ovs-dev] [PATCH V6 05/17] python tests: Added fcntl module for Windows X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@openvswitch.org Sender: "dev" This is needed for lockf function used to lock the PID file on Windows. ioctl and fcntl functions are not implemented at this time because they are not used by any script. Signed-off-by: Paul-Daniel Boca --- V2: No changes V3: No changes V4: No changes V5: No changes V6: No changes --- python/automake.mk | 1 + python/ovs/fcntl_win.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 python/ovs/fcntl_win.py diff --git a/python/automake.mk b/python/automake.mk index ecad39d..1c8fa38 100644 --- a/python/automake.mk +++ b/python/automake.mk @@ -11,6 +11,7 @@ ovstest_pyfiles = \ ovs_pyfiles = \ python/ovs/__init__.py \ python/ovs/daemon.py \ + python/ovs/fcntl_win.py \ python/ovs/db/__init__.py \ python/ovs/db/data.py \ python/ovs/db/error.py \ diff --git a/python/ovs/fcntl_win.py b/python/ovs/fcntl_win.py new file mode 100644 index 0000000..cf48aaa --- /dev/null +++ b/python/ovs/fcntl_win.py @@ -0,0 +1,36 @@ +import errno +import win32con +import win32file +import pywintypes +import msvcrt + +LOCK_EX = win32con.LOCKFILE_EXCLUSIVE_LOCK +LOCK_SH = 0 # the default +LOCK_NB = win32con.LOCKFILE_FAIL_IMMEDIATELY +LOCK_UN = 0x80000000 # unlock - non-standard + +def fcntl(fd, op, arg=0): + # not implemented yet on Windows + return 0 + +def ioctl(fd, op, arg=0, mutable_flag=True): + # not implemented yet on Windows + if mutable_flag: + return 0 + else: + return "" + +def lockf(fd, flags, length=0xFFFF0000, start=0, whence=0): + file_name = fd.name + overlapped = pywintypes.OVERLAPPED() + hfile = msvcrt.get_osfhandle(fd.fileno()) + if LOCK_UN & flags: + ret = win32file.UnlockFileEx(hfile, 0, start, length, overlapped) + else: + try: + ret = win32file.LockFileEx(hfile, flags, start, length, overlapped) + except: + raise IOError(errno.EAGAIN, "", "") + +def flock(fd, flags): + lockf(fd, flags, 0xFFFF0000, 0, 0)