From nobody Fri May 17 11:05:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1597301493; cv=none; d=zohomail.com; s=zohoarc; b=Byx4UFzWZS1Rlaqq90SaEH4fZXO1GyD7lS5unzkCUG+nnk2ICrZ2SnSowO4MDCZWI6VQmPU95MjohmuF9VdnXMhZ63b1Web6p0mSIG/+RlYlhRZ6EbkNLNnlNIieb9iNobsjN5Xf99VIe3XL8N9eRh5VSqI4YRKJFZDUALHCaJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597301493; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ei57CYmqMgBkRmhif2M0i7fosJgMffqE28HtYbeNmZY=; b=No+Cnl5rVqWuwRl55KLSLBzUmA8Rsmn7h7xwQ5UcylJaTx9smRxl8bHfvCR4qwYmTsSfRFwAkwg4KWhe0JODO/TxPuv/hQvjhUhnnkWOal511Zdz6ddbe+CNGHpINAKkcxMeo0aV022R6TH3GyIDpD04lo90H3agZZKQ65HFQBw= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15973014931391003.2113171860627; Wed, 12 Aug 2020 23:51:33 -0700 (PDT) Received: from localhost ([::1]:48954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k675H-0008H9-1T for importer@patchew.org; Thu, 13 Aug 2020 02:51:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673M-0006PB-NK for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:34 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:34523) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673J-0004bo-Dz for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:32 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MOAmt-1kLkDs3L8j-00OUWp; Thu, 13 Aug 2020 08:49:26 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 01/14] linux-user: Fix "print_fdset()" in "strace.c" to not print ", " after last value Date: Thu, 13 Aug 2020 08:49:10 +0200 Message-Id: <20200813064923.263565-2-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200813064923.263565-1-laurent@vivier.eu> References: <20200813064923.263565-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:k5WNklHgXJAKgUwHlCIhV2zupA6XopnwoqkM277mTHnXabjZgdG wl5JRLifnUxquMFokwBe0u/NEP/tGtdpeAGI6qIL4gKFalTJi2bSrlkOdJZmztHyvJrV1Vz w5D0i7XwBtE6zT+/LDzogqHinT9FptiFVTbNc5LylHmsTHL9AKqUKBOkJOVkSs3fmq7K4kS yJficVuZiEbdclqj/fjaA== X-UI-Out-Filterresults: notjunk:1;V03:K0:tx9HswNVwAk=:4qkAh7xZCsL+2Q+FVc08aV he/v4o5ENEnL8pfTT/ogi6bGPmc3xJ8p1VYNqNM16hYqgrOXwb+b1XfiKDmgCfrkP0bbV4SKB FcDak6mI2kk8RcHtwBxM/2VDEEibQZasUK3IErTGqVY7n+YXygfZoM7pUnxpdYuCqaql+wQgf ktvCeb0FaZMs+Fv1n2s2bkqnUGYvEKhj+dW9WOIKtD2g7vuVgZmsyTNARExQL2GzXFKu3WXDG i9n3fd/p/9kc15cODcVJX3a6KclF/KFGtaA6lFo9wHtHnLx5UMyUiO7hvps+fzjmsg6CNO6jg z0lyK9IOAK1thBtk7A9G77m6MiFhCzIeVTIuXsZW/FaFfJnOSklJ3qbCFp2rckuFHq5xPpcSb Ak+yJQodMB4fMus//odXfWCBf2h1vOlHvk89hDpskX3qzrF1PrcBrMioGMCw69OVRRzp8SG2y gurNxHSCIkSJg9dL3Qcd/7N7Hc7WSrD2xdkfSm5CQW/IEtgISq8hvLW7+JwvS/Jf5ENeG16Nl AjDiq7YEe4f6eGjID3CeyGA7q4zWyU2Fb46NHkPUIIPpx9WrHUTtmtsmrICiH1+yaKzphY9f2 jg2q1XnmRW4Zy2fdIHl5ddSOdqFk+Q9Sm8v+te5L2NhLDZWHjgsol17A/VdUeB8mU3mYkxMBz gy8Fz/7R/TzS4sC5I7QGlnD825p8gs4/BETv8JxplbuhfFGXWnLbRALYisR9Fz5yM2pgi66YX Dgqpyho92SwqCGYKwMIqRN5MEAUBN8Yb20ChDTzAbxqWRvJH2jRt+7jC+ZJKe/Zsr4vkFBKnu YnlXSWjxlIkoCALHL2XcJoW2sOh6zK78f7GbH19voVDxJkPgN538g5N2wjapRaazsZwxBNm Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.74; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/13 02:49:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Filip Bozuta Function "print_fdset()" in "strace.c" is used to print the file descriptor values in "print__newselect()" which prints arguments of syscall _newselect= (). Until changes from this patch, this function was printing "," even after the last value of the fd_set argument. This was changed in this patch by removi= ng this unnecessary "," after the last fd value and thus improving the estetic= s of the _newselect() "-strace" print. Implementation notes: The printing fix was made possible by using an existing function "get_co= mma()" which returns a "," or an empty string "" based on its argument (0 for "= ," and other for ""). Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200702160915.9517-1-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 13981341b327..5e380486433c 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -541,6 +541,7 @@ static void print_fdset(int n, abi_ulong target_fds_addr) { int i; + int first =3D 1; =20 qemu_log("["); if( target_fds_addr ) { @@ -555,9 +556,12 @@ print_fdset(int n, abi_ulong target_fds_addr) return; =20 for (i=3Dn; i>=3D0; i--) { - if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >> (i & (TARGET_= ABI_BITS - 1))) & 1) - qemu_log("%d,", i); + if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >> + (i & (TARGET_ABI_BITS - 1))) & 1) { + qemu_log("%s%d", get_comma(first), i); + first =3D 0; } + } unlock_user(target_fds, target_fds_addr, 0); } qemu_log("]"); --=20 2.26.2 From nobody Fri May 17 11:05:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1597301496; cv=none; d=zohomail.com; s=zohoarc; b=jdH+WCDkhOQFZwghE4qhqc9l1XZhqyGRrpAuPssIrBQ/+enYwHBVPUIPGNf0L0C/Fy7U7UP1clPcb3irqlWpXPBTOxD7oETerSdRTGR4PYttE5v7Whqv2ZJFXdApr6xIu3p5IeduHKSN05Ea3RWeuPQ0vnctC8pyqN/vDEY+oV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597301496; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JiEkVxcOfuMktQAh35q+WwnwzNzBhoyR5assqUVwYxs=; b=Vq2jaVOoL4ycSDnOGo5YDtiz7LlWyPlJghJmhSbCa5tDmHkaofBCgPDD/SsnnT/hjF1ZsmiLkFtjVCHdyh6kU+eYvpbLC5CZtan4Eqqk8aGKlepurVIM35sKM3fxy7pGpoSJ54Ng0JYhRgNV4RKhMrGKU+vUY0Y1F3CNj9s10XU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1597301496591957.8752523926871; Wed, 12 Aug 2020 23:51:36 -0700 (PDT) Received: from localhost ([::1]:49060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k675K-0008Jh-2W for importer@patchew.org; Thu, 13 Aug 2020 02:51:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673O-0006Pr-KX for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:34 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:44567) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673J-0004bn-Ca for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:34 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M9nAB-1k0uW31P77-005sHP; Thu, 13 Aug 2020 08:49:26 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 02/14] linux-user: Validate mmap/mprotect prot value Date: Thu, 13 Aug 2020 08:49:11 +0200 Message-Id: <20200813064923.263565-3-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200813064923.263565-1-laurent@vivier.eu> References: <20200813064923.263565-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:MRhH9J+P0CRWlAUTnys0givSaKEFDyAyISPI6Zx2JQHH/E8TC7A fpxBjntVvoxiS1cDgGL9+QI0A+Gvf/NfcBKch3cr5WlKAvPCF8TaF/VPkmoA4r3OC+4GRlS UDIFF5CpS2dhREiYDEn+r7T0gF8C4pHoW63LnNU2jlWD5KAGZykPBPZOpJdV6WCuFWUh1ap NYu+DX3Lr/fB/d5BGFWrg== X-UI-Out-Filterresults: notjunk:1;V03:K0:MnqWGUJFlaI=:V8FUSsWsAEedoemTbEGtrD Fa4Tc6Kh0HdtdfECUniVuedjNaN7nUHuCWkJC3mj/RsGZAMpIlq4NPJ/buAmNnHitGjRkuX9p 36ArzZKNhYc1FiMfmIUD7OBEjDeYMAFp6bTzDvA4mgrgn6ptkjqZbo3xj3Ud+KiLJEGVF8+3X bzli3oHOlAjMeBUPVGLjRw1kfKp07QGiuleAgj9IobYDyL/J6E5sfqwcQyJycuod5wPj6JKKm IfMTOJ7PS3uSZjDxVlvt/BygBeH30FU54tXfxPD+H8fh4Q1eNZA3iBIg1aNfD7f62Eri0yQMg 6XO+ZDxv1PmJoatR50Wg0ZRgIszQwNLsKczAJzm1hQwqsLsEEO5+ZIZ1JMFw8nH/9bGSVS5w+ P7gYQeKtA2eIWHepsZZ8eU8/JoVX+3mqM5A2ny/nxFiZGsze347IofQI/YlIyxNkasZ0a97Ic XKeOtEN4C9L9uwA3PGsu/xrym44T2fSzw1zyxuM0SfBHgDieIS/LYAy/MUGidyfUe8p9ww4x6 t4YiK76p3Nl5xEMW/l3xJ7O2VkH6HVCCNzYznCvX+PQxj3ZGSmVSUD/QKvHX+iqNOfB6JlSpy AqKg5UA0qlwOpo6+O4jKUY8WX49OrIIEJA3HoUKJhYq/XxwSmA6pdXy8/DJqK2dnxlGjs+3sy h6Opq2R8LldBXzHepzN4sS65j97FPLDckCrHw6l+p0/gCcFCwlGhKoAMCWmBLGG9HE9Nkl4vP 8wNOVac5lfvKuZR2xfAiagXxCjfHDV/bOKHjPSl6hgpm30bRHo8p3J7lb/Xc6N65Wj6EwLigx SVTu9fGH/f7xCBf4kIz11YKtf3oH6nPKj6xAdgFtt45sRccIgIeoNDEL0HQgoXr/ZmaARZX Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/13 02:49:26 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Peter Maydell , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Richard Henderson The kernel will return -EINVAL for bits set in the prot argument that are unknown or invalid. Previously we were simply cropping out the bits that we care about. Introduce validate_prot_to_pageflags to perform this check in a single place between the two syscalls. Differentiate between the target and host versions of prot. Compute the qemu internal page_flags value at the same time. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-Id: <20200519185645.3915-2-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/mmap.c | 106 +++++++++++++++++++++++++++++++--------------- 1 file changed, 73 insertions(+), 33 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 0019447892e0..46c7eeba9bd2 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -59,64 +59,96 @@ void mmap_fork_end(int child) pthread_mutex_unlock(&mmap_mutex); } =20 +/* + * Validate target prot bitmask. + * Return the prot bitmask for the host in *HOST_PROT. + * Return 0 if the target prot bitmask is invalid, otherwise + * the internal qemu page_flags (which will include PAGE_VALID). + */ +static int validate_prot_to_pageflags(int *host_prot, int prot) +{ + int valid =3D PROT_READ | PROT_WRITE | PROT_EXEC | TARGET_PROT_SEM; + int page_flags =3D (prot & PAGE_BITS) | PAGE_VALID; + + /* + * For the host, we need not pass anything except read/write/exec. + * While PROT_SEM is allowed by all hosts, it is also ignored, so + * don't bother transforming guest bit to host bit. Any other + * target-specific prot bits will not be understood by the host + * and will need to be encoded into page_flags for qemu emulation. + */ + *host_prot =3D prot & (PROT_READ | PROT_WRITE | PROT_EXEC); + + return prot & ~valid ? 0 : page_flags; +} + /* NOTE: all the constants are the HOST ones, but addresses are target. */ -int target_mprotect(abi_ulong start, abi_ulong len, int prot) +int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) { abi_ulong end, host_start, host_end, addr; - int prot1, ret; + int prot1, ret, page_flags, host_prot; =20 - trace_target_mprotect(start, len, prot); + trace_target_mprotect(start, len, target_prot); =20 - if ((start & ~TARGET_PAGE_MASK) !=3D 0) + if ((start & ~TARGET_PAGE_MASK) !=3D 0) { return -TARGET_EINVAL; + } + page_flags =3D validate_prot_to_pageflags(&host_prot, target_prot); + if (!page_flags) { + return -TARGET_EINVAL; + } len =3D TARGET_PAGE_ALIGN(len); end =3D start + len; if (!guest_range_valid(start, len)) { return -TARGET_ENOMEM; } - prot &=3D PROT_READ | PROT_WRITE | PROT_EXEC; - if (len =3D=3D 0) + if (len =3D=3D 0) { return 0; + } =20 mmap_lock(); host_start =3D start & qemu_host_page_mask; host_end =3D HOST_PAGE_ALIGN(end); if (start > host_start) { /* handle host page containing start */ - prot1 =3D prot; - for(addr =3D host_start; addr < start; addr +=3D TARGET_PAGE_SIZE)= { + prot1 =3D host_prot; + for (addr =3D host_start; addr < start; addr +=3D TARGET_PAGE_SIZE= ) { prot1 |=3D page_get_flags(addr); } if (host_end =3D=3D host_start + qemu_host_page_size) { - for(addr =3D end; addr < host_end; addr +=3D TARGET_PAGE_SIZE)= { + for (addr =3D end; addr < host_end; addr +=3D TARGET_PAGE_SIZE= ) { prot1 |=3D page_get_flags(addr); } end =3D host_end; } - ret =3D mprotect(g2h(host_start), qemu_host_page_size, prot1 & PAG= E_BITS); - if (ret !=3D 0) + ret =3D mprotect(g2h(host_start), qemu_host_page_size, + prot1 & PAGE_BITS); + if (ret !=3D 0) { goto error; + } host_start +=3D qemu_host_page_size; } if (end < host_end) { - prot1 =3D prot; - for(addr =3D end; addr < host_end; addr +=3D TARGET_PAGE_SIZE) { + prot1 =3D host_prot; + for (addr =3D end; addr < host_end; addr +=3D TARGET_PAGE_SIZE) { prot1 |=3D page_get_flags(addr); } - ret =3D mprotect(g2h(host_end - qemu_host_page_size), qemu_host_pa= ge_size, - prot1 & PAGE_BITS); - if (ret !=3D 0) + ret =3D mprotect(g2h(host_end - qemu_host_page_size), + qemu_host_page_size, prot1 & PAGE_BITS); + if (ret !=3D 0) { goto error; + } host_end -=3D qemu_host_page_size; } =20 /* handle the pages in the middle */ if (host_start < host_end) { - ret =3D mprotect(g2h(host_start), host_end - host_start, prot); - if (ret !=3D 0) + ret =3D mprotect(g2h(host_start), host_end - host_start, host_prot= ); + if (ret !=3D 0) { goto error; + } } - page_set_flags(start, start + len, prot | PAGE_VALID); + page_set_flags(start, start + len, page_flags); mmap_unlock(); return 0; error: @@ -360,19 +392,26 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong si= ze, abi_ulong align) } =20 /* NOTE: all the constants are the HOST ones */ -abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, +abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, int flags, int fd, abi_ulong offset) { abi_ulong ret, end, real_start, real_end, retaddr, host_offset, host_l= en; + int page_flags, host_prot; =20 mmap_lock(); - trace_target_mmap(start, len, prot, flags, fd, offset); + trace_target_mmap(start, len, target_prot, flags, fd, offset); =20 if (!len) { errno =3D EINVAL; goto fail; } =20 + page_flags =3D validate_prot_to_pageflags(&host_prot, target_prot); + if (!page_flags) { + errno =3D EINVAL; + goto fail; + } + /* Also check for overflows... */ len =3D TARGET_PAGE_ALIGN(len); if (!len) { @@ -438,14 +477,15 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int prot, /* Note: we prefer to control the mapping address. It is especially important if qemu_host_page_size > qemu_real_host_page_size */ - p =3D mmap(g2h(start), host_len, prot, + p =3D mmap(g2h(start), host_len, host_prot, flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); - if (p =3D=3D MAP_FAILED) + if (p =3D=3D MAP_FAILED) { goto fail; + } /* update start so that it points to the file position at 'offset'= */ host_start =3D (unsigned long)p; if (!(flags & MAP_ANONYMOUS)) { - p =3D mmap(g2h(start), len, prot, + p =3D mmap(g2h(start), len, host_prot, flags | MAP_FIXED, fd, host_offset); if (p =3D=3D MAP_FAILED) { munmap(g2h(start), host_len); @@ -479,19 +519,19 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int prot, /* msync() won't work here, so we return an error if write is possible while it is a shared mapping */ if ((flags & MAP_TYPE) =3D=3D MAP_SHARED && - (prot & PROT_WRITE)) { + (host_prot & PROT_WRITE)) { errno =3D EINVAL; goto fail; } - retaddr =3D target_mmap(start, len, prot | PROT_WRITE, + retaddr =3D target_mmap(start, len, target_prot | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (retaddr =3D=3D -1) goto fail; if (pread(fd, g2h(start), len, offset) =3D=3D -1) goto fail; - if (!(prot & PROT_WRITE)) { - ret =3D target_mprotect(start, len, prot); + if (!(host_prot & PROT_WRITE)) { + ret =3D target_mprotect(start, len, target_prot); assert(ret =3D=3D 0); } goto the_end; @@ -502,13 +542,13 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int prot, if (real_end =3D=3D real_start + qemu_host_page_size) { /* one single host page */ ret =3D mmap_frag(real_start, start, end, - prot, flags, fd, offset); + host_prot, flags, fd, offset); if (ret =3D=3D -1) goto fail; goto the_end1; } ret =3D mmap_frag(real_start, start, real_start + qemu_host_pa= ge_size, - prot, flags, fd, offset); + host_prot, flags, fd, offset); if (ret =3D=3D -1) goto fail; real_start +=3D qemu_host_page_size; @@ -517,7 +557,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t prot, if (end < real_end) { ret =3D mmap_frag(real_end - qemu_host_page_size, real_end - qemu_host_page_size, end, - prot, flags, fd, + host_prot, flags, fd, offset + real_end - qemu_host_page_size - star= t); if (ret =3D=3D -1) goto fail; @@ -533,13 +573,13 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int prot, else offset1 =3D offset + real_start - start; p =3D mmap(g2h(real_start), real_end - real_start, - prot, flags, fd, offset1); + host_prot, flags, fd, offset1); if (p =3D=3D MAP_FAILED) goto fail; } } the_end1: - page_set_flags(start, start + len, prot | PAGE_VALID); + page_set_flags(start, start + len, page_flags); the_end: trace_target_mmap_complete(start); if (qemu_loglevel_mask(CPU_LOG_PAGE)) { --=20 2.26.2 From nobody Fri May 17 11:05:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1597301572; cv=none; d=zohomail.com; s=zohoarc; b=KJmJnR0OjH7s6PdSPZLRtPTImdRIyPocLbJLfd2nl453Bs0FjC76fIaMkRpsaTX3C/updufZuzFTJ3UTuwTzxIJL9uPaKYtfS7oijfEpO9Hic6hNXoVrrib2ClyycNTiPcuNrYMLVQwAo+VH+w5ikT9NXxcG0jXxKP61jn5Z8Sg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597301572; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wur1SFGp5xDijZMn7bJkUj1KQAmzkSNHK88wQEnF7jk=; b=Ru0+cbxyEnCnNE2s9O7ROcJsCo4FtqSinY1l2WHHYL2vDqtxzcnsT/LhaHrhdpvPeyYoFbYLHUT8TzCh7iu8630blSy8JofxiPciT12WebHVAf9pJOwTTw1U7i3KGJc95EncH5NWCelwGXAE9EnSg6GvQ/z/Rx9TkNTadzYh+GY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159730157228126.458690972476347; Wed, 12 Aug 2020 23:52:52 -0700 (PDT) Received: from localhost ([::1]:53880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k676Y-0001q4-Vm for importer@patchew.org; Thu, 13 Aug 2020 02:52:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673Q-0006Qf-AF for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:36 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:40691) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673K-0004bz-88 for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:35 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MxEcg-1kuWsR03WC-00xYAE; Thu, 13 Aug 2020 08:49:27 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 03/14] linux-user: Adjust guest page protection for the host Date: Thu, 13 Aug 2020 08:49:12 +0200 Message-Id: <20200813064923.263565-4-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200813064923.263565-1-laurent@vivier.eu> References: <20200813064923.263565-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:dak7xG3V4W0QKLOhjASDpYW82SzC8Qlh7wh9zzOo5iPO3aBNtV9 Eqv/0+1EkMSD5+veXfO3ss+U+l4Nz2TXYnZY5zQEOaH/TgW47imod9zFmFtGsdQKXYqZH95 ZWZWZFLtkwR0Qpp/o6M0Nh0igovvtZIee8LmM0IwU0kXVcyPSwuATr/kzczqDyUN/j6YCI7 EtsTVsb/2Qfb0pQhcIqtw== X-UI-Out-Filterresults: notjunk:1;V03:K0:kFJa+kebwxI=:v3fkdMtEbWQdwcCMXgFwyP xaRgl9UMaOeqC3P+k5g5zEzixWLIL5AB1lk4R1FcVEv8F8yf3zv+vDkbzJnTXfaCvz1BGzT6i UGUN4UeW8h1itVEavw7RPrNmKTfZ1BGTRe51F1wxENbUHKSBZwyfKmMBjKMUAjT2WOe1At34c sEF8U+SNdfZDE/gtPvaXhA8D5crwo3N1YY5zyIx1KvQhsg8Eh9JbwQav1VsAbPMBIvn6GluBV ujyY9XlGgg6LR9XyzOrXhJsHbG+VRVVARxHYM1sIjl8q/Re7B3J0aq9GlcHxMbYoDKUqpOrf1 UGzM5/7QkPB4N6PWWzWEEoRcWRv5Y7hWEJxIeQnd3fegDkejPbsvOBnfdqv453xISFuhezNdh dAcWOCoMa71IfrRYEUPIe+KhlLkxewg3UUeCz9JbSQlRh75y3jLXnoY0tulIMaTfX5wCJADN/ LF3TcEl56g4ISmK8zbubnFQspU3yiX3T6k/cCZecRFHs8Lr2J2vp0NupRfLXb7fyJwPh2ZqSM 2LVtxHOVJ0JOKa4eGc0Y47eHLo8BHJ8hWXmXEx39owRoQr+u1KKrojcb7BBkElSNGNdA9L1oI cI6ttAzccfmTiXBsC+Q6swBDQwKkywg+abtFXUnO2RMtYqweRpKcqu61EpOceaeoGsroLU/OI De9ERNLEGTmWtvvnl3SnUIiwi1b2Fbi5IL1DC5+rnAbCmOIq6pw4QsvgFMYjuC6zXVKUlYNdc ZXD7Pzjs45x8KTOdtqMAUo3Gx8SjYLdqdNVesmlEFxaVfg4S/4OEFZQP2ebzxC34iSbUfT2y9 a71RPCsG0QPIzCngMeqCSsKxmhEytN5LoiJpkCV1SNWHBR6ASs8sRWAq++GLYId5zqa342v Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/13 02:49:26 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Peter Maydell , Richard Henderson , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Executable guest pages are never directly executed by the host, but do need to be readable for translation. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Maydell Message-Id: <20200519185645.3915-3-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/mmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 46c7eeba9bd2..f2615634201d 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -76,8 +76,12 @@ static int validate_prot_to_pageflags(int *host_prot, in= t prot) * don't bother transforming guest bit to host bit. Any other * target-specific prot bits will not be understood by the host * and will need to be encoded into page_flags for qemu emulation. + * + * Pages that are executable by the guest will never be executed + * by the host, but the host will need to be able to read them. */ - *host_prot =3D prot & (PROT_READ | PROT_WRITE | PROT_EXEC); + *host_prot =3D (prot & (PROT_READ | PROT_WRITE)) + | (prot & PROT_EXEC ? PROT_READ : 0); =20 return prot & ~valid ? 0 : page_flags; } --=20 2.26.2 From nobody Fri May 17 11:05:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1597301673; cv=none; d=zohomail.com; s=zohoarc; b=ge+eEBr9wdE6wT85THIKhRXJJZABQiLSUah2S6wtqALMNlMtkzlQ8Xes8x6RMsf1aGFiOGiJJq5iZijpVyAHoxU3pFOkYHWbIIC/lFrzVZbpqzC2aDDxNO7SGGu2tlBxDwvGrzyMuD+GZRBpKXBI6HCIjhq5SWj/sA6GTxjRXpk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597301673; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5cuv+qOzDbM1oZ6x+D57dKd0KZk7AYrYOwmjHCy0D/M=; b=SrVEOG547JNso0AeC4edzN/jqSqtFL/SUMSMvlzQC5YOSwRXkBFddyWuQGHwGQJQgdSYj9SWOyRSDEORD+diMFBwIIFyDH/SLmlPjskU2D/xmZkShCkAo6pVBSwgj1wSH1rW5sqTuMSXnKGcBFGwmvnMupenA74C4cyUAiNBCME= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1597301673786713.1325784039116; Wed, 12 Aug 2020 23:54:33 -0700 (PDT) Received: from localhost ([::1]:60694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k678C-0004by-GE for importer@patchew.org; Thu, 13 Aug 2020 02:54:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673V-0006WD-Tg for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:41 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:37993) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673K-0004c2-NC for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:41 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MdeKd-1kfRw61xJ3-00Zgix; Thu, 13 Aug 2020 08:49:27 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 04/14] linux-user: Modify 'target_to_host/host_to_target_itimerspec()' Date: Thu, 13 Aug 2020 08:49:13 +0200 Message-Id: <20200813064923.263565-5-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200813064923.263565-1-laurent@vivier.eu> References: <20200813064923.263565-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:zuSGs6czlh0CirxHVbZlJY/8PBEHKVCR7jiWGDildMGndVr0kLj KgSpUpF4wHq2wRGYQOD2+XOsBpyYk4sotSBQc7OWa8iJwGpY1Ku3Nw1FIdRqwGCAFrRXeWS lCn3f0eKG+i7+cofus4yyUh4Ga515DFSeNKC+ZrPCVtjFDh/4b+Ho5l2ptHaKj574wkJZEt rLPZ7MGvRsbxcyFA1SRPA== X-UI-Out-Filterresults: notjunk:1;V03:K0:/rimmTGr4uw=:1AqsU3sQC2R80cRyI2kxQX rLy3FsusP9OyqztdNZXKoUH8rNe0/uH6CrfpZf9dV0aXRkxvE9XJzT1ujE9lEIBAsLLcaZldY LDwu8A2pJaFICyVkyoS6VH8c4JqA4xYQzQniStlPlou22OYtPju2d9nV0il9/6fitUxZVMZCU BNhYDE2vHEROE+QbgvY9G6VGY/ylJkubdHdhS5KU8XL+3ijNC0lfTE37RAr2oIjDNJrHT8ufU NSpPxms9v9U+kQ8UJMZ1RT6Y16Ndjt/R4+YyZreu4DKyd2a/Bgr+FD8d9XyzOv8NZnNFckFch xpMTVEp4fsn8UPl409RyGzpDEK2JkWW575I0OPHMzftfQs8v/v+g3hcIGKP7K+8yI5g9oK76A Qj49DAI0y1zIfampmkHBlv81Y4zbnJcraP7qPLAPISj+Bauw4LEToxJhJlEn25vaJ+1t0rXOw trWLX4V2NXZIjqxfUB3mC5qKbuq57VD4dY+3mW26o19CEDE85//prltofNTIVzTHNewTvdM+P FfSOWArcJNzZyheqGSDsm6WJxdAZGkSbGSOEkzB9EIdDED7vXLhVClnD9s7mhwwoUwhr4Yln0 aXxc9Z48DqrTWK0A1IJX+DlJ6Ku/zmaX5REELvyRtyfEyiT2aPNzesRmqQg1XzKI010aP0zVp m/u6XmthE5nuvXtl8XqK0O91I6egnjfLoefEHi9mvnvKj3cxrn2Rfgt9sWLTFNmddW3L7t9vs 9uZtgzsBc89qO+ElrSrGKWtNm+dmKOKG3Uh/FR91stQD60D9jiqvaX4aacsD825+aXoeSgQd1 LIM/Wbb+X8LLqXq32I+UcJ5g+DfCFlE0wzShEkAJLX3EJyTXRGrFKdkONyyd9YcYNq8kaDz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/13 02:49:29 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Filip Bozuta Functions 'target_to_host_itimerspec()' and 'host_to_target_itimerspec()' are used to convert values of type 'struct itimerspec' between target and host. This type has 'struct timespec' as its fields. That is the reason why this patch introduces a little modification to the converting functions to be implemented using already existing functions that convert 'struct tim= espec': 'target_to_host_timespec()' and 'host_to_target_timespec()'. This makes the code of 'target_to_host_itimerspec()' and 'host_to_target_itimerspec()' more clean and readable. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200722153421.295411-2-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 46 ++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 945fc252791c..aea1160804a2 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1229,7 +1229,9 @@ static inline abi_long copy_to_user_timeval64(abi_ulo= ng target_tv_addr, defined(TARGET_NR_nanosleep) || defined(TARGET_NR_clock_settime) || \ defined(TARGET_NR_utimensat) || defined(TARGET_NR_mq_timedsend) || \ defined(TARGET_NR_mq_timedreceive) || defined(TARGET_NR_ipc) || \ - defined(TARGET_NR_semop) || defined(TARGET_NR_semtimedop) + defined(TARGET_NR_semop) || defined(TARGET_NR_semtimedop) || \ + defined(TARGET_NR_timer_settime) || \ + (defined(TARGET_NR_timerfd_settime) && defined(CONFIG_TIMERFD)) static inline abi_long target_to_host_timespec(struct timespec *host_ts, abi_ulong target_addr) { @@ -6783,46 +6785,36 @@ static inline abi_long target_ftruncate64(void *cpu= _env, abi_long arg1, =20 #if defined(TARGET_NR_timer_settime) || \ (defined(TARGET_NR_timerfd_settime) && defined(CONFIG_TIMERFD)) -static inline abi_long target_to_host_itimerspec(struct itimerspec *host_i= tspec, +static inline abi_long target_to_host_itimerspec(struct itimerspec *host_i= ts, abi_ulong target_addr) { - struct target_itimerspec *target_itspec; - - if (!lock_user_struct(VERIFY_READ, target_itspec, target_addr, 1)) { + if (target_to_host_timespec(&host_its->it_interval, target_addr + + offsetof(struct target_itimerspec, + it_interval)) || + target_to_host_timespec(&host_its->it_value, target_addr + + offsetof(struct target_itimerspec, + it_value))) { return -TARGET_EFAULT; } =20 - host_itspec->it_interval.tv_sec =3D - tswapal(target_itspec->it_interval.tv_sec); - host_itspec->it_interval.tv_nsec =3D - tswapal(target_itspec->it_interval.tv_nsec); - host_itspec->it_value.tv_sec =3D tswapal(target_itspec->it_value.tv_se= c); - host_itspec->it_value.tv_nsec =3D tswapal(target_itspec->it_value.tv_n= sec); - - unlock_user_struct(target_itspec, target_addr, 1); return 0; } #endif =20 #if ((defined(TARGET_NR_timerfd_gettime) || \ defined(TARGET_NR_timerfd_settime)) && defined(CONFIG_TIMERFD)) || \ - defined(TARGET_NR_timer_gettime) || defined(TARGET_NR_timer_settime) + defined(TARGET_NR_timer_gettime) || defined(TARGET_NR_timer_settime) static inline abi_long host_to_target_itimerspec(abi_ulong target_addr, - struct itimerspec *host_its) -{ - struct target_itimerspec *target_itspec; - - if (!lock_user_struct(VERIFY_WRITE, target_itspec, target_addr, 0)) { + struct itimerspec *host_i= ts) +{ + if (host_to_target_timespec(target_addr + offsetof(struct target_itime= rspec, + it_interval), + &host_its->it_interval) || + host_to_target_timespec(target_addr + offsetof(struct target_itime= rspec, + it_value), + &host_its->it_value)) { return -TARGET_EFAULT; } - - target_itspec->it_interval.tv_sec =3D tswapal(host_its->it_interval.tv= _sec); - target_itspec->it_interval.tv_nsec =3D tswapal(host_its->it_interval.t= v_nsec); - - target_itspec->it_value.tv_sec =3D tswapal(host_its->it_value.tv_sec); - target_itspec->it_value.tv_nsec =3D tswapal(host_its->it_value.tv_nsec= ); - - unlock_user_struct(target_itspec, target_addr, 0); return 0; } #endif --=20 2.26.2 From nobody Fri May 17 11:05:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1597301804; cv=none; d=zohomail.com; s=zohoarc; b=gl6ymppvjRnYm/Dlk/Cnh/9OQXF/PC4QWTorJDpVbW+8aezH7rsS6UptP+k95bOVlc34rHT/3dqPkdRUSmUNhRPnDz0WF+6WnNyHxholLy5j/JQKQMG8Rr9h8BjpJ3kx0kobn3BT7GSUJFViwNMsKXkcDi4KUdTrOdfn+0qbSts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597301804; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N5uCHe2Kpf4srQoqFqrW/C4gieg1uq22V3Jb8LypjZ4=; b=RBu5zCoojYb6Sh1Re2yHIdXTc/QCCuXUF3/3Nlx+Bg5866zoBVmL8r0PHzZhdMQzgzSap/uBOcIdZ4EmfwfIdwEKt7+L4WKaSDBpf3Ycs05Tu2uoJ+ZpgFKtAiWnZ+iDLhk7E42iOoKn+ltUkqxEMv+Ia56KfEmbt2J2U/x1SmE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1597301804661624.1840301168102; Wed, 12 Aug 2020 23:56:44 -0700 (PDT) Received: from localhost ([::1]:40754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k67AJ-00089m-8I for importer@patchew.org; Thu, 13 Aug 2020 02:56:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673T-0006TV-UX for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:40 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:52755) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673M-0004cC-Cm for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:39 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mrggc-1kQrSt3nGe-00nlbS; Thu, 13 Aug 2020 08:49:28 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 05/14] linux-user: Add support for a group of 2038 safe syscalls Date: Thu, 13 Aug 2020 08:49:14 +0200 Message-Id: <20200813064923.263565-6-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200813064923.263565-1-laurent@vivier.eu> References: <20200813064923.263565-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:dCqji8x8mJP+mxBL/CkPObTVzMKVc4hoXe0pSziuwVvevVaOgi2 cKXXQM0JwJZ+Wva5eZFuwpDTjfSi/VIkTTIUtYyrcjJbLR7OuPgs6fFVYtQ8lsBrWtcV9d2 PrLc+ZnYenh/IkZLFni5pFVpi5mo+0qGpkygl4hOrkeBgZ5bDr6eQORLVWpwliUoccims/o AVlAt6zSjLQ+yv2Wkltew== X-UI-Out-Filterresults: notjunk:1;V03:K0:KDuER9gwmHs=:8xKKPkQ8X/toify7RglusK stm+cR7tiWn14lfjH/JE/DBMiQh6n9DZpeGaOZdJ1m8VW/3EWfGNp+FtK2PwVSNquh44aQ3VZ zixEpj4hfH2yIqRjE/BWN5Ex0TnL6KmLmR2Rv3Mc8Gx1WKEbE9U29iL/hvyXNLFEQXyH3gN9Z OrBNNyKANijV9gtL6yK6ibsdbB1Q7HGRLCNRmsJvRNSF+1s0uOndA53/qLLucaA+dnPz6cYTF ke/95D2nVbAImR/hk6lJFeXbbpGkcSshOO/WFHI4DoAT4qRnO90y1KEYP2wvAAG9og+VTWOJa 4y/cxEroUoUeQVuIgSuFsduvw+iXBoftaO0m+sYPPX5Xhn38edC63LVlsoBmf0uHRpWrZTZsm JY52cFneRwFE4ThecO1poLZiY4cDpHNdv2AyqCFh3HRP7GIjy5N96q0bB1HErgY9q5zM9z1iF x+C96duw0m2C5Mut6pR22/J0GPoA4IcyibuYwbR8c+B8Slrelo27aL1JwpC8jOycGn2r1bCqP HJ4rALbXLQSrW/C0tez1l/+hzf3NAwy1rsG+DheYcx9K0hLvzKZkUttyk7IsltIAAgrTjmj4H Ziwf4UB9PkUZxPpnRA1nsjVS+O0ebO7NKXHqjKuB0QlgdNoutcAC1TMzZlfWxICA+C5wyvZCE KB3gJyCGmFJNe1XyP4ZlfZC+/8swM//xLZD1drQwJH5jduJA516hkRm5WRdXRo2k7I+vEnB49 8mDfBrBouTePWVmeLRHC265FSXw1K1/EOSEv/ATWgPfq31xH8A3gbiZQ8huXcpvZDoQZsw8zK 14j2kcn/C6eyC2IwKX4Z2esT2HkxUUElTl4FmZVx+okFiasGifOiyF65IvgG8vWvyYjP6rI Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.74; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/13 02:49:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Filip Bozuta This patch implements functionality for following time64 syscalls: *clock_getres_time64 This a year 2038 safe variant of syscall: int clock_getres(clockid_t clockid, struct timespec *res) --finding the resoultion of a specified clock-- man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html *timer_gettime64 *timer_settime64 These are year 2038 safe variants of syscalls: int timer_settime(timer_t timerid, int flags, const struct itimerspec *new_value, struct itimerspec *old_value) int timer_gettime(timer_t timerid, struct itimerspec *curr_value) --arming/dissarming and fetching state of POSIX per-process timer-- man page: https://man7.org/linux/man-pages/man2/timer_settime.2.html *timerfd_gettime64 *timerfd_settime64 These are year 2038 safe variants of syscalls: int timerfd_settime(int fd, int flags, const struct itimerspec *new_value, struct itimerspec *old_value) int timerfd_gettime(int fd, struct itimerspec *curr_value) --timers that notify via file descriptor-- man page: https://man7.org/linux/man-pages/man2/timerfd_settime.2.html Implementation notes: Syscall 'clock_getres_time64' was implemented similarly to 'clock_getr= es()'. The only difference was that for the conversion of 'struct timespec' f= rom host to target, function 'host_to_target_timespec64()' was used instea= d of 'host_to_target_timespec()'. For other syscalls, new functions 'host_to_target_itimerspec64()' and 'target_to_host_itimerspec64()' were added to convert the value of the 'struct itimerspec' from host to target and vice versa. A new type 'struct target__kernel_itimerspec' was added in 'syscall_defs.h'. This type was defined with fields which are of the already defined type 'struct target_timespec'. This new 'struct target__kernel_itimerspec' type is used in these new converting functions. These new functions we= re defined similarly to 'host_to_target_itimerspec()' and 'target_to_host= _itimerspec()' the only difference being that 'target_to_host_timespec64()' and 'host_to_target_timespec64()' were used. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200722153421.295411-3-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 139 +++++++++++++++++++++++++++++++++++++- linux-user/syscall_defs.h | 5 ++ 2 files changed, 143 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index aea1160804a2..bbb61a59c72f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1247,7 +1247,9 @@ static inline abi_long target_to_host_timespec(struct= timespec *host_ts, } #endif =20 -#if defined(TARGET_NR_clock_settime64) || defined(TARGET_NR_futex_time64) +#if defined(TARGET_NR_clock_settime64) || defined(TARGET_NR_futex_time64) = || \ + defined(TARGET_NR_timer_settime64) || \ + (defined(TARGET_NR_timerfd_settime64) && defined(CONFIG_TIMERFD)) static inline abi_long target_to_host_timespec64(struct timespec *host_ts, abi_ulong target_addr) { @@ -6801,6 +6803,24 @@ static inline abi_long target_to_host_itimerspec(str= uct itimerspec *host_its, } #endif =20 +#if defined(TARGET_NR_timer_settime64) || \ + (defined(TARGET_NR_timerfd_settime64) && defined(CONFIG_TIMERFD)) +static inline abi_long target_to_host_itimerspec64(struct itimerspec *host= _its, + abi_ulong target_addr) +{ + if (target_to_host_timespec64(&host_its->it_interval, target_addr + + offsetof(struct target__kernel_itimerspe= c, + it_interval)) || + target_to_host_timespec64(&host_its->it_value, target_addr + + offsetof(struct target__kernel_itimerspe= c, + it_value))) { + return -TARGET_EFAULT; + } + + return 0; +} +#endif + #if ((defined(TARGET_NR_timerfd_gettime) || \ defined(TARGET_NR_timerfd_settime)) && defined(CONFIG_TIMERFD)) || \ defined(TARGET_NR_timer_gettime) || defined(TARGET_NR_timer_settime) @@ -6819,6 +6839,26 @@ static inline abi_long host_to_target_itimerspec(abi= _ulong target_addr, } #endif =20 +#if ((defined(TARGET_NR_timerfd_gettime64) || \ + defined(TARGET_NR_timerfd_settime64)) && defined(CONFIG_TIMERFD)) ||= \ + defined(TARGET_NR_timer_gettime64) || defined(TARGET_NR_timer_settim= e64) +static inline abi_long host_to_target_itimerspec64(abi_ulong target_addr, + struct itimerspec *host= _its) +{ + if (host_to_target_timespec64(target_addr + + offsetof(struct target__kernel_itimerspe= c, + it_interval), + &host_its->it_interval) || + host_to_target_timespec64(target_addr + + offsetof(struct target__kernel_itimerspe= c, + it_value), + &host_its->it_value)) { + return -TARGET_EFAULT; + } + return 0; +} +#endif + #if defined(TARGET_NR_adjtimex) || \ (defined(TARGET_NR_clock_adjtime) && defined(CONFIG_CLOCK_ADJTIME)) static inline abi_long target_to_host_timex(struct timex *host_tx, @@ -11811,6 +11851,17 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, return ret; } #endif +#ifdef TARGET_NR_clock_getres_time64 + case TARGET_NR_clock_getres_time64: + { + struct timespec ts; + ret =3D get_errno(clock_getres(arg1, &ts)); + if (!is_error(ret)) { + host_to_target_timespec64(arg2, &ts); + } + return ret; + } +#endif #ifdef TARGET_NR_clock_nanosleep case TARGET_NR_clock_nanosleep: { @@ -12405,6 +12456,32 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, } #endif =20 +#ifdef TARGET_NR_timer_settime64 + case TARGET_NR_timer_settime64: + { + target_timer_t timerid =3D get_timer_id(arg1); + + if (timerid < 0) { + ret =3D timerid; + } else if (arg3 =3D=3D 0) { + ret =3D -TARGET_EINVAL; + } else { + timer_t htimer =3D g_posix_timers[timerid]; + struct itimerspec hspec_new =3D {{0},}, hspec_old =3D {{0},}; + + if (target_to_host_itimerspec64(&hspec_new, arg3)) { + return -TARGET_EFAULT; + } + ret =3D get_errno( + timer_settime(htimer, arg2, &hspec_new, &hspec_o= ld)); + if (arg4 && host_to_target_itimerspec64(arg4, &hspec_old)) { + return -TARGET_EFAULT; + } + } + return ret; + } +#endif + #ifdef TARGET_NR_timer_gettime case TARGET_NR_timer_gettime: { @@ -12428,6 +12505,29 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, } #endif =20 +#ifdef TARGET_NR_timer_gettime64 + case TARGET_NR_timer_gettime64: + { + /* args: timer_t timerid, struct itimerspec64 *curr_value */ + target_timer_t timerid =3D get_timer_id(arg1); + + if (timerid < 0) { + ret =3D timerid; + } else if (!arg2) { + ret =3D -TARGET_EFAULT; + } else { + timer_t htimer =3D g_posix_timers[timerid]; + struct itimerspec hspec; + ret =3D get_errno(timer_gettime(htimer, &hspec)); + + if (host_to_target_itimerspec64(arg2, &hspec)) { + ret =3D -TARGET_EFAULT; + } + } + return ret; + } +#endif + #ifdef TARGET_NR_timer_getoverrun case TARGET_NR_timer_getoverrun: { @@ -12481,6 +12581,20 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, return ret; #endif =20 +#if defined(TARGET_NR_timerfd_gettime64) && defined(CONFIG_TIMERFD) + case TARGET_NR_timerfd_gettime64: + { + struct itimerspec its_curr; + + ret =3D get_errno(timerfd_gettime(arg1, &its_curr)); + + if (arg2 && host_to_target_itimerspec64(arg2, &its_curr)) { + return -TARGET_EFAULT; + } + } + return ret; +#endif + #if defined(TARGET_NR_timerfd_settime) && defined(CONFIG_TIMERFD) case TARGET_NR_timerfd_settime: { @@ -12504,6 +12618,29 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, return ret; #endif =20 +#if defined(TARGET_NR_timerfd_settime64) && defined(CONFIG_TIMERFD) + case TARGET_NR_timerfd_settime64: + { + struct itimerspec its_new, its_old, *p_new; + + if (arg3) { + if (target_to_host_itimerspec64(&its_new, arg3)) { + return -TARGET_EFAULT; + } + p_new =3D &its_new; + } else { + p_new =3D NULL; + } + + ret =3D get_errno(timerfd_settime(arg1, arg2, p_new, &its_old)= ); + + if (arg4 && host_to_target_itimerspec64(arg4, &its_old)) { + return -TARGET_EFAULT; + } + } + return ret; +#endif + #if defined(TARGET_NR_ioprio_get) && defined(__NR_ioprio_get) case TARGET_NR_ioprio_get: return get_errno(ioprio_get(arg1, arg2)); diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 3c261cff0e5e..427a25f5bce5 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -259,6 +259,11 @@ struct target_itimerspec { struct target_timespec it_value; }; =20 +struct target__kernel_itimerspec { + struct target__kernel_timespec it_interval; + struct target__kernel_timespec it_value; +}; + struct target_timex { abi_uint modes; /* Mode selector */ abi_long offset; /* Time offset */ --=20 2.26.2 From nobody Fri May 17 11:05:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1597301698; cv=none; d=zohomail.com; s=zohoarc; b=LDgzSX5l9m421BkHO0+ozGjUFvIc8IzGK4LChRBxD7c3f2lPbr6zBOIRt/Ham9BraG7Q+prOylv3IUFZSAXOdh8SWv5mayqaWEkYmv3aU99/7HyYonfwurOmI8GmS8TwmjzYCpY68sGqW4/txUrd1MZgmPfKtvPc6sH9FzRQI18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597301698; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SgMDlsJgR4YUtCs/G8Y+44mHkHHDn00osOzAnr7gwW4=; b=gpUYJC/5CYiHGk4TG+4Y1LgwMWi46szJW8V+/QDd3X85UqmkAdLb7hiluQFKRr/2TGY5nQ71PGFTmPLM3WR5JTaGNHQye+huMEZk53JABLoQt/126NFOCIyuK+EzP/Qzaw3XH3U3efI2jGbNsOyE2ytSvEQ9q+b3gjqsbnJtMUc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1597301698201284.47140002929996; Wed, 12 Aug 2020 23:54:58 -0700 (PDT) Received: from localhost ([::1]:33980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k678a-0005Ev-V1 for importer@patchew.org; Thu, 13 Aug 2020 02:54:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673S-0006SD-9L for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:38 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:51863) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673M-0004cI-E2 for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:37 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MtObA-1kyMdC2Fhu-00un0u; Thu, 13 Aug 2020 08:49:28 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 06/14] linux-user: Add support for a group of btrfs ioctls used for subvolumes Date: Thu, 13 Aug 2020 08:49:15 +0200 Message-Id: <20200813064923.263565-7-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200813064923.263565-1-laurent@vivier.eu> References: <20200813064923.263565-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:KoC6zAaNCDMyXjDVi2VRR7G7Yd+aqOjsoINDfQuuw6DPQPHqI/e tTW8xJl7DPuWE6e6ToolarjaW76ni4/dVsDYtAfrY3U8ez2Fp0gWLwmMkhR65yIgQ4aXBen SFz5LNsOAr+he5Pj0aKgHr6YreKiHwZoR8j5+kq7CnA5L1/wbpPYF4DtahK9IOBhITpY+78 8OdIxCwJBmsdnJxSN9fCA== X-UI-Out-Filterresults: notjunk:1;V03:K0:oD/jXqUHFa0=:OjeV3eFivXww8CvuFfW+62 T8IAtpesxJm2hSmRI0cNB8JdsSX+gWCGEp6TZ05JRD9zOdAdw/GIq5nLmynmRjjp+vppNbk3B zAxtwemiHLK7Diwp4/ObdX7LjbVtZ8Pnh5COnX3uy4LYyM2OK0WvvveCe0ahQAmJCYG8E1pSC FAA6HZNS4nx2389EdVv5hrE/XdL49qYGY314OLD2l7Jj0gVNHYC+ieh0lwye0Uw4FzvL+chuc 25GLOXGFoceb3GsXBpnI2hefWOjG0QSnbwujcgSDbjmwOj3pruLZ+aQSTpJ2mUDpIBzdp/MBM CZTAvfm+x1ZF3PjK8fGmRDwtJ3BmeoO+X1p/4O26j18XiYp3Ar+PWbH/C5lubLRs1mOXA8O7A WVtZKfeMyFndfOMIwd2Jl1kK7sFitGiPQVqfe3cXMNMtZ3AwHq0SGKBYUHa8TpqmOJFxagSCd H9RoizKxEZf8dMjyTUs7AH0txxcfH/KyZzUeh83AMhvPj/eL4YBVMDexwRtwalbWQUPJlJupg D0by+YJWbXzE5bP4RfcunMlmF5eb9KCWzilgPgS7Hg8lDgl4VxQQs5oOwAMj39EoF0iBIJtIA D2kwRDyiBAp1RxyvM3Mc+1ZvLlg1PSnHX38G7eDfyCX1n90iFvrIh3zCicdgziBl9PyJkvX6m UyulwE6AktzXFUwxcGT85fiFIKumFmpO9Tp+F5/dpKiXcYvaJ1QsywsG0n/azccZ7cdsAA+7d uE8HOlPlxOEffBWmgsKqHpFKs0T6L+2tDRmltKBBRm31so3cCIfoTR8G9l8vUUpZKBIcFzcZA U9PSlx5tw1mYZ/ZpdQIW9X9Ax7gJuzyEphu1tfo9bR87sWeKwHmt6T2g6SC2+F4c6fKnUEL Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.10; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/13 02:49:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Filip Bozuta This patch implements functionality of following ioctls: BTRFS_IOC_SUBVOL_CREATE - Creating a btrfs subvolume Create a btrfs subvolume. The subvolume is created using the ioctl's third argument which represents a pointer to a following structure type: struct btrfs_ioctl_vol_args { __s64 fd; char name[BTRFS_PATH_NAME_MAX + 1]; }; Before calling this ioctl, the fields of this structure should be filled with aproppriate values. The fd field represents the file descriptor value of the subvolume and the name field represents the subvolume path. BTRFS_IOC_SUBVOL_GETFLAGS - Getting subvolume flags Read the flags of the btrfs subvolume. The flags are read using the ioctl's third argument that is a pointer of __u64 (unsigned long). The third argument represents a bit mask that can be composed of follow= ing values: BTRFS_SUBVOL_RDONLY (1ULL << 1) BTRFS_SUBVOL_QGROUP_INHERIT (1ULL << 2) BTRFS_DEVICE_SPEC_BY_ID (1ULL << 3) BTRFS_SUBVOL_SPEC_BY_ID (1ULL << 4) BTRFS_IOC_SUBVOL_SETFLAGS - Setting subvolume flags Set the flags of the btrfs subvolume. The flags are set using the ioctl's third argument that is a pointer of __u64 (unsigned long). The third argument represents a bit mask that can be composed of same values as in the case of previous ioctl (BTRFS_IOC_SUBVOL_GETFLAGS). BTRFS_IOC_SUBVOL_GETINFO - Getting subvolume information Read information about the subvolume. The subvolume information is returned in the ioctl's third argument which represents a pointer to a following structure type: struct btrfs_ioctl_get_subvol_info_args { /* Id of this subvolume */ __u64 treeid; /* Name of this subvolume, used to get the real name at mount point */ char name[BTRFS_VOL_NAME_MAX + 1]; /* * Id of the subvolume which contains this subvolume. * Zero for top-level subvolume or a deleted subvolume. */ __u64 parent_id; /* * Inode number of the directory which contains this subvolume. * Zero for top-level subvolume or a deleted subvolume */ __u64 dirid; /* Latest transaction id of this subvolume */ __u64 generation; /* Flags of this subvolume */ __u64 flags; /* UUID of this subvolume */ __u8 uuid[BTRFS_UUID_SIZE]; /* * UUID of the subvolume of which this subvolume is a snapshot. * All zero for a non-snapshot subvolume. */ __u8 parent_uuid[BTRFS_UUID_SIZE]; /* * UUID of the subvolume from which this subvolume was received. * All zero for non-received subvolume. */ __u8 received_uuid[BTRFS_UUID_SIZE]; /* Transaction id indicating when change/create/send/receive happened */ __u64 ctransid; __u64 otransid; __u64 stransid; __u64 rtransid; /* Time corresponding to c/o/s/rtransid */ struct btrfs_ioctl_timespec ctime; struct btrfs_ioctl_timespec otime; struct btrfs_ioctl_timespec stime; struct btrfs_ioctl_timespec rtime; /* Must be zero */ __u64 reserved[8]; }; All of the fields of this structure are filled after the ioctl call. Implementation notes: Ioctls BTRFS_IOC_SUBVOL_CREATE and BTRFS_IOC_SUBVOL_GETINFO have struct= ure types as third arguments. That is the reason why a corresponding defini= tion are added in file 'linux-user/syscall_types.h'. The line '#include ' is added in file 'linux-user/syscal= l.c' to recognise preprocessor definitions for these ioctls. Since the file "li= nux/btrfs.h" was added in the kernel version 3.9, it is enwrapped in an #ifdef state= ment with parameter CONFIG_BTRFS which is defined in 'configure' if the header file is present. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200803094629.21898-2-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- configure | 9 +++++++++ linux-user/ioctls.h | 15 +++++++++++++++ linux-user/syscall.c | 3 +++ linux-user/syscall_defs.h | 8 ++++++++ linux-user/syscall_types.h | 28 ++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+) diff --git a/configure b/configure index 2acc4d1465f8..1cba4e0b80fb 100755 --- a/configure +++ b/configure @@ -5079,6 +5079,12 @@ if check_include sys/kcov.h ; then kcov=3Dyes fi =20 +# check for btrfs filesystem support (kernel must be 3.9+) +btrfs=3Dno +if check_include linux/btrfs.h ; then + btrfs=3Dyes +fi + # If we're making warnings fatal, apply this to Sphinx runs as well sphinx_werror=3D"" if test "$werror" =3D "yes"; then @@ -7330,6 +7336,9 @@ fi if test "$kcov" =3D "yes" ; then echo "CONFIG_KCOV=3Dy" >> $config_host_mak fi +if test "$btrfs" =3D "yes" ; then + echo "CONFIG_BTRFS=3Dy" >> $config_host_mak +fi if test "$inotify" =3D "yes" ; then echo "CONFIG_INOTIFY=3Dy" >> $config_host_mak fi diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 0713ae131162..12d14442249f 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -174,6 +174,21 @@ IOCTL(FS_IOC32_GETVERSION, IOC_R, MK_PTR(TYPE_INT)) IOCTL(FS_IOC32_SETVERSION, IOC_W, MK_PTR(TYPE_INT)) =20 +#ifdef BTRFS_IOC_SUBVOL_CREATE + IOCTL(BTRFS_IOC_SUBVOL_CREATE, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif +#ifdef BTRFS_IOC_SUBVOL_GETFLAGS + IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG)) +#endif +#ifdef BTRFS_IOC_SUBVOL_SETFLAGS + IOCTL(BTRFS_IOC_SUBVOL_SETFLAGS, IOC_W, MK_PTR(TYPE_ULONGLONG)) +#endif +#ifdef BTRFS_IOC_GET_SUBVOL_INFO + IOCTL(BTRFS_IOC_GET_SUBVOL_INFO, IOC_R, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args))) +#endif + #ifdef CONFIG_USBFS /* USB ioctls */ IOCTL(USBDEVFS_CONTROL, IOC_RW, diff --git a/linux-user/syscall.c b/linux-user/syscall.c index bbb61a59c72f..10dd53bf999b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -115,6 +115,9 @@ #ifdef HAVE_DRM_H #include #endif +#ifdef CONFIG_BTRFS +#include +#endif #include "linux_loop.h" #include "uname.h" =20 diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 427a25f5bce5..5435baea38d9 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -972,6 +972,14 @@ struct target_rtc_pll_info { #define TARGET_FS_IOC32_GETVERSION TARGET_IOR('v', 1, int) #define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int) =20 +/* btrfs ioctls */ +#define TARGET_BTRFS_IOC_SUBVOL_CREATE TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 14) +#define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAG= IC, 25,\ + abi_ullong) +#define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAG= IC, 26,\ + abi_ullong) +#define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IORU(BTRFS_IOCTL_MA= GIC, 60) + /* usb ioctls */ #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0) #define TARGET_USBDEVFS_BULK TARGET_IOWRU('U', 2) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 3f1f0334649b..cfd8e1c7eea7 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -354,6 +354,34 @@ STRUCT(blkpg_partition, MK_ARRAY(TYPE_CHAR, BLKPG_DEVNAMELTH), /* devname */ MK_ARRAY(TYPE_CHAR, BLKPG_VOLNAMELTH)) /* volname */ =20 +STRUCT(btrfs_ioctl_vol_args, + TYPE_LONGLONG, /* fd */ + MK_ARRAY(TYPE_CHAR, BTRFS_PATH_NAME_MAX + 1)) /* name */ + +STRUCT(btrfs_ioctl_timespec, + TYPE_ULONGLONG, /* sec */ + TYPE_INT) /* nsec */ + +STRUCT(btrfs_ioctl_get_subvol_info_args, + TYPE_ULONGLONG, /* treeid */ + MK_ARRAY(TYPE_CHAR, BTRFS_VOL_NAME_MAX + 1), + TYPE_ULONGLONG, /* parentid */ + TYPE_ULONGLONG, /* dirid */ + TYPE_ULONGLONG, /* generation */ + TYPE_ULONGLONG, /* flags */ + MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* uuid */ + MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* parent_uuid */ + MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* received_uuid */ + TYPE_ULONGLONG, /* ctransid */ + TYPE_ULONGLONG, /* otransid */ + TYPE_ULONGLONG, /* stransid */ + TYPE_ULONGLONG, /* rtransid */ + MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* ctime */ + MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* otime */ + MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* stime */ + MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* rtime */ + MK_ARRAY(TYPE_ULONGLONG, 8)) /* reserved */ + STRUCT(rtc_time, TYPE_INT, /* tm_sec */ TYPE_INT, /* tm_min */ --=20 2.26.2 From nobody Fri May 17 11:05:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1597301621; cv=none; d=zohomail.com; s=zohoarc; b=YAzwFBPm9elBszH9JHN2U8jHvUApAgEogSJkr0dZG0JPGnuG2s3cGCeZMHX69Vg9hQYxaCFKVT3dsoWcMtnbEA9WM/1SWus7YgCH5/Y6KquXG8SYm31u5oXYqMzYYFYO8rHsx7vYlkHGkBrDSkBmxTy6+ytRELNoIRQj7GvFYwE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597301621; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=P/tKLeK2B+zabt0n9Tj7ySz8MI4v8NZGv6mFMTRO9lM=; b=IwCKkdPws7KUwkgP6aaTy7UG03PcXhDWQ0uVIghy60/ya4qW+YDPe1xsGn539mAxL4Y77Sokd7OsuVc8ZWhbphseRwPFEClDiQwDAgrfEvT1tQC1LKDvNH7ACsJlqCVei9mLspWvrS+u7Db7m9OgAvScOtP7FDLG0jiLlOih2xE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1597301621393963.2941934820753; Wed, 12 Aug 2020 23:53:41 -0700 (PDT) Received: from localhost ([::1]:57320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k677M-0003DD-5T for importer@patchew.org; Thu, 13 Aug 2020 02:53:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673R-0006RC-9K for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:37 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:41329) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673M-0004cK-Dt for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:36 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M9Evp-1k1SU20D3f-006QVh; Thu, 13 Aug 2020 08:49:29 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 07/14] linux-user: Add support for a group of btrfs ioctls used for snapshots Date: Thu, 13 Aug 2020 08:49:16 +0200 Message-Id: <20200813064923.263565-8-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200813064923.263565-1-laurent@vivier.eu> References: <20200813064923.263565-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:tsAE1iOXlHQiM4x0Z1TzTkGxdmG10Vmsy4wvE/faaGCJ2OC+GQT DMSUPpGtmr04G6TvzgqpLWy2PpHWBbHfX5fATwI9IHOY7G7DSetU3ai/lEutN3uJTO8GUyn taqHi0SUd+uhvEW3AubglYtSUsjV1nffSYW8zYdXz0oH+gYjkImnN/Au7c0uKOj1BEgvAKD d5SVDzJSwytj/0dOaGjeQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:a5GWrqxTXFQ=:64r3JsbyovqS2yvHzmHiKz ih/HvbvMMKedD1aUog1hvAK45b50q13ZyDHgrFYgsWUTvNUTsAEvB39UjCoJ/A1LOppevgqrT 04TPGzmd1BCQwdx4UaIiw+1Xxd1SRIjHvXIl7Lh/vtJNjtXifMsZYFD7Z6R103/5v04bb5ivM 1k/cJ7FcaAMmrvBGjy3R85/PEqedI4Rflc5waFHMdW19n0sSAesjyLG9zfuqBIERc3aKxhlhl usD9at/TF1/fFcy+Q3pdshQbp99wUypGB2dkWKGGEU7sDd1anCVADLGQDVru7BqNdlVkhOMSv gfQ7y5Xe80QqG2LCgo4rjtfbXrIn5UHVEiZqCgxnEiL+Lj4wkmvfCOSOOHAT0Rzmf7FrvtzRe awOH9mJB3tjusBZaAb0ZsALpA/H/1quV8wL8sZxCHE+Q1vk11gG/m7YcmAbjARI3+Fwmi7J3u WX/03+Y++5UvxiYE8r9Okbj82/s2Os7Mz9J5moTL4D2NEybRfJWhfYlt5npji93p2RvrMTp47 DjDQYg2UxlDoC87vywiIucXuKlEU8lJEFt869fMwH/wfyAAtwbBbI/b74mWL8IFJl0uyl1ra2 J5vVofmxhZ1w0dIeOAImeGCogJp40McxYnJ0GHQj95pGeHllGh1WVuRX8RqMvDOgKktUHr9x3 yW7uLVWrdLksme1nDYCPyk/pOtVJe2kz6aqY1/PTBOibQHYb3X4RQPV4RoI8sWkfSJD8+BrBr SsAovSFvmlXNXygTbq9nEfh8AY6QDTOPqSr3SwhI+vmvXuiwTWgce4O+PiJN8x/JhwDOzXhJv kwfwUjAAsbc3D1ElgcObkvb41aWORfPTQs7SRsu3bUPNZ4aZKyBwjNvI+4HhBr7BUuzfwek Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/13 02:49:26 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Filip Bozuta This patch implements functionality for following ioctls: BTRFS_IOC_SNAP_CREATE - Creating a subvolume snapshot Create a snapshot of a btrfs subvolume. The snapshot is created using t= he ioctl's third argument that is a pointer to a 'struct btrfs_ioctl_vol_a= rgs' (which was mentioned in the previous patch). Before calling this ioctl, the fields of the structure should be filled with aproppriate values for the file descriptor and path of the subvolume for which the snapshot is= to be created. BTRFS_IOC_SNAP_DESTROY - Removing a subvolume snapshot Delete a snapshot of a btrfs subvolume. The snapshot is deleted using t= he ioctl's third argument that is a pointer to a 'struct btrfs_ioctl_vol_a= rgs' (which was mentioned in the previous patch). Before calling this ioctl, the fields of the structure should be filled with aproppriate values for the file descriptor and path of the subvolume for which the snapshot is= to be deleted. Implementation notes: Since the thunk type 'struct btrfs_ioctl_vol_args' is defined in the previous patch, the implementation for these ioctls was straightforward. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200803094629.21898-3-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 8 ++++++++ linux-user/syscall_defs.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 12d14442249f..f33a99f8b642 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -174,10 +174,18 @@ IOCTL(FS_IOC32_GETVERSION, IOC_R, MK_PTR(TYPE_INT)) IOCTL(FS_IOC32_SETVERSION, IOC_W, MK_PTR(TYPE_INT)) =20 +#ifdef BTRFS_IOC_SNAP_CREATE + IOCTL(BTRFS_IOC_SNAP_CREATE, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif #ifdef BTRFS_IOC_SUBVOL_CREATE IOCTL(BTRFS_IOC_SUBVOL_CREATE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) #endif +#ifdef BTRFS_IOC_SNAP_DESTROY + IOCTL(BTRFS_IOC_SNAP_DESTROY, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif #ifdef BTRFS_IOC_SUBVOL_GETFLAGS IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG)) #endif diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 5435baea38d9..e514cb6916ed 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -973,7 +973,9 @@ struct target_rtc_pll_info { #define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int) =20 /* btrfs ioctls */ +#define TARGET_BTRFS_IOC_SNAP_CREATE TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 1) #define TARGET_BTRFS_IOC_SUBVOL_CREATE TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 14) +#define TARGET_BTRFS_IOC_SNAP_DESTROY TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 15) #define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAG= IC, 25,\ abi_ullong) #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAG= IC, 26,\ --=20 2.26.2 From nobody Fri May 17 11:05:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1597301728; cv=none; d=zohomail.com; s=zohoarc; b=CmTb6EBpr3SuQYh6i4NOF+KV9LhwS15kdytUkF01mnIjuMNN8+LJhgAWA+s3Q8v/h7POZm9UlMnCAK86+J1xn8c2JDwfITwWFQ/gYtINeJkeuIumLOml5MnhK3zkNE3QBnPw81vdy9HvXSYOwMfUJ7pKyMzRYuAhPxjZ2v9iLT4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597301728; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wt2g2I4E5Zb/HxswVADyr1gekoEV60Io4ivuMvjD+iI=; b=jBMW/7VjReKl/1i8sEKSLa/m3nWdCAlseG6BN7bPhwNtQriJ0L3SZe2HyboMMFlq/Kzx++gUzaZtwwZnwv5R5ILEuIrdIk77KROiS7BMNWCVxskQwnmj3gEYGjAZOmEYXJkofHY+OpDjpG+AUUUTP1uLSgUSX/jDPY51ucdeBr4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1597301728300344.55731074204857; Wed, 12 Aug 2020 23:55:28 -0700 (PDT) Received: from localhost ([::1]:36926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k6794-0006TV-Sx for importer@patchew.org; Thu, 13 Aug 2020 02:55:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673W-0006WY-8K for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:43 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:48395) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673O-0004ca-9s for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:41 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mleo0-1kWt592TY2-00inWi; Thu, 13 Aug 2020 08:49:29 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 08/14] linux-user: Add support for btrfs ioctls used to manipulate with devices Date: Thu, 13 Aug 2020 08:49:17 +0200 Message-Id: <20200813064923.263565-9-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200813064923.263565-1-laurent@vivier.eu> References: <20200813064923.263565-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:hqTxDPynkogFLZ5+5CvGqKbiyz4EjOYjOCaoXUzNP+YP8MnXBIj J5yj8gG5OgcSA7p5P3uIuuymbse2uX0W8MNiiDF8vJVKIKAMOA+kOp/SkMNxMRFWNH17ldE etEmNWYx7Nxzqd/xFqw6t11Y7p7RoWF8IBVQ/6qNakLY5T8+UXoiVtey9ZOKQaR8LOoH6Dt yBBizren36n5ARpfZNZGw== X-UI-Out-Filterresults: notjunk:1;V03:K0:vyBkMHAxbtc=:pPWEZCHYOl9SmEwk4fNToP N5/zKy19Z2SkTnNbLmSqQ5sUYBoX/1g+AxSjPULFCMJtEm6CugZyxKnEjK15P4AqZrJN0rXRN 6Z9ZdZoR2oyLJWYzJWyttmPLOxdHpwnTMfYvR1D7xMT2d8hKzyUK5ZC22p36rU6gXLIqNCT1X rMwo1GWgq+mk3pAzbVVyqDwDvTkUJOV5dy0N6Qw3dtb/KhZqwPVDt3J2eYo3rQIDA+DFu3+Qb b+Q7LVuKloyu/VfgyziShU09D3M2nFdsAlPBEUpCWRY1lHeb5AXbyDytAsEZr5NFQxSC+N4ps NZ8YExCicG+MXQAAkyDFHKgoElsu07zhUYoVSs6tjpv9QqdvRQBBWU7Iqq85lSDciuzj0577n mLyDJdItOtyphk6/1rrXmLAZAsE6TTrOEUezqVQ602gry3Q2BIXY4ZUcEhwP1b/1wCFAzqr+G gg4cAtk8bFid9plav6t8FsKIFLR724xd4L8NxgV7PsO4H7wDi7/ybt2xHVmoulAu+tOu6I+sY WJ4GGVaAPyHwF6ZffTlQsc7NKRtc0oUqxOwkVxxt1Vsbmsc6QETum12cmvyRrt04vuREO3M4Y 9cwE6yr5aIEEmi6UtSoHvQRzjS70i7iKlbNq+RmJVF9MVRJLP7Tj5jYU39URnN8i/YHGcqJC9 w4z4yN464YxXCWQCSKsdPSg00u6xuMlyE+HYaCMDSEi97QMsHXs1rZVGqAQLiWCR5HgvRnpR0 F7Yu+NUfN+eO4XZoMsHyR6XTHS2DtSJlE76qb3Cat1AelO7cnLu63I0jcavKL1lZCe7VC/wE8 a7BfHyYfCANXP6NXpFYpkogZAIl2xNCYxPpyAEiIEWl/K39agcimrpyrxvOY89ahzQ5eVuY Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/13 02:49:32 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Filip Bozuta This patch implements functionality for following ioctls: BTRFS_IOC_SCAN_DEV - Scanning device for a btrfs filesystem Scan a device for a btrfs filesystem. The device that is to be scanned is passed in the ioctl's third argument which represents a pointer to a 'struct ioc_vol_args' (which was mentioned in a previous patch). Before calling this ioctl, the name field of this structure should be filled with the aproppriate name value which represents a path for the device. If the device contains a btrfs filesystem, the ioctl returns 0, otherwise a negative value is returned. BTRFS_IOC_ADD_DEV - Adding a device to a btrfs filesystem Add a device to a btrfs filesystem. The device that is to be added is passed in the ioctl's third argument which represents a pointer to a 'struct ioc_vol_args' (which was mentioned in a previous patch). Before calling this ioctl, the name field of this structure should be filled with the aproppriate name value which represents a path for the device. BTRFS_IOC_RM_DEV - Removing a device from a btrfs filesystem Remove a device from a btrfs filesystem. The device that is to be removed is passed in the ioctl's third argument which represents a pointer to a 'struct ioc_vol_args' (which was mentioned in a previous patch). Before calling this ioctl, the name field of this structure should be filled with the aproppriate name value which represents a path for the device. BTRFS_IOC_DEV_INFO - Getting information about a device Obtain information for device in a btrfs filesystem. The information is gathered in the ioctl's third argument which represents a pointer to a following structure type: struct btrfs_ioctl_dev_info_args { __u64 devid; /* in/out */ __u8 uuid[BTRFS_UUID_SIZE]; /* in/out */ __u64 bytes_used; /* out */ __u64 total_bytes; /* out */ __u64 unused[379]; /* pad to 4k */ __u8 path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */ }; Before calling this ioctl, field "devid" should be set with the id value for the device for which the information is to be obtained. If this fie= ld is not aproppriately set, the errno ENODEV ("No such device") is return= ed. BTRFS_IOC_GET_DEV_STATS - Getting device statistics Obtain stats informatin for device in a btrfs filesystem. The informati= on is gathered in the ioctl's third argument which represents a pointer to a following structure type: struct btrfs_ioctl_get_dev_stats { __u64 devid; /* in */ __u64 nr_items; /* in/out */ __u64 flags; /* in/out */ /* out values: */ __u64 values[BTRFS_DEV_STAT_VALUES_MAX]; /* * This pads the struct to 1032 bytes. It was originally meant to pad to * 1024 bytes, but when adding the flags field, the padding calculation * was not adjusted. */ __u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX]; }; Before calling this ioctl, field "devid" should be set with the id value for the device for which the information is to be obtained. If this fie= ld is not aproppriately set, the errno ENODEV ("No such device") is return= ed. BTRFS_IOC_FORGET_DEV - Remove unmounted devices Search and remove all stale devices (devices which are not mounted). The third ioctl argument is a pointer to a 'struct btrfs_ioctl_vol_args= '. The ioctl call will release all unmounted devices which match the path which is specified in the "name" field of the structure. If an empty path ("") is specified, all unmounted devices will be released. Implementation notes: Ioctls BTRFS_IOC_DEV_INFO and BTRFS_IOC_GET_DEV_STATS use types 'struct btrfs_ioctl_dev_info_args' and ' struct btrfs_ioctl_get_dev_sta= ts' as third argument types. That is the reason why corresponding structure definitions were added in file 'linux-user/syscall_types.h'. Since the thunk type for 'struct ioc_vol_args' was already added in a previous patch, the rest of the implementation was straightforward. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200803094629.21898-4-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 24 ++++++++++++++++++++++++ linux-user/syscall_defs.h | 6 ++++++ linux-user/syscall_types.h | 16 ++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index f33a99f8b642..55a6cbeca515 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -178,6 +178,22 @@ IOCTL(BTRFS_IOC_SNAP_CREATE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) #endif +#ifdef BTRFS_IOC_SCAN_DEV + IOCTL(BTRFS_IOC_SCAN_DEV, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif +#ifdef BTRFS_IOC_FORGET_DEV + IOCTL(BTRFS_IOC_FORGET_DEV, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif +#ifdef BTRFS_IOC_ADD_DEV + IOCTL(BTRFS_IOC_ADD_DEV, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif +#ifdef BTRFS_IOC_RM_DEV + IOCTL(BTRFS_IOC_RM_DEV, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif #ifdef BTRFS_IOC_SUBVOL_CREATE IOCTL(BTRFS_IOC_SUBVOL_CREATE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) @@ -192,6 +208,14 @@ #ifdef BTRFS_IOC_SUBVOL_SETFLAGS IOCTL(BTRFS_IOC_SUBVOL_SETFLAGS, IOC_W, MK_PTR(TYPE_ULONGLONG)) #endif +#ifdef BTRFS_IOC_DEV_INFO + IOCTL(BTRFS_IOC_DEV_INFO, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_dev_info_args))) +#endif +#ifdef BTRFS_IOC_GET_DEV_STATS + IOCTL(BTRFS_IOC_GET_DEV_STATS, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_dev_stats))) +#endif #ifdef BTRFS_IOC_GET_SUBVOL_INFO IOCTL(BTRFS_IOC_GET_SUBVOL_INFO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args))) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index e514cb6916ed..f9f94c9c08cc 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -974,12 +974,18 @@ struct target_rtc_pll_info { =20 /* btrfs ioctls */ #define TARGET_BTRFS_IOC_SNAP_CREATE TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 1) +#define TARGET_BTRFS_IOC_SCAN_DEV TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 4) +#define TARGET_BTRFS_IOC_FORGET_DEV TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 5) +#define TARGET_BTRFS_IOC_ADD_DEV TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 10) +#define TARGET_BTRFS_IOC_RM_DEV TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 11) #define TARGET_BTRFS_IOC_SUBVOL_CREATE TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 14) #define TARGET_BTRFS_IOC_SNAP_DESTROY TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 15) #define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAG= IC, 25,\ abi_ullong) #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAG= IC, 26,\ abi_ullong) +#define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 30) +#define TARGET_BTRFS_IOC_GET_DEV_STATS TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 52) #define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IORU(BTRFS_IOCTL_MA= GIC, 60) =20 /* usb ioctls */ diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index cfd8e1c7eea7..35f94cdfc8ba 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -382,6 +382,22 @@ STRUCT(btrfs_ioctl_get_subvol_info_args, MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* rtime */ MK_ARRAY(TYPE_ULONGLONG, 8)) /* reserved */ =20 +STRUCT(btrfs_ioctl_dev_info_args, + TYPE_ULONGLONG, /* devid */ + MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* uuid */ + TYPE_ULONGLONG, /* bytes_used */ + TYPE_ULONGLONG, /* total_bytes */ + MK_ARRAY(TYPE_ULONGLONG, 379), /* unused */ + MK_ARRAY(TYPE_CHAR, BTRFS_DEVICE_PATH_NAME_MAX)) /* path */ + +STRUCT(btrfs_ioctl_get_dev_stats, + TYPE_ULONGLONG, /* devid */ + TYPE_ULONGLONG, /* nr_items */ + TYPE_ULONGLONG, /* flags */ + MK_ARRAY(TYPE_ULONGLONG, BTRFS_DEV_STAT_VALUES_MAX), /* values */ + MK_ARRAY(TYPE_ULONGLONG, + 128 - 2 - BTRFS_DEV_STAT_VALUES_MAX)) /* unused */ + STRUCT(rtc_time, TYPE_INT, /* tm_sec */ TYPE_INT, /* tm_min */ --=20 2.26.2 From nobody Fri May 17 11:05:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1597301622; cv=none; d=zohomail.com; s=zohoarc; b=WXSQQTDrWQcAttFgG91bYaQ6qRYU/5ag1oGKuFPuj0+QvemxRUKjLBBKzaZ6wBCPesda6Q1wqlcqgwDSo7i0i0yGPwDagvSWru50dU8CD9LjAcC6wG3CF89y4mX01fSNXnCqDKSIidS3AkF1N4Hfe0Zn3rpWozsvv/0kNwgHC6M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597301622; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IAHIcZ/uhlWT20zk5gmzOy47dW73AzqSPLYlK54/lWc=; b=BqNkrgTvN4AaVV8YYaPQCMxwV1xAS71mUJxvaDoMg8regmCTV1pQFjyt4b86s4N5EKIoqIw2VQNvNhnybWV3GB1vdNaHWnw3fWu1MAidceCrg30kEtuayq1Iv2FVrOfOSEiyZGan2rpDOSZqELLtjJ2wvHhDPRhxddHLFhEXhMM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1597301622217137.95106811966775; Wed, 12 Aug 2020 23:53:42 -0700 (PDT) Received: from localhost ([::1]:57406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k677M-0003Ew-Vp for importer@patchew.org; Thu, 13 Aug 2020 02:53:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673Z-0006Yp-JL for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:45 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:48837) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673O-0004cV-9L for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:43 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MUXd0-1kEoCQ0Zqy-00QROc; Thu, 13 Aug 2020 08:49:30 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 09/14] linux-user: Add support for btrfs ioctls used to get/set features Date: Thu, 13 Aug 2020 08:49:18 +0200 Message-Id: <20200813064923.263565-10-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200813064923.263565-1-laurent@vivier.eu> References: <20200813064923.263565-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:m6VFafcuoNf5mrYO2G0qw5Y+EVpgAne4v30b/Wd/urDsIc19UKR JASVzk6h6Q1Z+LoSd7rd3nLpaAOJ8rsy8rx9rniFd3DGpirPPfCasJe1izhma1QFIIT0ind hnlAzEBdSmp8DQJcbdmExxBBXlJNUNCUUwxCZiCN4IobW/EuSqZ511jI70NxTLY7R+70kKV +kGcCFllhglI0xKVm5maw== X-UI-Out-Filterresults: notjunk:1;V03:K0:gDbEU3g0TYM=:8YUL5o8Xi1Eh5gEneCwr3f kT2a+gVGT54NTYcgC5QyM6sSOJ6oeIle7Thq27Wf2kOAY5U438TaV198z5s3dnE0GXZlYOL8I 8UUzBgD1OHjs0NqLMB2K84FPuQ9uuLSiybX7iNMytVZqgQiq6LSra6W7FU7X8puLWICng7jd/ McYZDB8gZ3iAVr8NeYRNgfopu8KZxzB3VQgwDqhLRSvaPDeMf0y6FBLhCYPQmJHmrsquIcQe4 eaonlSK4pIBTGxKqLj6wbUZzNOdwQpEAFFva09J2oTl7Br+AADexQ/k4xgzOQeagFqdzIWwb6 YHSLNa9/CI4atSqzrdEzCHp4RQkx4+NkhXN+b2ir/V4iDwheaj+nu5gEhOTLch+qxRkj0D/w2 mqxoNOF/ltWwVs4Fyb5FxBLKky/TnGOAl0QV1ZkEL2pKBrWrgcnEIX0OuhL5CtuHK9RXS0wwd wsnq9C0SXwbt52P7U19I1A1dfouBa+TZFsH8XYjx/eYxxDXRQMhBHa4Hpzb0prwgN9lGhbHL0 JmxuxnhJos/X1fRADnHmI+iASauWvfhglwUqjRenoOpHiO0zW9/3eTTnH4nm5LsoKb9PhvOS6 XB8lmLRJYPvfLUwK+iT54o5GYMOdnNKb/8AdSNkYdUCdClF51EwW7+y++VCKrMCNH9RVcJEkT 3lrrHQVQaJ4565/zZjChGlovbbrZNQbzeywfvgU887oIagwKMeVaCqPwhkvRzcDapbSZ2lZEK zE1Vh/pvSOhBEASNVAb146zEIA6Xv9LNn0Gvl/WhtcYYTZYciHPb1ZYPMp3wBdWWaDSegviU3 N3lXB+rprWHQsZNEiB4oAN8ZrPxwLO0w3VfgpVI1VADy/RqnIBaItz+tennz3Yq0ucgRqKN Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/13 02:49:29 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Filip Bozuta This patch implements functionality for following ioctls: BTRFS_IOC_GET_FEATURES - Getting feature flags Read feature flags for a btrfs filesystem. The feature flags are returned inside the ioctl's third argument which represents a pointer to a following structure type: struct btrfs_ioctl_feature_flags { __u64 compat_flags; __u64 compat_ro_flags; __u64 incompat_flags; }; All of the structure field represent bit masks that can be composed of values which can be found on: https://elixir.bootlin.com/linux/latest/source/fs/btrfs/ctree.h#L282 BTRFS_IOC_SET_FEATURES - Setting feature flags Set and clear feature flags for a btrfs filesystem. The feature flags are set using the ioctl's third argument which represents a 'struct btrfs_ioctl_feature_flags[2]' array. The first element of the array represent flags which are to be cleared and the second element of the array represent flags which are to be set. The second element has t= he priority over the first, which means that if there are matching flags in the elements, they will be set in the filesystem. If the flag values in the third argument aren't correctly set to be composed of the availa= ble predefined flag values, errno ENOPERM ("Operation not permitted") is re= turned. BTRFS_IOC_GET_SUPPORTED_FEATURES - Getting supported feature flags Read supported feature flags for a btrfs filesystem. The supported feature flags are read using the ioctl's third argument which represents a 'struct btrfs_ioctl_feature_flags[3]' array. The first element of this array represents all of the supported flags in the btrfs filesystem. The second element represents flags that can be safely set and third el= ement represent flags that can be safely clearead. Implementation notes: All of the implemented ioctls use 'struct btrfs_ioctl_feature_flags' as third argument. That is the reason why a corresponding defintion was ad= ded in file 'linux-user/syscall_types.h'. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200803094629.21898-5-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 12 ++++++++++++ linux-user/syscall_defs.h | 3 +++ linux-user/syscall_types.h | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 55a6cbeca515..50fae1e33bc4 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -216,6 +216,18 @@ IOCTL(BTRFS_IOC_GET_DEV_STATS, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_dev_stats))) #endif +#ifdef BTRFS_IOC_GET_FEATURES + IOCTL(BTRFS_IOC_GET_FEATURES, IOC_R, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags))) +#endif +#ifdef BTRFS_IOC_SET_FEATURES + IOCTL(BTRFS_IOC_SET_FEATURES, IOC_W, + MK_PTR(MK_ARRAY(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags), 2)= )) +#endif +#ifdef BTRFS_IOC_GET_SUPPORTED_FEATURES + IOCTL(BTRFS_IOC_GET_SUPPORTED_FEATURES, IOC_R, + MK_PTR(MK_ARRAY(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags), 3)= )) +#endif #ifdef BTRFS_IOC_GET_SUBVOL_INFO IOCTL(BTRFS_IOC_GET_SUBVOL_INFO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args))) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index f9f94c9c08cc..6cc3c1f6f5ba 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -986,6 +986,9 @@ struct target_rtc_pll_info { abi_ullong) #define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 30) #define TARGET_BTRFS_IOC_GET_DEV_STATS TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 52) +#define TARGET_BTRFS_IOC_GET_FEATURES TARGET_IORU(BTRFS_IOCTL_MA= GIC, 57) +#define TARGET_BTRFS_IOC_SET_FEATURES TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 57) +#define TARGET_BTRFS_IOC_GET_SUPPORTED_FEATURES TARGET_IORU(BTRFS_IOCTL_MA= GIC, 57) #define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IORU(BTRFS_IOCTL_MA= GIC, 60) =20 /* usb ioctls */ diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 35f94cdfc8ba..808f4daaf72e 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -398,6 +398,11 @@ STRUCT(btrfs_ioctl_get_dev_stats, MK_ARRAY(TYPE_ULONGLONG, 128 - 2 - BTRFS_DEV_STAT_VALUES_MAX)) /* unused */ =20 +STRUCT(btrfs_ioctl_feature_flags, + TYPE_ULONGLONG, /* compat_flags */ + TYPE_ULONGLONG, /* compat_ro_flags */ + TYPE_ULONGLONG) /* incompat_flags */ + STRUCT(rtc_time, TYPE_INT, /* tm_sec */ TYPE_INT, /* tm_min */ --=20 2.26.2 From nobody Fri May 17 11:05:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1597301888; cv=none; d=zohomail.com; s=zohoarc; b=kARofxasNNjKd2kKJlJuBIzv6WPWG4+xdyHmEYJEmixDu5Fo96CwAN/THNhO5iokZPq+hRl/Vcxeg+AUjjh6Ym3Vjiy/erKAuQiH9T7Hjy8SBIxFpri4oApU8U4MGLz99c4A6BJXo2AIsqAMQtcIsozw0LG31wxIND7G+qTTGw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597301888; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=p6B5DguJN5CqFvM8LnjJOxLi2tj9incfesg0phZmnwU=; b=Py/LrUlEmvxpgKZd+1TEUOvWnnDlNTl0MvcqMTxiU9/HRw99T8OBFlo1KmGIOFFesUvzsn+RoWe2Wj6C9XvRV4zSn/SiwtbItiUwLBaO7SUw27YBDzYBmY2DtjArwonr4xkYzJ1obmoGWJhvuPpd+nl1E+yvwBPDP7/ITpZPQMk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1597301888149500.786080245869; Wed, 12 Aug 2020 23:58:08 -0700 (PDT) Received: from localhost ([::1]:47812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k67Be-0002dd-Mi for importer@patchew.org; Thu, 13 Aug 2020 02:58:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673c-0006dH-Hp for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:48 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:45471) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673O-0004cX-9W for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:48 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N2VGj-1kpo2f2Rln-013toj; Thu, 13 Aug 2020 08:49:31 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 10/14] linux-user: Add support for a group of btrfs inode ioctls Date: Thu, 13 Aug 2020 08:49:19 +0200 Message-Id: <20200813064923.263565-11-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200813064923.263565-1-laurent@vivier.eu> References: <20200813064923.263565-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:M6VZirVnvZvgZh51g8Ztv66mzFUjuxN3G8P0ZyRRhJ0ugJYkCja FfqglNe7ycZDCHZLdD07+72oqsBUW/5MteM0GF3uABb7of1/xJOjv5xWhj/ejRERy9/SEQq tdRnnz9otsrI77fc56Jd419TU64b3N0h04vgiK+rg3MJxkWDpFIOO0LzSm0O/oOE+WXm5ME zUHZssW0rEIA+7Lv8dfjw== X-UI-Out-Filterresults: notjunk:1;V03:K0:L5v3DXt05MY=:7dxhgJ2iRcCeqMhrlqX51X 5jf0tKbPJfkg9cdgGAI282Jh5c872y8RV4i5ozImDUX8Wu+vhWP5BFgv0zy9vEP86d4ZcoCtU IwKu6O5wNjfG2i3SLE04+cX5Z4XHOivHNizPEeYC5YF25/A7SoicFAFVM7jITw/BYBrsu9kL7 L/epPekiTJVVGaiT9Euu6wSu8xpg21rAJ+D0AYdNgkFf3wkeHDnbjtnYXv6QIJY0LKP9pq0Ki 7tLM3EcKoUmznTmiJGmOjYDTSRNSInxYqm/UC6xv8r/5TMhX3p/RYSNeEEQqfbgOhCufz6Mx9 NUNvcIntNdVh5pORcLehf6J5kAPCNE0+U7pn+JgWB5RM78C/8hlaIWOt3bSwtB6pA2L1etEE1 0t1tz+dkbVYj+E3Ir/ZITw8FNl8y31ytb+fx4CyBo/o30NBK5xGrkHeDBQJb461Snr/H/VUa7 IoQUH4M48dzPV4pyiZgzXxUxciVo05xPRYT8CEkLdEJiwUaOf048803FtvR0nARGDaC+zTKAA ybxQITbXkOc8RMlWfxODpl1Ufd6Za/hF+9d5suQGQO013jiqLBoOzo8Sa9RWb4/tzmNrsV73J UP6UgQAVS7Dz9vN7zTZhLdnT4SbkJ90RDkfxovuLbmoSEdbLQFGaH2XrSjqxskP3GA6s7Vcq9 CbOqtuHQaK1mzqprRjV73WjGylunND5SA3ITR1JxIcY9jJouon60w2+75NJ/vTj5nnCnpTdo5 3iXoiCYmxgoFNrOYh7pwdaJncfXVDiBxm5wahNj3owG4dsSehUgRibj7h0inYcPCSVcOZAckS s30vr8nSD+mxM0t2nhH4puGUGocmTCveLFj4xYZW4jeWKow38Q1KWUttSShNOoOIBHd/Lny Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.74; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/13 02:49:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Filip Bozuta This patch implements functionality of following ioctls: BTRFS_IOC_INO_LOOKUP - Reading tree root id and path Read tree root id and path for a given file or directory. The name and tree root id are returned in an ioctl's third argument that represents a pointer to a following type: struct btrfs_ioctl_ino_lookup_args { __u64 treeid; __u64 objectid; char name[BTRFS_INO_LOOKUP_PATH_MAX]; }; Before calling this ioctl, field 'objectid' should be filled with the object id value for which the tree id and path are to be read. Value 'BTRFS_FIRST_FREE_OBJECTID' represents the object id for the first available btrfs object (directory or file). BTRFS_IOC_INO_PATHS - Reading paths to all files Read path to all files with a certain inode number. The paths are returned in the ioctl's third argument which represents a pointer to a following type: struct btrfs_ioctl_ino_path_args { __u64 inum; /* in */ __u64 size; /* in */ __u64 reserved[4]; /* struct btrfs_data_container *fspath; out */ __u64 fspath; /* out */ }; Before calling this ioctl, the 'inum' and 'size' field should be filled with the aproppriate inode number and size of the directory where file paths should be looked for. For now, the paths are returned in an '__u64' (unsigned long long) value 'fspath'. BTRFS_IOC_LOGICAL_INO - Reading inode numbers Read inode numbers for files on a certain logical adress. The inode numbers are returned in the ioctl's third argument which represents a pointer to a following type: struct btrfs_ioctl_logical_ino_args { __u64 logical; /* in */ __u64 size; /* in */ __u64 reserved[3]; /* must be 0 for now */ __u64 flags; /* in, v2 only */ /* struct btrfs_data_container *inodes; out */ __u64 inodes; }; Before calling this ioctl, the 'logical' and 'size' field should be filled with the aproppriate logical adress and size of where the inode numbers of files should be looked for. For now, the inode numbers are returned in an '__u64' (unsigned long long) value 'inodes'. BTRFS_IOC_LOGICAL_INO_V2 - Reading inode numbers Same as the above mentioned ioctl except that it allows passing a flags 'BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET'. BTRFS_IOC_INO_LOOKUP_USER - Reading subvolume name and path Read name and path of a subvolume. The tree root id and path are read in an ioctl's third argument which represents a pointer to a following type: struct btrfs_ioctl_ino_lookup_user_args { /* in, inode number containing the subvolume of 'subvolid' */ __u64 dirid; /* in */ __u64 treeid; /* out, name of the subvolume of 'treeid' */ char name[BTRFS_VOL_NAME_MAX + 1]; /* * out, constructed path from the directory with which the ioctl is * called to dirid */ char path[BTRFS_INO_LOOKUP_USER_PATH_MAX]; }; Before calling this ioctl, the 'dirid' and 'treeid' field should be filled with aproppriate values which represent the inode number of the directory that contains the subvolume and treeid of the subvolume. Implementation notes: All of the ioctls in this patch use structure types as third arguments. That is the reason why aproppriate thunk definitions were added in file 'syscall_types.h'. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200803094629.21898-6-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 20 ++++++++++++++++++++ linux-user/syscall_defs.h | 5 +++++ linux-user/syscall_types.h | 24 ++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 50fae1e33bc4..169f98f7a301 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -202,6 +202,10 @@ IOCTL(BTRFS_IOC_SNAP_DESTROY, IOC_W, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) #endif +#ifdef BTRFS_IOC_INO_LOOKUP + IOCTL(BTRFS_IOC_INO_LOOKUP, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_args))) +#endif #ifdef BTRFS_IOC_SUBVOL_GETFLAGS IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG)) #endif @@ -212,6 +216,14 @@ IOCTL(BTRFS_IOC_DEV_INFO, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_dev_info_args))) #endif +#ifdef BTRFS_IOC_INO_PATHS + IOCTL(BTRFS_IOC_INO_PATHS, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_path_args))) +#endif +#ifdef BTRFS_IOC_LOGICAL_INO + IOCTL(BTRFS_IOC_LOGICAL_INO, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_logical_ino_args))) +#endif #ifdef BTRFS_IOC_GET_DEV_STATS IOCTL(BTRFS_IOC_GET_DEV_STATS, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_dev_stats))) @@ -228,10 +240,18 @@ IOCTL(BTRFS_IOC_GET_SUPPORTED_FEATURES, IOC_R, MK_PTR(MK_ARRAY(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags), 3)= )) #endif +#ifdef BTRFS_IOC_LOGICAL_INO_V2 + IOCTL(BTRFS_IOC_LOGICAL_INO_V2, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_logical_ino_args))) +#endif #ifdef BTRFS_IOC_GET_SUBVOL_INFO IOCTL(BTRFS_IOC_GET_SUBVOL_INFO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args))) #endif +#ifdef BTRFS_IOC_INO_LOOKUP_USER + IOCTL(BTRFS_IOC_INO_LOOKUP_USER, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_user_args))) +#endif =20 #ifdef CONFIG_USBFS /* USB ioctls */ diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 6cc3c1f6f5ba..48ebf56d0f36 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -980,16 +980,21 @@ struct target_rtc_pll_info { #define TARGET_BTRFS_IOC_RM_DEV TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 11) #define TARGET_BTRFS_IOC_SUBVOL_CREATE TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 14) #define TARGET_BTRFS_IOC_SNAP_DESTROY TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 15) +#define TARGET_BTRFS_IOC_INO_LOOKUP TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 18) #define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAG= IC, 25,\ abi_ullong) #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAG= IC, 26,\ abi_ullong) #define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 30) +#define TARGET_BTRFS_IOC_INO_PATHS TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 35) +#define TARGET_BTRFS_IOC_LOGICAL_INO TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 36) #define TARGET_BTRFS_IOC_GET_DEV_STATS TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 52) #define TARGET_BTRFS_IOC_GET_FEATURES TARGET_IORU(BTRFS_IOCTL_MA= GIC, 57) #define TARGET_BTRFS_IOC_SET_FEATURES TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 57) #define TARGET_BTRFS_IOC_GET_SUPPORTED_FEATURES TARGET_IORU(BTRFS_IOCTL_MA= GIC, 57) +#define TARGET_BTRFS_IOC_LOGICAL_INO_V2 TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 59) #define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IORU(BTRFS_IOCTL_MA= GIC, 60) +#define TARGET_BTRFS_IOC_INO_LOOKUP_USER TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 62) =20 /* usb ioctls */ #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 808f4daaf72e..6e64e6c4f57c 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -382,6 +382,30 @@ STRUCT(btrfs_ioctl_get_subvol_info_args, MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* rtime */ MK_ARRAY(TYPE_ULONGLONG, 8)) /* reserved */ =20 +STRUCT(btrfs_ioctl_ino_lookup_args, + TYPE_ULONGLONG, /* treeid */ + TYPE_ULONGLONG, /* objectid */ + MK_ARRAY(TYPE_CHAR, BTRFS_INO_LOOKUP_PATH_MAX)) /* name */ + +STRUCT(btrfs_ioctl_ino_path_args, + TYPE_ULONGLONG, /* inum */ + TYPE_ULONGLONG, /* size */ + MK_ARRAY(TYPE_ULONGLONG, 4), /* reserved */ + TYPE_ULONGLONG) /* fspath */ + +STRUCT(btrfs_ioctl_logical_ino_args, + TYPE_ULONGLONG, /* logical */ + TYPE_ULONGLONG, /* size */ + MK_ARRAY(TYPE_ULONGLONG, 3), /* reserved */ + TYPE_ULONGLONG, /* flags */ + TYPE_ULONGLONG) /* inodes */ + +STRUCT(btrfs_ioctl_ino_lookup_user_args, + TYPE_ULONGLONG, /* dirid */ + TYPE_ULONGLONG, /* treeid */ + MK_ARRAY(TYPE_CHAR, BTRFS_VOL_NAME_MAX + 1), /* name */ + MK_ARRAY(TYPE_CHAR, BTRFS_INO_LOOKUP_USER_PATH_MAX)) /* path */ + STRUCT(btrfs_ioctl_dev_info_args, TYPE_ULONGLONG, /* devid */ MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* uuid */ --=20 2.26.2 From nobody Fri May 17 11:05:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1597301841; cv=none; d=zohomail.com; s=zohoarc; b=NzTPtVy0EpzMlfnomzsdhYiLS/3mU1brz+9Pt7+yIocFhJXs+nbp8fLF4cFL0bLaX3g5rOYFyvLEuiK1fanXoRI7IHYPXqWddfVP3iDRjq7XvknzBqccLLU2gP3bMO+B6Od0b0wcqhuBlFZ9aySPOfABJBAeLH910TO42FBM/mg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597301841; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eVYCR67owabXJUTD2kSfIfwbKEf00LoqMaUiSTHwtAU=; b=LL3nNiLevyCDSZ60cwAvRTMlOcFYYtyTfuQiCJWwgc1bdCDGgKvYghxfeGJc5+xa5ZKjdMevJ3K02xldooijjA704ALdrSMO5rhgOvypREDFK7YHqpohGapdNtauMnE4qTpZOFsdmx9MjYjtuHl36NPsIhQsG/VQCc2YeoWRLl0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1597301841271244.78806456469465; Wed, 12 Aug 2020 23:57:21 -0700 (PDT) Received: from localhost ([::1]:44086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k67Au-00015U-4m for importer@patchew.org; Thu, 13 Aug 2020 02:57:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673b-0006aF-GB for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:47 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:37185) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673O-0004ch-95 for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:45 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MeTHG-1ke4tT2afM-00aW4U; Thu, 13 Aug 2020 08:49:31 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 11/14] linux-user: Add support for two btrfs ioctls used for subvolume Date: Thu, 13 Aug 2020 08:49:20 +0200 Message-Id: <20200813064923.263565-12-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200813064923.263565-1-laurent@vivier.eu> References: <20200813064923.263565-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:YTHbNury7aNAxG8cTwPbNnm4lFterGWtBVcfpph2bCr/7AVKirq /6gK/bd/v5kWNgvlmlZRyiPMbWmSotK3d3KMZJYudz76XPjwXdF2caGC36MiMn6lrwlAGKd cmsQOfXd6b58XFLaTOZz/Z2eNNZpU8lAB/3ITIFIdtVM5Eb8Zkxr55PbV3XMMlk1Xn/tSLR VkutFLW19YPm46WK6q9Wg== X-UI-Out-Filterresults: notjunk:1;V03:K0:WeJMt6sJNpc=:DadDqg5aR0UWP/FZBQ9XZ3 iyEGFiW4LzXhMOVQrs1zF0S2DQFt/AFTi4RMoYN9f8hNukiT9QXHeT1+ehPsiOawV6HFyEStL eu7dd5FfgCiqvMm3/qXzlQRPgwVjR8CWOWlxQz6sASRTL+36CPjyMIdxEH/VdvTR7Je62G4Nm Q3SHizs28uOUDTdLfp4h9uWkgC5OJh1fUhOin41aA3qDuAdySUh2yrYg0nqjGAxkZU1d1hcgh ZBgBuJjg7d518s3zSqRD9nv3b5go8AKpOu6j7AnegcwW4ze1InnBqTSMXZB9cChlBdOzrUaF/ fAXOVuPlAFPmo+2L4DaYijHf1nFgm3D4hsG8JQCwrmm+YxqYxBX6Zv1dXbqKPtKzmk6dEEdVJ iJ58cWtsbEcaWJ5RFInnHHWhyfBaR7Fgu+vwCiBYrR40FCXC7Z0XReIfXgfzKhK+3zTud8TLA wKcBfGkRzIxQbDgTCEMpKaaRJca6gBi05N1ZXGbU7EfLc0k59p57WdWBF6kr6mkFOLhXqRgwO 71sb01DK3hobOoZC0yUADt6Lf0y/7rZ0xpEob992Nih0WjSftBPCPSoa7+xgcmMUORg/Jicjt rN2ajWxHct0GTowN1b/BtV/59qFiLQNv1ge2fa3ii2iGYEVOdCvggkfCENTgWHqeT32MnwNR0 OYBCeeLUaV5X6IAX4s6aM3JjYWn0tYEcrnnUwyIbBg0bhUgy+gurVajaj1TAG5SvAeWtcFqZG kKJS/6uMOZq1yz1eEaaqfixMJfBMZtjIirEaBMonz9DUxkYHHvMBkcjc/sO7UzIIzoaYRp6sf N0ymn59M9TXzQiU7VGJ4C1AJ0bI47MAHNJ4cbYxhoXxezrSvlNYbksUBA4jrH6U0NnBF+b6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.10; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/13 02:49:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Filip Bozuta This patch implements functionality for following ioctl: BTRFS_IOC_DEFAULT_SUBVOL - Setting a default subvolume Set a default subvolume for a btrfs filesystem. The third ioctl's argument is a '__u64' (unsigned long long) which represents the id of a subvolume that is to be set as the default. BTRFS_IOC_GET_SUBVOL_ROOTREF - Getting tree and directory id of subvolumes Read tree and directory id of subvolumes from a btrfs filesystem. The tree and directory id's are returned in the ioctl's third argument which represents a pointer to a following type: struct btrfs_ioctl_get_subvol_rootref_args { /* in/out, minimum id of rootref's treeid to be searched */ __u64 min_treeid; /* out */ struct { __u64 treeid; __u64 dirid; } rootref[BTRFS_MAX_ROOTREF_BUFFER_NUM]; /* out, number of found items */ __u8 num_items; __u8 align[7]; }; Before calling this ioctl, 'min_treeid' field should be filled with value that represent the minimum value for the tree id. Implementation notes: Ioctl BTRFS_IOC_GET_SUBVOL_ROOTREF uses the above mentioned structure type as third argument. That is the reason why a aproppriate thunk structure definition is added in file 'syscall_types.h'. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200803094629.21898-7-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 7 +++++++ linux-user/syscall_defs.h | 3 +++ linux-user/syscall_types.h | 11 +++++++++++ 3 files changed, 21 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 169f98f7a301..728880b9f37b 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -206,6 +206,9 @@ IOCTL(BTRFS_IOC_INO_LOOKUP, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_args))) #endif +#ifdef BTRFS_IOC_DEFAULT_SUBVOL + IOCTL(BTRFS_IOC_DEFAULT_SUBVOL, IOC_W, MK_PTR(TYPE_ULONGLONG)) +#endif #ifdef BTRFS_IOC_SUBVOL_GETFLAGS IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG)) #endif @@ -248,6 +251,10 @@ IOCTL(BTRFS_IOC_GET_SUBVOL_INFO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args))) #endif +#ifdef BTRFS_IOC_GET_SUBVOL_ROOTREF + IOCTL(BTRFS_IOC_GET_SUBVOL_ROOTREF, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_rootref_args))) +#endif #ifdef BTRFS_IOC_INO_LOOKUP_USER IOCTL(BTRFS_IOC_INO_LOOKUP_USER, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_user_args))) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 48ebf56d0f36..b025032626a3 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -981,6 +981,8 @@ struct target_rtc_pll_info { #define TARGET_BTRFS_IOC_SUBVOL_CREATE TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 14) #define TARGET_BTRFS_IOC_SNAP_DESTROY TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 15) #define TARGET_BTRFS_IOC_INO_LOOKUP TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 18) +#define TARGET_BTRFS_IOC_DEFAULT_SUBVOL TARGET_IOW(BTRFS_IOCTL_MAG= IC, 19,\ + abi_ullong) #define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAG= IC, 25,\ abi_ullong) #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAG= IC, 26,\ @@ -994,6 +996,7 @@ struct target_rtc_pll_info { #define TARGET_BTRFS_IOC_GET_SUPPORTED_FEATURES TARGET_IORU(BTRFS_IOCTL_MA= GIC, 57) #define TARGET_BTRFS_IOC_LOGICAL_INO_V2 TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 59) #define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IORU(BTRFS_IOCTL_MA= GIC, 60) +#define TARGET_BTRFS_IOC_GET_SUBVOL_ROOTREF TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 61) #define TARGET_BTRFS_IOC_INO_LOOKUP_USER TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 62) =20 /* usb ioctls */ diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 6e64e6c4f57c..851010c78104 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -414,6 +414,17 @@ STRUCT(btrfs_ioctl_dev_info_args, MK_ARRAY(TYPE_ULONGLONG, 379), /* unused */ MK_ARRAY(TYPE_CHAR, BTRFS_DEVICE_PATH_NAME_MAX)) /* path */ =20 +STRUCT(rootref, + TYPE_ULONGLONG, /* treeid */ + TYPE_ULONGLONG) /* dirid */ + +STRUCT(btrfs_ioctl_get_subvol_rootref_args, + TYPE_ULONGLONG, /* min_treeid */ + MK_ARRAY(MK_STRUCT(STRUCT_rootref), + BTRFS_MAX_ROOTREF_BUFFER_NUM), /* rootref */ + TYPE_CHAR, /* num_items */ + MK_ARRAY(TYPE_CHAR, 7)) /* align */ + STRUCT(btrfs_ioctl_get_dev_stats, TYPE_ULONGLONG, /* devid */ TYPE_ULONGLONG, /* nr_items */ --=20 2.26.2 From nobody Fri May 17 11:05:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1597302040; cv=none; d=zohomail.com; s=zohoarc; b=gMxGXTqKxTjl0DHacizB2iFd5TFzU0VL7H8lNUaUqlBG8E5/VTsMaNx2Zi4+TFTq4MypAIdgIDAQVcE+8MJn8+HEPf5ic7GSTVT9O3UuQcUHbp/AlAKJZjREv0PueBTUA13qDcjBFcRgZsqMc3iw5prF0t/9LWgbKypKPfBsFkM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597302040; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XW/B7IhNQth9Osl5L6Y1ywphSFuokq+xjOlRbe7KJ1s=; b=MqLMfi0YXDat2SgDFrq5X85DFd3u6LXWjJAQz7S5eeSq3fH7MP13fQ2GIGd0Ne+ugfytP4c+gkZ6U0nprnuTl2gwy+YKgt+cPN2sEMWdgivVQJnAl6TrrDGq2CR5N33sC3m7jOxXrgXQzAAgw65T9JMbKN6fGo3sdWth4r0xh2Y= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1597302040489963.8534020674047; Thu, 13 Aug 2020 00:00:40 -0700 (PDT) Received: from localhost ([::1]:57744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k67E7-0006xj-4R for importer@patchew.org; Thu, 13 Aug 2020 03:00:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60472) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673e-0006hV-36 for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:50 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:45025) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673Q-0004cr-1q for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:49 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MYvLi-1kAQTk0wMq-00UrEw; Thu, 13 Aug 2020 08:49:32 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 12/14] linux-user: Add support for btrfs ioctls used to manage quota Date: Thu, 13 Aug 2020 08:49:21 +0200 Message-Id: <20200813064923.263565-13-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200813064923.263565-1-laurent@vivier.eu> References: <20200813064923.263565-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:bA7Mj79f2CF1c3iSmvIoCDdlqtxnkZnVY2fbVfWWp5kU8FhXM0l lSeLMdUKSjQr8JpoNIMpkFwyeAWyTR6PahAeZLNPN9my0PvIjULEZyl9ZmajkB5+UQ1gIPm vKpOAi4Jy2Fy/xkW7cc5JnuWZNLuR3YHOYxoywirc93qcXwCHUtBhmLzypY73FQvqYnwP7Q Dv06YHofhENyVj55qcXMw== X-UI-Out-Filterresults: notjunk:1;V03:K0:+i0yaeM1eaU=:/OB1lrqAYVEmPDxve422WW gRQJGLrDeu6lj5JQMDljogpFuFHLg0nJna9I/r8i4u82mlOli/QgH3phY//afYAGcDrG98KJJ Dtg3335d1alt/B8BZhJefyQ/zLVwO0aQuwRW6qBkqJGv8Vw4mjCM14WlDQ4OG1YijpnE9byHn 8zO0JT3+5Rpk5vgeUKQUaBF3NwpiwPtOL54kKBMufWwM8Cnld7QPDVwLzA+WryekSZqFmaqxT doQWTkc6otZ4fCDxjM5GL8f5Iao5ST5Na88aCpZEqW6pCRzU5HuyP9H8ZpymEO2isRZDuw1lU t30ICnZT0Q1bmv7mfg6CZdzKFWe4ZRChrh/sIrj02Ulazn8dlF6Bc/KARgbDI+zEDW7ARFkza pMPrBtasL7G89IoN3GxFrdmMpjOBYxO3mVCQfIo0dQTNwzwnmcp6Du/nIW5T1M64jNWX7Mdiw tTneCADcClfncwe4h3BtdruDNQJDYPR20uwfkmkB5PWw5IKuVnvZcbblpgXV9IilF5poCFW1/ h4CqxWks13d221hnvzbhL/QEotNYzoIVqm8uUdhwOet9x4/rKov9WC57AMhkwBcRrpOODjihL WnG8W89MvsmHfhZdGxRBNAwOZy+pymC/V9eIKClRqFc5iJujZR1nd/HBbMeGe0y6Px5Q7I40R 7DcN2sVyxN0IUKlHvpctbtzGrxpHPYYtqH7HEf8waUcOPjzdXGzTIOrOfpI7ixdP6mTLKpFF8 jFGF4WvHPnzzBBwW8mXSRomyusfnKOBgsAsWdagc3o1B7HsNjjDmS9/qxfhRjNx41e70AYbkZ 060ljEUhj2V+1zcNzsUnOQ49JcCclBVQe1864WbK7LT1+NZV/C0HItCaXaoYOeapgOwLHpb Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/13 02:49:32 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Filip Bozuta This patch implements functionality for following ioctls: BTRFS_IOC_QUOTA_CTL - Enabling/Disabling quota support Enable or disable quota support for a btrfs filesystem. Quota support is enabled or disabled using the ioctls third argument which represents a pointer to a following type: struct btrfs_ioctl_quota_ctl_args { __u64 cmd; __u64 status; }; Before calling this ioctl, the 'cmd' field should be filled with one of the values 'BTRFS_QUOTA_CTL_ENABLE' (enabling quota) 'BTRFS_QUOTA_CTL_DISABLE' (disabling quota). BTRFS_IOC_QGROUP_CREATE - Creating/Removing a subvolume quota group Create or remove a subvolume quota group. The subvolume quota group is created or removed using the ioctl's third argument which represents a pointer to a following type: struct btrfs_ioctl_qgroup_create_args { __u64 create; __u64 qgroupid; }; Before calling this ioctl, the 'create' field should be filled with the aproppriate value depending on if the user wants to create or remove a quota group (0 for removing, everything else for creating). Also, the 'qgroupid' field should be filled with the value for the quota group id that is to be created. BTRFS_IOC_QGROUP_ASSIGN - Asigning or removing a quota group as child group Asign or remove a quota group as child quota group of another group in the btrfs filesystem. The asignment is done using the ioctl's third argument which represents a pointert to a following type: struct btrfs_ioctl_qgroup_assign_args { __u64 assign; __u64 src; __u64 dst; }; Before calling this ioctl, the 'assign' field should be filled with the aproppriate value depending on if the user wants to asign or remove a quota group as a child quota group of another group (0 for removing, everythin else for asigning). Also, the 'src' and 'dst' fields should be filled with the aproppriate quota group id values depending on which quota group needs to asigned or removed as child quota group of another group ('src' gets asigned or removed as child group of 'dst'). BTRFS_IOC_QGROUP_LIMIT - Limiting the size of a quota group Limit the size of a quota group. The size of the quota group is limited with the ioctls third argument which represents a pointer to a following type: struct btrfs_ioctl_qgroup_limit_args { __u64 qgroupid; struct btrfs_qgroup_limit lim; }; Before calling this ioctl, the 'qgroup' id field should be filled with aproppriate value of the quota group id for which the size is to be limited. The second field is of following type: struct btrfs_qgroup_limit { __u64 flags; __u64 max_rfer; __u64 max_excl; __u64 rsv_rfer; __u64 rsv_excl; }; The 'max_rfer' field should be filled with the size to which the quota group should be limited. The 'flags' field can be used for passing additional options and can have values which can be found on: https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/btrfs= .h#L67 BTRFS_IOC_QUOTA_RESCAN_STATUS - Checking status of running rescan operation Check status of a running rescan operation. The status is checked using the ioctl's third argument which represents a pointer to a following ty= pe: struct btrfs_ioctl_quota_rescan_args { __u64 flags; __u64 progress; __u64 reserved[6]; }; If there is a rescan operation running, 'flags' field is set to 1, and 'progress' field is set to aproppriate value which represents the progr= ess of the operation. BTRFS_IOC_QUOTA_RESCAN - Starting a rescan operation Start ar rescan operation to Trash all quota groups and scan the metada= ta again with the current config. Before calling this ioctl, BTRFS_IOC_QUOTA_RESCAN_STATUS sould be run to check if there is already= a rescan operation runing. After that ioctl call, the received 'struct btrfs_ioctl_quota_rescan_args' should be than passed as this io= ctls third argument. BTRFS_IOC_QUOTA_RESCAN_WAIT - Waiting for a rescan operation to finish Wait until a rescan operation is finished (if there is a rescan operati= on running). The third ioctls argument is ignored. Implementation notes: Almost all of the ioctls in this patch use structure types as third arg= uments. That is the reason why aproppriate thunk definitions were added in file 'syscall_types.h'. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200803094629.21898-8-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 27 +++++++++++++++++++++++++++ linux-user/syscall_defs.h | 7 +++++++ linux-user/syscall_types.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 728880b9f37b..882bfb3e8854 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -227,6 +227,33 @@ IOCTL(BTRFS_IOC_LOGICAL_INO, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_logical_ino_args))) #endif +#ifdef BTRFS_IOC_QUOTA_CTL + IOCTL(BTRFS_IOC_QUOTA_CTL, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_quota_ctl_args))) +#endif +#ifdef BTRFS_IOC_QGROUP_ASSIGN + IOCTL(BTRFS_IOC_QGROUP_ASSIGN, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_qgroup_assign_args))) +#endif +#ifdef BTRFS_IOC_QGROUP_CREATE + IOCTL(BTRFS_IOC_QGROUP_CREATE, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_qgroup_create_args))) +#endif +#ifdef BTRFS_IOC_QGROUP_LIMIT + IOCTL(BTRFS_IOC_QGROUP_LIMIT, IOC_R, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_qgroup_limit_args))) +#endif +#ifdef BTRFS_IOC_QUOTA_RESCAN + IOCTL(BTRFS_IOC_QUOTA_RESCAN, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_quota_rescan_args))) +#endif +#ifdef BTRFS_IOC_QUOTA_RESCAN_STATUS + IOCTL(BTRFS_IOC_QUOTA_RESCAN_STATUS, IOC_R, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_quota_rescan_args))) +#endif +#ifdef BTRFS_IOC_QUOTA_RESCAN_WAIT + IOCTL(BTRFS_IOC_QUOTA_RESCAN_WAIT, 0, TYPE_NULL) +#endif #ifdef BTRFS_IOC_GET_DEV_STATS IOCTL(BTRFS_IOC_GET_DEV_STATS, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_dev_stats))) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index b025032626a3..8ae54f6946ed 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -990,6 +990,13 @@ struct target_rtc_pll_info { #define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 30) #define TARGET_BTRFS_IOC_INO_PATHS TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 35) #define TARGET_BTRFS_IOC_LOGICAL_INO TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 36) +#define TARGET_BTRFS_IOC_QUOTA_CTL TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 40) +#define TARGET_BTRFS_IOC_QGROUP_ASSIGN TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 41) +#define TARGET_BTRFS_IOC_QGROUP_CREATE TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 42) +#define TARGET_BTRFS_IOC_QGROUP_LIMIT TARGET_IORU(BTRFS_IOCTL_MA= GIC, 43) +#define TARGET_BTRFS_IOC_QUOTA_RESCAN TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 44) +#define TARGET_BTRFS_IOC_QUOTA_RESCAN_STATUS TARGET_IORU(BTRFS_IOCTL_MA= GIC, 45) +#define TARGET_BTRFS_IOC_QUOTA_RESCAN_WAIT TARGET_IO(BTRFS_IOCTL_MAGI= C, 46) #define TARGET_BTRFS_IOC_GET_DEV_STATS TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 52) #define TARGET_BTRFS_IOC_GET_FEATURES TARGET_IORU(BTRFS_IOCTL_MA= GIC, 57) #define TARGET_BTRFS_IOC_SET_FEATURES TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 57) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 851010c78104..51743bb75237 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -433,6 +433,35 @@ STRUCT(btrfs_ioctl_get_dev_stats, MK_ARRAY(TYPE_ULONGLONG, 128 - 2 - BTRFS_DEV_STAT_VALUES_MAX)) /* unused */ =20 +STRUCT(btrfs_ioctl_quota_ctl_args, + TYPE_ULONGLONG, /* cmd */ + TYPE_ULONGLONG) /* status */ + +STRUCT(btrfs_ioctl_quota_rescan_args, + TYPE_ULONGLONG, /* flags */ + TYPE_ULONGLONG, /* progress */ + MK_ARRAY(TYPE_ULONGLONG, 6)) /* reserved */ + +STRUCT(btrfs_ioctl_qgroup_assign_args, + TYPE_ULONGLONG, /* assign */ + TYPE_ULONGLONG, /* src */ + TYPE_ULONGLONG) /* dst */ + +STRUCT(btrfs_ioctl_qgroup_create_args, + TYPE_ULONGLONG, /* create */ + TYPE_ULONGLONG) /* qgroupid */ + +STRUCT(btrfs_qgroup_limit, + TYPE_ULONGLONG, /* flags */ + TYPE_ULONGLONG, /* max_rfer */ + TYPE_ULONGLONG, /* max_excl */ + TYPE_ULONGLONG, /* rsv_rfer */ + TYPE_ULONGLONG) /* rsv_excl */ + +STRUCT(btrfs_ioctl_qgroup_limit_args, + TYPE_ULONGLONG, /* qgroupid */ + MK_STRUCT(STRUCT_btrfs_qgroup_limit)) /* lim */ + STRUCT(btrfs_ioctl_feature_flags, TYPE_ULONGLONG, /* compat_flags */ TYPE_ULONGLONG, /* compat_ro_flags */ --=20 2.26.2 From nobody Fri May 17 11:05:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1597301789; cv=none; d=zohomail.com; s=zohoarc; b=n1wwJLU3FB4exdjJTy/r4JuRZ8ZTt2X/Im0718tVq+v+6smOzq5SoLikAkX9HjAl6H9pFtdLcGlzzsraw/FZeyMqRoWJrfW4qcgpItudavkYyC2ahXDxEfmTNu40ZXInv7GBDaa08xegQMu8JPBbhZJ+aRD9ddgNtfF8IucZhIE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597301789; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kXyE7s2jLVSkn4Me8pCTHao2kSMzEqcda2auLnfReQQ=; b=XsWj49U5h8Fd22uAwLsc08ujr0ffYPEcNA+MimJ2pRSepCWjdym/IGFZKXPwdaIbf4mezaDGq/22I4qo6BrVYUt8OSpLwaXAPGsMW0Z38x6+WLYLrvG2vOHiDMPa5a6IMNlZiceDfCaujHUlOeH9QogqSiYMlsZlmafIBgBvObY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1597301789362976.3710756061814; Wed, 12 Aug 2020 23:56:29 -0700 (PDT) Received: from localhost ([::1]:39412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k67A3-0007X7-TX for importer@patchew.org; Thu, 13 Aug 2020 02:56:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673b-0006aR-IP for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:47 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:36419) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673Q-0004cv-1x for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:47 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M734j-1k3fP934D1-008cN3; Thu, 13 Aug 2020 08:49:32 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 13/14] linux-user: Add support for btrfs ioctls used to scrub a filesystem Date: Thu, 13 Aug 2020 08:49:22 +0200 Message-Id: <20200813064923.263565-14-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200813064923.263565-1-laurent@vivier.eu> References: <20200813064923.263565-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:sJQgqB+yrFfcywyEc++7ZtyzxLgCyEK7lGk6SAgeNP0VQDgLoDl IiTtMWRyomXxyptlXG9fqYK4VdvQ1ysQWOX1k6U6LmMy53Rz9Ut81BPMdGbUVvX/M/0R1CS bW1TVSjSTeJdBQwkJSROQYn+0ZrzGVh01HRgDdQiVKE/C5ey50rt968aM9p2KqZu1O52DAv Gv0h1y8dhIqOnFE4pRF0g== X-UI-Out-Filterresults: notjunk:1;V03:K0:QIy7UvtZsTQ=:PSAK6HErv2XLCfe0pKgmIR JbgcdkoSODPcULw528N2MNTMCO/VY9n5wlqJ6jDlnAXI2Dt3OCuWdbr0PyqXbkGQ/w7aiNUR4 EmqcuqE3wqtoIvpA6mSkSq/Pg5z3Jyj3e0qbtSD44EtT8JpJa1cVbqpR9rwQ2q9xzNkc8A+Yk USSVd3bJhgYMWpPOxwCM07pBZJTNKYM45/3ThpQv1QPp1OsA9r/OgyrD/KhjRpkAkF+wG231C A1Ix771epWUFvKSRdafPGJU8z2AKFTkvPu4aBa9wy1sbIcnjXU7q+yEdjJJywHg74LjsXl2T7 TzOZcNN1Idt3U0uFkKwZ8Ut+EnucVl32B6pUMkqC0SAq1WN2HGkryd/xTlMwObp4JqDorCq4C yoxZmSw7p1qlnOy+FH8DVCUybJzO4RsjrfuzaCReyDaqXSUhwVQJWBPlEFP6s/WkeeasQmWJ6 4buYQg1gTyBBGYKJcC7fciOtud3Pn0nt9O5crSYw6d8AoYRHjzOJff/AVFVvNMYHNTwsAxtsr 00g03egjOK96wRwtXVG5zEBKWRugaorZ1Fd9v6oxXa3T+vJrUo0cc2LSKYz4/37rIcgjYu2BH cIwcWz3d9WzqXxyArsKJxS0NPgid2Q+fAjXIgXCRWkPTIyD0wjBNi8dbVSL5NVVNdZ+Opg2Af JyvfSrcFPOmjAwyJcjLFDQqGv+IjOR5cMhnIFKDL/YaHrAk5kiKJiK0YYHXECrwUn9qV1UT5+ lBpREzfYnISkkA9rekMTc7N4dBXqnTYRaOUTvKRKeNK07XINHNvsujY1ZuDPHDbiMeA7+eA/W PR5FVM7yIaKeOXvKWw5XaWmAcBHbUXRXmvnwG1EyM29FTRYtisAMXTCkvi1Z4Q5HBh9u6FH Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.74; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/13 02:49:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Filip Bozuta This patch implements functionality for following ioctls: BTRFS_IOC_SCRUB - Starting a btrfs filesystem scrub Start a btrfs filesystem scrub. The third ioctls argument is a pointer to a following type: struct btrfs_ioctl_scrub_args { __u64 devid; /* in */ __u64 start; /* in */ __u64 end; /* in */ __u64 flags; /* in */ struct btrfs_scrub_progress progress; /* out */ /* pad to 1k */ __u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8]; }; Before calling this ioctl, field 'devid' should be filled with value that represents the device id of the btrfs filesystem for which the scrub is to be started. BTRFS_IOC_SCRUB_CANCEL - Canceling scrub of a btrfs filesystem Cancel a btrfs filesystem scrub if it is running. The third ioctls argument is ignored. BTRFS_IOC_SCRUB_PROGRESS - Getting status of a running scrub Read the status of a running btrfs filesystem scrub. The third ioctls argument is a pointer to the above mentioned 'struct btrfs_ioctl_scrub_args'. Similarly as with 'BTRFS_IOC_SCRUB', the 'devid' field should be filled with value that represents the id of the btrfs device for which the scrub has started. The status of a running scrub is returned in the field 'progress' which is of type 'struct btrfs_scrub_progress' and its definition can be found at: https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/btrfs= .h#L150 Implementation nots: Ioctls in this patch use type 'struct btrfs_ioctl_scrub_args' as their third argument. That is the reason why an aproppriate thunk type definition is added in file 'syscall_types.h'. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200803094629.21898-9-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 11 +++++++++++ linux-user/syscall_defs.h | 3 +++ linux-user/syscall_types.h | 27 +++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 882bfb3e8854..e3bfe7877433 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -215,6 +215,17 @@ #ifdef BTRFS_IOC_SUBVOL_SETFLAGS IOCTL(BTRFS_IOC_SUBVOL_SETFLAGS, IOC_W, MK_PTR(TYPE_ULONGLONG)) #endif +#ifdef BTRFS_IOC_SCRUB + IOCTL(BTRFS_IOC_SCRUB, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_scrub_args))) +#endif +#ifdef BTRFS_IOC_SCRUB_CANCEL + IOCTL(BTRFS_IOC_SCRUB_CANCEL, 0, TYPE_NULL) +#endif +#ifdef BTRFS_IOC_SCRUB_PROGRESS + IOCTL(BTRFS_IOC_SCRUB_PROGRESS, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_scrub_args))) +#endif #ifdef BTRFS_IOC_DEV_INFO IOCTL(BTRFS_IOC_DEV_INFO, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_dev_info_args))) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 8ae54f6946ed..d4fe0085bef4 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -987,6 +987,9 @@ struct target_rtc_pll_info { abi_ullong) #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAG= IC, 26,\ abi_ullong) +#define TARGET_BTRFS_IOC_SCRUB TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 27) +#define TARGET_BTRFS_IOC_SCRUB_CANCEL TARGET_IO(BTRFS_IOCTL_MAGI= C, 28) +#define TARGET_BTRFS_IOC_SCRUB_PROGRESS TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 29) #define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 30) #define TARGET_BTRFS_IOC_INO_PATHS TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 35) #define TARGET_BTRFS_IOC_LOGICAL_INO TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 36) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 51743bb75237..8d4b5b3e921a 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -406,6 +406,33 @@ STRUCT(btrfs_ioctl_ino_lookup_user_args, MK_ARRAY(TYPE_CHAR, BTRFS_VOL_NAME_MAX + 1), /* name */ MK_ARRAY(TYPE_CHAR, BTRFS_INO_LOOKUP_USER_PATH_MAX)) /* path */ =20 +STRUCT(btrfs_scrub_progress, + TYPE_ULONGLONG, /* data_extents_scrubbed */ + TYPE_ULONGLONG, /* tree_extents_scrubbed */ + TYPE_ULONGLONG, /* data_bytes_scrubbed */ + TYPE_ULONGLONG, /* tree_bytes_scrubbed */ + TYPE_ULONGLONG, /* read_errors */ + TYPE_ULONGLONG, /* csum_errors */ + TYPE_ULONGLONG, /* verify_errors */ + TYPE_ULONGLONG, /* no_csum */ + TYPE_ULONGLONG, /* csum_discards */ + TYPE_ULONGLONG, /* super_errors */ + TYPE_ULONGLONG, /* malloc_errors */ + TYPE_ULONGLONG, /* uncorrectable_errors */ + TYPE_ULONGLONG, /* corrected_er */ + TYPE_ULONGLONG, /* last_physical */ + TYPE_ULONGLONG) /* unverified_errors */ + +STRUCT(btrfs_ioctl_scrub_args, + TYPE_ULONGLONG, /* devid */ + TYPE_ULONGLONG, /* start */ + TYPE_ULONGLONG, /* end */ + TYPE_ULONGLONG, /* flags */ + MK_STRUCT(STRUCT_btrfs_scrub_progress), /* progress */ + MK_ARRAY(TYPE_ULONGLONG, + (1024 - 32 - + sizeof(struct btrfs_scrub_progress)) / 8)) /* unused */ + STRUCT(btrfs_ioctl_dev_info_args, TYPE_ULONGLONG, /* devid */ MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* uuid */ --=20 2.26.2 From nobody Fri May 17 11:05:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1597301971; cv=none; d=zohomail.com; s=zohoarc; b=BzKYF/tbnydBjxEC/lV4tVmpA/jn1Iwn0isMZCXB8ByCXrYNUV1QtFtlMSr1vK5a/4xg9vV+YjELi9UXqsw0uGSzCgCaz0DQzrPKDzeBHIXlI1eXnyxRABjrCTg/SEx9sXWDkNP2rPlxtPDDczlAY/dFcwfp43FkFgM2rn2goK8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597301971; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2xLokJELY3jgLJNMeV0tuRUN+vnuCAgtMzJ/vTYuaDM=; b=KoNHacDwCNo1HOpd9blyWm3AFvahO4+np/3qTTUE74rQxOmXAPc1CU8rdiYJ0MB/1Z3Wm2dWWRhXdcxy7WvCGRDq+D7gLEDIlUtcpCRCtsTR54bOszy7GdmLZa6WEsk9G0XU+7seu41Q5lIeQ+NKYzHHg+EQs7wt9oe0H5MNtWE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1597301971607770.9798248796161; Wed, 12 Aug 2020 23:59:31 -0700 (PDT) Received: from localhost ([::1]:55188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k67D0-0005jr-EA for importer@patchew.org; Thu, 13 Aug 2020 02:59:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673c-0006df-M7 for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:48 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:57799) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k673Q-0004cu-1L for qemu-devel@nongnu.org; Thu, 13 Aug 2020 02:49:48 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Ma1HG-1k9KY50mNY-00Vxhe; Thu, 13 Aug 2020 08:49:33 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 14/14] linux-user: Fix 'utimensat()' implementation Date: Thu, 13 Aug 2020 08:49:23 +0200 Message-Id: <20200813064923.263565-15-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200813064923.263565-1-laurent@vivier.eu> References: <20200813064923.263565-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:Ciq6cPuHeA4AGiSmNqi0J42q6MLfR/IXUMXK4fPs/iZgsmVr6jD lHt0vM0mVHnqPPFpAW7VnaC/vhwza4tlJuKZ2LZsWUgACMeaYqj/LTHKIfq1PiX3aG6IP+E wtWtjU+4HSnogSoAfkPPrWRkJB5PyJRo5yFeeTQmpwRyjwzAaeOFAtQEunUOvxPN9SjMGL3 FtcAn1fPtZZOcSFiQbkVw== X-UI-Out-Filterresults: notjunk:1;V03:K0:zmZxLy57UYI=:qhlGyJnwzJXAYhd1gjj4XG DmsnhoLOjF0XrC8hxDMt3FPbHDPAVzFV8SjXra3Vd/Gkj0dXv0fhRLU/AKld9xSFrLVZlqWFn YKHCKVlZ8Kqkmx5Zcy6k7SFRm6qIRQRCVmQfsSwOy9CdQY1Zk7lncgiFP6BD1siDdeAEJRKu9 cjHqDJ3oLIIlRqLDmxmIqyUghsnTu3dE2fMAKmxz2r0+H5WBLi73ctoCHjeUWvcl37+d2jo8Z rlUDV75LjRluRsM71wbd3ql3sraTcQ3wAQe9e6g/KP8Wjtix+ZxjqQhV2SHoGDWoblcXMxOXv PMuB9ncnheKaql6Klc9Q7k0cyXSKr92+RoXty6+Klt1cxZaVcC5EgFW5LlZl0w5noRo5YHOdj zRL/jD5JUIiqw3FSVbooXJPZtCklbBLS9yvjqT6axWu0//tAO9++DnmTPG9Mt+gTzkjkVemiZ cdABxDbVsV6sAaY3MSD55fdGTAslyjsbbCZQx6bdk1ls/LK8KXQ55YksJ29d05JK1pC+q4DFi AL7OKTJdffab36ANLb4MjvIxNC8V4/l8//4kgF8iEd+uewoVeA/6vSN+kODP4psDQiUcgQdmI ItX7dGHVxuheS9EXA/U/b8PwoFhGzRz9LdOm3pTiuXeXw909ONbgowOWez7EjcJA4rt1FIIsK qi+4j7KoFK46hIaX/bXhfixUA9l89GuGMix94rRt8ufCgLacogulczI6IDfE9lGCrXz+T6QYi O0aS9tu5/6ee9A2WoHye/wWXWMvySBn9IWv5+iBIaBSM4U9TFwtv2qNylkZtu6xwCvz61DiGr dovxunUbo0xAXGO/5kaniEpTrB8ny6zyRDQNRpiN05HQoP7rWdZBPddwR/iRp1by2obZUSB Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.10; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/13 02:49:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Filip Bozuta Implementation of syscall 'utimensat()' in 'syscall.c' uses functions target_to_host/host_to_target_timespec() to convert values of 'struct timespec' between host and target. However, the implementation doesn't check whether the conversion succeeds and thus can cause an inappropriate error or succeed unappropriately instead of setting errno EFAULT ('Bad address') which is supposed to be set in these cases. This was confirmed with the LTP test for utimensat ('testcases/utimensat') which fails for test cases when the errno EFAULT is expected. After changes from this patch, the test passes for all test cases. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200811113101.6636-1-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 10dd53bf999b..96ae942909ab 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11922,8 +11922,13 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, if (!arg3) { tsp =3D NULL; } else { - target_to_host_timespec(ts, arg3); - target_to_host_timespec(ts+1, arg3+sizeof(struct target_ti= mespec)); + if (target_to_host_timespec(ts, arg3)) { + return -TARGET_EFAULT; + } + if (target_to_host_timespec(ts + 1, arg3 + + sizeof(struct target_timespec)= )) { + return -TARGET_EFAULT; + } tsp =3D ts; } if (!arg2) --=20 2.26.2