Browse Source

+ Restore "stat" data structure in backward compatible state

git-svn-id: trunk@6963 -
daniel 18 năm trước cách đây
mục cha
commit
d030103742
6 tập tin đã thay đổi với 324 bổ sung146 xóa
  1. 53 22
      rtl/bsd/ostypes.inc
  2. 99 42
      rtl/linux/i386/stat.inc
  3. 41 20
      rtl/linux/m68k/stat.inc
  4. 43 20
      rtl/linux/powerpc/stat.inc
  5. 43 21
      rtl/linux/x86_64/stat.inc
  6. 45 21
      rtl/solaris/ostypes.inc

+ 53 - 22
rtl/bsd/ostypes.inc

@@ -59,34 +59,65 @@ TYPE
 
   { file characteristics services }
    stat    = record { the types are real}
-        st_dev        : dev_t;             // inode's device
-        st_ino        : ino_t;             // inode's number
-        st_mode       : mode_t;            // inode protection mode
-        st_nlink      : nlink_t;           // number of hard links
-        st_uid        : uid_t;             // user ID of the file's owner
-        st_gid        : gid_t;             // group ID of the file's group
-        st_rdev       : dev_t;             // device type
-        st_atime      : time_t;            // time of last access
-        st_atimensec  : clong;             // nsec of last access
-        st_mtime      : time_t;            // time of last data modification
-        st_mtimensec  : clong;             // nsec of last data modification
-        st_ctime      : time_t;            // time of last file status change
-        st_ctimensec  : clong;             // nsec of last file status change
+     case byte of
+       0:
+         (dev        : dev_t;            // inode's device
+         ino        : ino_t;             // inode's number
+         mode       : mode_t;            // inode protection mode
+         nlink      : nlink_t;           // number of hard links
+         uid        : uid_t;             // user ID of the file's owner
+         gid        : gid_t;             // group ID of the file's group
+         rdev       : dev_t;             // device type
+         atime      : time_t;            // time of last access
+         atimensec  : clong;             // nsec of last access
+         mtime      : time_t;            // time of last data modification
+         mtimensec  : clong;             // nsec of last data modification
+         ctime      : time_t;            // time of last file status change
+         ctimensec  : clong;             // nsec of last file status change
 {$ifdef netbsdPowerpc}
-        st_padd1              : cint;
+         padd1              : cint;
 {$endif}
-        st_size       : off_t;             // file size, in bytes
-        st_blocks     : cint64;            // blocks allocated for file
-        st_blksize    : cuint32;           // optimal blocksize for I/O
-        st_flags      : cuint32;           // user defined flags for file
-        st_gen        : cuint32;           // file generation number
+         size       : off_t;             // file size, in bytes
+         blocks     : cint64;            // blocks allocated for file
+         blksize    : cuint32;           // optimal blocksize for I/O
+         flags      : cuint32;           // user defined flags for file
+         gen        : cuint32;           // file generation number
 {$ifdef netbsdPowerpc}
-        st_padd2              : cint;
+         padd2              : cint;
 {$endif}
 {$ifndef NetBSD}
-        st_lspare     : cint32;
+         lspare     : cint32;
 {$endif}
-        st_qspare     : array[0..1] Of cint64;
+         qspare     : array[0..1] Of cint64;);
+       1:
+         (st_dev        : dev_t;            // inode's device
+         st_ino        : ino_t;             // inode's number
+         st_mode       : mode_t;            // inode protection mode
+         st_nlink      : nlink_t;           // number of hard links
+         st_uid        : uid_t;             // user ID of the file's owner
+         st_gid        : gid_t;             // group ID of the file's group
+         st_rdev       : dev_t;             // device type
+         st_atime      : time_t;            // time of last access
+         st_atimensec  : clong;             // nsec of last access
+         st_mtime      : time_t;            // time of last data modification
+         st_mtimensec  : clong;             // nsec of last data modification
+         st_ctime      : time_t;            // time of last file status change
+         st_ctimensec  : clong;             // nsec of last file status change
+{$ifdef netbsdPowerpc}
+         st_padd1              : cint;
+{$endif}
+         st_size       : off_t;             // file size, in bytes
+         st_blocks     : cint64;            // blocks allocated for file
+         st_blksize    : cuint32;           // optimal blocksize for I/O
+         st_flags      : cuint32;           // user defined flags for file
+         st_gen        : cuint32;           // file generation number
+{$ifdef netbsdPowerpc}
+         st_padd2              : cint;
+{$endif}
+{$ifndef NetBSD}
+         st_lspare     : cint32;
+{$endif}
+         st_qspare     : array[0..1] Of cint64;);
    end;
    TStat = stat;
    pStat = ^stat;

