blob: 537abfc297852ea8cfbfec6f004652d90d52bc87 [file] [log] [blame]
// Copyright 2017 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.
#include "src/storage/memfs/vnode.h"
namespace memfs {
class VnodeFile final : public Vnode {
VnodeFile(PlatformVfs* vfs, uint64_t max_file_size);
~VnodeFile() override;
fs::VnodeProtocolSet GetProtocols() const final;
zx_status_t CreateStream(uint32_t stream_options, zx::stream* out_stream) final;
void DidModifyStream() final;
zx_status_t Truncate(size_t len) final;
zx_status_t GetAttributes(fs::VnodeAttributes* a) final;
zx_status_t GetNodeInfoForProtocol(fs::VnodeProtocol protocol, fs::Rights rights,
fs::VnodeRepresentation* info) final;
zx_status_t GetVmo(fuchsia_io::wire::VmoFlags flags, zx::vmo* out_vmo) final;
zx_status_t CreateBackingStoreIfNeeded();
size_t GetContentSize() const;
// Ensure the underlying vmo is filled with zero from:
// [start, round_up(end, PAGE_SIZE)).
void ZeroTail(size_t start, size_t end);
const uint64_t max_file_size_;
zx::vmo vmo_;
} // namespace memfs