From patchwork Wed Feb 17 19:57:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 45660 X-Patchwork-Delegate: apw@canonical.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 6AA64B7C98 for ; Thu, 18 Feb 2010 06:57:36 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1Nhq1W-0001Js-IM; Wed, 17 Feb 2010 19:57:26 +0000 Received: from mail.tpi.com ([70.99.223.143]) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1Nhq1U-0001JT-QH for kernel-team@lists.ubuntu.com; Wed, 17 Feb 2010 19:57:25 +0000 Received: from sepang.rtg.net (unknown [10.0.2.5]) by mail.tpi.com (Postfix) with ESMTP id ED21E21D9FA; Wed, 17 Feb 2010 11:56:49 -0800 (PST) Received: by sepang.rtg.net (Postfix, from userid 1000) id 5BAD4F8BD4; Wed, 17 Feb 2010 12:57:31 -0700 (MST) To: apw@canonical.com Subject: Sent to stable: eCryptfs: Add getattr function Message-Id: <20100217195731.5BAD4F8BD4@sepang.rtg.net> Date: Wed, 17 Feb 2010 12:57:31 -0700 (MST) From: timg@tpi.com (Tim Gardner) Cc: kernel-team@lists.ubuntu.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Mime-version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com The following changes since commit 4b876bd4ad82fb8866fcf8724514c80ebc158f1d: Andy Whitcroft (1): UBUNTU: ensure we build the source package contents when enabled are available in the git repository at: git://kernel.ubuntu.com/rtg/ubuntu-lucid.git lp390833 Tyler Hicks (1): eCryptfs: Add getattr function fs/ecryptfs/inode.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) From 546d6ff6604d15ae3997969ff2b35dc72b2b44e4 Mon Sep 17 00:00:00 2001 From: Tyler Hicks Date: Wed, 4 Nov 2009 02:48:01 -0600 Subject: [PATCH] eCryptfs: Add getattr function MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit The i_blocks field of an eCryptfs inode cannot be trusted, but generic_fillattr() uses it to instantiate the blocks field of a stat() syscall when a filesystem doesn't implement its own getattr(). Users have noticed that the output of du is incorrect on newly created files. This patch creates ecryptfs_getattr() which calls into the lower filesystem's getattr() so that eCryptfs can use its kstat.blocks value after calling generic_fillattr(). It is important to note that the block count includes the eCryptfs metadata stored in the beginning of the lower file plus any padding used to fill an extent before encryption. BugLink: http://bugs.launchpad.net/bugs/390833 Reported-by: Dominic Sacré Signed-off-by: Tyler Hicks (cherry picked from commit f8f484d1b6677dd5cd5e7e605db747e8c30bbd47) Signed-off-by: Tim Gardner --- fs/ecryptfs/inode.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 056fed6..728f07e 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c @@ -971,6 +971,21 @@ out: return rc; } +int ecryptfs_getattr(struct vfsmount *mnt, struct dentry *dentry, + struct kstat *stat) +{ + struct kstat lower_stat; + int rc; + + rc = vfs_getattr(ecryptfs_dentry_to_lower_mnt(dentry), + ecryptfs_dentry_to_lower(dentry), &lower_stat); + if (!rc) { + generic_fillattr(dentry->d_inode, stat); + stat->blocks = lower_stat.blocks; + } + return rc; +} + int ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) @@ -1100,6 +1115,7 @@ const struct inode_operations ecryptfs_dir_iops = { const struct inode_operations ecryptfs_main_iops = { .permission = ecryptfs_permission, .setattr = ecryptfs_setattr, + .getattr = ecryptfs_getattr, .setxattr = ecryptfs_setxattr, .getxattr = ecryptfs_getxattr, .listxattr = ecryptfs_listxattr,