]> git.proxmox.com Git - ceph.git/blob - ceph/src/mds/Anchor.cc
import quincy beta 17.1.0
[ceph.git] / ceph / src / mds / Anchor.cc
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
19 void Anchor::encode(bufferlist &bl) const
20 {
21 ENCODE_START(2, 1, bl);
22 encode(ino, bl);
23 encode(dirino, bl);
24 encode(d_name, bl);
25 encode(d_type, bl);
26 encode(frags, bl);
27 ENCODE_FINISH(bl);
28 }
29
30 void Anchor::decode(bufferlist::const_iterator &bl)
31 {
32 DECODE_START(2, bl);
33 decode(ino, bl);
34 decode(dirino, bl);
35 decode(d_name, bl);
36 decode(d_type, bl);
37 if (struct_v >= 2)
38 decode(frags, bl);
39 DECODE_FINISH(bl);
40 }
41
42 void 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
50 void Anchor::generate_test_instances(std::list<Anchor*>& ls)
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
60 std::ostream& operator<<(std::ostream& out, const Anchor &a)
61 {
62 return out << "a(" << a.ino << " " << a.dirino << "/'" << a.d_name << "' " << a.d_type << ")";
63 }