This is the mail archive of the sid@sourceware.org mailing list for the SID project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

sid-20110801 Patch to implement gloss SYS_stat


Currently sid lacks support for SYS_stat.

The enclosed patch has been tested on FreeBSD with sid configured for
tomi Borealis (a processor under development by Venray Technology).

ChangeLog:

Mon Sep 19 01:20:11 EDT 2011  John Wehle  (john@feith.com)

	* component/gloss/gloss.cxx (do_sys_stat): New method
	based on code shamelessly stolen from do_sys_fstat.
	* component/gloss/gloss.h (do_sys_stat): New method
	of gloss32.

-- John
------------------------8<------------------------------8<---------------
--- component/gloss/gloss.cxx.ORIGINAL	2011-09-19 00:56:13.000000000 -0400
+++ component/gloss/gloss.cxx	2011-09-18 03:28:49.000000000 -0400
@@ -925,6 +925,9 @@
     case libgloss::SYS_fstat:
       do_sys_fstat();
       break;
+    case libgloss::SYS_stat:
+      do_sys_stat();
+      break;
     case libgloss::SYS_close:
       do_sys_close();
       break;
@@ -1317,6 +1320,56 @@
 }
 
 void
+gloss32::do_sys_stat()
+{
+  string filename;
+  struct stat st;
+  int32 str_ptr, ptr;
+
+  get_int_argument (1, str_ptr);
+  get_int_argument (2, ptr);
+
+  if (verbose_p)
+    cerr << "*** stat (" << str_ptr << "," << ptr << ")" << endl;
+
+  if (!get_string (str_ptr, filename))
+    {
+      set_error_result (newlib::eFault);
+      set_int_result (-1);
+      return;
+    }
+
+  int rc = ::stat (filename.c_str (), &st);
+  if (rc < 0)
+    {
+      set_host_error_result (errno);
+      set_int_result (-1);
+    }
+  else
+    {
+      set_error_result (0);
+      set_int_result (rc);
+    }
+
+  // Populate struct stat in target memory.
+  set_halfword (ptr, st.st_dev);
+  ptr += 2;
+  set_halfword (ptr, st.st_ino);
+  ptr += 2;
+  set_word (ptr, st.st_mode);
+  ptr += 4;
+  set_halfword (ptr, st.st_nlink);
+  ptr += 2;
+  set_halfword (ptr, st.st_uid);
+  ptr += 2;
+  set_halfword (ptr, st.st_gid);
+  ptr += 2;
+  set_halfword (ptr, st.st_rdev);
+  ptr += 2;
+  set_word (ptr, st.st_size);
+}
+
+void
 gloss32::do_sys_read()
 {
   int32 handle, str_ptr, str_length;
--- component/gloss/gloss.h.ORIGINAL	2011-09-19 00:56:13.000000000 -0400
+++ component/gloss/gloss.h	2011-09-18 00:51:30.000000000 -0400
@@ -174,6 +174,7 @@
   void do_sys_close();
   void do_sys_lseek();
   void do_sys_fstat();
+  void do_sys_stat();
   void do_sys_time();
   void do_sys_gettimeofday();
   void do_sys_times();
-------------------------------------------------------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]