RFR: 8356597: AOT cache and CDS archive should not be created in read-only mode

Aleksey Shipilev shade at openjdk.org
Fri May 9 16:25:53 UTC 2025


On Fri, 9 May 2025 15:42:26 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>> Also matches what Linux does:
>> 
>> 
>> $ rm 1; touch 1; stat 1 | grep Access
>> Access: (0664/-rw-rw-r--)  Uid: ( 1000/   shade)   Gid: ( 1000/   shade)
>
> We have existing code that uses `0666`
> 
> 
> ./share/ci/ciEnv.cpp:    int fd = os::open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
> ./share/ci/ciEnv.cpp:    int fd = os::open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
> ./share/runtime/os.cpp:  int fd = ::open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
> ./share/utilities/vmError.cpp:    fd = open(buf, mode, 0666);
> 
> 
> `0666` is the default mode on Linux (posix?). The actual file mode will be combined with umask.
> 
> (And your umask happens to be `002` so you get `rw-rw-r--` instead of `rw-r--r--` :-) )
> 
> 
> $ umask
> 0002
> $ rm -f foo
> $ strace -f touch foo 2>&1 | grep 'foo.*O_CREAT'
> openat(AT_FDCWD, "foo", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
> $ ls -l foo
> -rw-rw-r-- 1 iklam iklam 0 May  9 08:36 foo
> 
> 
> Also Javac does the same:
> 
> 
> $ rm -f HelloWorld.class
> $ strace -f jdk24/bin/javac HelloWorld.java 2>&1 | grep O_CREAT.*HelloWorld.class
> [pid 3673548] openat(AT_FDCWD, "/tmp/HelloWorld.class", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
> $ ls -l HelloWorld.class
> -rw-rw-r-- 1 iklam iklam 425 May  9 08:37 HelloWorld.class
> 
> and
> 
> $ umask 022
> $ rm -f HelloWorld.class
> $ strace -f /jdk3/official/jdk24/bin/javac HelloWorld.java 2>&1 | grep HelloWorld.class | grep O_CREAT
> [pid 3674853] openat(AT_FDCWD, "/jdk3/tmp/HelloWorld.class", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
> $ ls -l HelloWorld.class
> -rw-r--r-- 1 iklam iklam 425 May  9 08:37 HelloWorld.class

Oh, TIL. Thanks!

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25137#discussion_r2082026482


More information about the hotspot-runtime-dev mailing list