Skip to content

Commit

Permalink
ftp: add read-only support for ctime and atime
Browse files Browse the repository at this point in the history
This patch adds support for the UNIX.ctime and UNIX.atime facts,
which allows clients to know a file's ctime and atime respectively.

Target: master
Patch: http://rb.dcache.org/r/6794/
Acked-by: Gerd Behrmann
  • Loading branch information
paulmillar committed Mar 25, 2014
1 parent 5d6ae37 commit 86f3486
Showing 1 changed file with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,10 @@ protected enum Fact
PERM("Perm"),
OWNER("UNIX.owner"),
GROUP("UNIX.group"),
MODE("UNIX.mode");
MODE("UNIX.mode"),
// See http://www.iana.org/assignments/os-specific-parameters
CHANGE("UNIX.ctime"),
ACCESS("UNIX.atime");

private final String _name;

Expand Down Expand Up @@ -4154,6 +4157,14 @@ public Set<FileAttribute> getRequiredAttributes()
attributes.add(MODIFICATION_TIME);
attributes.addAll(_pdp.getRequiredAttributes());
break;
case CHANGE:
attributes.add(CHANGE_TIME);
attributes.addAll(_pdp.getRequiredAttributes());
break;
case ACCESS:
attributes.add(ACCESS_TIME);
attributes.addAll(_pdp.getRequiredAttributes());
break;
case TYPE:
attributes.add(SIMPLE_TYPE);
attributes.addAll(_pdp.getRequiredAttributes());
Expand Down Expand Up @@ -4217,6 +4228,22 @@ public void print(FsPath dir, FileAttributes dirAttr, DirectoryEntry entry)
printModifyFact(attr);
}
break;
case CHANGE:
access =
_pdp.canGetAttributes(_subject, dirAttr, attr,
EnumSet.of(CHANGE_TIME));
if (access == AccessType.ACCESS_ALLOWED) {
printChangeFact(attr);
}
break;
case ACCESS:
access =
_pdp.canGetAttributes(_subject, dirAttr, attr,
EnumSet.of(ACCESS_TIME));
if (access == AccessType.ACCESS_ALLOWED) {
printAccessFact(attr);
}
break;
case TYPE:
access =
_pdp.canGetAttributes(_subject, dirAttr, attr,
Expand Down Expand Up @@ -4291,6 +4318,20 @@ private void printModifyFact(FileAttributes attr)
printFact(Fact.MODIFY, TIMESTAMP_FORMAT.format(new Date(time)));
}

/** Writes UNIX.ctime fact to a writer. */
private void printChangeFact(FileAttributes attr)
{
long time = attr.getChangeTime();
printFact(Fact.CHANGE, TIMESTAMP_FORMAT.format(new Date(time)));
}

/** Writes UNIX.atime fact to a writer. */
private void printAccessFact(FileAttributes attr)
{
long time = attr.getAccessTime();
printFact(Fact.ACCESS, TIMESTAMP_FORMAT.format(new Date(time)));
}

/** Writes a RFC 3659 size fact to a writer. */
private void printSizeFact(FileAttributes attr)
{
Expand Down

0 comments on commit 86f3486

Please sign in to comment.