mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 00:14:35 +03:00
9f07485239
Summary: The serialized data for each file handle needs to be enough to re-construct the handle when we load it into a new process later on. We need the inode number, the file handle number that we communicated to the kernel and a flag to let us know whether it is a file or a dir. Note that the file handle allocation strategy already accomodates the idea of migrating to a new process; we don't need to serialize anything like a next file handle id number. This doesn't implement instantiating the handles from the loaded state, it is just the plumbing for saving and loading that state information. Reviewed By: bolinfest Differential Revision: D5733079 fbshipit-source-id: 8fb8afb8ae9694d013ce7a4a82c31bc876ed33c9
92 lines
2.4 KiB
C++
92 lines
2.4 KiB
C++
/*
|
|
* Copyright (c) 2016-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 "BufVec.h"
|
|
#include "Dispatcher.h"
|
|
#include "PollHandle.h"
|
|
#include <folly/futures/Future.h>
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
namespace fusell {
|
|
|
|
class Dispatcher;
|
|
|
|
class FileHandleBase {
|
|
public:
|
|
virtual ~FileHandleBase();
|
|
|
|
/**
|
|
* Return the inode number.
|
|
* This is used in lieu of getattr() by the code that serializes
|
|
* the FileHandleMap. */
|
|
virtual fuse_ino_t getInodeNumber() = 0;
|
|
|
|
/**
|
|
* Get file attributes
|
|
*/
|
|
virtual folly::Future<Dispatcher::Attr> getattr() = 0;
|
|
|
|
/**
|
|
* Set file attributes
|
|
*
|
|
* In the 'attr' argument only members indicated by the 'to_set'
|
|
* bitmask contain valid values. Other members contain undefined
|
|
* values.
|
|
*
|
|
* @param attr the attributes
|
|
* @param to_set bit mask of attributes which should be set
|
|
*/
|
|
virtual folly::Future<Dispatcher::Attr> setattr(const struct stat& attr,
|
|
int to_set) = 0;
|
|
|
|
/* The result of an ioctl operation */
|
|
struct Ioctl {
|
|
int result;
|
|
BufVec buf;
|
|
};
|
|
|
|
/**
|
|
* Ioctl
|
|
*
|
|
* Only well-formed (restricted) ioctls are supported. These are ioctls
|
|
* that have the argument size encoded using _IOR, _IOW, _IOWR macros.
|
|
*
|
|
* @param arg is the argument passed in from userspace
|
|
* @param inputData is a copy of the arg data from userspace
|
|
* @param outputSize is the maximum size of the output data
|
|
*/
|
|
virtual folly::Future<Ioctl> ioctl(int cmd,
|
|
const void* arg,
|
|
folly::ByteRange inputData,
|
|
size_t outputSize);
|
|
|
|
/**
|
|
* Poll for IO readiness
|
|
*
|
|
* Introduced in version 2.8
|
|
*
|
|
* Note: If ph is non-NULL, the client should notify
|
|
* when IO readiness events occur by calling
|
|
* ph->notify().
|
|
*
|
|
* Regardless of the number of times poll with a non-NULL ph
|
|
* is received, single notification is enough to clear all.
|
|
* Notifying more times incurs overhead but doesn't harm
|
|
* correctness.
|
|
*
|
|
* Return the poll(2) revents mask.
|
|
*/
|
|
virtual folly::Future<unsigned> poll(std::unique_ptr<PollHandle> ph);
|
|
};
|
|
}
|
|
}
|
|
}
|