On Fri, Jun 9, 2023 at 2:12 PM Christian Brauner <brauner@xxxxxxxxxx> wrote: > > On Fri, Jun 09, 2023 at 10:32:39AM +0300, Amir Goldstein wrote: > > Instead of storing only the fake path in f_path, store the real path > > in f_path and the fake path in file_fake container. > > > > Call sites that use the macro file_fake_path() continue to get the fake > > path from its new location. > > > > Call sites that access f_path directly will now see the overlayfs real > > path instead of the fake overlayfs path, which is the desired bahvior > > for most users, because it makes f_path consistent with f_inode. > > > > Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx> > > --- > > If you resend, can you take the chance and refactor this into a slightly more > readable pattern, please? So something like > Sure! I like this better myself. Thanks, Amir. > struct file *open_with_fake_path(const struct path *fake_path, int flags, > const struct path *path, > const struct cred *cred) > { > int error; > struct file *f; > > f = alloc_empty_file_fake(fake_path, flags, cred); > if (IS_ERR(f)) > return f; > > f->f_path = *path; > error = do_dentry_open(f, d_inode(path->dentry), NULL); > if (error) { > fput(f); > return ERR_PTR(error); > } > > return f; > }