Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1983071rdh; Tue, 26 Sep 2023 08:56:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEpBS+wuCNJHdDVgP3nt1AA6U3LpwyKQuDkPjxN6fKbg1mM2u8zfVx7keUDl0g0M1obGQ3E X-Received: by 2002:a05:6a00:d66:b0:68e:3eff:e93a with SMTP id n38-20020a056a000d6600b0068e3effe93amr10357899pfv.2.1695743814943; Tue, 26 Sep 2023 08:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695743814; cv=none; d=google.com; s=arc-20160816; b=04ShJPlkRsF+m9nY2dyjqOojTblYsgcXYUr8zDydt7+q0kwhKp0D3OpzRVnwNeTzH5 WokpM+ExlA12NkbzIVQRe6r6uh0jdj3fBphUTgaob5FZ4qZWNed+r+Ql5xQ1Qfh+Qrn6 iTNER9DqiKXbuRaqs24KgFkxekyEvrpUdcqG9ef1drNYFsC/agmUkcC5ZxZU4WKme4C2 ioGUaG3BoLwdcL4ODChUPjT+Ao2nFDeD+kh0mEC3x8jseI8EbIqgtTjKAkRGujpiG+F+ lSMeCi+Nki7mvTBD8TrHoRHLlId64aCfR9vd8Oi4bxjgz1pxQXN18nG2MM6rGotXmjfa dKxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=f6kk2TiTStm9eDcVWQMgpEpJ22Rj2XRqKEyxt8qhEtA=; fh=ii1wDhy1SnSrvv5E1TsrWN692ttf1PCgsHP4OwL81FY=; b=EYnNb1mSGq6POcKeEqr3/C5FSTE0Xp/ob9K9l1MC3gamVDGJjhWR0obXybqyC29Q+m 3pZn6Q9Me9z5ENTyh6xw/km6ogPubWGI6m7g5eREcg4kP333Kbcm7cIUtTP7962Kl3iQ 9X3nQZ81keJzzaTCdpfuIPAq9CaGbNQduqJ7tu3IprbRLKYM0gVOoOGKN0+jpP/gEosy tnYQoretm+cV6Sqjj9VOx1OpRe+LVKoFwlF2u3qpszqCAI+i/sk/mD3dr+GT+3BTrCFB tX6lDCWmhxSGNCydCuDjgPmbg4haC3BVlmWZ6N8u0mgWUJivvCbWzcWXCBEv505JOctp 2bag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@szeredi.hu header.s=google header.b=YcIbDNgI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=szeredi.hu Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id o8-20020a056a001bc800b0068e39cd7acdsi12505266pfw.83.2023.09.26.08.56.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 08:56:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@szeredi.hu header.s=google header.b=YcIbDNgI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=szeredi.hu Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id C76C1807FC2C; Tue, 26 Sep 2023 07:34:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234074AbjIZOeO (ORCPT + 99 others); Tue, 26 Sep 2023 10:34:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233819AbjIZOeL (ORCPT ); Tue, 26 Sep 2023 10:34:11 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E75BE11D for ; Tue, 26 Sep 2023 07:34:03 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-9ad8bba8125so1179349966b.3 for ; Tue, 26 Sep 2023 07:34:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; t=1695738842; x=1696343642; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=f6kk2TiTStm9eDcVWQMgpEpJ22Rj2XRqKEyxt8qhEtA=; b=YcIbDNgI0bkoTIo6MqWRZy2lIoQ+WPsLVAfBfdg1jzx4c8ov4uErwM4T/W+JgiLp1L nNOezxmiRpSSIPazwSdPNeE+u8kkNn/ddAQ2JrDEDEXH0wm0ykVUAmCPzzZID4cHGbk0 2NpMX022JEhC2IwObveTMl2yG4f0f9ADwKLiw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695738842; x=1696343642; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=f6kk2TiTStm9eDcVWQMgpEpJ22Rj2XRqKEyxt8qhEtA=; b=IKb3gr/rgY96Z7tL5Xx2Nnqh11Ti0iN9MTa9f6jyEqxODurj1vaaoyrHKtsDjVLtJV /Hn3pj1uVo9ZIIA3xwTqPPoko5Tl4lF2RtZk1ETyLpg9D96a663BpSpEBmLAbPrZZicl 8LF81cdKkRuYrGt530ceipftRKMKttGxcXemaBDJGy8Zmv8CrWdEm1fwI2XrD5yrqZ/J zCpxVP5Uya4SvP/zCpkn66HzNXB5GZHClOB+HZ/hGd1lpx2sFmwnl3dYsWiSi/qw8sYD d/tO3DymyzP4Et7ZRFuhJ40MABOETuGVvvJr/3ypSTUNnjdq5sZgno0eml5km3aPOtIq 6AWQ== X-Gm-Message-State: AOJu0Yz3VWNIfjIYggY96ff5Rfvhbl1WF/NXNPGos0e402hYAvivOLTF zZX7lBYGq5K98zvpzTWCJcs8p07pHMYZWbwZcFwo5A== X-Received: by 2002:a17:906:ae81:b0:9ae:961a:de7f with SMTP id md1-20020a170906ae8100b009ae961ade7fmr9336652ejb.30.1695738842442; Tue, 26 Sep 2023 07:34:02 -0700 (PDT) MIME-Version: 1.0 References: <20230913152238.905247-1-mszeredi@redhat.com> <20230913152238.905247-3-mszeredi@redhat.com> <20230914-salzig-manifest-f6c3adb1b7b4@brauner> <20230914-lockmittel-verknallen-d1a18d76ba44@brauner> <20230918-grafik-zutreffen-995b321017ae@brauner> <871qeloxj0.fsf@oldenburg.str.redhat.com> <87wmwdnhj1.fsf@oldenburg.str.redhat.com> In-Reply-To: <87wmwdnhj1.fsf@oldenburg.str.redhat.com> From: Miklos Szeredi Date: Tue, 26 Sep 2023 16:33:50 +0200 Message-ID: Subject: Re: [RFC PATCH 2/3] add statmnt(2) syscall To: Florian Weimer Cc: Miklos Szeredi , Christian Brauner , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-man@vger.kernel.org, linux-security-module@vger.kernel.org, Karel Zak , Ian Kent , David Howells , Al Viro , Christian Brauner , Amir Goldstein Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 26 Sep 2023 07:34:22 -0700 (PDT) On Tue, 26 Sept 2023 at 16:19, Florian Weimer wrote: > getdents gets away with this buffer size because applications can copy > out all the data from struct dirent if they need long-term storage. > They have to do that because the usual readdir interface overwrites the > buffer, potentially at the next readdir call. This means the buffer > size does not introduce an amount of memory fragmention that is > dependent on the directory size. > > With an opaque, pointer-carrying struct, copying out the data is not > possible in a generic fashion. Only the parts that the application > knows about can be copied out. So I think it's desirable to have a > fairly exact allocation. Okay, so let's add a 'size' field to the struct, which is set to the size used (as opposed to the size of the buffer). That should solve copying without wasting a single byte of memory. Otherwise the format is fully copyable, since the strings are denoted with an offset, which doesn't change after the buffer is copied. Thanks, Miklos