mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 13:41:51 +00:00
init: add an init_chmod helper
Add a simple helper to chmod with a kernel space file name and switch the early init code over to it. Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
b873498f99
commit
1097742efc
13
fs/init.c
13
fs/init.c
@ -96,6 +96,19 @@ int __init init_chown(const char *filename, uid_t user, gid_t group, int flags)
|
||||
return error;
|
||||
}
|
||||
|
||||
int __init init_chmod(const char *filename, umode_t mode)
|
||||
{
|
||||
struct path path;
|
||||
int error;
|
||||
|
||||
error = kern_path(filename, LOOKUP_FOLLOW, &path);
|
||||
if (error)
|
||||
return error;
|
||||
error = chmod_common(&path, mode);
|
||||
path_put(&path);
|
||||
return error;
|
||||
}
|
||||
|
||||
int __init init_unlink(const char *pathname)
|
||||
{
|
||||
return do_unlinkat(AT_FDCWD, getname_kernel(pathname));
|
||||
|
@ -131,7 +131,7 @@ extern struct open_how build_open_how(int flags, umode_t mode);
|
||||
extern int build_open_flags(const struct open_how *how, struct open_flags *op);
|
||||
|
||||
long do_sys_ftruncate(unsigned int fd, loff_t length, int small);
|
||||
int do_fchmodat(int dfd, const char __user *filename, umode_t mode);
|
||||
int chmod_common(const struct path *path, umode_t mode);
|
||||
int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group,
|
||||
int flag);
|
||||
int chown_common(const struct path *path, uid_t user, gid_t group);
|
||||
|
@ -563,7 +563,7 @@ out:
|
||||
return error;
|
||||
}
|
||||
|
||||
static int chmod_common(const struct path *path, umode_t mode)
|
||||
int chmod_common(const struct path *path, umode_t mode)
|
||||
{
|
||||
struct inode *inode = path->dentry->d_inode;
|
||||
struct inode *delegated_inode = NULL;
|
||||
@ -610,7 +610,7 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode)
|
||||
return err;
|
||||
}
|
||||
|
||||
int do_fchmodat(int dfd, const char __user *filename, umode_t mode)
|
||||
static int do_fchmodat(int dfd, const char __user *filename, umode_t mode)
|
||||
{
|
||||
struct path path;
|
||||
int error;
|
||||
|
@ -6,5 +6,6 @@ int __init init_umount(const char *name, int flags);
|
||||
int __init init_chdir(const char *filename);
|
||||
int __init init_chroot(const char *filename);
|
||||
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_unlink(const char *pathname);
|
||||
int __init init_rmdir(const char *pathname);
|
||||
|
@ -1304,13 +1304,6 @@ static inline long ksys_link(const char __user *oldname,
|
||||
return do_linkat(AT_FDCWD, oldname, AT_FDCWD, newname, 0);
|
||||
}
|
||||
|
||||
extern int do_fchmodat(int dfd, const char __user *filename, umode_t mode);
|
||||
|
||||
static inline int ksys_chmod(const char __user *filename, umode_t mode)
|
||||
{
|
||||
return do_fchmodat(AT_FDCWD, filename, mode);
|
||||
}
|
||||
|
||||
long do_faccessat(int dfd, const char __user *filename, int mode, int flags);
|
||||
|
||||
static inline long ksys_access(const char __user *filename, int mode)
|
||||
|
@ -350,14 +350,14 @@ static int __init do_name(void)
|
||||
} else if (S_ISDIR(mode)) {
|
||||
ksys_mkdir(collected, mode);
|
||||
init_chown(collected, uid, gid, 0);
|
||||
ksys_chmod(collected, mode);
|
||||
init_chmod(collected, mode);
|
||||
dir_add(collected, mtime);
|
||||
} else if (S_ISBLK(mode) || S_ISCHR(mode) ||
|
||||
S_ISFIFO(mode) || S_ISSOCK(mode)) {
|
||||
if (maybe_link() == 0) {
|
||||
ksys_mknod(collected, mode, rdev);
|
||||
init_chown(collected, uid, gid, 0);
|
||||
ksys_chmod(collected, mode);
|
||||
init_chmod(collected, mode);
|
||||
do_utime(collected, mtime);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user