:: Re: [DNG] Help needed:[Fwd: eudev: …
Kezdőlap
Delete this message
Reply to this message
Szerző: Ralph Ronnquist
Dátum:  
Címzett: dng
Tárgy: Re: [DNG] Help needed:[Fwd: eudev: Methods to detect if running in a container.]
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 /".

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
>