2
$Id: sysutils.pp,v 1.59 2005/03/25 22:53:39 jonas Exp $
3
This file is part of the Free Pascal run time library.
4
Copyright (c) 1999-2000 by Florian Klaempfl
5
member of the Free Pascal development team
7
Sysutils unit for linux
9
See the file COPYING.FPC, included in this distribution,
10
for details about the copyright.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
**********************************************************************}
20
KernelUUID = '/proc/sys/kernel/random/uuid';
23
Procedure GetURandomBytes(Var Buf; NBytes : Integer);
31
fd:=FileOpen('/dev/urandom',fmOpenRead);
36
I:=FileRead(fd,P^,nbytes);
47
GetRandomBytes(Buf,NBytes);
51
Function CreateKernelGUID(Var GUID : TGUID) : Boolean;
61
fd:=FileOpen(KernelUUID,fmOpenRead);
66
SetLength(S,FileRead(fd,S[1],UUIDLen));
67
Result:=(Length(S)=UUIDLen);
70
GUID:=StringToGUID('{'+S+'}');
71
//Writeln('Kernel ID = ',GuidToString(GUID));
76
Function SysCreateGUID(out GUID : TGUID) : Integer;
79
if not CreateKernelGUID(Guid) then
80
GetRandomBytes(GUID,SizeOf(Guid));