+ 99 - 42
rtl/linux/i386/stat.inc

@@ -15,63 +15,120 @@
 {$ifndef FPC_USE_LIBC} // kernel record
 
   Stat = packed record  // No unix typing because of differences
-    st_dev    : culonglong;
-    __pad0    : array[0..3] of cuchar;
-    __st_ino  : culong;
-    st_mode   : cuint;
-    st_nlink  : cuint;
-    st_uid    : culong;
-    st_gid    : culong;
-    st_rdev   : culonglong;
-    __pad3    : array[0..3] of cuchar;
-    st_size   : culonglong;
-    st_blksize: culong;
-    st_blocks : culonglong;
-    st_atime  : culong;
-    st_atime_nsec : culong;
-    st_mtime  : culong;
-    st_mtime_nsec : cuint;
-    st_ctime  : culong;
-    st_ctime_nsec : culong;
-    st_ino    : culonglong;
+    case byte of
+      0:
+        (dev    : qword;
+        __pad0  : array[0..3] of byte;
+        __ino,
+        mode,
+        nlink,
+        uid,
+        gid     : cardinal;
+        rdev    : qword;
+        __pad3  : array[0..3] of byte;
+        size    : qword;
+        blksize : cardinal;
+        blocks  : qword;
+        atime,
+        atime_nsec,
+        mtime,
+        mtime_nsec,
+        ctime,
+        ctime_nsec : cardinal;
+        ino    : qword);
+      1:
+        (st_dev   : qword;
+        __pad0_   : array[0..3] of byte;
+        __st_ino_,
+        st_mode,
+        st_nlink,
+        st_uid,
+        st_gid    : cardinal;
+        st_rdev   : qword;
+        __pad3_   : array[0..3] of byte;
+        st_size   : qword;
+        st_blksize: cardinal;
+        st_blocks : qword;
+        st_atime,
+        st_atime_nsec,
+        st_mtime,
+        st_mtime_nsec,
+        st_ctime,
+        st_ctime_nsec : cardinal;
+        st_ino    : qword);
   end;
 
 {$else}
 
 {$packrecords C}
-  Stat =  Record  // No unix typing because of differences
+  Stat =  Record
+    case byte of
+      0:
                               // kernel <->libc
-    st_dev     : dev_t;
-    pad1       : word;
+        (dev     : dev_t;
+        pad1       : word;
 {$ifdef fs32bit}
-    st_ino     : ino_t;
+        ino     : ino_t;
 {$else}
-    __st_ino   : ino_t;
+        __ino   : ino_t;
 {$endif}    
-    st_mode    : mode_t;
-    st_nlink   : nlink_t;
-    st_uid     : uid_t;
-    st_gid     : gid_t;
-    st_rdev    : dev_t;
-    pad2       : word;
-    st_size    : off_t;
-    st_blksize : blksize_t;
+        mode    : mode_t;
+        nlink   : nlink_t;
+        uid     : uid_t;
+        gid     : gid_t;
+        rdev    : dev_t;
+        pad2       : word;
+        size    : off_t;
+        blksize : blksize_t;
 {$ifdef fs32bit}
-    st_blocks  : blkcnt_t;
+        blocks  : blkcnt_t;
 {$else}    
-    st_blocks  : blkcnt64_t;
+        blocks  : blkcnt64_t;
 {$endif}    
-    st_atime,
-    st_atime_nsec,
-    st_mtime,
-    st_mtime_nsec,
-    st_ctime,
-    st_ctime_nsec : culong;
+        atime,
+        atime_nsec,
+        mtime,
+        mtime_nsec,
+        ctime,
+        ctime_nsec : cardinal;
 {$ifdef fs32bit}
-    unused4, unused5: culong;
+        unused4, unused5: cardinal;
 {$else}    
-    st_ino     : ino64_t;
+        ino     : ino64_t;
+{$endif});
+      1:
+                              // kernel <->libc
+        (st_dev    : dev_t;
+        pad1_      : word;
+{$ifdef fs32bit}
+        st_ino     : ino_t;
+{$else}
+        __st_ino   : ino_t;
+{$endif}    
+        st_mode    : mode_t;
+        st_nlink   : nlink_t;
+        st_uid     : uid_t;
+        st_gid     : gid_t;
+        st_rdev    : dev_t;
+        pad2_       : word;
+        st_size    : off_t;
+        st_blksize : blksize_t;
+{$ifdef fs32bit}
+        st_blocks  : blkcnt_t;
+{$else}    
+        st_blocks  : blkcnt64_t;
 {$endif}    
+        st_atime,
+        st_atime_nsec,
+        st_mtime,
+        st_mtime_nsec,
+        st_ctime,
+        st_ctime_nsec : culong;
+{$ifdef fs32bit}
+        unused4_, unused5_: culong;
+{$else}    
+        st_ino     : ino64_t;
+{$endif});
   end;
 
 

