nfs4: Let stat() retrieve access, change, etc dates
This commit is contained in:
@@ -206,7 +206,9 @@ Inode::Stat(struct stat* st)
|
|||||||
|
|
||||||
req.PutFH(fHandle);
|
req.PutFH(fHandle);
|
||||||
|
|
||||||
Attribute attr[] = { FATTR4_SIZE, FATTR4_MODE, FATTR4_NUMLINKS };
|
Attribute attr[] = { FATTR4_SIZE, FATTR4_MODE, FATTR4_NUMLINKS,
|
||||||
|
FATTR4_TIME_ACCESS, FATTR4_TIME_CREATE,
|
||||||
|
FATTR4_TIME_METADATA, FATTR4_TIME_MODIFY };
|
||||||
req.GetAttr(attr, sizeof(attr) / sizeof(Attribute));
|
req.GetAttr(attr, sizeof(attr) / sizeof(Attribute));
|
||||||
|
|
||||||
status_t result = request.Send();
|
status_t result = request.Send();
|
||||||
@@ -272,6 +274,30 @@ Inode::Stat(struct stat* st)
|
|||||||
} else
|
} else
|
||||||
st->st_nlink = 1;
|
st->st_nlink = 1;
|
||||||
|
|
||||||
|
if (count >= next && values[next].fAttribute == FATTR4_TIME_ACCESS) {
|
||||||
|
memcpy(&st->st_atim, values[next].fData.fPointer, sizeof(timespec));
|
||||||
|
next++;
|
||||||
|
} else
|
||||||
|
memset(&st->st_atim, 0, sizeof(timespec));
|
||||||
|
|
||||||
|
if (count >= next && values[next].fAttribute == FATTR4_TIME_CREATE) {
|
||||||
|
memcpy(&st->st_crtim, values[next].fData.fPointer, sizeof(timespec));
|
||||||
|
next++;
|
||||||
|
} else
|
||||||
|
memset(&st->st_crtim, 0, sizeof(timespec));
|
||||||
|
|
||||||
|
if (count >= next && values[next].fAttribute == FATTR4_TIME_METADATA) {
|
||||||
|
memcpy(&st->st_ctim, values[next].fData.fPointer, sizeof(timespec));
|
||||||
|
next++;
|
||||||
|
} else
|
||||||
|
memset(&st->st_ctim, 0, sizeof(timespec));
|
||||||
|
|
||||||
|
if (count >= next && values[next].fAttribute == FATTR4_TIME_MODIFY) {
|
||||||
|
memcpy(&st->st_mtim, values[next].fData.fPointer, sizeof(timespec));
|
||||||
|
next++;
|
||||||
|
} else
|
||||||
|
memset(&st->st_mtim, 0, sizeof(timespec));
|
||||||
|
|
||||||
st->st_uid = 0;
|
st->st_uid = 0;
|
||||||
st->st_gid = 0;
|
st->st_gid = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,20 @@
|
|||||||
#include <util/kernel_cpp.h>
|
#include <util/kernel_cpp.h>
|
||||||
|
|
||||||
|
|
||||||
|
AttrValue::AttrValue()
|
||||||
|
:
|
||||||
|
fFreePointer(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AttrValue::~AttrValue()
|
||||||
|
{
|
||||||
|
if (fFreePointer)
|
||||||
|
free(fData.fPointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DirEntry::DirEntry()
|
DirEntry::DirEntry()
|
||||||
:
|
:
|
||||||
fName(NULL),
|
fName(NULL),
|
||||||
@@ -327,6 +341,58 @@ ReplyInterpreter::_DecodeAttrs(XDR::ReadStream& str, AttrValue** attrs,
|
|||||||
current++;
|
current++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sIsAttrSet(FATTR4_TIME_ACCESS, bitmap, bcount)) {
|
||||||
|
values[current].fAttribute = FATTR4_TIME_ACCESS;
|
||||||
|
values[current].fFreePointer = true;
|
||||||
|
|
||||||
|
struct timespec ts;
|
||||||
|
ts.tv_sec = static_cast<time_t>(stream.GetHyper());
|
||||||
|
ts.tv_nsec = static_cast<long>(stream.GetUInt());
|
||||||
|
|
||||||
|
values[current].fData.fPointer = malloc(sizeof(ts));
|
||||||
|
memcpy(values[current].fData.fPointer, &ts, sizeof(ts));
|
||||||
|
current++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sIsAttrSet(FATTR4_TIME_CREATE, bitmap, bcount)) {
|
||||||
|
values[current].fAttribute = FATTR4_TIME_CREATE;
|
||||||
|
values[current].fFreePointer = true;
|
||||||
|
|
||||||
|
struct timespec ts;
|
||||||
|
ts.tv_sec = static_cast<time_t>(stream.GetHyper());
|
||||||
|
ts.tv_nsec = static_cast<long>(stream.GetUInt());
|
||||||
|
|
||||||
|
values[current].fData.fPointer = malloc(sizeof(ts));
|
||||||
|
memcpy(values[current].fData.fPointer, &ts, sizeof(ts));
|
||||||
|
current++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sIsAttrSet(FATTR4_TIME_METADATA, bitmap, bcount)) {
|
||||||
|
values[current].fAttribute = FATTR4_TIME_METADATA;
|
||||||
|
values[current].fFreePointer = true;
|
||||||
|
|
||||||
|
struct timespec ts;
|
||||||
|
ts.tv_sec = static_cast<time_t>(stream.GetHyper());
|
||||||
|
ts.tv_nsec = static_cast<long>(stream.GetUInt());
|
||||||
|
|
||||||
|
values[current].fData.fPointer = malloc(sizeof(ts));
|
||||||
|
memcpy(values[current].fData.fPointer, &ts, sizeof(ts));
|
||||||
|
current++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sIsAttrSet(FATTR4_TIME_MODIFY, bitmap, bcount)) {
|
||||||
|
values[current].fAttribute = FATTR4_TIME_MODIFY;
|
||||||
|
values[current].fFreePointer = true;
|
||||||
|
|
||||||
|
struct timespec ts;
|
||||||
|
ts.tv_sec = static_cast<time_t>(stream.GetHyper());
|
||||||
|
ts.tv_nsec = static_cast<long>(stream.GetUInt());
|
||||||
|
|
||||||
|
values[current].fData.fPointer = malloc(sizeof(ts));
|
||||||
|
memcpy(values[current].fData.fPointer, &ts, sizeof(ts));
|
||||||
|
current++;
|
||||||
|
}
|
||||||
|
|
||||||
delete[] bitmap;
|
delete[] bitmap;
|
||||||
|
|
||||||
*count = attr_count;
|
*count = attr_count;
|
||||||
|
|||||||
@@ -16,7 +16,11 @@
|
|||||||
|
|
||||||
|
|
||||||
struct AttrValue {
|
struct AttrValue {
|
||||||
|
AttrValue();
|
||||||
|
~AttrValue();
|
||||||
|
|
||||||
uint8 fAttribute;
|
uint8 fAttribute;
|
||||||
|
bool fFreePointer;
|
||||||
union {
|
union {
|
||||||
uint32 fValue32;
|
uint32 fValue32;
|
||||||
uint64 fValue64;
|
uint64 fValue64;
|
||||||
|
|||||||
Reference in New Issue
Block a user