RFR: 8261242: [Linux] OSContainer::is_containerized() returns true when run outside a container [v2]
Severin Gehwolf
sgehwolf at openjdk.org
Fri May 3 15:57:53 UTC 2024
On Tue, 16 Apr 2024 18:10:08 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> src/hotspot/os/linux/cgroupSubsystem_linux.cpp line 351:
>>
>>> 349: //
>>> 350: // We collect the read only mount option in the cgroup infos so as to have that
>>> 351: // info ready when determining is_containerized().
>>
>> Here, and in other places: a comment indicating the line format we scan would be appreciated, possibly with argument numbers. Saves the casual code reader from looking into proc man page. Even just pasting the example line for proc manpage would be fine (https://man7.org/linux/man-pages/man5/proc.5.html) (but with order adapted to your scanf call, they count major:minor as one)
>
> Trying to parse the `%s%*[^-]-`
>
> So, %s parses the mount options, until we encounter whitespace. Then %*[^-]- parses everything that is not a dash, until we encounter the dash? Then we eat the dash? This is to skip the optionals?
Correct. Note that `%s %*[^-]` doesn't work for files without optionals. Since `%*[^-]` requires a non-empty match and the optionals are, well, optional :-) I've added more verbose comments to clarify this.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18201#discussion_r1589390841
More information about the serviceability-dev
mailing list