On Tue, Jul 21, 2020 at 06:28:00PM +0200, Christoph Hellwig wrote:
> Instead of passing a kernel pointer to vfs_stat by relying on the
> implicit set_fs(KERNEL_DS) in md_setup_drive, just open code the
> trivial getattr, and use the opportunity to move a little bit more
> code from the caller into the new helper.

Ugh...

> +static void __init md_lookup_dev(const char *devname, dev_t *dev)
> +{
> +     struct kstat stat;
> +     struct path path;
> +     char filename[64];
> +
> +     if (strncmp(devname, "/dev/", 5) == 0)
> +             devname += 5;
> +     snprintf(filename, 63, "/dev/%s", devname);
> +
> +     if (!kern_path(filename, LOOKUP_FOLLOW, &path) &&
> +         !vfs_getattr(&path, &stat, STATX_BASIC_STATS, AT_NO_AUTOMOUNT) &&
> +         S_ISBLK(stat.mode))
> +             *dev = new_decode_dev(stat.rdev);
> +     path_put(&path);
> +}

How about fs/for_init.c and putting the damn helpers there?  With
calling conventions as close to syscalls as possible, and a fat
comment regarding their intended use being _ONLY_ the setup
in should-have-been-done-in-userland parts of init?

I really want to keep the surface as small as possible - we had
fun shite several releases ago when somebody tried that kind of
crap (with open(), IIRC).  Let's not go there again...

Reply via email to