nfs4: Let stat() retrieve access, change, etc dates
This commit is contained in:
parent
0792abe006
commit
96e3dbc2d0
@ -206,7 +206,9 @@ Inode::Stat(struct stat* st)
|
||||
|
||||
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));
|
||||
|
||||
status_t result = request.Send();
|
||||
@ -272,6 +274,30 @@ Inode::Stat(struct stat* st)
|
||||
} else
|
||||
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_gid = 0;
|
||||
|
||||
|
@ -14,6 +14,20 @@
|
||||
#include <util/kernel_cpp.h>
|
||||
|
||||
|
||||
AttrValue::AttrValue()
|
||||
:
|
||||
fFreePointer(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AttrValue::~AttrValue()
|
||||
{
|
||||
if (fFreePointer)
|
||||
free(fData.fPointer);
|
||||
}
|
||||
|
||||
|
||||
DirEntry::DirEntry()
|
||||
:
|
||||
fName(NULL),
|
||||
@ -327,6 +341,58 @@ ReplyInterpreter::_DecodeAttrs(XDR::ReadStream& str, AttrValue** attrs,
|
||||
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;
|
||||
|
||||
*count = attr_count;
|
||||
|
@ -16,7 +16,11 @@
|
||||
|
||||
|
||||
struct AttrValue {
|
||||
AttrValue();
|
||||
~AttrValue();
|
||||
|
||||
uint8 fAttribute;
|
||||
bool fFreePointer;
|
||||
union {
|
||||
uint32 fValue32;
|
||||
uint64 fValue64;
|
||||
|
Loading…
Reference in New Issue
Block a user