00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #pragma ident "@(#) libf/fio/fstat.c 92.2 08/02/99 10:38:18"
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 #include <stdio.h>
00065 #include <foreign.h>
00066 #include <errno.h>
00067 #include <liberrno.h>
00068 #include <sys/types.h>
00069 #include <sys/stat.h>
00070 #include "fio.h"
00071
00072 extern int __fstat_f90(int *u, int *stbuf);
00073 #ifdef KEY
00074 static _f_int fstatf90_(_f_int *u, _f_int *stbuf);
00075 #else
00076 extern _f_int fstatf90_(_f_int *u, _f_int *stbuf);
00077 #endif
00078 extern int __fstat64_f90(int *u, _f_int8 *stbuf);
00079 extern _f_int fstatf90_4_4_8_(_f_int *u, _f_int8 *stbuf);
00080 extern _f_int8 fstatf90_8_(_f_int8 *u, _f_int8 *stbuf);
00081
00082 #ifdef KEY
00083
00084 int
00085 pathf90_fstat(int *u, int *stbuf, int *status)
00086 {
00087 int junk;
00088 status = (0 == status) ? (&junk) : status;
00089 return *status = fstatf90_(u, stbuf);
00090 }
00091
00092 #endif
00093
00094 int
00095 __fstat_f90(int *u, int *stbuf)
00096 {
00097 return fstatf90_(u,stbuf);
00098 }
00099
00100 #ifdef KEY
00101
00102 static
00103 #endif
00104 _f_int
00105 fstatf90_(_f_int *u, _f_int *stbuf)
00106 {
00107 int n, retval;
00108 unum_t unum;
00109 unit *cup;
00110 struct stat buf;
00111 struct fiostate cfs;
00112
00113 unum = *u;
00114 STMT_BEGIN(unum, 0, T_INQU, NULL, &cfs, cup);
00115
00116 if (cup == NULL && !GOOD_UNUM(unum))
00117 _ferr(&cfs, FEIVUNIT, unum);
00118
00119 if (cup == NULL)
00120 retval = -1;
00121 else if (cup->usysfd == -1)
00122 retval = -1;
00123 else {
00124 n = fstat(cup->usysfd, &buf);
00125 if (n < 0)
00126 _ferr(&cfs, errno);
00127 *stbuf++ = buf.st_dev;
00128 *stbuf++ = buf.st_ino;
00129 *stbuf++ = buf.st_mode;
00130 *stbuf++ = buf.st_nlink;
00131 *stbuf++ = buf.st_uid;
00132 *stbuf++ = buf.st_gid;
00133 *stbuf++ = buf.st_rdev;
00134 *stbuf++ = buf.st_size;
00135 *stbuf++ = buf.st_atime;
00136 *stbuf++ = buf.st_mtime;
00137 *stbuf++ = buf.st_ctime;
00138 *stbuf++ = buf.st_blksize;
00139 #ifdef KEY
00140 *stbuf++ = buf.st_blocks;
00141 #endif
00142 retval = 0;
00143 }
00144
00145 STMT_END(cup, T_INQU, NULL, &cfs);
00146 return(retval);
00147 }
00148
00149 int
00150 __fstat64_f90(int *u, _f_int8 *stbuf)
00151 {
00152 return fstatf90_4_4_8_(u,stbuf);
00153 }
00154
00155 _f_int
00156 fstatf90_4_4_8_(_f_int *u, _f_int8 *stbuf)
00157 {
00158 int n, retval;
00159 unum_t unum;
00160 unit *cup;
00161 #if defined(_LITTLE_ENDIAN) && !defined(__sv2)
00162 struct stat buf;
00163 #else
00164 struct stat64 buf;
00165 #endif
00166 struct fiostate cfs;
00167
00168 unum = *u;
00169 STMT_BEGIN(unum, 0, T_INQU, NULL, &cfs, cup);
00170
00171 if (cup == NULL && !GOOD_UNUM(unum))
00172 _ferr(&cfs, FEIVUNIT, unum);
00173
00174 if (cup == NULL)
00175 retval = -1;
00176 else if (cup->usysfd == -1)
00177 retval = -1;
00178 else {
00179 n = fstat(cup->usysfd, &buf);
00180 if (n < 0)
00181 _ferr(&cfs, errno);
00182 *stbuf++ = buf.st_dev;
00183 *stbuf++ = buf.st_ino;
00184 *stbuf++ = buf.st_mode;
00185 *stbuf++ = buf.st_nlink;
00186 *stbuf++ = buf.st_uid;
00187 *stbuf++ = buf.st_gid;
00188 *stbuf++ = buf.st_rdev;
00189 *stbuf++ = buf.st_size;
00190 *stbuf++ = buf.st_atime;
00191 *stbuf++ = buf.st_mtime;
00192 *stbuf++ = buf.st_ctime;
00193 *stbuf++ = buf.st_blksize;
00194 #ifdef KEY
00195 *stbuf++ = buf.st_blocks;
00196 #endif
00197 retval = 0;
00198 }
00199
00200 STMT_END(cup, T_INQU, NULL, &cfs);
00201 return(retval);
00202 }
00203
00204 _f_int8
00205 fstatf90_8_(_f_int8 *u, _f_int8 *stbuf)
00206 {
00207 int n, retval;
00208 unum_t unum;
00209 unit *cup;
00210 #if defined(_LITTLE_ENDIAN) && !defined(__sv2)
00211 struct stat buf;
00212 #else
00213 struct stat64 buf;
00214 #endif
00215 struct fiostate cfs;
00216
00217 unum = *u;
00218 STMT_BEGIN(unum, 0, T_INQU, NULL, &cfs, cup);
00219
00220 if (cup == NULL && !GOOD_UNUM(unum))
00221 _ferr(&cfs, FEIVUNIT, unum);
00222
00223 if (cup == NULL)
00224 retval = -1;
00225 else if (cup->usysfd == -1)
00226 retval = -1;
00227 else {
00228 n = fstat(cup->usysfd, &buf);
00229 if (n < 0)
00230 _ferr(&cfs, errno);
00231 *stbuf++ = buf.st_dev;
00232 *stbuf++ = buf.st_ino;
00233 *stbuf++ = buf.st_mode;
00234 *stbuf++ = buf.st_nlink;
00235 *stbuf++ = buf.st_uid;
00236 *stbuf++ = buf.st_gid;
00237 *stbuf++ = buf.st_rdev;
00238 *stbuf++ = buf.st_size;
00239 *stbuf++ = buf.st_atime;
00240 *stbuf++ = buf.st_mtime;
00241 *stbuf++ = buf.st_ctime;
00242 *stbuf++ = buf.st_blksize;
00243 #ifdef KEY
00244 *stbuf++ = buf.st_blocks;
00245 #endif
00246 retval = 0;
00247 }
00248
00249 STMT_END(cup, T_INQU, NULL, &cfs);
00250 return( (_f_int8)retval );
00251 }