+ 41 - 20
rtl/linux/m68k/stat.inc

@@ -13,24 +13,45 @@
  **********************************************************************}
 
   Stat = packed record  // No unix typing because of differences
-    st_dev    : culonglong;
-    __pad0    : array[0..1] of cuchar;
-    __st_ino  : culong;
-    st_mode   : cuint;
-    st_nlink  : cuint;
-    st_uid    : culong;
-    st_gid    : culong;
-    st_rdev   : culonglong;
-    __pad3    : array[0..1] of cuchar;
-    st_size   : clonglong;
-    st_blksize: culong;
-    st_blocks : culonglong;
-    st_atime  : culong;
-    st_atime_nsec : culong;
-    st_mtime  : culong;
-    st_mtime_nsec : culong;
-    st_ctime  : culong;
-    st_ctime_nsec : culong;
-    st_ino    : culonglong;
+    case byte of
+      0:
+        (dev    : qword;
+        __pad0  : array[0..3] of byte;
+        __ino,
+        mode,
+        nlink,
+        uid,
+        gid     : cardinal;
+        rdev    : qword;
+        __pad3  : array[0..3] of byte;
+        size    : qword;
+        blksize : cardinal;
+        blocks  : qword;
+        atime,
+        atime_nsec,
+        mtime,
+        mtime_nsec,
+        ctime,
+        ctime_nsec : cardinal;
+        ino    : qword);
+      1:
+        (st_dev   : qword;
+        __pad0_   : array[0..3] of byte;
+        __st_ino_,
+        st_mode,
+        st_nlink,
+        st_uid,
+        st_gid    : cardinal;
+        st_rdev   : qword;
+        __pad3_   : array[0..3] of byte;
+        st_size   : qword;
+        st_blksize: cardinal;
+        st_blocks : qword;
+        st_atime,
+        st_atime_nsec,
+        st_mtime,
+        st_mtime_nsec,
+        st_ctime,
+        st_ctime_nsec : cardinal;
+        st_ino    : qword);
   end;
-

+ 43 - 20
rtl/linux/powerpc/stat.inc

@@ -26,26 +26,49 @@
 {$IFNDEF FPC_USE_LIBC}
 
   Stat = record  // No unix typing because of differences
-    st_dev    : culonglong;
-    st_ino    : culonglong;
-    st_mode   : cuint;
-    st_nlink  : cuint;
-    st_uid    : cuint;
-    st_gid    : cuint;
-    st_rdev   : culonglong;
-    __pad2    : cushort;
-    st_size   : clonglong;
-    st_blksize: clong;
-
-    st_blocks : clonglong;
-    st_atime  : clong;
-    st_atime_nsec : culong;
-    st_mtime  : clong;
-    st_mtime_nsec : culong;
-    st_ctime  : clong;
-    __unused3 : culong;
-    __unused4 : culong;
-    __unused5 : culong;
+    case byte of
+      0:
+        (dev    : culonglong;
+        ino    : culonglong;
+        mode   : cuint;
+        nlink  : cuint;
+        uid    : cuint;
+        gid    : cuint;
+        rdev   : culonglong;
+        __pad2 : cushort;
+        size   : clonglong;
+        blksize: clong;
+
+        blocks : clonglong;
+        atime  : clong;
+        atime_nsec : culong;
+        mtime  : clong;
+        mtime_nsec : culong;
+        ctime  : clong;
+        __unused3 : culong;
+        __unused4 : culong;
+        __unused5 : culong;);
+      1:
+        (st_dev    : culonglong;
+        st_ino    : culonglong;
+        st_mode   : cuint;
+        st_nlink  : cuint;
+        st_uid    : cuint;
+        st_gid    : cuint;
+        st_rdev   : culonglong;
+        __pad2_    : cushort;
+        st_size   : clonglong;
+        st_blksize: clong;
+
+        st_blocks : clonglong;
+        st_atime  : clong;
+        st_atime_nsec : culong;
+        st_mtime  : clong;
+        st_mtime_nsec : culong;
+        st_ctime  : clong;
+        __unused3_ : culong;
+        __unused4_ : culong;
+        __unused5_ : culong;);
   end;
 
 {$ELSE FPC_USE_LIBC}

+ 43 - 21
rtl/linux/x86_64/stat.inc

@@ -15,27 +15,49 @@
 {$ifndef FPC_USE_LIBC} // kernel record
 
   stat = packed record  // No unix typing because of differences
