2004-09-29 Andrew Cagney <cagney@gnu.org>
[deliverable/binutils-gdb.git] / gdb / remote-fileio.c
index 348d637647fa7119fe1f7a362d4c839c46b03865..281872ec6c0900e0dee1260ec497a12a5890d0e3 100644 (file)
@@ -28,6 +28,7 @@
 #include "gdb/fileio.h"
 #include "gdb_wait.h"
 #include "gdb_stat.h"
+#include "remote-fileio.h"
 
 #include <fcntl.h>
 #include <sys/time.h>
@@ -362,12 +363,6 @@ remote_fileio_to_be (LONGEST num, char *buf, int bytes)
     buf[i] = (num >> (8 * (bytes - i - 1))) & 0xff;
 }
 
-static void
-remote_fileio_to_fio_int (long num, fio_int_t fnum)
-{
-  remote_fileio_to_be ((LONGEST) num, (char *) fnum, 4);
-}
-
 static void
 remote_fileio_to_fio_uint (long num, fio_uint_t fnum)
 {
@@ -410,7 +405,16 @@ remote_fileio_to_fio_stat (struct stat *st, struct fio_stat *fst)
   remote_fileio_to_fio_uint ((long) st->st_rdev, fst->fst_rdev);
   remote_fileio_to_fio_ulong ((LONGEST) st->st_size, fst->fst_size);
   remote_fileio_to_fio_ulong ((LONGEST) st->st_blksize, fst->fst_blksize);
+#if HAVE_STRUCT_STAT_ST_BLOCKS
   remote_fileio_to_fio_ulong ((LONGEST) st->st_blocks, fst->fst_blocks);
+#else
+  /* FIXME: This is correct for DJGPP, but other systems that don't
+     have st_blocks, if any, might prefer 512 instead of st_blksize.
+     (eliz, 30-12-2003)  */
+  remote_fileio_to_fio_ulong (((LONGEST) st->st_size + st->st_blksize - 1)
+                             / (LONGEST) st->st_blksize,
+                             fst->fst_blocks);
+#endif
   remote_fileio_to_fio_time (st->st_atime, fst->fst_atime);
   remote_fileio_to_fio_time (st->st_mtime, fst->fst_mtime);
   remote_fileio_to_fio_time (st->st_ctime, fst->fst_ctime);
@@ -1130,7 +1134,9 @@ remote_fileio_func_fstat (char *buf)
       st.st_rdev = 0;
       st.st_size = 0;
       st.st_blksize = 512;
+#if HAVE_STRUCT_STAT_ST_BLOCKS
       st.st_blocks = 0;
+#endif
       if (!gettimeofday (&tv, NULL))
        st.st_atime = st.st_mtime = st.st_ctime = tv.tv_sec;
       else
This page took 0.024393 seconds and 4 git commands to generate.