On Thu, 17 Aug 2023 19:50:56 GMT, Roger Riggs <rri...@openjdk.org> wrote:

>> Hi Roger,  sounds like a good idea  to translate it to a more informative 
>> string.
>> Do you have an  utility function in mind that does this ?
>
> Not trivial in java, there are platform specific native functions to get the 
> string for the current errno.
> The function definition for `getLastErrorString` is in jni_uti.h, returning a 
> java String.
> 
> If there are only a couple of errno's that occur for these cases, it might be 
> easier to hardwire the translation.
> Otherwise, an appropriate native method call and implementation could be 
> added to FileSystemPreferences.c for both unix and windows.

Hi Roger , seems we can get errno numbers at least from open and fcntl , see
Java_java_util_prefs_FileSystemPreferences_lockFile0
https://github.com/openjdk/jdk/blob/master/src/java.prefs/unix/native/libprefs/FileSystemPreferences.c#L70

Those functions have quite a few potential errnos, from the Linux manpages at 
least those
https://man7.org/linux/man-pages/man2/open.2.html
https://man7.org/linux/man-pages/man2/fcntl.2.html
EACCES 
EAGAIN 
EBADF  
EBUSY
EDEADLK
EDQUOT
EEXIST 
EFAULT 
EFBIG  See EOVERFLOW.
EINTR  
EINVAL 
EISDIR 
ELOOP  
EMFILE 
ENAMETOOLONG
ENFILE 
ENODEV 
ENOENT 
ENOLCK 
ENOMEM
ENOSPC 
ENOTDIR
ENXIO  
EOPNOTSUPP
EOVERFLOW
EPERM  
EROFS  
ETXTBSY
EWOULDBLOCK

I noticed src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template 
contains some of them, should I add the missing ones there and reference from 
there ?

Btw. when looking at Java_java_util_prefs_FileSystemPreferences_lockFile0  
should we better initialize
`int result[2]`
https://github.com/openjdk/jdk/blob/master/src/java.prefs/unix/native/libprefs/FileSystemPreferences.c#L74
There seems to be a codepath where  result[1] is never written but at the end 
used to fill javeResult
https://github.com/openjdk/jdk/blob/master/src/java.prefs/unix/native/libprefs/FileSystemPreferences.c#L117

 this looks a bit problematic ?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15308#discussion_r1298136160

Reply via email to