From patchwork Sun Oct 19 13:21:22 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 5031 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7738EDDDE6 for ; Mon, 20 Oct 2008 00:23:06 +1100 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.68 #1 (Red Hat Linux)) id 1KrYDp-0002IX-CD; Sun, 19 Oct 2008 13:21:29 +0000 Received: from www.tglx.de ([62.245.132.106]) by bombadil.infradead.org with esmtps (Exim 4.68 #1 (Red Hat Linux)) id 1KrYDn-0002FK-Gn; Sun, 19 Oct 2008 13:21:27 +0000 Received: from www.tglx.de (www.tglx.de [127.0.0.1]) by www.tglx.de (8.13.8/8.13.8/TGLX-2007100201) with ESMTP id m9JDLMEv022865 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 19 Oct 2008 15:21:22 +0200 Received: (from bigeasy@localhost) by www.tglx.de (8.13.8/8.13.8/Submit) id m9JDLMSh022864; Sun, 19 Oct 2008 15:21:22 +0200 Date: Sun, 19 Oct 2008 15:21:22 +0200 From: Sebastian Andrzej Siewior To: Artem Bityutskiy Subject: [RFC] ubi: tmp hack for lstat Message-ID: <20081019132122.GA20282@www.tglx.de> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.4.2.2i X-Key-Id: 97C4700B X-Key-Fingerprint: 09E2 D1F3 9A3A FF13 C3D3 961C 0688 1C1E 97C4 700B X-Virus-Scanned: ClamAV 0.93.2/8443/Sat Oct 18 08:08:31 2008 on www.tglx.de X-Virus-Status: Clean X-Spam-Status: No, score=-1.4 required=5.0 tests=ALL_TRUSTED,AWL autolearn=failed version=3.2.4 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on www.tglx.de X-Spam-Score: 0.0 (/) Cc: linux-mtd@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org lstat() on /dev/ubi%d_%d returns 0 in the st_size field. This hack allows to get the correct file size (as long as nobody updates the volume in the meantime). Signed-off-by: Sebastian Andrzej Siewior --- I have userpsace programs which stat() the file and process the returned number bytes. The other work around is to copy the file somewhere and use this file instead of /dev/ubi. Artem, do you thing it is possible to implement this functionality properly or would it be reasonable not to use stat() at all on ubi volumes? drivers/mtd/ubi/cdev.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c index 03c759b..921dd81 100644 --- a/drivers/mtd/ubi/cdev.c +++ b/drivers/mtd/ubi/cdev.c @@ -123,6 +123,7 @@ static int vol_cdev_open(struct inode *inode, struct file *file) if (IS_ERR(desc)) return PTR_ERR(desc); + i_size_write(inode, desc->vol->used_bytes); file->private_data = desc; return 0; }