Skip to content

Commit cd3acb6

Browse files
author
Christoph Hellwig
committed
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 <[email protected]>
1 parent 812931d commit cd3acb6

File tree

6 files changed

+19
-13
lines changed

6 files changed

+19
-13
lines changed

fs/init.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,22 @@ int __init init_link(const char *oldname, const char *newname)
155155
return error;
156156
}
157157

158+
int __init init_symlink(const char *oldname, const char *newname)
159+
{
160+
struct dentry *dentry;
161+
struct path path;
162+
int error;
163+
164+
dentry = kern_path_create(AT_FDCWD, newname, &path, 0);
165+
if (IS_ERR(dentry))
166+
return PTR_ERR(dentry);
167+
error = security_path_symlink(&path, dentry, oldname);
168+
if (!error)
169+
error = vfs_symlink(path.dentry->d_inode, dentry, oldname);
170+
done_path_create(&path, dentry);
171+
return error;
172+
}
173+
158174
int __init init_unlink(const char *pathname)
159175
{
160176
return do_unlinkat(AT_FDCWD, getname_kernel(pathname));

fs/internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ long do_mknodat(int dfd, const char __user *filename, umode_t mode,
6767
long do_mkdirat(int dfd, const char __user *pathname, umode_t mode);
6868
long do_rmdir(int dfd, struct filename *name);
6969
long do_unlinkat(int dfd, struct filename *name);
70-
long do_symlinkat(const char __user *oldname, int newdfd,
71-
const char __user *newname);
7270
int may_linkat(struct path *link);
7371

7472
/*

fs/namei.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3955,7 +3955,7 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
39553955
}
39563956
EXPORT_SYMBOL(vfs_symlink);
39573957

3958-
long do_symlinkat(const char __user *oldname, int newdfd,
3958+
static long do_symlinkat(const char __user *oldname, int newdfd,
39593959
const char __user *newname)
39603960
{
39613961
int error;

include/linux/init_syscalls.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ int __init init_chown(const char *filename, uid_t user, gid_t group, int flags);
99
int __init init_chmod(const char *filename, umode_t mode);
1010
int __init init_eaccess(const char *filename);
1111
int __init init_link(const char *oldname, const char *newname);
12+
int __init init_symlink(const char *oldname, const char *newname);
1213
int __init init_unlink(const char *pathname);
1314
int __init init_rmdir(const char *pathname);

include/linux/syscalls.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,15 +1277,6 @@ static inline long ksys_mkdir(const char __user *pathname, umode_t mode)
12771277
return do_mkdirat(AT_FDCWD, pathname, mode);
12781278
}
12791279

1280-
extern long do_symlinkat(const char __user *oldname, int newdfd,
1281-
const char __user *newname);
1282-
1283-
static inline long ksys_symlink(const char __user *oldname,
1284-
const char __user *newname)
1285-
{
1286-
return do_symlinkat(oldname, AT_FDCWD, newname);
1287-
}
1288-
12891280
extern long do_mknodat(int dfd, const char __user *filename, umode_t mode,
12901281
unsigned int dev);
12911282

init/initramfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ static int __init do_symlink(void)
392392
{
393393
collected[N_ALIGN(name_len) + body_len] = '\0';
394394
clean_path(collected, 0);
395-
ksys_symlink(collected + N_ALIGN(name_len), collected);
395+
init_symlink(collected + N_ALIGN(name_len), collected);
396396
init_chown(collected, uid, gid, AT_SYMLINK_NOFOLLOW);
397397
do_utime(collected, mtime);
398398
state = SkipIt;

0 commit comments

Comments
 (0)