mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-08 12:52:40 -04:00
fs: new helper vfs_empty_path()
Make it possible to quickly check whether AT_EMPTY_PATH is valid. Note, after some discussion we decided to also allow NULL to be passed instead of requiring the empty string. Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
@@ -3631,4 +3631,21 @@ extern int vfs_fadvise(struct file *file, loff_t offset, loff_t len,
|
||||
extern int generic_fadvise(struct file *file, loff_t offset, loff_t len,
|
||||
int advice);
|
||||
|
||||
static inline bool vfs_empty_path(int dfd, const char __user *path)
|
||||
{
|
||||
char c;
|
||||
|
||||
if (dfd < 0)
|
||||
return false;
|
||||
|
||||
/* We now allow NULL to be used for empty path. */
|
||||
if (!path)
|
||||
return true;
|
||||
|
||||
if (unlikely(get_user(c, path)))
|
||||
return false;
|
||||
|
||||
return !c;
|
||||
}
|
||||
|
||||
#endif /* _LINUX_FS_H */
|
||||
|
||||
Reference in New Issue
Block a user