~aleteoryx/muditaos

ref: cd700b7c16a4ab403f76c619ee60bf63ddbc55c8 muditaos/board/rt1051/crashdump/crashdumpwriter_vfs.hpp -rw-r--r-- 1012 bytes
cd700b7c — Przemyslaw Brudny Merge remote-tracking branch 'origin/stable' 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "crashdumpwriter.hpp"
#include <rotator/Rotator.hpp>

#include <array>
#include <ctime>
#include <memory>

namespace purefs::fs
{
    class filesystem;
}

namespace crashdump
{
    constexpr inline auto maxRotationFilesCount = 5;
    class CrashDumpWriterVFS : public CrashDumpWriter
    {
      public:
        CrashDumpWriterVFS() : rotator{".hex"}
        {}
        void openDump() override;
        void saveDump() override;

        void writeBytes(const std::uint8_t *buff, std::size_t size) override;
        void writeHalfWords(const std::uint16_t *buff, std::size_t size) override;
        void writeWords(const std::uint32_t *buff, std::size_t size) override;

      private:
        utils::Rotator<maxRotationFilesCount> rotator;
        int dumpFd{-1};

        std::shared_ptr<purefs::fs::filesystem> vfs;
    };

} // namespace crashdump