* Updated PDir to BSD libc layout. (which is totally different from Linux)

This commit is contained in:
marco 2000-04-16 16:08:30 +00:00
parent 4b6a9896bf
commit 59e9da20d8

View File

@ -1,161 +1,177 @@
{ {
$Id$ $Id$
This file is part of the Free Pascal run time library. This file is part of the Free Pascal run time library.
Copyright (c) 1999-2000 by Michael Van Canneyt, Copyright (c) 1999-2000 by Michael Van Canneyt,
member of the Free Pascal development team. member of the Free Pascal development team.
See the file COPYING.FPC, included in this distribution, See the file COPYING.FPC, included in this distribution,
for details about the copyright. for details about the copyright.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************} **********************************************************************}
type type
{ {
Linux system calls take arguments as follows : Linux system calls take arguments as follows :
i386/m68k: i386/m68k:
%eax/%d0 : System call number %eax/%d0 : System call number
%ebx/%d1 : first argument %ebx/%d1 : first argument
%ecx/%d2 : second argument %ecx/%d2 : second argument
%edx/%d3 : third argumens %edx/%d3 : third argumens
%esi/%d3 : fourth argument %esi/%d3 : fourth argument
%edi/%d4 : fifth argument %edi/%d4 : fifth argument
That is why we define a special type, with only these arguments That is why we define a special type, with only these arguments
To make it processor independent, we don't give any system dependent To make it processor independent, we don't give any system dependent
names, but the rather abstract reg1,reg2 etc; names, but the rather abstract reg1,reg2 etc;
} }
SysCallRegs=record SysCallRegs=record
reg1,reg2,reg3,reg4,reg5,reg6 : longint; reg1,reg2,reg3,reg4,reg5,reg6 : longint;
end; end;
PSysCallRegs=^SysCallRegs; PSysCallRegs=^SysCallRegs;
TSysCallRegs=SysCallRegs; TSysCallRegs=SysCallRegs;
{ The following are records for system calls BSD updated } { The following are records for system calls BSD updated }
dirent = packed record dirent = packed record
ino : cardinal; { This is not inode number, but "a number ino : cardinal; { This is not inode number, but "a number
unique for each file on a filesystem"} unique for each file on a filesystem"}
reclen : word; reclen : word;
d_type, d_type,
namlen : byte; namlen : byte;
name : array [0..255] of char; name : array [0..255] of char;
end; end;
pdirent =^dirent; pdirent =^dirent;
TDirEnt = dirent; TDirEnt = dirent;
TDir = packed record TDir= packed record {BSD libc record.}
fd : longint; fd : longint; { file descriptor associated with directory }
loc : longint; loc, { offset in current buffer }
size : integer; size : cardinal; { amount of data returned by getdirentries}
buf : pdirent; buf : pdirent; { data buffer, actually a pchar}
{The following are used in libc, but NOT in the linux kernel sources ??} len : longint; { size of data buffer }
nextoff: longint; seek, { magic cookie returned by getdirentries}
dd_max : integer; {size of buf. Irrelevant, as buf is of type dirent} rewind: cardinal; { magic cookie for rewinding}
lock : pointer; flags : longint; { flags for readdir }
dummy : array[0..1023] of char; end;
end;
PDir =^TDir; { Linux kernel record
TDir = packed record
{$packrecords C} fd : longint;
Stat =record {BSD version} loc : longint;
dev, { inode's device } size : integer;
ino : cardinal; { inode's number } buf : pdirent;
mode, { inode protection mode } {The following are used in libc, but NOT in the linux kernel sources ??}
nlink : word; { number of hard links } nextoff: longint;
uid, { user ID of the file's owner } dd_max : integer; {size of buf. Irrelevant, as buf is of type dirent}
gid, { group ID of the file's group } lock : pointer;
dev_t : cardinal; { device type } dummy : array[0..1023] of char;
atime, { time of last access } end;}
atime_nsec, { nsec of last access }
mtime, { time of last data modification } PDir =^TDir;
mtime_nsec, { nsec of last data modification }
ctime, { time of last file status change } {$packrecords C}
ctime_nsec : longint; { nsec of last file status change } Stat =record {BSD version}
size, { file size, in bytes } dev, { inode's device }
blocks : Int64; { blocks allocated for file } ino : cardinal; { inode's number }
blksze, { optimal blocksize for I/O } mode, { inode protection mode }
flags, { user defined flags for file } nlink : word; { number of hard links }
filegen : cardinal; { file generation number } uid, { user ID of the file's owner }
lspare : longint; gid, { group ID of the file's group }
qspare : array[0..1] of int64; dev_t : cardinal; { device type }
end; atime, { time of last access }
atime_nsec, { nsec of last access }
PStat=^Stat; mtime, { time of last data modification }
TStat=Stat; mtime_nsec, { nsec of last data modification }
ctime, { time of last file status change }
Statfs = packed record ctime_nsec : longint; { nsec of last file status change }
spare2, { place holder} size, { file size, in bytes }
bsize, { fundamental block size} blocks : Int64; { blocks allocated for file }
iosize, { optimal block size } blksze, { optimal blocksize for I/O }
blocks, { total blocks} flags, { user defined flags for file }
bfree, { blocks free} filegen : cardinal; { file generation number }
bavail, { block available for mortal users} lspare : longint;
files, { Total file nodes} qspare : array[0..1] of int64;
ffree : longint; { file nodes free} end;
fsid : array[0..1] of longint;
fowner : longint; {mounter uid} PStat=^Stat;
ftype : longint; TStat=Stat;
fflags : longint; {copy of mount flags}
spare : array [0..1] of longint; { For later use } Statfs = packed record
fstypename : array[0..15] of char; spare2, { place holder}
mountpoint : array[0..89] of char; bsize, { fundamental block size}
mnfromname : array[0..89] of char; iosize, { optimal block size }
end; blocks, { total blocks}
PStatFS=^StatFS; bfree, { blocks free}
TStatFS=StatFS; bavail, { block available for mortal users}
files, { Total file nodes}
fdSet=array[0..7] of longint;{=256 bits} ffree : longint; { file nodes free}
pfdset=^fdset; fsid : array[0..1] of longint;
TFDSet=fdset; fowner : longint; {mounter uid}
ftype : longint;
timeval = packed record fflags : longint; {copy of mount flags}
sec,usec:int64; spare : array [0..1] of longint; { For later use }
end; fstypename : array[0..15] of char;
ptimeval=^timeval; mountpoint : array[0..89] of char;
TTimeVal=timeval; mnfromname : array[0..89] of char;
end;
timezone = packed record PStatFS=^StatFS;
minuteswest,dsttime:longint; TStatFS=StatFS;
end;
ptimezone =^timezone; fdSet=array[0..7] of longint;{=256 bits}
TTimeZone = timezone; pfdset=^fdset;
TFDSet=fdset;
utsname = packed record
sysname, timeval = packed record
nodename, sec,usec:int64;
release, end;
version, ptimeval=^timeval;
machine, TTimeVal=timeval;
domainname : Array[0..64] of char;
end; timezone = packed record
PUTSName=^UTSName; minuteswest,dsttime:longint;
TUTSName=UTSName; end;
ptimezone =^timezone;
{ TTimeZone = timezone;
utsname = packed record
sysname,
nodename,
release,
version,
machine,
domainname : Array[0..64] of char;
end;
PUTSName=^UTSName;
TUTSName=UTSName;
{
$Log$ $Log$
Revision 1.7 2000-04-10 15:46:52 marco Revision 1.8 2000-04-16 16:08:30 marco
* Updated PDir to BSD libc layout. (which is totally different from Linux)
Revision 1.7 2000/04/10 15:46:52 marco
* worked all day. probably a lot changed * worked all day. probably a lot changed
Revision 1.5 2000/03/17 12:58:57 marco Revision 1.5 2000/03/17 12:58:57 marco
* some changes to ftruncate based procs. Added a "0" as extra parameter * some changes to ftruncate based procs. Added a "0" as extra parameter
Revision 1.4 2000/02/04 16:55:47 marco Revision 1.4 2000/02/04 16:55:47 marco
* Fixed tdir, some params need to be 32-bit * Fixed tdir, some params need to be 32-bit
Revision 1.3 2000/02/03 17:05:55 marco Revision 1.3 2000/02/03 17:05:55 marco
* Some types fixed/ported. * Some types fixed/ported.
Revision 1.2 2000/02/02 16:45:38 marco Revision 1.2 2000/02/02 16:45:38 marco
* Typo in STAT record * Typo in STAT record
Revision 1.1 2000/02/02 16:36:09 marco Revision 1.1 2000/02/02 16:36:09 marco
* Initial version. Copy of linux version, with BSD stat. * Initial version. Copy of linux version, with BSD stat.
} }