From: Laurent Desnogues <laurent.desnogues@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] User mode: Handle the timezone argument for gettimeofday and settimeofday
Date: Sat, 11 Jul 2009 16:35:09 +0200 [thread overview]
Message-ID: <761ea48b0907110735s1b4871bdq1cac53f782161eb2@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 261 bytes --]
Hello,
this patch:
- adds the timezone parameter to gettimeofday and settimeofday
- allows the timeval pointer to be NULL (as per the man page of my
system and quick testing)
Laurent
Signed-off-by: Laurent Desnogues <laurent.desnogues@gmail.com>
[-- Attachment #2: timezone.patch --]
[-- Type: application/octet-stream, Size: 3251 bytes --]
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 0009623..326da72 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -849,6 +849,38 @@ static inline abi_long copy_to_user_timeval(abi_ulong target_tv_addr,
return 0;
}
+static inline abi_long copy_from_user_timezone(struct timezone *tz,
+ abi_ulong target_tz_addr)
+{
+ struct target_timezone *target_tz;
+
+ if (!lock_user_struct(VERIFY_READ, target_tz, target_tz_addr, 1))
+ return -TARGET_EFAULT;
+
+ __get_user(tz->tz_minuteswest, &target_tz->tz_minuteswest);
+ __get_user(tz->tz_dsttime, &target_tz->tz_dsttime);
+
+ unlock_user_struct(target_tz, target_tz_addr, 0);
+
+ return 0;
+}
+
+static inline abi_long copy_to_user_timezone(abi_ulong target_tz_addr,
+ const struct timezone *tz)
+{
+ struct target_timezone *target_tz;
+
+ if (!lock_user_struct(VERIFY_WRITE, target_tz, target_tz_addr, 0))
+ return -TARGET_EFAULT;
+
+ __put_user(tz->tz_minuteswest, &target_tz->tz_minuteswest);
+ __put_user(tz->tz_dsttime, &target_tz->tz_dsttime);
+
+ unlock_user_struct(target_tz, target_tz_addr, 1);
+
+ return 0;
+}
+
static inline abi_long copy_from_user_mq_attr(struct mq_attr *attr,
abi_ulong target_mq_attr_addr)
{
@@ -5065,19 +5097,35 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
case TARGET_NR_gettimeofday:
{
struct timeval tv;
- ret = get_errno(gettimeofday(&tv, NULL));
+ struct timezone tz;
+ ret = get_errno(gettimeofday(&tv, &tz));
if (!is_error(ret)) {
- if (copy_to_user_timeval(arg1, &tv))
- goto efault;
+ if (arg1) {
+ if (copy_to_user_timeval(arg1, &tv))
+ goto efault;
+ }
+ if (arg2) {
+ if (copy_to_user_timezone(arg2, &tz))
+ goto efault;
+ }
}
}
break;
case TARGET_NR_settimeofday:
{
- struct timeval tv;
- if (copy_from_user_timeval(&tv, arg1))
- goto efault;
- ret = get_errno(settimeofday(&tv, NULL));
+ struct timeval tv1, *tv = &tv1;
+ struct timezone tz1, *tz = &tz1;
+ if (arg1) {
+ if (copy_from_user_timeval(tv, arg1))
+ goto efault;
+ } else
+ tv = NULL;
+ if (arg2) {
+ if (copy_from_user_timezone(tz, arg2))
+ goto efault;
+ } else
+ tz = NULL;
+ ret = get_errno(settimeofday(tv, tz));
}
break;
#ifdef TARGET_NR_select
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index ac5dbc5..43d3e2e 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -138,6 +138,11 @@ struct target_timeval {
abi_long tv_usec;
};
+struct target_timezone {
+ int tz_minuteswest;
+ int tz_dsttime;
+};
+
struct target_timespec {
abi_long tv_sec;
abi_long tv_nsec;
reply other threads:[~2009-07-11 14:35 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=761ea48b0907110735s1b4871bdq1cac53f782161eb2@mail.gmail.com \
--to=laurent.desnogues@gmail.com \
--cc=qemu-devel@nongnu.org \
/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 NNTP newsgroup(s).