init: add an init_symlink helper

Add a simple helper to symlink with a kernel space file name and switch
the early init code over to it.  Remove the now unused ksys_symlink.

Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
Christoph Hellwig 2020-07-22 11:14:36 +02:00
parent 812931d693
commit cd3acb6a79
6 changed files with 19 additions and 13 deletions

View file

@ -155,6 +155,22 @@ int __init init_link(const char *oldname, const char *newname)
return error;
}
int __init init_symlink(const char *oldname, const char *newname)
{
struct dentry *dentry;
struct path path;
int error;
dentry = kern_path_create(AT_FDCWD, newname, &path, 0);
if (IS_ERR(dentry))
return PTR_ERR(dentry);
error = security_path_symlink(&path, dentry, oldname);
if (!error)
error = vfs_symlink(path.dentry->d_inode, dentry, oldname);
done_path_create(&path, dentry);
return error;
}
int __init init_unlink(const char *pathname)
{
return do_unlinkat(AT_FDCWD, getname_kernel(pathname));

View file

@ -67,8 +67,6 @@ long do_mknodat(int dfd, const char __user *filename, umode_t mode,
long do_mkdirat(int dfd, const char __user *pathname, umode_t mode);
long do_rmdir(int dfd, struct filename *name);
long do_unlinkat(int dfd, struct filename *name);
long do_symlinkat(const char __user *oldname, int newdfd,
const char __user *newname);
int may_linkat(struct path *link);
/*

View file

@ -3955,7 +3955,7 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
}
EXPORT_SYMBOL(vfs_symlink);
long do_symlinkat(const char __user *oldname, int newdfd,
static long do_symlinkat(const char __user *oldname, int newdfd,
const char __user *newname)
{
int error;

View file

@ -9,5 +9,6 @@ int __init init_chown(const char *filename, uid_t user, gid_t group, int flags);
int __init init_chmod(const char *filename, umode_t mode);
int __init init_eaccess(const char *filename);
int __init init_link(const char *oldname, const char *newname);
int __init init_symlink(const char *oldname, const char *newname);
int __init init_unlink(const char *pathname);
int __init init_rmdir(const char *pathname);

View file

@ -1277,15 +1277,6 @@ static inline long ksys_mkdir(const char __user *pathname, umode_t mode)
return do_mkdirat(AT_FDCWD, pathname, mode);
}
extern long do_symlinkat(const char __user *oldname, int newdfd,
const char __user *newname);
static inline long ksys_symlink(const char __user *oldname,
const char __user *newname)
{
return do_symlinkat(oldname, AT_FDCWD, newname);
}
extern long do_mknodat(int dfd, const char __user *filename, umode_t mode,
unsigned int dev);

View file

@ -392,7 +392,7 @@ static int __init do_symlink(void)
{
collected[N_ALIGN(name_len) + body_len] = '\0';
clean_path(collected, 0);
ksys_symlink(collected + N_ALIGN(name_len), collected);
init_symlink(collected + N_ALIGN(name_len), collected);
init_chown(collected, uid, gid, AT_SYMLINK_NOFOLLOW);
do_utime(collected, mtime);
state = SkipIt;