blob: 9adc6156f8ddb0fd45b367de37d20577b1174821 [file] [log] [blame]
Andrew Jeffery812923d2018-02-22 11:59:52 +10301// SPDX-License-Identifier: Apache-2.0
2// Copyright (C) 2018 IBM Corp.
3
4#include "test/vpnor/tmpd.hpp"
5
6namespace openpower
7{
8namespace virtual_pnor
9{
10namespace test
11{
12
13namespace fs = std::experimental::filesystem;
14
15size_t VpnorRoot::write(const std::string &name, const void *data, size_t len)
16{
Andrew Jeffery097495c2018-02-22 11:36:13 +103017 // write() is for test environment setup - always write to ro section
18 fs::path path = root / "ro" / name;
Andrew Jeffery812923d2018-02-22 11:59:52 +103019
20 if (!fs::exists(path))
21 /* It's not in the ToC */
22 throw std::invalid_argument(name);
23
Andrew Jeffery097495c2018-02-22 11:36:13 +103024 std::ofstream(path).write((const char *)data, len);
Andrew Jeffery812923d2018-02-22 11:59:52 +103025
26 return len;
27}
28
Andrew Jeffery2a4bee72018-03-01 15:49:17 +103029size_t VpnorRoot::patch(const std::string &name, const void *data, size_t len)
30{
31 if (!fs::exists(root / "ro" / name))
32 /* It's not in the ToC */
33 throw std::invalid_argument(name);
34
35 std::ofstream(root / "patch" / name).write((const char *)data, len);
36
37 return len;
38}
39
Andrew Jeffery812923d2018-02-22 11:59:52 +103040} // test
41} // virtual_pnor
42} // openpower