mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +03:00
94a46d9c0e
Summary: Taking a fuse_setattr_in arg means that it can only be used on FUSE, and while FUSE has been the only backend on UNIX for a while, this is changing with NFS being added. Thus, we need to find a solution that isn't tied to FUSE. The solution is fairly simple, let's simply have a struct with optional fields that needs changing, FUSE and NFS will set these to what needs changing. Reviewed By: chadaustin Differential Revision: D26742213 fbshipit-source-id: 16e3e8cdd22d88ace43485d9e3744280de1ee8ad
46 lines
959 B
C++
46 lines
959 B
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#ifndef _WIN32
|
|
|
|
#include "eden/fs/inodes/InodeMetadata.h"
|
|
#include "eden/fs/fuse/FuseTypes.h"
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
|
|
void InodeMetadata::updateFromDesired(
|
|
const Clock& clock,
|
|
const DesiredMetadata& attr) {
|
|
if (attr.mode.has_value()) {
|
|
// Make sure we preserve the file type bits, and only update
|
|
// permissions.
|
|
mode = (mode & S_IFMT) | (07777 & attr.mode.value());
|
|
}
|
|
|
|
if (attr.uid.has_value()) {
|
|
uid = attr.uid.value();
|
|
}
|
|
if (attr.gid.has_value()) {
|
|
gid = attr.gid.value();
|
|
}
|
|
|
|
timestamps.setattrTimes(clock, attr);
|
|
}
|
|
|
|
void InodeMetadata::applyToStat(struct stat& st) const {
|
|
st.st_mode = mode;
|
|
st.st_uid = uid;
|
|
st.st_gid = gid;
|
|
timestamps.applyToStat(st);
|
|
}
|
|
|
|
} // namespace eden
|
|
} // namespace facebook
|
|
|
|
#endif
|