aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/auditfilter.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-10-10 15:25:25 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-10-12 00:32:02 -0400
commite3d6b07b8ba161f638b026feba0c3c97875d7f1c (patch)
treed40cea06665f9092820d76948d38e329c178011b /kernel/auditfilter.c
parent29e9a3467c1367549568d7d411d5f30209ae181b (diff)
audit: optimize audit_compare_dname_path
In the cases where we already know the length of the parent, pass it as a parm so we don't need to recompute it. In the cases where we don't know the length, pass in AUDIT_NAME_FULL (-1) to indicate that it should be determined. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'kernel/auditfilter.c')
-rw-r--r--kernel/auditfilter.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index d705eb17661b..7f19f23d38a3 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -1328,11 +1328,17 @@ int parent_len(const char *path)
1328 return p - path; 1328 return p - path;
1329} 1329}
1330 1330
1331/* Compare given dentry name with last component in given path, 1331/**
1332 * return of 0 indicates a match. */ 1332 * audit_compare_dname_path - compare given dentry name with last component in
1333int audit_compare_dname_path(const char *dname, const char *path) 1333 * given path. Return of 0 indicates a match.
1334 * @dname: dentry name that we're comparing
1335 * @path: full pathname that we're comparing
1336 * @parentlen: length of the parent if known. Passing in AUDIT_NAME_FULL
1337 * here indicates that we must compute this value.
1338 */
1339int audit_compare_dname_path(const char *dname, const char *path, int parentlen)
1334{ 1340{
1335 int dlen, pathlen, parentlen; 1341 int dlen, pathlen;
1336 const char *p; 1342 const char *p;
1337 1343
1338 dlen = strlen(dname); 1344 dlen = strlen(dname);
@@ -1340,7 +1346,7 @@ int audit_compare_dname_path(const char *dname, const char *path)
1340 if (pathlen < dlen) 1346 if (pathlen < dlen)
1341 return 1; 1347 return 1;
1342 1348
1343 parentlen = parent_len(path); 1349 parentlen = parentlen == AUDIT_NAME_FULL ? parent_len(path) : parentlen;
1344 if (pathlen - parentlen != dlen) 1350 if (pathlen - parentlen != dlen)
1345 return 1; 1351 return 1;
1346 1352