From patchwork Sun Oct 19 13:21:22 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [RFC] ubi: tmp hack for lstat From: Sebastian Siewior X-Patchwork-Id: 5031 Message-Id: <20081019132122.GA20282@www.tglx.de> To: Artem Bityutskiy Cc: linux-mtd@lists.infradead.org Date: Sun, 19 Oct 2008 15:21:22 +0200 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; }