From patchwork Sun Jun 10 03:01:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138123 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2593527lji; Sat, 9 Jun 2018 20:38:24 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI3QzUSDa8fXA1KLK7NE/tVXaD2MJUhxWOeiX5jn2QnyN/ArI4mONTcmtMek5EqqQZ0tvFU X-Received: by 2002:a0c:d4d2:: with SMTP id y18-v6mr10766051qvh.63.1528601904841; Sat, 09 Jun 2018 20:38:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601904; cv=none; d=google.com; s=arc-20160816; b=dilAqvhXkjXPOED1A5pJpQu7Gu+VVPf7AJt0kvCuiLjE4J2ymU+N9Mi8ooi9hHSyYX Cs54rsBGMNtKORh1aRT4hVDX6+i0nG3qYMRMuK7521rwTdTbDOKl0jjn/1DhuHk7j0nU +zHpFzDRXRJzXsyKuAch8/oQ52yeg5VASDJ3XONS1K/ZsTdz6APz//+DIB+iXJoW8RkR gpOfsX9PBvjxdMb6huWrQTURrcWf82HA64/nB5NzRa8i7kfDNPhq1U5YbEyzVWn57bXd DqZ2NjwIo2+pZFlUxQh9KCSQZb1VpxUVV2cNY7Rgs2oCInyRZviuLU9fOPixcQ+ZhUMe BmVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=SF2dE5sRByvOLy3iaC3SQQTLER/KaLyYNlFv9XOiQRI=; b=j0ECQdfd00xk83eMbBKoKWttg01R/BPjfye3O043bjxSd5Ig7mGuJB2BNKwRP8VFuY HfRpAp5sfS7E9NlOSZPXdiPbSkI0NlKZIIgXRWFCOmZicfwziRUkJDmila5S5gKYq3aV 2oFfOmDeOjBhjENI5N6gLlDbwKLYnFxNsEqex6pH28/OxvVIsREuAgWLkOyg/xN7oZXl 6LxuYLwFuLQ8ueAFYvlg/KCQsDl8ACjl7r5A0mnMtr3UcDxkeG1WGTmMsJ1m8bXrbT4r Hocl4bgdpOsbxHTVb6B5f9qrfOQpqIlES/nIlY4RR8xC27byb2dbZdbLDRNmwaqHHkW1 iOqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YLudTcir; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i4-v6si1975341qkf.65.2018.06.09.20.38.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:38:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YLudTcir; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42369 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrBQ-0007te-9F for patch@linaro.org; Sat, 09 Jun 2018 23:38:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeP-00037D-DS for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeO-0003jF-68 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:17 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:35910) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeN-0003j3-Tm for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:16 -0400 Received: by mail-pl0-x244.google.com with SMTP id a7-v6so7899611plp.3 for ; Sat, 09 Jun 2018 20:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SF2dE5sRByvOLy3iaC3SQQTLER/KaLyYNlFv9XOiQRI=; b=YLudTcirlVSyLa6GbHTLf8fDWESUDYiLYRFovvFeyTYMJmz0kpsBow1i1NmKvt634v mqaRGjvPI99efsne7R7ilZuRSOZhQCPrCsop9XvQ7NAmLoDjUfDpbwQ7SsHo7IQQr+2J wlwVyTG7Y0++B6UTSWoVDcEozm2H1MPdZVCs0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SF2dE5sRByvOLy3iaC3SQQTLER/KaLyYNlFv9XOiQRI=; b=frkcMI1lfVcty7edNXbea3YO75Opc6P4aFHfCgBOJvKPL0OWxuWFwIKb52CTEhRnGE ch3n+fZ4YIeyFQDrzJNlb3kLBWU8480N0/rSVBzK3bnLOqB7AK5mALShvbPNwrnfYCto 1ZmrPm1xrm9ralS3l40GtEYx8BFIIGlyFSNczmzUGFfsSvfIgXJz/yGJBnFpgzKJSdUb H++MV9VnWPMXo8Fam0AQhnV70w+YN+feGUCRvFu5SAAnmEqMyzpWJ635QFPdvVMSPvWj N11gRgbxSDpc6Yw36WQTxtgHkCrYVV/rOdi5XYkfm0Iw0a5v0tTaa9n4+6TH1T20Xoli AFRw== X-Gm-Message-State: APt69E3JY75bpj0OwmLOOfFWN3jyshetitJw3Inc2ctmHFvD5BZBJrqQ wKyeNi8/sGSwOwV5FRFM+k41oZNjWDs= X-Received: by 2002:a17:902:4c88:: with SMTP id b8-v6mr12600416ple.285.1528599854735; Sat, 09 Jun 2018 20:04:14 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:22 -1000 Message-Id: <20180610030220.3777-51-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::244 Subject: [Qemu-devel] [PATCH v2 050/108] linux-user: Split out getitimer, setitimer, syslog X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" All targets define syslog; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 155 ++++++++++++++++++++++--------------------- 1 file changed, 79 insertions(+), 76 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 46c7c485fd..c8fc7fc908 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8154,6 +8154,20 @@ IMPL(futimesat) } #endif +IMPL(getitimer) +{ + struct itimerval value; + abi_long ret = get_errno(getitimer(arg1, &value)); + + if (!is_error(ret) && arg2 && + (copy_to_user_timeval(arg2, &value.it_interval) || + copy_to_user_timeval(arg2 + sizeof(struct target_timeval), + &value.it_value))) { + return -TARGET_EFAULT; + } + return ret; +} + #ifdef TARGET_NR_getpeername IMPL(getpeername) { @@ -9357,6 +9371,28 @@ IMPL(sethostname) return ret; } +IMPL(setitimer) +{ + struct itimerval ivalue, ovalue; + abi_long ret; + + if (arg2 && + (copy_from_user_timeval(&ivalue.it_interval, arg2) || + copy_from_user_timeval(&ivalue.it_value, + arg2 + sizeof(struct target_timeval)))) { + return -TARGET_EFAULT; + } + ret = get_errno(setitimer(arg1, arg2 ? &ivalue : NULL, + arg3 ? &ovalue : NULL)); + if (!is_error(ret) && arg3 && + (copy_to_user_timeval(arg3, &ovalue.it_interval) || + copy_to_user_timeval(arg3 + sizeof(struct target_timeval), + &ovalue.it_value))) { + return -TARGET_EFAULT; + } + return ret; +} + IMPL(setpgid) { return get_errno(setpgid(arg1, arg2)); @@ -9848,6 +9884,46 @@ IMPL(syncfs) } #endif +IMPL(syslog) +{ + abi_long ret; + char *p; + int len; + + switch (arg1) { + case TARGET_SYSLOG_ACTION_CLOSE: /* Close log */ + case TARGET_SYSLOG_ACTION_OPEN: /* Open log */ + case TARGET_SYSLOG_ACTION_CLEAR: /* Clear ring buffer */ + case TARGET_SYSLOG_ACTION_CONSOLE_OFF: /* Disable logging */ + case TARGET_SYSLOG_ACTION_CONSOLE_ON: /* Enable logging */ + case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: /* Set messages level */ + case TARGET_SYSLOG_ACTION_SIZE_UNREAD: /* Number of chars */ + case TARGET_SYSLOG_ACTION_SIZE_BUFFER: /* Size of the buffer */ + return get_errno(sys_syslog((int)arg1, NULL, (int)arg3)); + + case TARGET_SYSLOG_ACTION_READ: /* Read from log */ + case TARGET_SYSLOG_ACTION_READ_CLEAR: /* Read/clear msgs */ + case TARGET_SYSLOG_ACTION_READ_ALL: /* Read last messages */ + len = arg2; + if (len < 0) { + return -TARGET_EINVAL; + } + if (len == 0) { + return 0; + } + p = lock_user(VERIFY_WRITE, arg2, arg3, 0); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(sys_syslog((int)arg1, p, (int)arg3)); + unlock_user(p, arg2, arg3); + return ret; + + default: + return -TARGET_EINVAL; + } +} + #ifdef TARGET_NR_time IMPL(time) { @@ -10077,82 +10153,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#if defined(TARGET_NR_syslog) - case TARGET_NR_syslog: - { - int len = arg2; - - switch (arg1) { - case TARGET_SYSLOG_ACTION_CLOSE: /* Close log */ - case TARGET_SYSLOG_ACTION_OPEN: /* Open log */ - case TARGET_SYSLOG_ACTION_CLEAR: /* Clear ring buffer */ - case TARGET_SYSLOG_ACTION_CONSOLE_OFF: /* Disable logging */ - case TARGET_SYSLOG_ACTION_CONSOLE_ON: /* Enable logging */ - case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: /* Set messages level */ - case TARGET_SYSLOG_ACTION_SIZE_UNREAD: /* Number of chars */ - case TARGET_SYSLOG_ACTION_SIZE_BUFFER: /* Size of the buffer */ - return get_errno(sys_syslog((int)arg1, NULL, (int)arg3)); - case TARGET_SYSLOG_ACTION_READ: /* Read from log */ - case TARGET_SYSLOG_ACTION_READ_CLEAR: /* Read/clear msgs */ - case TARGET_SYSLOG_ACTION_READ_ALL: /* Read last messages */ - { - if (len < 0) { - return -TARGET_EINVAL; - } - if (len == 0) { - return 0; - } - p = lock_user(VERIFY_WRITE, arg2, arg3, 0); - if (!p) { - return -TARGET_EFAULT; - } - ret = get_errno(sys_syslog((int)arg1, p, (int)arg3)); - unlock_user(p, arg2, arg3); - } - return ret; - default: - return -TARGET_EINVAL; - } - } - break; -#endif - case TARGET_NR_setitimer: - { - struct itimerval value, ovalue, *pvalue; - - if (arg2) { - pvalue = &value; - if (copy_from_user_timeval(&pvalue->it_interval, arg2) - || copy_from_user_timeval(&pvalue->it_value, - arg2 + sizeof(struct target_timeval))) - return -TARGET_EFAULT; - } else { - pvalue = NULL; - } - ret = get_errno(setitimer(arg1, pvalue, &ovalue)); - if (!is_error(ret) && arg3) { - if (copy_to_user_timeval(arg3, - &ovalue.it_interval) - || copy_to_user_timeval(arg3 + sizeof(struct target_timeval), - &ovalue.it_value)) - return -TARGET_EFAULT; - } - } - return ret; - case TARGET_NR_getitimer: - { - struct itimerval value; - - ret = get_errno(getitimer(arg1, &value)); - if (!is_error(ret) && arg2) { - if (copy_to_user_timeval(arg2, - &value.it_interval) - || copy_to_user_timeval(arg2 + sizeof(struct target_timeval), - &value.it_value)) - return -TARGET_EFAULT; - } - } - return ret; #ifdef TARGET_NR_stat case TARGET_NR_stat: if (!(p = lock_user_string(arg1))) { @@ -12881,6 +12881,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_futimesat SYSCALL(futimesat); #endif + SYSCALL(getitimer); #ifdef TARGET_NR_getpeername SYSCALL(getpeername); #endif @@ -13026,6 +13027,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(sendto); #endif SYSCALL(sethostname); + SYSCALL(setitimer); SYSCALL(setpgid); SYSCALL(setpriority); SYSCALL(setrlimit); @@ -13077,6 +13079,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef CONFIG_SYNCFS SYSCALL(syncfs); #endif + SYSCALL(syslog); #ifdef TARGET_NR_time SYSCALL(time); #endif