]> git.proxmox.com Git - ceph.git/blame - ceph/src/mds/Anchor.cc
Import ceph 15.2.8
[ceph.git] / ceph / src / mds / Anchor.cc
CommitLineData
11fdf7f2
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3/*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2018 Red Hat
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15#include "mds/Anchor.h"
16
17#include "common/Formatter.h"
18
19void Anchor::encode(bufferlist &bl) const
20{
f91f0fd5 21 ENCODE_START(2, 1, bl);
11fdf7f2
TL
22 encode(ino, bl);
23 encode(dirino, bl);
24 encode(d_name, bl);
25 encode(d_type, bl);
f91f0fd5 26 encode(frags, bl);
11fdf7f2
TL
27 ENCODE_FINISH(bl);
28}
29
30void Anchor::decode(bufferlist::const_iterator &bl)
31{
f91f0fd5 32 DECODE_START(2, bl);
11fdf7f2
TL
33 decode(ino, bl);
34 decode(dirino, bl);
35 decode(d_name, bl);
36 decode(d_type, bl);
f91f0fd5
TL
37 if (struct_v >= 2)
38 decode(frags, bl);
11fdf7f2
TL
39 DECODE_FINISH(bl);
40}
41
42void Anchor::dump(Formatter *f) const
43{
44 f->dump_unsigned("ino", ino);
45 f->dump_unsigned("dirino", dirino);
46 f->dump_string("d_name", d_name);
47 f->dump_unsigned("d_type", d_type);
48}
49
9f95a23c 50void Anchor::generate_test_instances(std::list<Anchor*>& ls)
11fdf7f2
TL
51{
52 ls.push_back(new Anchor);
53 ls.push_back(new Anchor);
54 ls.back()->ino = 1;
55 ls.back()->dirino = 2;
56 ls.back()->d_name = "hello";
57 ls.back()->d_type = DT_DIR;
58}
59
60ostream& operator<<(ostream& out, const Anchor &a)
61{
62 return out << "a(" << a.ino << " " << a.dirino << "/'" << a.d_name << "' " << a.d_type << ")";
63}