From: John Wehle <john@feith.com>
To: sid@sources.redhat.com
Subject: sid-20110801 Patch to implement gloss SYS_stat
Date: Mon, 19 Sep 2011 07:03:00 -0000 [thread overview]
Message-ID: <201109190703.p8J73ZPj009316@jwlab.FEITH.COM> (raw)
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();
-------------------------------------------------------------------------
reply other threads:[~2011-09-19 7:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201109190703.p8J73ZPj009316@jwlab.FEITH.COM \
--to=john@feith.com \
--cc=sid@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).