fpc/tests/tbs/tb0561a.pp
Jonas Maebe 53ad1bcabe * fixed linux flock type by defining and using a kernel_off_t type
whose size depends on whether the run time environment is 32 or
    64 bit (mantis #13647)
  + added flock64 type for 32 bit systems (usable with special 64 bit
    fcntl operations)

git-svn-id: trunk@13119 -
2009-05-09 19:47:59 +00:00

32 lines
662 B
ObjectPascal

{ %norun }
{ %target=linux }
program test;
{$mode delphi}{$H+}
Uses cthreads, Classes, SysUtils, BaseUnix;
Const Fn = '/tmp/fpctest.lock';
F_RDLCK = 0;
F_WRLCK = 1;
F_UNLCK = 2;
Var F, I : Integer;
Region : FLock;
Begin
F := FpOpen (Fn, O_RDWR Or O_CREAT, $1B6); // $1B6 = o666
With Region Do Begin
l_type := F_RDLCK; l_whence := SEEK_SET;
l_start := 80; l_len := 1
End;
If FpFcntl (F, F_SETLK, Region) = -1 Then
begin
writeln(fpgeterrno);
WriteLn ('unable to apply readlock on 80'); // <-- Error
halt(1);
end;
FpClose (F);
End.