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
72 lines
1.7 KiB
C++
72 lines
1.7 KiB
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.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <sys/stat.h>
|
|
#include <optional>
|
|
#include "eden/fs/inodes/InodeTimestamps.h"
|
|
|
|
struct stat;
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
|
|
/**
|
|
* Set of metadata to update during an InodeBase::setattr call.
|
|
*
|
|
* Any non-optional field will be reflected into the corresponding
|
|
* InodeMetadata object.
|
|
*/
|
|
struct DesiredMetadata {
|
|
std::optional<size_t> size;
|
|
std::optional<mode_t> mode;
|
|
std::optional<uid_t> uid;
|
|
std::optional<gid_t> gid;
|
|
std::optional<timespec> atime;
|
|
std::optional<timespec> mtime;
|
|
};
|
|
|
|
/**
|
|
* Fixed-size structure of per-inode bits that should be persisted across runs.
|
|
*
|
|
* Warning: This data structure is serialized directly to disk via InodeTable.
|
|
* Do not change the order, sizes, or meanings of the fields. Instead, rename
|
|
* this struct, create a new InodeMetadata struct with the next VERSION value,
|
|
* add an explicit constructor from the old version, and add the old version to
|
|
* the InodeMetadataTable typedef in InodeTable.h.
|
|
*/
|
|
struct InodeMetadata {
|
|
enum { VERSION = 0 };
|
|
|
|
InodeMetadata() = default;
|
|
|
|
explicit InodeMetadata(
|
|
mode_t m,
|
|
uid_t u,
|
|
gid_t g,
|
|
const InodeTimestamps& ts) noexcept
|
|
: mode{m}, uid{u}, gid{g}, timestamps{ts} {}
|
|
|
|
mode_t mode{0};
|
|
uid_t uid{0};
|
|
gid_t gid{0};
|
|
InodeTimestamps timestamps;
|
|
|
|
void updateFromDesired(const Clock& clock, const DesiredMetadata& attr);
|
|
|
|
void applyToStat(struct stat& st) const;
|
|
|
|
// Other potential things to include:
|
|
// nlink_t nlinks;
|
|
// dev_t rdev;
|
|
// creation time
|
|
};
|
|
|
|
} // namespace eden
|
|
} // namespace facebook
|