[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN RFC for-4.14] Re: use of "stat -"



On Thu, Jun 25, 2020 at 9:48 AM Jan Beulich <jbeulich@xxxxxxxx> wrote:
>
> On 25.06.2020 15:31, Ian Jackson wrote:
> > Jan Beulich writes ("Re: [XEN RFC for-4.14] Re: use of "stat -""):
> >> Looking at vfs_statx() in the kernel, I can't see any provisions to
> >> get at the data without traversing the specified path.
> >
> > The question is what "traversing the path" means.
> >
> > How do you explain this ?
> >
> > $ >t
> > $ exec 3>t
> > $ stat -L -c '%F %i' /dev/stdin <&3
> > regular empty file 421124
> > $ ll /dev/stdin <&3
> > lrwxrwxrwx 1 root root 15 Jun  7 02:01 /dev/stdin -> /proc/self/fd/0
> > $ ll /proc/self/fd/0 <&3
> > l-wx------ 1 ian ian 64 Jun 25 14:29 /proc/self/fd/0 -> /home/ian/t
> > $ mv t u
> > $ ll /proc/self/fd/0 <&3
> > l-wx------ 1 ian ian 64 Jun 25 14:29 /proc/self/fd/0 -> /home/ian/u
> > $ rm u
> > $ ll /proc/self/fd/0 <&3
> > l-wx------ 1 ian ian 64 Jun 25 14:29 /proc/self/fd/0 -> '/home/ian/u 
> > (deleted)'
> > $ stat -L -c '%F %i' /dev/stdin <&3
> > regular empty file 421124
> > $ ll -Li /dev/stdin <&3
> > 421124 -rw-rw-r-- 0 ian ian 0 Jun 25 14:28 /dev/stdin
> > $
> >
> > Clearly it isn't actually following this synthetic symlink to
> > "/home/ian/u (deleted)".
>
> Okay, so there's clearly some trickery then which don't know where
> to find.

I can't say I've taken the time to read and understand all this, but
the code in here
https://elixir.bootlin.com/linux/latest/source/fs/proc/fd.c#L147 seems
to lookup FDs to existing structs.

-Jason



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.