Commit 2d8646510120bb1eb251ae3381e950805a877763
1 parent
197df04c74
Exists in
master
and in
20 other branches
introduce kern_path_mountpoint()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 2 changed files with 25 additions and 11 deletions Side-by-side Diff
fs/namei.c
... | ... | @@ -2360,6 +2360,20 @@ |
2360 | 2360 | return err; |
2361 | 2361 | } |
2362 | 2362 | |
2363 | +static int | |
2364 | +filename_mountpoint(int dfd, struct filename *s, struct path *path, | |
2365 | + unsigned int flags) | |
2366 | +{ | |
2367 | + int error = path_mountpoint(dfd, s->name, path, flags | LOOKUP_RCU); | |
2368 | + if (unlikely(error == -ECHILD)) | |
2369 | + error = path_mountpoint(dfd, s->name, path, flags); | |
2370 | + if (unlikely(error == -ESTALE)) | |
2371 | + error = path_mountpoint(dfd, s->name, path, flags | LOOKUP_REVAL); | |
2372 | + if (likely(!error)) | |
2373 | + audit_inode(s, path->dentry, 0); | |
2374 | + return error; | |
2375 | +} | |
2376 | + | |
2363 | 2377 | /** |
2364 | 2378 | * user_path_mountpoint_at - lookup a path from userland in order to umount it |
2365 | 2379 | * @dfd: directory file descriptor |
2366 | 2380 | |
2367 | 2381 | |
... | ... | @@ -2380,22 +2394,21 @@ |
2380 | 2394 | { |
2381 | 2395 | struct filename *s = getname(name); |
2382 | 2396 | int error; |
2383 | - | |
2384 | 2397 | if (IS_ERR(s)) |
2385 | 2398 | return PTR_ERR(s); |
2386 | - | |
2387 | - error = path_mountpoint(dfd, s->name, path, flags | LOOKUP_RCU); | |
2388 | - if (unlikely(error == -ECHILD)) | |
2389 | - error = path_mountpoint(dfd, s->name, path, flags); | |
2390 | - if (unlikely(error == -ESTALE)) | |
2391 | - error = path_mountpoint(dfd, s->name, path, flags | LOOKUP_REVAL); | |
2392 | - | |
2393 | - if (likely(!error)) | |
2394 | - audit_inode(s, path->dentry, 0); | |
2395 | - | |
2399 | + error = filename_mountpoint(dfd, s, path, flags); | |
2396 | 2400 | putname(s); |
2397 | 2401 | return error; |
2398 | 2402 | } |
2403 | + | |
2404 | +int | |
2405 | +kern_path_mountpoint(int dfd, const char *name, struct path *path, | |
2406 | + unsigned int flags) | |
2407 | +{ | |
2408 | + struct filename s = {.name = name}; | |
2409 | + return filename_mountpoint(dfd, &s, path, flags); | |
2410 | +} | |
2411 | +EXPORT_SYMBOL(kern_path_mountpoint); | |
2399 | 2412 | |
2400 | 2413 | /* |
2401 | 2414 | * It's inline, so penalty for filesystems that don't use sticky bit is |
include/linux/namei.h
... | ... | @@ -70,6 +70,7 @@ |
70 | 70 | extern struct dentry *user_path_create(int, const char __user *, struct path *, unsigned int); |
71 | 71 | extern void done_path_create(struct path *, struct dentry *); |
72 | 72 | extern struct dentry *kern_path_locked(const char *, struct path *); |
73 | +extern int kern_path_mountpoint(int, const char *, struct path *, unsigned int); | |
73 | 74 | |
74 | 75 | extern struct dentry *lookup_one_len(const char *, struct dentry *, int); |
75 | 76 |