^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Routines that mimic syscalls, but don't use the user address space or file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * descriptors. Only for init/ and related early init code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/mount.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/namei.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/fs_struct.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/init_syscalls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/security.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) int __init init_mount(const char *dev_name, const char *dir_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) const char *type_page, unsigned long flags, void *data_page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct path path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) ret = kern_path(dir_name, LOOKUP_FOLLOW, &path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) ret = path_mount(dev_name, &path, type_page, flags, data_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) path_put(&path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) int __init init_umount(const char *name, int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) int lookup_flags = LOOKUP_MOUNTPOINT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct path path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) if (!(flags & UMOUNT_NOFOLLOW))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) lookup_flags |= LOOKUP_FOLLOW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) ret = kern_path(name, lookup_flags, &path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) return path_umount(&path, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) int __init init_chdir(const char *filename)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct path path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) error = kern_path(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) set_fs_pwd(current->fs, &path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) path_put(&path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) int __init init_chroot(const char *filename)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) struct path path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) error = kern_path(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) goto dput_and_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) error = -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) if (!ns_capable(current_user_ns(), CAP_SYS_CHROOT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) goto dput_and_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) error = security_path_chroot(&path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) goto dput_and_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) set_fs_root(current->fs, &path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) dput_and_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) path_put(&path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) int __init init_chown(const char *filename, uid_t user, gid_t group, int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) int lookup_flags = (flags & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct path path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) error = kern_path(filename, lookup_flags, &path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) error = mnt_want_write(path.mnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) if (!error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) error = chown_common(&path, user, group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) mnt_drop_write(path.mnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) path_put(&path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) int __init init_chmod(const char *filename, umode_t mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct path path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) error = kern_path(filename, LOOKUP_FOLLOW, &path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) error = chmod_common(&path, mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) path_put(&path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) int __init init_eaccess(const char *filename)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) struct path path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) error = kern_path(filename, LOOKUP_FOLLOW, &path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) error = inode_permission(d_inode(path.dentry), MAY_ACCESS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) path_put(&path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) int __init init_stat(const char *filename, struct kstat *stat, int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int lookup_flags = (flags & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) struct path path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) error = kern_path(filename, lookup_flags, &path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) error = vfs_getattr(&path, stat, STATX_BASIC_STATS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) flags | AT_NO_AUTOMOUNT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) path_put(&path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) int __init init_mknod(const char *filename, umode_t mode, unsigned int dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) struct dentry *dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) struct path path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if (S_ISFIFO(mode) || S_ISSOCK(mode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) dev = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) else if (!(S_ISBLK(mode) || S_ISCHR(mode)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) dentry = kern_path_create(AT_FDCWD, filename, &path, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) if (IS_ERR(dentry))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) return PTR_ERR(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) if (!IS_POSIXACL(path.dentry->d_inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) mode &= ~current_umask();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) error = security_path_mknod(&path, dentry, mode, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) error = vfs_mknod(path.dentry->d_inode, dentry, mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) new_decode_dev(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) done_path_create(&path, dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) int __init init_link(const char *oldname, const char *newname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) struct dentry *new_dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) struct path old_path, new_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) error = kern_path(oldname, 0, &old_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) new_dentry = kern_path_create(AT_FDCWD, newname, &new_path, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) error = PTR_ERR(new_dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if (IS_ERR(new_dentry))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) error = -EXDEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) if (old_path.mnt != new_path.mnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) goto out_dput;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) error = may_linkat(&old_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) goto out_dput;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) error = security_path_link(old_path.dentry, &new_path, new_dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) goto out_dput;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) out_dput:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) done_path_create(&new_path, new_dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) path_put(&old_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) int __init init_symlink(const char *oldname, const char *newname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) struct dentry *dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) struct path path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) dentry = kern_path_create(AT_FDCWD, newname, &path, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) if (IS_ERR(dentry))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) return PTR_ERR(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) error = security_path_symlink(&path, dentry, oldname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) error = vfs_symlink(path.dentry->d_inode, dentry, oldname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) done_path_create(&path, dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) int __init init_unlink(const char *pathname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) return do_unlinkat(AT_FDCWD, getname_kernel(pathname));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) int __init init_mkdir(const char *pathname, umode_t mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) struct dentry *dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) struct path path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) dentry = kern_path_create(AT_FDCWD, pathname, &path, LOOKUP_DIRECTORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) if (IS_ERR(dentry))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) return PTR_ERR(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if (!IS_POSIXACL(path.dentry->d_inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) mode &= ~current_umask();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) error = security_path_mkdir(&path, dentry, mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) done_path_create(&path, dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) int __init init_rmdir(const char *pathname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) return do_rmdir(AT_FDCWD, getname_kernel(pathname));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) int __init init_utimes(char *filename, struct timespec64 *ts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) struct path path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) error = kern_path(filename, 0, &path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) error = vfs_utimes(&path, ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) path_put(&path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) int __init init_dup(struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) int fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) fd = get_unused_fd_flags(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) if (fd < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) return fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) fd_install(fd, get_file(file));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) }