2016-05-12 23:43:17 +03:00
|
|
|
/*
|
2017-01-21 09:02:33 +03:00
|
|
|
* Copyright (c) 2016-present, Facebook, Inc.
|
2016-05-12 23:43:17 +03:00
|
|
|
* 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
|
2017-04-14 21:31:48 +03:00
|
|
|
#include "eden/fs/fuse/Dispatcher.h"
|
2016-12-13 04:48:45 +03:00
|
|
|
#include "eden/fs/inodes/InodePtr.h"
|
2016-05-12 23:43:17 +03:00
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace eden {
|
2016-12-02 04:49:42 +03:00
|
|
|
|
|
|
|
class EdenMount;
|
2016-05-12 23:43:17 +03:00
|
|
|
class FileInode;
|
2016-12-08 07:03:50 +03:00
|
|
|
class InodeBase;
|
2016-12-23 02:34:56 +03:00
|
|
|
class InodeMap;
|
2016-12-02 04:49:42 +03:00
|
|
|
class TreeInode;
|
2016-05-12 23:43:17 +03:00
|
|
|
|
|
|
|
/**
|
2016-12-02 04:49:42 +03:00
|
|
|
* A FUSE request dispatcher for eden mount points.
|
2016-05-12 23:43:17 +03:00
|
|
|
*/
|
2018-03-20 03:01:15 +03:00
|
|
|
class EdenDispatcher : public Dispatcher {
|
2016-05-12 23:43:17 +03:00
|
|
|
public:
|
|
|
|
/*
|
2016-12-23 02:34:56 +03:00
|
|
|
* Create an EdenDispatcher.
|
2016-05-12 23:43:17 +03:00
|
|
|
* setRootInode() must be called before using this dispatcher.
|
|
|
|
*/
|
2016-12-02 04:49:42 +03:00
|
|
|
explicit EdenDispatcher(EdenMount* mount);
|
2016-05-12 23:43:17 +03:00
|
|
|
|
2018-03-20 03:01:15 +03:00
|
|
|
folly::Future<Attr> getattr(InodeNumber ino) override;
|
|
|
|
folly::Future<Attr> setattr(InodeNumber ino, const fuse_setattr_in& attr)
|
|
|
|
override;
|
|
|
|
folly::Future<std::shared_ptr<DirHandle>> opendir(InodeNumber ino, int flags)
|
|
|
|
override;
|
2018-01-03 03:25:03 +03:00
|
|
|
folly::Future<fuse_entry_out> lookup(
|
2018-03-20 03:01:15 +03:00
|
|
|
InodeNumber parent,
|
2016-05-12 23:43:17 +03:00
|
|
|
PathComponentPiece name) override;
|
2016-05-26 19:49:10 +03:00
|
|
|
|
2018-04-27 06:41:40 +03:00
|
|
|
void forget(InodeNumber ino, unsigned long nlookup) override;
|
2018-03-20 03:01:15 +03:00
|
|
|
folly::Future<std::shared_ptr<FileHandle>> open(InodeNumber ino, int flags)
|
|
|
|
override;
|
|
|
|
folly::Future<std::string> readlink(InodeNumber ino) override;
|
2018-01-03 03:25:03 +03:00
|
|
|
folly::Future<fuse_entry_out> mknod(
|
2018-03-20 03:01:15 +03:00
|
|
|
InodeNumber parent,
|
2016-05-12 23:43:17 +03:00
|
|
|
PathComponentPiece name,
|
|
|
|
mode_t mode,
|
|
|
|
dev_t rdev) override;
|
2018-03-20 03:01:15 +03:00
|
|
|
folly::Future<fuse_entry_out>
|
|
|
|
mkdir(InodeNumber parent, PathComponentPiece name, mode_t mode) override;
|
|
|
|
folly::Future<folly::Unit> unlink(InodeNumber parent, PathComponentPiece name)
|
|
|
|
override;
|
|
|
|
folly::Future<folly::Unit> rmdir(InodeNumber parent, PathComponentPiece name)
|
|
|
|
override;
|
2018-01-03 03:25:03 +03:00
|
|
|
folly::Future<fuse_entry_out> symlink(
|
2018-03-20 03:01:15 +03:00
|
|
|
InodeNumber parent,
|
2016-12-15 02:35:06 +03:00
|
|
|
PathComponentPiece name,
|
|
|
|
folly::StringPiece link) override;
|
2016-05-12 23:43:17 +03:00
|
|
|
folly::Future<folly::Unit> rename(
|
2018-03-20 03:01:15 +03:00
|
|
|
InodeNumber parent,
|
2016-05-12 23:43:17 +03:00
|
|
|
PathComponentPiece name,
|
2018-03-20 03:01:15 +03:00
|
|
|
InodeNumber newparent,
|
2016-05-12 23:43:17 +03:00
|
|
|
PathComponentPiece newname) override;
|
|
|
|
|
2018-01-03 03:25:03 +03:00
|
|
|
folly::Future<fuse_entry_out> link(
|
2018-03-20 03:01:15 +03:00
|
|
|
InodeNumber ino,
|
|
|
|
InodeNumber newparent,
|
2016-05-12 23:43:17 +03:00
|
|
|
PathComponentPiece newname) override;
|
|
|
|
|
|
|
|
folly::Future<Dispatcher::Create> create(
|
2018-03-20 03:01:15 +03:00
|
|
|
InodeNumber parent,
|
2016-05-12 23:43:17 +03:00
|
|
|
PathComponentPiece name,
|
|
|
|
mode_t mode,
|
|
|
|
int flags) override;
|
2018-03-20 03:01:15 +03:00
|
|
|
folly::Future<std::string> getxattr(InodeNumber ino, folly::StringPiece name)
|
|
|
|
override;
|
|
|
|
folly::Future<std::vector<std::string>> listxattr(InodeNumber ino) override;
|
2016-12-23 02:34:56 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
// The EdenMount that owns this EdenDispatcher.
|
|
|
|
EdenMount* const mount_;
|
|
|
|
// The EdenMount's InodeMap.
|
|
|
|
// We store this pointer purely for convenience. We need it on pretty much
|
|
|
|
// every FUSE request, and having it locally avoids having to dereference
|
|
|
|
// mount_ first.
|
|
|
|
InodeMap* const inodeMap_;
|
2016-05-12 23:43:17 +03:00
|
|
|
};
|
2017-11-04 01:58:04 +03:00
|
|
|
} // namespace eden
|
|
|
|
} // namespace facebook
|