From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff Layton Subject: [PATCH 2/3] audit: break the setup of the audit_name out of audit_inode and into separate function Date: Fri, 26 Oct 2012 11:43:41 -0400 Message-ID: <1351266222-11107-3-git-send-email-jlayton@redhat.com> References: <1351266222-11107-1-git-send-email-jlayton@redhat.com> Cc: hch@infradead.org, eparis@redhat.com, linux-audit@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org To: viro@ZenIV.linux.org.uk Return-path: In-Reply-To: <1351266222-11107-1-git-send-email-jlayton@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org When we have 2 variants of __audit_inode then they can each call this function to do the setup. Signed-off-by: Jeff Layton --- kernel/auditsc.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 6a6d95a..9a65af0 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -2160,6 +2160,21 @@ static void audit_copy_inode(struct audit_names *name, security_inode_getsecid(inode, &name->osid); } +static void audit_names_setup(struct audit_names *n, + const struct dentry *dentry, unsigned int parent) +{ + if (parent) { + n->name_len = n->name ? parent_len(n->name->name) : AUDIT_NAME_FULL; + n->type = AUDIT_TYPE_PARENT; + } else { + n->name_len = AUDIT_NAME_FULL; + n->type = AUDIT_TYPE_NORMAL; + } + handle_path(dentry); + audit_copy_inode(n, dentry->d_inode); + audit_copy_fcaps(n, dentry); +} + /** * __audit_inode - store the inode and device from a lookup * @name: name being audited @@ -2170,7 +2185,6 @@ void __audit_inode(struct filename *name, const struct dentry *dentry, unsigned int parent) { struct audit_context *context = current->audit_context; - const struct inode *inode = dentry->d_inode; struct audit_names *n; if (!context->in_syscall) @@ -2223,16 +2237,7 @@ out_alloc: if (!n) return; out: - if (parent) { - n->name_len = n->name ? parent_len(n->name->name) : AUDIT_NAME_FULL; - n->type = AUDIT_TYPE_PARENT; - } else { - n->name_len = AUDIT_NAME_FULL; - n->type = AUDIT_TYPE_NORMAL; - } - handle_path(dentry); - audit_copy_inode(n, inode); - audit_copy_fcaps(n, dentry); + audit_names_setup(n, dentry, parent); } /** -- 1.7.11.7