fs: expose do_unlinkat for built-in callers
And make it take a struct filename instead of a user pointer. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
e145b35bb9
commit
da2f1362c8
|
@ -55,6 +55,7 @@ extern void __init chrdev_init(void);
|
||||||
extern int user_path_mountpoint_at(int, const char __user *, unsigned int, struct path *);
|
extern int user_path_mountpoint_at(int, const char __user *, unsigned int, struct path *);
|
||||||
extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
|
extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
|
||||||
const char *, unsigned int, struct path *);
|
const char *, unsigned int, struct path *);
|
||||||
|
long do_unlinkat(int dfd, struct filename *name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* namespace.c
|
* namespace.c
|
||||||
|
|
12
fs/namei.c
12
fs/namei.c
|
@ -4009,10 +4009,9 @@ EXPORT_SYMBOL(vfs_unlink);
|
||||||
* writeout happening, and we don't want to prevent access to the directory
|
* writeout happening, and we don't want to prevent access to the directory
|
||||||
* while waiting on the I/O.
|
* while waiting on the I/O.
|
||||||
*/
|
*/
|
||||||
static long do_unlinkat(int dfd, const char __user *pathname)
|
long do_unlinkat(int dfd, struct filename *name)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
struct filename *name;
|
|
||||||
struct dentry *dentry;
|
struct dentry *dentry;
|
||||||
struct path path;
|
struct path path;
|
||||||
struct qstr last;
|
struct qstr last;
|
||||||
|
@ -4021,8 +4020,7 @@ static long do_unlinkat(int dfd, const char __user *pathname)
|
||||||
struct inode *delegated_inode = NULL;
|
struct inode *delegated_inode = NULL;
|
||||||
unsigned int lookup_flags = 0;
|
unsigned int lookup_flags = 0;
|
||||||
retry:
|
retry:
|
||||||
name = filename_parentat(dfd, getname(pathname), lookup_flags,
|
name = filename_parentat(dfd, name, lookup_flags, &path, &last, &type);
|
||||||
&path, &last, &type);
|
|
||||||
if (IS_ERR(name))
|
if (IS_ERR(name))
|
||||||
return PTR_ERR(name);
|
return PTR_ERR(name);
|
||||||
|
|
||||||
|
@ -4064,12 +4062,12 @@ static long do_unlinkat(int dfd, const char __user *pathname)
|
||||||
mnt_drop_write(path.mnt);
|
mnt_drop_write(path.mnt);
|
||||||
exit1:
|
exit1:
|
||||||
path_put(&path);
|
path_put(&path);
|
||||||
putname(name);
|
|
||||||
if (retry_estale(error, lookup_flags)) {
|
if (retry_estale(error, lookup_flags)) {
|
||||||
lookup_flags |= LOOKUP_REVAL;
|
lookup_flags |= LOOKUP_REVAL;
|
||||||
inode = NULL;
|
inode = NULL;
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
putname(name);
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
slashes:
|
slashes:
|
||||||
|
@ -4090,12 +4088,12 @@ SYSCALL_DEFINE3(unlinkat, int, dfd, const char __user *, pathname, int, flag)
|
||||||
if (flag & AT_REMOVEDIR)
|
if (flag & AT_REMOVEDIR)
|
||||||
return do_rmdir(dfd, pathname);
|
return do_rmdir(dfd, pathname);
|
||||||
|
|
||||||
return do_unlinkat(dfd, pathname);
|
return do_unlinkat(dfd, getname(pathname));
|
||||||
}
|
}
|
||||||
|
|
||||||
SYSCALL_DEFINE1(unlink, const char __user *, pathname)
|
SYSCALL_DEFINE1(unlink, const char __user *, pathname)
|
||||||
{
|
{
|
||||||
return do_unlinkat(AT_FDCWD, pathname);
|
return do_unlinkat(AT_FDCWD, getname(pathname));
|
||||||
}
|
}
|
||||||
|
|
||||||
int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
|
int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
|
||||||
|
|
Loading…
Reference in New Issue