mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 20:49:23 +02:00
* hopefully final fix to unix locking: specifying no locking mode again
means "exclusive lock" where supported (not on Solaris when opening a file in read-only mode) git-svn-id: trunk@12675 -
This commit is contained in:
parent
adaae268ae
commit
6581c8dec5
@ -185,12 +185,26 @@ begin
|
|||||||
{$ifndef beos}
|
{$ifndef beos}
|
||||||
if (Handle>=0) then
|
if (Handle>=0) then
|
||||||
begin
|
begin
|
||||||
case (mode and (fmShareCompat or fmShareExclusive or fmShareDenyWrite or fmShareDenyRead)) of
|
{$ifdef solaris}
|
||||||
|
{ Solaris' flock is based on top of fcntl, which does not allow
|
||||||
|
exclusive locks for files only opened for reading nor shared
|
||||||
|
locks for files opened only for writing
|
||||||
|
}
|
||||||
|
if ((mode and (fmShareCompat or fmShareExclusive or fmShareDenyWrite or fmShareDenyRead)) = 0) then
|
||||||
|
begin
|
||||||
|
mode := mode and not(fmShareCompat);
|
||||||
|
if ((mode and (fmOpenRead or fmOpenWrite or fmOpenReadWrite)) = fmOpenWrite) then
|
||||||
|
mode := mode or fmShareExclusive
|
||||||
|
else
|
||||||
|
mode := mode or fmShareDenyWrite;
|
||||||
|
end;
|
||||||
|
{$endif solaris}
|
||||||
|
case (mode and (fmShareCompat or fmShareExclusive or fmShareDenyWrite or fmShareDenyRead or fmShareDenyNone)) of
|
||||||
|
fmShareCompat,
|
||||||
fmShareExclusive:
|
fmShareExclusive:
|
||||||
lockop:=LOCK_EX or LOCK_NB;
|
lockop:=LOCK_EX or LOCK_NB;
|
||||||
fmShareDenyWrite:
|
fmShareDenyWrite:
|
||||||
lockop:=LOCK_SH or LOCK_NB;
|
lockop:=LOCK_SH or LOCK_NB;
|
||||||
fmShareCompat,
|
|
||||||
fmShareDenyNone:
|
fmShareDenyNone:
|
||||||
exit;
|
exit;
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user