* syscall.c (cb_syscall) <case CB_SYS_lstat>: New case.
[deliverable/binutils-gdb.git] / sim / common / callback.c
index bbb3fe5baa8d1b469882b1697b06635b57c61996..7ba0c06fb0656fde8967e735ca3485762163e6c2 100644 (file)
@@ -407,6 +407,16 @@ os_fstat (p, fd, buf)
   return wrap (p, fstat (fdmap (p, fd), buf));
 }
 
+static int
+os_lstat (p, file, buf)
+     host_callback *p;
+     const char *file;
+     struct stat *buf;
+{
+  /* NOTE: hpn/2004-12-12: Same issue here as with os_fstat.  */
+  return wrap (p, lstat (file, buf));
+}
+
 static int 
 os_ftruncate (p, fd, len)
      host_callback *p;
@@ -453,6 +463,7 @@ os_shutdown (p)
          /* At the initial call of os_init, we got -1, 0, 0, 0, ...  */
          if (next < 0)
            {
+             p->fd_buddy[i] = -1;
              do_close = 0;
              break;
            }
@@ -588,6 +599,7 @@ host_callback default_callback =
 
   os_stat,
   os_fstat,
+  os_lstat,
 
   os_ftruncate,
   os_truncate,
@@ -815,10 +827,54 @@ cb_host_to_target_stat (cb, hs, ts)
 
       if (hs != NULL)
        {
-         if (strncmp (m, "st_dev", q - m) == 0)
-           store (p, size, hs->st_dev, big_p);
-         else if (strncmp (m, "st_ino", q - m) == 0)
-           store (p, size, hs->st_ino, big_p);
+         if (0)
+           ;
+         /* Defined here to avoid emacs indigestion on a lone "else".  */
+#undef ST_x
+#define ST_x(FLD)                                      \
+         else if (strncmp (m, #FLD, q - m) == 0)       \
+           store (p, size, hs->FLD, big_p)
+
+#ifdef HAVE_STRUCT_STAT_ST_DEV
+         ST_x (st_dev);
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_INO
+         ST_x (st_ino);
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_MODE
+         ST_x (st_mode);
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_NLINK
+         ST_x (st_nlink);
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_UID
+         ST_x (st_uid);
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_GID
+         ST_x (st_gid);
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_RDEV
+         ST_x (st_rdev);
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_SIZE
+         ST_x (st_size);
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
+         ST_x (st_blksize);
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
+         ST_x (st_blocks);
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_ATIME
+         ST_x (st_atime);
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_MTIME
+         ST_x (st_mtime);
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_CTIME
+         ST_x (st_ctime);
+#endif
+#undef ST_x
          /* FIXME:wip */
          else
            store (p, size, 0, big_p); /* unsupported field, store 0 */
This page took 0.023144 seconds and 4 git commands to generate.