blob: 0b6816daaafb478c441ed36d5b35eaea2b8c1a06 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SRC_LIB_STORAGE_VFS_CPP_FILE_CONNECTION_H_
#define SRC_LIB_STORAGE_VFS_CPP_FILE_CONNECTION_H_
#ifndef __Fuchsia__
#error "Fuchsia-only header"
#endif
#include <fidl/fuchsia.io/cpp/wire.h>
#include <cstdint>
#include <fbl/ref_ptr.h>
#include "src/lib/storage/vfs/cpp/connection.h"
#include "src/lib/storage/vfs/cpp/vfs_types.h"
#include "src/lib/storage/vfs/cpp/vnode.h"
namespace fs {
namespace internal {
class FileConnection : public Connection, public fidl::WireServer<fuchsia_io::File> {
public:
// Refer to documentation for |Connection::Connection|.
FileConnection(fs::FuchsiaVfs* vfs, fbl::RefPtr<fs::Vnode> vnode, VnodeProtocol protocol,
VnodeConnectionOptions options, zx_koid_t koid);
~FileConnection() override;
private:
std::unique_ptr<Binding> Bind(async_dispatcher*, zx::channel, OnUnbound) override;
//
// |fuchsia.io/Node| operations.
//
void Clone(CloneRequestView request, CloneCompleter::Sync& completer) final;
void Close(CloseCompleter::Sync& completer) final;
void Query(QueryCompleter::Sync& completer) final;
void GetConnectionInfo(GetConnectionInfoCompleter::Sync& completer) final;
void Sync(SyncCompleter::Sync& completer) final;
void GetAttr(GetAttrCompleter::Sync& completer) final;
void SetAttr(SetAttrRequestView request, SetAttrCompleter::Sync& completer) final;
void QueryFilesystem(QueryFilesystemCompleter::Sync& completer) final;
void GetAttributes(fuchsia_io::wire::Node2GetAttributesRequest* request,
GetAttributesCompleter::Sync& completer) final {
completer.ReplyError(ZX_ERR_NOT_SUPPORTED);
}
void UpdateAttributes(fuchsia_io::wire::MutableNodeAttributes* request,
UpdateAttributesCompleter::Sync& completer) final {
completer.ReplyError(ZX_ERR_NOT_SUPPORTED);
}
void Reopen(fuchsia_io::wire::Node2ReopenRequest* request,
ReopenCompleter::Sync& completer) final {
request->object_request.Close(ZX_ERR_NOT_SUPPORTED);
}
//
// |fuchsia.io/File| operations.
//
void Describe(DescribeCompleter::Sync& completer) final;
void Resize(ResizeRequestView request, ResizeCompleter::Sync& completer) final;
void GetBackingMemory(GetBackingMemoryRequestView request,
GetBackingMemoryCompleter::Sync& completer) final;
//
// |fuchsia.io/AdvisoryLocking| operations.
//
void AdvisoryLock(fidl::WireServer<fuchsia_io::File>::AdvisoryLockRequestView request,
AdvisoryLockCompleter::Sync& _completer) final;
zx_status_t ResizeInternal(uint64_t length);
zx_status_t GetBackingMemoryInternal(fuchsia_io::wire::VmoFlags flags, zx::vmo* out_vmo);
const zx_koid_t koid_;
};
} // namespace internal
} // namespace fs
#endif // SRC_LIB_STORAGE_VFS_CPP_FILE_CONNECTION_H_