Skip to content

Commit

Permalink
vfs: expose files creation (birth) time
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kofemann committed Jan 12, 2022
1 parent 1e0a4bd commit 7d670d7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
8 changes: 5 additions & 3 deletions core/src/main/java/org/dcache/nfs/v4/OperationGETATTR.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* 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
Expand Down Expand Up @@ -87,6 +87,7 @@
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;
Expand Down Expand Up @@ -333,8 +334,9 @@ static Optional<? extends XdrAble> fattr2xdr(int fattr, VirtualFileSystem fs, In
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))));
Expand Down
16 changes: 14 additions & 2 deletions core/src/main/java/org/dcache/nfs/vfs/Stat.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* 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
Expand Down Expand Up @@ -42,7 +42,8 @@ public enum StatAttribute {
GENERATION,
ATIME,
MTIME,
CTIME
CTIME,
BTIME
};

private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -155,6 +156,7 @@ public static Type fromMode(int mode) {
private long _atime;
private long _mtime;
private long _ctime;
private long _btime;

public int getDev() {
guard(StatAttribute.DEV);
Expand Down Expand Up @@ -266,6 +268,16 @@ public void setCTime(long ctime) {
_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;
Expand Down

0 comments on commit 7d670d7

Please sign in to comment.