Skip to content

Commit

Permalink
revert "use stat -c linux command line to determise support create ti…
Browse files Browse the repository at this point in the history
…me or not", and set nfs not suoport create time
  • Loading branch information
sendaoYan committed Aug 26, 2024
1 parent 1614f8e commit 5ed7b8c
Showing 1 changed file with 4 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ static void test(Path top) throws IOException {
}
} else if (Platform.isLinux()) {
// Creation time read depends on statx system call support and on the file
// system storing the birth time. The tmpfs/ext3/nfs etc. file system type does not store
// system storing the birth time. The tmpfs/nfs etc. file system type does not store
// the birth time.
boolean statxIsPresent = Linker.nativeLinker().defaultLookup().find("statx").isPresent();
if (statxIsPresent && supportBirthTimeOnLinux(file)) {
if (statxIsPresent &&
!Files.getFileStore(file).type().contentEquals("tmpfs") &&
!Files.getFileStore(file).type().contains("nfs")) {
supportsCreationTimeRead = true;
}
// Creation time updates are not supported on Linux
Expand Down Expand Up @@ -148,25 +150,6 @@ static void test(Path top) throws IOException {
}
}


/**
* read the output of linux command `stat -c "%w" file`, if the output is "-",
* then the file system doesn't support birth time
*/
public static boolean supportBirthTimeOnLinux(Path file) {
try {
String filePath = file.toAbsolutePath().toString();
ProcessBuilder pb = new ProcessBuilder("stat", "-c", "%w", filePath);
pb.redirectErrorStream(true);
Process p = pb.start();
BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream()));
String l = b.readLine();
if (l != null && l.equals("-")) { return false; }
} catch(Exception e) {
}
return true;
}

public static void main(String[] args) throws IOException {
// create temporary directory to run tests
Path dir;
Expand Down

0 comments on commit 5ed7b8c

Please sign in to comment.