:: Re: [DNG] Help needed:[Fwd: eudev: …
Góra strony
Delete this message
Reply to this message
Autor: Hendrik Boom
Data:  
Dla: dng
Temat: Re: [DNG] Help needed:[Fwd: eudev: Methods to detect if running in a container.]
On Wed, Apr 01, 2020 at 09:42:56AM +1100, Ralph Ronnquist via Dng wrote:
> Note that the inode number is per file system. If you make a file as an ext4
> image, then its root will have inode=2 as well. You can verify that by mounting
> the file somewhere and then stat that somewhere; or even chroot into that file
> system (if set up), and use "stat /".


Right. Once when I used inodes to check file identity I also checked what
file system the file was on.

That ws in a C inplementation where the parser identified include files that
had the usual #ifdef's to block multiple inclusion, and then proceeded to skip
them without bothering with the usual search for corrsponding #endif's.
Having already seen the file, it didn't need to look at it again.

I know I must have forgetten some of the context, but in this specific system
it caused a significant speedup. Which seems implausible not that I'm
reminiscing.

-- hendrik

>
> Ralph.
>
> aitor_czr wrote on 2020-03-31 02:18:
> > Hi Svante,
> >
> > On 19/2/20 15:17, Svante Signell via Dng wrote:
> >> Hello,
> >>
> >> No replies so far from the devuan-dev list. Maybe with a larger audience I can
> >> get some help!
> >>
> >> Thanks!
> > Checking  whether the *inode* number of the primary directory in the
> > standard filesystem hierarchy
> > used in the most unix-like sytems(that is, the root "/" directory) is
> > *equal* to 2 will help to differentiate
> > if you are within a container or not. eg you can do:
> >
> > $ ls --inode --directory "/"
> >
> > 2 /
> >
> > While in a container the output of this command will return a high inode
> > number. I tested it in three
> > different scenarios:
> >
> > a) Using docker bash shell of ubuntu:
> >
> > # docker run -it ubuntu bash
> >
> > root@b87da5b70a84:/# ls --inode --directory "/"
> >
> > 2492863 /
> >
> > b) Using a qemu qcow2 image of devuan:
> >
> > $ ls --inode --directory "/"
> >
> > 9531 /
> >
> > c) Inside the chroot jail of the live-sdk:
> >
> > root@devuan:/# ls --inode --directory "/"
> >
> > 22839335 /
> >
> > I reckon this approach won't work neither in the case of operating
> > systems using random inode numbers
> > (but this is not our case),nor in the case of chroot jails rooted on a
> > mount point, in which case we have
> > the following workaround(at least in debian-based systems):
> >
> > https://manpages.debian.org/jessie/debianutils/ischroot.1.en.html
> >
> > Hope this helps,
> >
> > Aitor.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > _______________________________________________
> > Dng mailing list
> > Dng@???
> > https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
> >
> _______________________________________________
> Dng mailing list
> Dng@???
> https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng