mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 14:28:17 +03:00
nfs: add RPC types for SETATTR
Summary: This merely adds the types for the SETATTR RPC. Reviewed By: kmancini Differential Revision: D26707362 fbshipit-source-id: 89cbf7a501cf4e13878cd84b6c36691d2a08594f
This commit is contained in:
parent
aed51e9e44
commit
ba37453611
@ -980,9 +980,30 @@ std::string formatGetattr(folly::io::Cursor deser) {
|
||||
return fmt::format(FMT_STRING("ino={}"), args.object.ino);
|
||||
}
|
||||
|
||||
std::string formatSetattr(folly::io::Cursor /*deser*/) {
|
||||
// TODO(xavierd): Fill this in.
|
||||
return "";
|
||||
std::string formatSattr3(const sattr3& attr) {
|
||||
auto formatOpt = [](auto&& val, const char* fmtString = "{}") {
|
||||
using T = std::decay_t<decltype(val)>;
|
||||
if (val.tag) {
|
||||
return fmt::format(fmtString, std::get<typename T::TrueVariant>(val.v));
|
||||
}
|
||||
return std::string();
|
||||
};
|
||||
|
||||
// TODO(xavierd): format the times too?
|
||||
return fmt::format(
|
||||
FMT_STRING("mode={}, uid={}, gid={}, size={}"),
|
||||
formatOpt(attr.mode, "{:#o}"),
|
||||
formatOpt(attr.uid),
|
||||
formatOpt(attr.gid),
|
||||
formatOpt(attr.size));
|
||||
}
|
||||
|
||||
std::string formatSetattr(folly::io::Cursor deser) {
|
||||
auto args = XdrTrait<SETATTR3args>::deserialize(deser);
|
||||
return fmt::format(
|
||||
FMT_STRING("ino={}, attr=({})"),
|
||||
args.object.ino,
|
||||
formatSattr3(args.new_attributes));
|
||||
}
|
||||
|
||||
std::string formatLookup(folly::io::Cursor deser) {
|
||||
@ -1044,16 +1065,24 @@ std::string formatCreate(folly::io::Cursor deser) {
|
||||
}
|
||||
};
|
||||
return fmt::format(
|
||||
FMT_STRING("dir={}, name={}, mode={}"),
|
||||
FMT_STRING("dir={}, name={}, mode={}{}"),
|
||||
args.where.dir.ino,
|
||||
args.where.name,
|
||||
formatMode(args.how.tag));
|
||||
formatMode(args.how.tag),
|
||||
args.how.tag != createmode3::EXCLUSIVE
|
||||
? fmt::format(
|
||||
FMT_STRING(" attr=({})"),
|
||||
formatSattr3(std::get<sattr3>(args.how.v)))
|
||||
: "");
|
||||
}
|
||||
|
||||
std::string formatMkdir(folly::io::Cursor deser) {
|
||||
auto args = XdrTrait<MKDIR3args>::deserialize(deser);
|
||||
return fmt::format(
|
||||
FMT_STRING("dir={}, name={}"), args.where.dir.ino, args.where.name);
|
||||
FMT_STRING("dir={}, name={}, attr=({})"),
|
||||
args.where.dir.ino,
|
||||
args.where.name,
|
||||
formatSattr3(args.attributes));
|
||||
}
|
||||
|
||||
std::string formatSymlink(folly::io::Cursor /*deser*/) {
|
||||
|
@ -33,6 +33,9 @@ EDEN_XDR_SERDE_IMPL(sattr3, mode, uid, gid, size, atime, mtime);
|
||||
EDEN_XDR_SERDE_IMPL(diropargs3, dir, name);
|
||||
EDEN_XDR_SERDE_IMPL(GETATTR3args, object);
|
||||
EDEN_XDR_SERDE_IMPL(GETATTR3resok, obj_attributes);
|
||||
EDEN_XDR_SERDE_IMPL(SETATTR3args, object, new_attributes, guard);
|
||||
EDEN_XDR_SERDE_IMPL(SETATTR3resok, obj_wcc);
|
||||
EDEN_XDR_SERDE_IMPL(SETATTR3resfail, obj_wcc);
|
||||
EDEN_XDR_SERDE_IMPL(LOOKUP3args, what);
|
||||
EDEN_XDR_SERDE_IMPL(LOOKUP3resok, object, obj_attributes, dir_attributes);
|
||||
EDEN_XDR_SERDE_IMPL(LOOKUP3resfail, dir_attributes);
|
||||
|
@ -305,6 +305,30 @@ EDEN_XDR_SERDE_DECL(GETATTR3resok, obj_attributes);
|
||||
|
||||
struct GETATTR3res : public detail::Nfsstat3Variant<GETATTR3resok> {};
|
||||
|
||||
// SETATTR Procedure:
|
||||
|
||||
struct sattrguard3 : public XdrOptionalVariant<nfstime3> {};
|
||||
|
||||
struct SETATTR3args {
|
||||
nfs_fh3 object;
|
||||
sattr3 new_attributes;
|
||||
sattrguard3 guard;
|
||||
};
|
||||
EDEN_XDR_SERDE_DECL(SETATTR3args, object, new_attributes, guard);
|
||||
|
||||
struct SETATTR3resok {
|
||||
wcc_data obj_wcc;
|
||||
};
|
||||
EDEN_XDR_SERDE_DECL(SETATTR3resok, obj_wcc);
|
||||
|
||||
struct SETATTR3resfail {
|
||||
wcc_data obj_wcc;
|
||||
};
|
||||
EDEN_XDR_SERDE_DECL(SETATTR3resfail, obj_wcc);
|
||||
|
||||
struct SETATTR3res
|
||||
: public detail::Nfsstat3Variant<SETATTR3resok, SETATTR3resfail> {};
|
||||
|
||||
// LOOKUP Procedure:
|
||||
|
||||
struct LOOKUP3args {
|
||||
|
Loading…
Reference in New Issue
Block a user