From patchwork Wed Apr 1 09:47:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 185139 Delivered-To: patch@linaro.org Received: by 2002:a92:de47:0:0:0:0:0 with SMTP id e7csp331148ilr; Wed, 1 Apr 2020 02:51:37 -0700 (PDT) X-Google-Smtp-Source: APiQypIuMU4Y0tVaSfIBJwKrfW5rnFZ0WgUDLXWeaichJenPCp5sSqSMPGRniewRcuIT6Y1OmVT6 X-Received: by 2002:aed:24b2:: with SMTP id t47mr3559432qtc.317.1585734697855; Wed, 01 Apr 2020 02:51:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585734697; cv=none; d=google.com; s=arc-20160816; b=hoij4JQYuf8iHg10UodzBBQQsXSNoihlEHEzE8p3jG7diqUW1ipjINaYfLp6dI0KD7 sGMYCjflRLLQwGDjwt3VifabmeirYgriJFa9Z2ZAwjNgPghlPLLjzkTIkAkW9fRURiM7 bT2HdD4gbXXwoMSIdQ0iUh5+IQkZCD1HwcIpndVg5DNL5MWYvnUyHzQ2pX9zeXHly3vC FIKzoNx2X3ILSPf0oodPObvaMVutftdOUF0k8Bjtfde4mNzyCPQ+25tvEKjzDF5xo64f 5PdnlQVG+n2ExWRjRuhJW/8Gb8zUFVWh4ubOmaA8b/5z3hLAI5Ice6JdMJteRyK8MOVP 6/Jw== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=WLTsGPoiyiZpQWSAjDx1Jd/3OsKOnqyDSFWAME1qJxU=; b=LB8y50vr++yV5Eink7sO2YzJtFPLTHz8Etxle8yP9u1AsVsmngu/Ut6MixH/KhYre3 rnNDsBh6sxdFS0mnctBGTQwCUJcshSxbAKq+aDnxGE21fSmPkwYFwcyT0zqXiuTiXu9V QRpmAnsPW72vmbe4zDbe4d+7xgXgSbABsp0cezsx0sfrQzr/rfJ3kMyupjG1560ehYv+ EzkMgateB++En4JAzqANDVeV9Gf23aF1FDMlsAFPMkfDxzIRlUzo/47/m8Fv3tfaU8Wt hbS+tLUsiwvLQXH5QGSdtztEwj0KN0T+eDNE9Xe9I4p9SI71L3ddBRGXJUfVcrhcE2lq aZRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Bho9PpvI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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. [209.51.188.17]) by mx.google.com with ESMTPS id e18si796597qkm.379.2020.04.01.02.51.37 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Apr 2020 02:51:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Bho9PpvI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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]:57294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJa25-0002u3-Ap for patch@linaro.org; Wed, 01 Apr 2020 05:51:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38494) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJZyp-0004TV-Dg for qemu-devel@nongnu.org; Wed, 01 Apr 2020 05:48:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJZyo-0002Fw-9f for qemu-devel@nongnu.org; Wed, 01 Apr 2020 05:48:15 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:45978) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jJZyo-0002FX-3D for qemu-devel@nongnu.org; Wed, 01 Apr 2020 05:48:14 -0400 Received: by mail-wr1-x442.google.com with SMTP id t7so29717079wrw.12 for ; Wed, 01 Apr 2020 02:48:14 -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 :mime-version:content-transfer-encoding; bh=WLTsGPoiyiZpQWSAjDx1Jd/3OsKOnqyDSFWAME1qJxU=; b=Bho9PpvIJqh1yBVCpgktnF2q4gBLJiWRK1Bdesx3wnL+bemJhpFF1PtSZ+V0z2Whcl qnChS1AabKalg2BP7QCt6e9x5+0GxJXZhVSve+cbD1XWZkvsnFYExxwP4WasdAmzJj0J hYEhtdQc1gRLIleu5WkOCk/gRUSVRzSOvABl/rfkX5KLwSh2fgqh9RYG4gD2EEf+omeo P5UTatdU0nrIn57LzZRfvI8FXFZYveF8tlWC1zdqhDnhA4eO/hNs6IucRB1l6c7Wa9N+ x/6atOLjsBst1LJAEw4RkvK+ntRfZykRlGvD/plb2bySagklsTfkDhdAApKYjyKlDUez UAPQ== 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:mime-version:content-transfer-encoding; bh=WLTsGPoiyiZpQWSAjDx1Jd/3OsKOnqyDSFWAME1qJxU=; b=nWQaj1jUyEJDpLujiLffm+QJOGTp14laUIiEi8lJMyIC8+dCquMPIUz1qt7Lj8Slcr fT8qAhr2EU4AlPEJTcyO7JiPvfO8NUBmjeInfADxLjA2XWZfxkhNeZRpnF6RHXTwmmXO 3cGMwTfE2hQw25U2EPVBr5nugSeF/Fd2+bkcFUO47bl/i389uAi8/UEBpDj4XVCWcmAf P2abDXvdsmXIlBBTy415yDoCE/nMlm4zOSOaqMdeMwLCDuIYFeU34jeBrBXoZHfG0rSC vyO+K3fr2XulfRlAC8hUQfJ696CO1zDdlquqPAWMBNmUjvuDXHDsa0YzdKnAePCB7qgU pkaA== X-Gm-Message-State: ANhLgQ3VHu9JhzhEJ/IwP9CytePMVazEWI1d2sEmcdTEZ8kjxvKcUmu+ t9sd14xn8bLtI4Jy4wHHUCRaCg== X-Received: by 2002:adf:bb06:: with SMTP id r6mr25539282wrg.324.1585734493143; Wed, 01 Apr 2020 02:48:13 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r15sm2350519wra.19.2020.04.01.02.48.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2020 02:48:09 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C998A1FF98; Wed, 1 Apr 2020 10:48:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 09/10] linux-user: clean-up padding on /proc/self/maps Date: Wed, 1 Apr 2020 10:47:58 +0100 Message-Id: <20200401094759.5835-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200401094759.5835-1-alex.bennee@linaro.org> References: <20200401094759.5835-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Don't use magic spaces, calculate the justification for the file field like the kernel does with seq_pad. Signed-off-by: Alex Bennée --- linux-user/syscall.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 0246df01573..b921432f4ff 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7235,6 +7235,7 @@ static int open_self_maps(void *cpu_env, int fd) TaskState *ts = cpu->opaque; GSList *map_info = read_self_maps(); GSList *s; + int count; for (s = map_info; s; s = g_slist_next(s)) { MapInfo *e = (MapInfo *) s->data; @@ -7253,20 +7254,24 @@ static int open_self_maps(void *cpu_env, int fd) } if (h2g(min) == ts->info->stack_limit) { - path = " [stack]"; + path = "[stack]"; } else { path = e->path; } - dprintf(fd, TARGET_ABI_FMT_ptr "-" TARGET_ABI_FMT_ptr - " %c%c%c%c %08" PRIx64 " %s %d %s%s\n", - h2g(min), h2g(max - 1) + 1, - e->is_read ? 'r' : '-', - e->is_write ? 'w' : '-', - e->is_exec ? 'x' : '-', - e->is_priv ? 'p' : '-', - e->offset, e->dev, e->inode, - path ? " " : "", path ? path : ""); + count = dprintf(fd, TARGET_ABI_FMT_ptr "-" TARGET_ABI_FMT_ptr + " %c%c%c%c %08" PRIx64 " %s %d", + h2g(min), h2g(max - 1) + 1, + e->is_read ? 'r' : '-', + e->is_write ? 'w' : '-', + e->is_exec ? 'x' : '-', + e->is_priv ? 'p' : '-', + e->offset, e->dev, e->inode); + if (path) { + dprintf(fd, "%*s%s\n", 73 - count, "", path); + } else { + dprintf(fd, "\n"); + } } } @@ -7277,9 +7282,10 @@ static int open_self_maps(void *cpu_env, int fd) * We only support execution from the vsyscall page. * This is as if CONFIG_LEGACY_VSYSCALL_XONLY=y from v5.3. */ - dprintf(fd, TARGET_FMT_lx "-" TARGET_FMT_lx - " --xp 00000000 00:00 0 [vsyscall]\n", - TARGET_VSYSCALL_PAGE, TARGET_VSYSCALL_PAGE + TARGET_PAGE_SIZE); + count = dprintf(fd, TARGET_FMT_lx "-" TARGET_FMT_lx + " --xp 00000000 00:00 0", + TARGET_VSYSCALL_PAGE, TARGET_VSYSCALL_PAGE + TARGET_PAGE_SIZE); + dprintf(fd, "%*s%s\n", 73 - count, "", "[vsyscall]"); #endif return 0;