sapling/eden/fs/inodes/InodeMetadata.h
Chad Austin 951eb290b1 allow changing permissions on directories
Summary:
Unify how inode metadata is modified across inode types.  This allows
changing the permission bits on a directory.

Reviewed By: simpkins

Differential Revision: D7767254

fbshipit-source-id: 35e9cf652c84c7d8680cc22dec7942e94e9f5af1
2018-05-22 11:22:19 -07:00

58 lines
1.5 KiB
C++

/*
* Copyright (c) 2018-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include <sys/stat.h>
#include "eden/fs/inodes/InodeTimestamps.h"
struct fuse_setattr_in;
struct stat;
namespace facebook {
namespace eden {
/**
* 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 updateFromAttr(const Clock& clock, const fuse_setattr_in& attr);
void applyToStat(struct stat& st) const;
// Other potential things to include:
// nlink_t nlinks;
// dev_t rdev;
// creation time
};
} // namespace eden
} // namespace facebook