diff options
author | Guido van Rossum <guido@python.org> | 1996-07-30 16:28:45 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1996-07-30 16:28:45 (GMT) |
commit | 7698d12a8bb3a5b42d89843fd17a8caa8d4153cc (patch) | |
tree | a9b1564a08f09ce7076ab24b8ee8520ed3e593c3 /Lib | |
parent | f17361d314f118610d6e9ad4ca603350fc986abb (diff) | |
download | cpython-7698d12a8bb3a5b42d89843fd17a8caa8d4153cc.zip cpython-7698d12a8bb3a5b42d89843fd17a8caa8d4153cc.tar.gz cpython-7698d12a8bb3a5b42d89843fd17a8caa8d4153cc.tar.bz2 |
Changes to make it work on FreeBSD 2.x.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/posixfile.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Lib/posixfile.py b/Lib/posixfile.py index 459cd52..64cda98 100644 --- a/Lib/posixfile.py +++ b/Lib/posixfile.py @@ -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 |