From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5E67C433E0 for ; Tue, 26 Jan 2021 17:37:45 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6223822228 for ; Tue, 26 Jan 2021 17:37:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6223822228 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94) (envelope-from ) id 1l4SHT-0005wP-CZ; Tue, 26 Jan 2021 12:37:31 -0500 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1l4SHR-0005u1-Fj for kernelnewbies@kernelnewbies.org; Tue, 26 Jan 2021 12:37:29 -0500 Received: by mail-pj1-x1033.google.com with SMTP id g15so2651152pjd.2 for ; Tue, 26 Jan 2021 09:37:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=uN66q8CiCV0636mcGENI4cxE8HTVu/3ocYpLovCg5Ms=; b=DOfHbvjO9PqInREthTz6yrY0D2R/4K8cknrfisrxQqFlnBh+7SbZ25xxfqUVVO2dRn 3Fz7IdpNVaufuT+H1zrlFw1qrP2ZNSGELngw+U6drPuMUB90hCF0c3QaYBjReMGmraRo atGlPCHMAyeu+dj+Yq2jEiVDM3H6mB0TL1tWmAffaHWVcidZkyJVigTxkfycuD6hKPRt X5KDI8DRPbvZskKwiEzmjROc9kv3uh4IKOApoA98zkY5oWDHyyCsYlO3O7qQ2av9alOe xfZP0Krsh4vINTLwMGMEJAPgzC0B0PcYspI6bv3RliV3G+yGPS72rexmrLUAkpIhw3UJ 51qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=uN66q8CiCV0636mcGENI4cxE8HTVu/3ocYpLovCg5Ms=; b=O2BsYMysyLCRpd1HVZiEW7dmoi5JQwW7UusnoxYBHUTEtDw8GkEWBLClj+EyDisM/1 7hUiccTG2dObGA9N+yGsPoAHKy7vQ1tYVl7TY4cg2rWH14cc8Eh008d3qIYKelA6q53L l5CsueR2+w24hNipz5OQoi4TUraazkADesZAK+qOxkmlzNPsrCehTwBBjCsZKHcO0Wq3 o2t+CEpp0SokbWUK2y9JiM7wF8ntg1JdubXltvb2rELnLvlPNhEUzw5i0Ck7HFgXIXlQ xGAg5OJhe3zZotFGxWGKwsFiDXM8G3+dV/opOuZ1SXpWOt1LAg7i1Stz2NnydyZ9fEfl boTQ== X-Gm-Message-State: AOAM5324NQXY9pRgSMz4siiSxEgTZyDk8uwvJomg75QBnYYl54iFCLZ7 InNYdLg0jy91DECKYcOhmpcMrRp0WAc= X-Google-Smtp-Source: ABdhPJy3/Dx1ABWuuqWElIlsS9UeNmaVlyf6Drft+d228Aem220wwgTQMeysw0s2zn+jW/vJDF7JOQ== X-Received: by 2002:a17:90a:77c1:: with SMTP id e1mr892268pjs.141.1611682647725; Tue, 26 Jan 2021 09:37:27 -0800 (PST) Received: from [192.168.0.159] ([49.205.248.109]) by smtp.gmail.com with ESMTPSA id j3sm2790076pjs.50.2021.01.26.09.37.26 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 26 Jan 2021 09:37:27 -0800 (PST) From: Mohana Datta Yelugoti To: kernelnewbies@kernelnewbies.org Subject: Doubt on show() function of sysfs attribute Message-ID: <98fe87f5-19ac-dfa7-41eb-2e00d7415021@gmail.com> Date: Tue, 26 Jan 2021 23:07:24 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Language: en-US X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org Hello everyone, I am going through Documentation/filesystems/sysfs.rst. It says that sysfs allocates a buffer of size PAGE_SIZE and passes it to the show/store functions of the attribute. On read(), the show() method should fill the entire buffer[0]. The document also says that sysfs_emit() and sysfs_emit_at() are the preferred function calls in show() function when formatting the value to be returned to the user space [1]. I checked the sysfs_emit() function definition. sysfs_emit() -> vscnprintf() -> vsnprintf() is the function series. (-> = calls) In the vsnprintf() function, i found that only in the case of (start + size > end) the buffer is completely filled, in the other case, that's not the case [2]. Isn't this contradictory to what the sysfs.rst says? (that entire buffer should be filled) Can you please help me understand what i am missing here? Thank you for your time. Cheers, ymdatta. [0]: https://elixir.bootlin.com/linux/latest/source/Documentation/filesystems/sysfs.rst#L214 [1]: https://elixir.bootlin.com/linux/latest/source/Documentation/filesystems/sysfs.rst#L246 [2]: https://elixir.bootlin.com/linux/latest/source/lib/vsprintf.c#L2689 _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies