[patch][freebsd] correct offsets of STAT structure fields due to ino64 changes

FreeBSD CI team has reported that CI can’t fetch SVN repository if Jenkins is installed on FreeBSD 12.0 (quite fresh release). The error message is ‘svn: E155004: Lock file ‘/usr/home/mizhka/.jenkins/workspace/test/.svn/lock’ is not a regular file’ but actually it’s file. The root cause is that SVNKit treated it as directory due to incorrect offset of MODE field in STAT structure.

This patch fixes SVNKit functionality on FreeBSD version 12 and later. The part of release 12.0 was change of inode size to 64 bits and adjustment of “struct stat”. More details can be found in SVN commit:
https://svnweb.freebsd.org/base?view=revision&revision=318736

Patch is tested on FreeBSD 13-CURRENT. Patch is based on git mirror and against 1.9.3 (version used by Jenkins) and HEAD.
Both versions has been tested by simple test:

package pkg;

import org.tmatesoft.svn.core.internal.util.jna.*;
import java.io.File;

public class Test {
public static void main(String[] args) {
String path="/home/mizhka/.jenkins/workspace/test/.svn/lock";
System.out.println(SVNLinuxUtil.getFileType(new File(path)));
}
}

Thanks!

FreeBSD 12.1 Happen and it is not working anymore.

Hello,
thanks for letting us know. We have limited ability to test on freebsd. Could you elaborate: what happened in 12.1? Was the binary format changed? Or is it about parsing version number string? It would be we awesome if you could propose a fix or an idea of the fix…

At the moment SVNKit does the following: “static” initializer of SVNFileUtil class it parses BSD version and sets isIno64 variable:

{code}
if (isBSD && “freebsd”.equals(osNameLC)) {
final SVNVersion version12 = SVNVersion.parse(“12.0-CURRENT”);
final SVNVersion version = SVNVersion.parse(System.getProperty(“os.version”));
isIno64 = (version != null) && (version12 != null) &&
(version12.compareNumericParts(version) <= 0);
} else {
isIno64 = false;
}
{code}

Later in SVNLinuxUtil it uses the variable to calculate offsets in the returned data of various JNA calls.

If the binary format has changed we could calculate offsets in a different manner in FreeBSD>=12.1; if it’s about string parsing (e.g. 12.1 version string is not parsed correctly), we could fix version parsing code. Any information would help!

Sorry, I’m a bit confused, the patch attached contains the fix that is already present (in a different form) in the latest SVNKit version. On the other hand you write that it doesn’t work anymore… Is it your patch that doesn’t work anymore or is it SVNKit fix (have a look at it) that doesn’t work in 12.1 but works in 12.0?

Hi Dmitry, thanks for looking into this. I am still tracking what is happening but results are almost identical as before patch. It is difficult to replicate as some projects work fine. Some just lose files on updates( mean svn checkout goes correctly but does not get updated files - and give no error), other time I am getting E155004. It is just like before patch or patch is not working with FreeBSD 12.1. The first thought is freebsd12.0 vs 12.1 string is not being parsed correctly.

Thanks for the information. Unfortunately, so far, it’s not enough to fix the problem.
May I ask you at which level you’re using SVNKit (as a library in your code / as command line utility / as a part of 3rd party product)? Do you have a an ability to create, compile, and test a minimal Java program with SVNKit? If yes we could test a program that parses FreeBSD version string and check it and also a minimal program that gets file attributes using JNA and see whether the correct offsets are used.