Commit a0781209 authored by John Johansen's avatar John Johansen

apparmor: cleanup: simplify code to get ns symlink name

ns_get_name() is called in only one place and can be folded in.
Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
parent cf916000
...@@ -119,9 +119,7 @@ static int aafs_count; ...@@ -119,9 +119,7 @@ static int aafs_count;
static int aafs_show_path(struct seq_file *seq, struct dentry *dentry) static int aafs_show_path(struct seq_file *seq, struct dentry *dentry)
{ {
struct inode *inode = d_inode(dentry); seq_printf(seq, "%s:[%lu]", AAFS_NAME, d_inode(dentry)->i_ino);
seq_printf(seq, "%s:[%lu]", AAFS_NAME, inode->i_ino);
return 0; return 0;
} }
...@@ -2392,29 +2390,18 @@ static const char *policy_get_link(struct dentry *dentry, ...@@ -2392,29 +2390,18 @@ static const char *policy_get_link(struct dentry *dentry,
return NULL; return NULL;
} }
static int ns_get_name(char *buf, size_t size, struct aa_ns *ns,
struct inode *inode)
{
int res = snprintf(buf, size, "%s:[%lu]", AAFS_NAME, inode->i_ino);
if (res < 0 || res >= size)
res = -ENOENT;
return res;
}
static int policy_readlink(struct dentry *dentry, char __user *buffer, static int policy_readlink(struct dentry *dentry, char __user *buffer,
int buflen) int buflen)
{ {
struct aa_ns *ns;
char name[32]; char name[32];
int res; int res;
ns = aa_get_current_ns(); res = snprintf(name, sizeof(name), "%s:[%lu]", AAFS_NAME,
res = ns_get_name(name, sizeof(name), ns, d_inode(dentry)); d_inode(dentry)->i_ino);
if (res >= 0) if (res > 0 && res < sizeof(name))
res = readlink_copy(buffer, buflen, name); res = readlink_copy(buffer, buflen, name);
aa_put_ns(ns); else
res = -ENOENT;
return res; return res;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment