diff --git a/src/add-ons/kernel/file_systems/nfs4/Inode.cpp b/src/add-ons/kernel/file_systems/nfs4/Inode.cpp index 71ec69a34d..6e6d77373d 100644 --- a/src/add-ons/kernel/file_systems/nfs4/Inode.cpp +++ b/src/add-ons/kernel/file_systems/nfs4/Inode.cpp @@ -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; diff --git a/src/add-ons/kernel/file_systems/nfs4/ReplyInterpreter.cpp b/src/add-ons/kernel/file_systems/nfs4/ReplyInterpreter.cpp index 5782247493..d38f6d542f 100644 --- a/src/add-ons/kernel/file_systems/nfs4/ReplyInterpreter.cpp +++ b/src/add-ons/kernel/file_systems/nfs4/ReplyInterpreter.cpp @@ -14,6 +14,20 @@ #include +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(stream.GetHyper()); + ts.tv_nsec = static_cast(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(stream.GetHyper()); + ts.tv_nsec = static_cast(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(stream.GetHyper()); + ts.tv_nsec = static_cast(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(stream.GetHyper()); + ts.tv_nsec = static_cast(stream.GetUInt()); + + values[current].fData.fPointer = malloc(sizeof(ts)); + memcpy(values[current].fData.fPointer, &ts, sizeof(ts)); + current++; + } + delete[] bitmap; *count = attr_count; diff --git a/src/add-ons/kernel/file_systems/nfs4/ReplyInterpreter.h b/src/add-ons/kernel/file_systems/nfs4/ReplyInterpreter.h index e0c56f6297..1531fe73e2 100644 --- a/src/add-ons/kernel/file_systems/nfs4/ReplyInterpreter.h +++ b/src/add-ons/kernel/file_systems/nfs4/ReplyInterpreter.h @@ -16,7 +16,11 @@ struct AttrValue { + AttrValue(); + ~AttrValue(); + uint8 fAttribute; + bool fFreePointer; union { uint32 fValue32; uint64 fValue64;