-    st_dev    : culong;
-    st_ino    : culong;
-    st_nlink  : culong;
-
-    st_mode   : cuint;
-    st_uid    : cuint;
-    st_gid    : cuint;
-    __pad0    : cuint;
-    st_rdev   : culong;
-    st_size   : clong;
-    st_blksize: clong;
-    st_blocks : clong;
-
-    st_atime  : culong;
-    st_atime_nsec : culong;
-    st_mtime  : culong;
-    st_mtime_nsec : culong;
-    st_ctime  : culong;
-    st_ctime_nsec : culong;
-
-    __unused  : array[0..2] of clong;
+    case byte of
+      0:
+        (dev,
+        ino,
+        nlink  : qword;
+
+        mode,
+        uid,
+        gid,
+        __pad0 : cardinal;
+        rdev   : qword;
+        size,
+        blksize,
+        blocks : int64;
+
+        atime,
+        atime_nsec,
+        mtime,
+        mtime_nsec,
+        ctime,
+        ctime_nsec : qword
+        __unused  : array[0..2] of qword);
+      1:
+        (st_dev,
+        st_ino,
+        st_nlink  : qword;
+
+        st_mode,
+        st_uid,
+        st_gid,
+        __pad0    : cardinal;
+        st_rdev   : qword;
+        st_size,
+        st_blksize,
+        st_blocks : int64;
+
+        st_atime,
+        st_atime_nsec,
+        st_mtime,
+        st_mtime_nsec,
+        st_ctime,
+        st_ctime_nsec : qword;
+        __unused  : array[0..2] of qword;);
   end;
 
 {$else}

+ 45 - 21
rtl/solaris/ostypes.inc

@@ -40,27 +40,51 @@ TYPE
 
    { file characteristics services }
    stat = packed record { verify the alignment of the members }
-     st_dev : dev_t;
-     st_pad1 : array[1..3] of longint;  { reserve for dev expansion }
-     st_ino : ino_t;
-     st_mode : mode_t;
-     st_nlink : nlink_t;
-     st_uid : uid_t;
-     st_gid : gid_t;
-     st_rdev : dev_t;
-     st_pad2 : array[1..2] of longint;
-     st_size : off_t;
-     st_pad3 : longint;   {* reserve pad for future off_t expansion *}
-     st_atime : time_t;
-     st_atimens : longint;    { access time nanosecond field         }
-     st_mtime : time_t;
-     st_mtimens : longint;    { modification time nanosecond field   }
-     st_ctime : time_t;
-     st_ctimens : longint;    { modification time nanosecond field   }
-     st_blksize : blksize_t;
-     st_blocks : blkcnt_t;
-     st_fstype : array[0..ST_FSTYPSZ-1] of char;
-     st_pad4 : array[1..8] of longint;
+     case byte of
+       0:
+         (dev : dev_t;
+         pad1 : array[1..3] of longint;  { reserve for dev expansion }
+         ino : ino_t;
+         mode : mode_t;
+         nlink : nlink_t;
+         uid : uid_t;
+         gid : gid_t;
+         rdev : dev_t;
+         pad2 : array[1..2] of longint;
+         size : off_t;
+         pad3 : longint;   {* reserve pad for future off_t expansion *}
+         atime : time_t;
+         atimens : longint;    { access time nanosecond field         }
+         mtime : time_t;
+         mtimens : longint;    { modification time nanosecond field   }
+         ctime : time_t;
+         ctimens : longint;    { modification time nanosecond field   }
+         blksize : blksize_t;
+         blocks : blkcnt_t;
+         fstype : array[0..ST_FSTYPSZ-1] of char;
+         pad4 : array[1..8] of longint);
+       1:
+         (st_dev : dev_t;
+         st_pad1 : array[1..3] of longint;  { reserve for dev expansion }
+         st_ino : ino_t;
+         st_mode : mode_t;
+         st_nlink : nlink_t;
+         st_uid : uid_t;
+         st_gid : gid_t;
+         st_rdev : dev_t;
+         st_pad2 : array[1..2] of longint;
+         st_size : off_t;
+         st_pad3 : longint;   {* reserve pad for future off_t expansion *}
+         st_atime : time_t;
+         st_atimens : longint;    { access time nanosecond field         }
+         st_mtime : time_t;
+         st_mtimens : longint;    { modification time nanosecond field   }
+         st_ctime : time_t;
+         st_ctimens : longint;    { modification time nanosecond field   }
+         st_blksize : blksize_t;
+         st_blocks : blkcnt_t;
+         st_fstype : array[0..ST_FSTYPSZ-1] of char;
+         st_pad4 : array[1..8] of longint);
    end;
    TStat             = Stat;
    PStat             = ^Stat;