Commit 71e6be6f authored by Al Viro's avatar Al Viro Committed by David S. Miller

fold unix_mknod() into unix_bind_bsd()

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fa42d910
...@@ -984,46 +984,38 @@ static struct sock *unix_find_other(struct net *net, ...@@ -984,46 +984,38 @@ static struct sock *unix_find_other(struct net *net,
return NULL; return NULL;
} }
static int unix_mknod(const char *sun_path, umode_t mode, struct path *res) static int unix_bind_bsd(struct sock *sk, struct unix_address *addr)
{ {
struct unix_sock *u = unix_sk(sk);
umode_t mode = S_IFSOCK |
(SOCK_INODE(sk->sk_socket)->i_mode & ~current_umask());
struct path parent, path;
struct user_namespace *ns; // barf...
struct dentry *dentry; struct dentry *dentry;
struct path path; unsigned int hash;
int err = 0; int err;
/* /*
* Get the parent directory, calculate the hash for last * Get the parent directory, calculate the hash for last
* component. * component.
*/ */
dentry = kern_path_create(AT_FDCWD, sun_path, &path, 0); dentry = kern_path_create(AT_FDCWD, addr->name->sun_path, &parent, 0);
err = PTR_ERR(dentry);
if (IS_ERR(dentry)) if (IS_ERR(dentry))
return err; return PTR_ERR(dentry);
ns = mnt_user_ns(parent.mnt);
/* /*
* All right, let's create it. * All right, let's create it.
*/ */
err = security_path_mknod(&path, dentry, mode, 0); err = security_path_mknod(&parent, dentry, mode, 0);
if (!err) { if (!err) {
err = vfs_mknod(mnt_user_ns(path.mnt), d_inode(path.dentry), err = vfs_mknod(ns, d_inode(parent.dentry), dentry, mode, 0);
dentry, mode, 0);
if (!err) { if (!err) {
res->mnt = mntget(path.mnt); path.mnt = mntget(parent.mnt);
res->dentry = dget(dentry); path.dentry = dget(dentry);
} }
} }
done_path_create(&path, dentry); done_path_create(&parent, dentry);
return err;
}
static int unix_bind_bsd(struct sock *sk, struct unix_address *addr)
{
struct unix_sock *u = unix_sk(sk);
struct path path = { };
umode_t mode = S_IFSOCK |
(SOCK_INODE(sk->sk_socket)->i_mode & ~current_umask());
unsigned int hash;
int err;
err = unix_mknod(addr->name->sun_path, mode, &path);
if (err) if (err)
return err; return err;
......
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