mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	init: add an init_stat helper
Add a simple helper to stat 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
							
								
									5fee64fcde
								
							
						
					
					
						commit
						716308a533
					
				
					 4 changed files with 20 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -5,6 +5,7 @@
 | 
			
		|||
#include <linux/mount.h>
 | 
			
		||||
#include <linux/major.h>
 | 
			
		||||
#include <linux/delay.h>
 | 
			
		||||
#include <linux/init_syscalls.h>
 | 
			
		||||
#include <linux/raid/detect.h>
 | 
			
		||||
#include <linux/raid/md_u.h>
 | 
			
		||||
#include <linux/raid/md_p.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -151,7 +152,7 @@ static void __init md_setup_drive(struct md_setup_args *args)
 | 
			
		|||
		if (strncmp(devname, "/dev/", 5) == 0)
 | 
			
		||||
			devname += 5;
 | 
			
		||||
		snprintf(comp_name, 63, "/dev/%s", devname);
 | 
			
		||||
		if (vfs_stat(comp_name, &stat) == 0 && S_ISBLK(stat.mode))
 | 
			
		||||
		if (init_stat(comp_name, &stat, 0) == 0 && S_ISBLK(stat.mode))
 | 
			
		||||
			dev = new_decode_dev(stat.rdev);
 | 
			
		||||
		if (!dev) {
 | 
			
		||||
			pr_warn("md: Unknown device name: %s\n", devname);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										15
									
								
								fs/init.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								fs/init.c
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -122,6 +122,21 @@ int __init init_eaccess(const char *filename)
 | 
			
		|||
	return error;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int __init init_stat(const char *filename, struct kstat *stat, int flags)
 | 
			
		||||
{
 | 
			
		||||
	int lookup_flags = (flags & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
 | 
			
		||||
	struct path path;
 | 
			
		||||
	int error;
 | 
			
		||||
 | 
			
		||||
	error = kern_path(filename, lookup_flags, &path);
 | 
			
		||||
	if (error)
 | 
			
		||||
		return error;
 | 
			
		||||
	error = vfs_getattr(&path, stat, STATX_BASIC_STATS,
 | 
			
		||||
			    flags | AT_NO_AUTOMOUNT);
 | 
			
		||||
	path_put(&path);
 | 
			
		||||
	return error;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int __init init_mknod(const char *filename, umode_t mode, unsigned int dev)
 | 
			
		||||
{
 | 
			
		||||
	struct dentry *dentry;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,6 +8,7 @@ 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_eaccess(const char *filename);
 | 
			
		||||
int __init init_stat(const char *filename, struct kstat *stat, int flags);
 | 
			
		||||
int __init init_mknod(const char *filename, umode_t mode, unsigned int dev);
 | 
			
		||||
int __init init_link(const char *oldname, const char *newname);
 | 
			
		||||
int __init init_symlink(const char *oldname, const char *newname);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -298,7 +298,8 @@ static void __init clean_path(char *path, umode_t fmode)
 | 
			
		|||
{
 | 
			
		||||
	struct kstat st;
 | 
			
		||||
 | 
			
		||||
	if (!vfs_lstat(path, &st) && (st.mode ^ fmode) & S_IFMT) {
 | 
			
		||||
	if (init_stat(path, &st, AT_SYMLINK_NOFOLLOW) &&
 | 
			
		||||
	    (st.mode ^ fmode) & S_IFMT) {
 | 
			
		||||
		if (S_ISDIR(st.mode))
 | 
			
		||||
			init_rmdir(path);
 | 
			
		||||
		else
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue