summaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2023-12-30 19:46:00 -0500
committerChuck Lever <chuck.lever@oracle.com>2024-01-23 10:58:56 -0500
commit42c3732fa8073717dd7d924472f1c0bc5b452fdc (patch)
treed62658e93e5fe91a8e0e75b7c1ab90d384c90e54 /fs/namei.c
parent9473c4450e9c83d890d435577a3776d925fa748c (diff)
downloadlinux-42c3732fa8073717dd7d924472f1c0bc5b452fdc.tar.gz
linux-42c3732fa8073717dd7d924472f1c0bc5b452fdc.tar.bz2
linux-42c3732fa8073717dd7d924472f1c0bc5b452fdc.zip
fs: Create a generic is_dot_dotdot() utility
De-duplicate the same functionality in several places by hoisting the is_dot_dotdot() utility function into linux/fs.h. Suggested-by: Amir Goldstein <amir73il@gmail.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Acked-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 71c13b2990b4..2386a70667fa 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2667,10 +2667,8 @@ static int lookup_one_common(struct mnt_idmap *idmap,
if (!len)
return -EACCES;
- if (unlikely(name[0] == '.')) {
- if (len < 2 || (len == 2 && name[1] == '.'))
- return -EACCES;
- }
+ if (is_dot_dotdot(name, len))
+ return -EACCES;
while (len--) {
unsigned int c = *(const unsigned char *)name++;