From patchwork Fri Jul 1 16:26:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Boca X-Patchwork-Id: 643142 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 3rh2GN2Lt3z9sxR for ; Sat, 2 Jul 2016 02:40:12 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 9B50610BE6; Fri, 1 Jul 2016 09:40:08 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 19C2310B97 for ; Fri, 1 Jul 2016 09:40:07 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id A3BE0162BF0 for ; Fri, 1 Jul 2016 10:40:06 -0600 (MDT) X-ASG-Debug-ID: 1467391204-0b32373fc615d5e0001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar6.cudamail.com with ESMTP id rT1kCmqAjdFJPnMx (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Fri, 01 Jul 2016 10:40:05 -0600 (MDT) X-Barracuda-Envelope-From: pboca@cloudbasesolutions.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO cbssmtp1.cloudbase.local) (91.232.152.5) by mx1-pf1.cudamail.com with SMTP; 1 Jul 2016 16:40:04 -0000 Received-SPF: pass (mx1-pf1.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 9B9F441826 for ; Fri, 1 Jul 2016 19:40:03 +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 dLAP-d1g8pcL for ; Fri, 1 Jul 2016 19:39:43 +0300 (EEST) Received: from CBSEX1.cloudbase.local (unknown [10.77.78.3]) by cbssmtp1.cloudbase.local (Postfix) with ESMTP id DEDAD41858 for ; Fri, 1 Jul 2016 19:26:59 +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; Fri, 1 Jul 2016 18:26:59 +0200 X-CudaMail-Envelope-Sender: pboca@cloudbasesolutions.com From: Paul Boca To: "dev@openvswitch.org" X-CudaMail-MID: CM-E1-630038247 X-CudaMail-DTE: 070116 X-CudaMail-Originating-IP: 91.232.152.5 Thread-Topic: [PATCH V5 05/17] python tests: Added fcntl module for Windows X-ASG-Orig-Subj: [##CM-E1-630038247##][PATCH V5 05/17] python tests: Added fcntl module for Windows Thread-Index: AQHR07Vkk9JTkdE78kqWDN1xxM8+KQ== Date: Fri, 1 Jul 2016 16:26:59 +0000 Message-ID: <1467390322-12852-6-git-send-email-pboca@cloudbasesolutions.com> References: <1467390322-12852-1-git-send-email-pboca@cloudbasesolutions.com> In-Reply-To: <1467390322-12852-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-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1467391205 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 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.30926 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 V5 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 --- 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)