Update of /cvsroot/libsysio/libsysio/src
In directory sc8-pr-cvs1:/tmp/cvs-serv4984/src
Modified Files:
stat.c
Log Message:
A struct stat and a struct sts64 don't quite match up with the field offsets.
I had thought otherwise. Now, we convert between the two.
Index: stat.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/stat.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -b -B -p -r1.6 -r1.7
--- stat.c 20 Oct 2003 17:15:38 -0000 1.6
+++ stat.c 24 Oct 2003 18:49:24 -0000 1.7
@@ -66,8 +66,25 @@
#define _STAT_VER 0
#endif
-#if 0 && !(defined(__GLIBC__) && __GLIBC__ >= 2)
-#warning Check assumptions here about stat/stat64 sizes and offsets
+#if _LARGEFILE64_SOURCE
+static void
+convstat(struct stat64 *st64_buf, struct stat *st_buf)
+{
+
+ st_buf->st_dev = st64_buf->st_dev;
+ st_buf->st_ino = st64_buf->st_ino;
+ st_buf->st_mode = st64_buf->st_mode;
+ st_buf->st_nlink = st64_buf->st_nlink;
+ st_buf->st_uid = st64_buf->st_uid;
+ st_buf->st_gid = st64_buf->st_gid;
+ st_buf->st_rdev = st64_buf->st_rdev;
+ st_buf->st_size = st64_buf->st_size;
+ st_buf->st_blksize = st64_buf->st_blksize;
+ st_buf->st_blocks = st64_buf->st_blocks;
+ st_buf->st_atime = st64_buf->st_atime;
+ st_buf->st_mtime = st64_buf->st_mtime;
+ st_buf->st_ctime = st64_buf->st_ctime;
+}
#endif
int
@@ -75,6 +92,10 @@ __fxstat(int __ver, int __fildes, struct
{
struct file *fil;
int err;
+ struct intnl_stat *buf;
+#if _LARGEFILE64_SOURCE
+ struct stat64 st64;
+#endif
if (__ver != _STAT_VER) {
err = -ENOSYS;
@@ -87,15 +108,21 @@ __fxstat(int __ver, int __fildes, struct
err = -EBADF;
goto out;
}
+#if _LARGEFILE64_SOURCE
+ buf = &st64;
+#else
+ buf = __stat_buf;
+#endif
err =
- fil->f_ino->i_ops.inop_getattr(NULL,
- fil->f_ino,
- (struct intnl_stat *)__stat_buf);
+ fil->f_ino->i_ops.inop_getattr(NULL, fil->f_ino, buf);
out:
if (err) {
errno = -err;
err = -1;
}
+#if _LARGEFILE64_SOURCE
+ convstat(buf, __stat_buf);
+#endif
return err;
}
@@ -120,6 +147,10 @@ __xstat(int __ver, const char *__filenam
int err;
struct pnode *pno;
struct inode *ino;
+ struct intnl_stat *buf;
+#if _LARGEFILE64_SOURCE
+ struct stat64 st64;
+#endif
if (__ver != _STAT_VER) {
err = -ENOSYS;
@@ -131,11 +162,19 @@ __xstat(int __ver, const char *__filenam
if (err)
goto out;
ino = pno->p_base->pb_ino;
+#if _LARGEFILE64_SOURCE
+ buf = &st64;
+#else
+ buf = __stat_buf;
+#endif
err =
ino->i_ops.inop_getattr(pno,
pno->p_base->pb_ino,
- (struct intnl_stat *)__stat_buf);
+ buf);
P_RELE(pno);
+#if _LARGEFILE64_SOURCE
+ convstat(buf, __stat_buf);
+#endif
out:
if (err) {
errno = -err;
@@ -165,6 +204,10 @@ __lxstat(int __ver, const char *__filena
int err;
struct pnode *pno;
struct inode *ino;
+ struct intnl_stat *buf;
+#if _LARGEFILE64_SOURCE
+ struct stat64 st64;
+#endif
if (__ver != _STAT_VER) {
err = -ENOSYS;
@@ -175,12 +218,20 @@ __lxstat(int __ver, const char *__filena
err = _sysio_namei(_sysio_cwd, __filename, ND_NOFOLLOW, &intent, &pno);
if (err)
goto out;
+#if _LARGEFILE64_SOURCE
+ buf = &st64;
+#else
+ buf = __stat_buf;
+#endif
ino = pno->p_base->pb_ino;
err =
ino->i_ops.inop_getattr(pno,
pno->p_base->pb_ino,
- (struct intnl_stat *)__stat_buf);
+ buf);
P_RELE(pno);
+#if _LARGEFILE64_SOURCE
+ convstat(buf, __stat_buf);
+#endif
out:
if (err) {
errno = -err;
|