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
|
|
|
*/
|
2016-12-02 04:49:42 +03:00
|
|
|
class EdenDispatcher : public fusell::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);
|
2017-09-09 05:15:18 +03:00
|
|
|
void initConnection(fuse_conn_info& conn) override;
|
2016-05-12 23:43:17 +03:00
|
|
|
|
|
|
|
folly::Future<Attr> getattr(fuse_ino_t ino) override;
|
|
|
|
folly::Future<Attr> setattr(fuse_ino_t ino,
|
|
|
|
const struct stat& attr,
|
|
|
|
int to_set) override;
|
2016-12-02 04:49:42 +03:00
|
|
|
folly::Future<std::shared_ptr<fusell::DirHandle>> opendir(
|
2016-05-18 04:16:07 +03:00
|
|
|
fuse_ino_t ino,
|
|
|
|
const struct fuse_file_info& fi) override;
|
2016-05-12 23:43:17 +03:00
|
|
|
folly::Future<fuse_entry_param> lookup(
|
|
|
|
fuse_ino_t parent,
|
|
|
|
PathComponentPiece name) override;
|
2016-05-26 19:49:10 +03:00
|
|
|
|
2016-05-12 23:43:17 +03:00
|
|
|
folly::Future<folly::Unit> forget(fuse_ino_t ino,
|
|
|
|
unsigned long nlookup) override;
|
2016-12-02 04:49:42 +03:00
|
|
|
folly::Future<std::shared_ptr<fusell::FileHandle>> open(
|
2016-05-18 04:16:07 +03:00
|
|
|
fuse_ino_t ino,
|
|
|
|
const struct fuse_file_info& fi) override;
|
2016-05-12 23:43:17 +03:00
|
|
|
folly::Future<std::string> readlink(fuse_ino_t ino) override;
|
|
|
|
folly::Future<fuse_entry_param> mknod(
|
|
|
|
fuse_ino_t parent,
|
|
|
|
PathComponentPiece name,
|
|
|
|
mode_t mode,
|
|
|
|
dev_t rdev) override;
|
|
|
|
folly::Future<fuse_entry_param>
|
|
|
|
mkdir(fuse_ino_t parent, PathComponentPiece name, mode_t mode) override;
|
|
|
|
folly::Future<folly::Unit> unlink(fuse_ino_t parent, PathComponentPiece name)
|
|
|
|
override;
|
|
|
|
folly::Future<folly::Unit> rmdir(fuse_ino_t parent, PathComponentPiece name)
|
|
|
|
override;
|
|
|
|
folly::Future<fuse_entry_param> symlink(
|
|
|
|
fuse_ino_t 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(
|
|
|
|
fuse_ino_t parent,
|
|
|
|
PathComponentPiece name,
|
|
|
|
fuse_ino_t newparent,
|
|
|
|
PathComponentPiece newname) override;
|
|
|
|
|
|
|
|
folly::Future<fuse_entry_param> link(
|
|
|
|
fuse_ino_t ino,
|
|
|
|
fuse_ino_t newparent,
|
|
|
|
PathComponentPiece newname) override;
|
|
|
|
|
|
|
|
folly::Future<Dispatcher::Create> create(
|
|
|
|
fuse_ino_t parent,
|
|
|
|
PathComponentPiece name,
|
|
|
|
mode_t mode,
|
|
|
|
int flags) override;
|
|
|
|
folly::Future<std::string> getxattr(fuse_ino_t ino, folly::StringPiece name)
|
|
|
|
override;
|
|
|
|
folly::Future<std::vector<std::string>> listxattr(fuse_ino_t 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
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|