Commit 7d670d7e authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan
Browse files

vfs: expose files creation (birth) time

Motivation:
the new developments on the client side start to proper
handle files creation time, thus this is a good time for
nfs4j to support it as well.

Modification:
Introduce Stat#set/getBTime. Update NFS code to use btime if provided.

Result:
first steps to support of file creation time.

Acked-by: Paul Millar
Target: master
parent 1e0a4bd6
Pipeline #19000 passed with stage
in 1 minute and 50 seconds
/*
* Copyright (c) 2009 - 2020 Deutsches Elektronen-Synchroton,
* Copyright (c) 2009 - 2022 Deutsches Elektronen-Synchroton,
* Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY
*
* This library is free software; you can redistribute it and/or modify
......@@ -87,6 +87,7 @@ import org.dcache.nfs.v4.xdr.layouttype4;
import org.dcache.nfs.v4.xdr.GETATTR4resok;
import org.dcache.nfs.v4.xdr.GETATTR4res;
import org.dcache.nfs.vfs.Stat.StatAttribute;
import org.dcache.oncrpc4j.xdr.XdrAble;
import org.dcache.oncrpc4j.xdr.Xdr;
import org.dcache.nfs.status.InvalException;
......@@ -333,8 +334,9 @@ public class OperationGETATTR extends AbstractNFSv4Operation {
case nfs4_prot.FATTR4_TIME_BACKUP:
return Optional.empty();
case nfs4_prot.FATTR4_TIME_CREATE:
fattr4_time_create ctime = new fattr4_time_create(stat.getCTime());
return Optional.of(ctime);
long btimeMillis = stat.isDefined(StatAttribute.BTIME) ? stat.getBTime() : stat.getCTime();
fattr4_time_create btime = new fattr4_time_create(btimeMillis);
return Optional.of(btime);
case nfs4_prot.FATTR4_TIME_DELTA:
// one (1) second is a common value for time delta across nfs4 servers
return Optional.of(new fattr4_time_delta( new nfstime4(TimeUnit.SECONDS.toMillis(1))));
......
/*
* Copyright (c) 2009 - 2018 Deutsches Elektronen-Synchroton,
* Copyright (c) 2009 - 2022 Deutsches Elektronen-Synchroton,
* Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY
*
* This library is free software; you can redistribute it and/or modify
......@@ -42,7 +42,8 @@ public class Stat implements Serializable, Cloneable {
GENERATION,
ATIME,
MTIME,
CTIME
CTIME,
BTIME
};
private static final long serialVersionUID = 1L;
......@@ -155,6 +156,7 @@ public class Stat implements Serializable, Cloneable {
private long _atime;
private long _mtime;
private long _ctime;
private long _btime;
public int getDev() {
guard(StatAttribute.DEV);
......@@ -266,6 +268,16 @@ public class Stat implements Serializable, Cloneable {
_ctime = ctime;
}
public long getBTime() {
guard(StatAttribute.BTIME);
return _btime;
}
public void setBTime(long btime) {
define(StatAttribute.BTIME);
_ctime = btime;
}
public long getFileId() {
guard(StatAttribute.FILEID);
return _fileid;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment