]> granicus.if.org Git - python/commitdiff
Changes to make it work on FreeBSD 2.x.
authorGuido van Rossum <guido@python.org>
Tue, 30 Jul 1996 16:28:45 +0000 (16:28 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 30 Jul 1996 16:28:45 +0000 (16:28 +0000)
Lib/posixfile.py

index 459cd520784eef1363233e6d8ba1a8a55731cbd4..64cda986223f373a1cc10d43c712e67dd1ef55ec 100644 (file)
@@ -174,12 +174,25 @@ class _posixfile_:
        elif len(args) > 3:
            raise TypeError, 'too many arguments'
 
-       flock = struct.pack('hhllhh', l_type, l_whence, l_start, l_len, 0, 0)
+       # Hack by davem@magnet.com to get locking to go on freebsd
+        import sys, os
+        if sys.platform == 'freebsd2':
+           flock = struct.pack('lxxxxlxxxxlhh', \
+                 l_start, l_len, os.getpid(), l_type, l_whence) 
+       else:
+           flock = struct.pack('hhllhh', \
+                 l_type, l_whence, l_start, l_len, 0, 0)
+
        flock = fcntl.fcntl(self._file_.fileno(), cmd, flock)
 
        if '?' in how:
-           l_type, l_whence, l_start, l_len, l_sysid, l_pid = \
-               struct.unpack('hhllhh', flock)
+           if sys.platform == 'freebsd2':
+               l_start, l_len, l_pid, l_type, l_whence = \
+                   struct.unpack('lxxxxlxxxxlhh', flock)
+           else:
+               l_type, l_whence, l_start, l_len, l_sysid, l_pid = \
+                   struct.unpack('hhllhh', flock)
+
            if l_type != FCNTL.F_UNLCK:
                if l_type == FCNTL.F_RDLCK:
                    return 'r', l_len, l_start, l_whence, l_pid