diff options
-rw-r--r-- | include/linux/dcache.h | 12 | ||||
-rw-r--r-- | net/unix/af_unix.c | 6 |
2 files changed, 15 insertions, 3 deletions
diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 484c8792da82..f28100f6b556 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h | |||
@@ -575,5 +575,17 @@ static inline struct inode *vfs_select_inode(struct dentry *dentry, | |||
575 | return inode; | 575 | return inode; |
576 | } | 576 | } |
577 | 577 | ||
578 | /** | ||
579 | * d_real_inode - Return the real inode | ||
580 | * @dentry: The dentry to query | ||
581 | * | ||
582 | * If dentry is on an union/overlay, then return the underlying, real inode. | ||
583 | * Otherwise return d_inode(). | ||
584 | */ | ||
585 | static inline struct inode *d_real_inode(struct dentry *dentry) | ||
586 | { | ||
587 | return d_backing_inode(d_real(dentry)); | ||
588 | } | ||
589 | |||
578 | 590 | ||
579 | #endif /* __LINUX_DCACHE_H */ | 591 | #endif /* __LINUX_DCACHE_H */ |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 80aa6a3e6817..735362c26c8e 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -315,7 +315,7 @@ static struct sock *unix_find_socket_byinode(struct inode *i) | |||
315 | &unix_socket_table[i->i_ino & (UNIX_HASH_SIZE - 1)]) { | 315 | &unix_socket_table[i->i_ino & (UNIX_HASH_SIZE - 1)]) { |
316 | struct dentry *dentry = unix_sk(s)->path.dentry; | 316 | struct dentry *dentry = unix_sk(s)->path.dentry; |
317 | 317 | ||
318 | if (dentry && d_backing_inode(dentry) == i) { | 318 | if (dentry && d_real_inode(dentry) == i) { |
319 | sock_hold(s); | 319 | sock_hold(s); |
320 | goto found; | 320 | goto found; |
321 | } | 321 | } |
@@ -911,7 +911,7 @@ static struct sock *unix_find_other(struct net *net, | |||
911 | err = kern_path(sunname->sun_path, LOOKUP_FOLLOW, &path); | 911 | err = kern_path(sunname->sun_path, LOOKUP_FOLLOW, &path); |
912 | if (err) | 912 | if (err) |
913 | goto fail; | 913 | goto fail; |
914 | inode = d_backing_inode(path.dentry); | 914 | inode = d_real_inode(path.dentry); |
915 | err = inode_permission(inode, MAY_WRITE); | 915 | err = inode_permission(inode, MAY_WRITE); |
916 | if (err) | 916 | if (err) |
917 | goto put_fail; | 917 | goto put_fail; |
@@ -1048,7 +1048,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
1048 | goto out_up; | 1048 | goto out_up; |
1049 | } | 1049 | } |
1050 | addr->hash = UNIX_HASH_SIZE; | 1050 | addr->hash = UNIX_HASH_SIZE; |
1051 | hash = d_backing_inode(dentry)->i_ino & (UNIX_HASH_SIZE - 1); | 1051 | hash = d_real_inode(dentry)->i_ino & (UNIX_HASH_SIZE - 1); |
1052 | spin_lock(&unix_table_lock); | 1052 | spin_lock(&unix_table_lock); |
1053 | u->path = u_path; | 1053 | u->path = u_path; |
1054 | list = &unix_socket_table[hash]; | 1054 | list = &unix_socket_table[hash]; |