]> git.proxmox.com Git - ceph.git/blob - ceph/src/mds/Anchor.cc
import 15.2.0 Octopus source
[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(1, 1, bl);
22 encode(ino, bl);
23 encode(dirino, bl);
24 encode(d_name, bl);
25 encode(d_type, bl);
26 ENCODE_FINISH(bl);
27 }
28
29 void Anchor::decode(bufferlist::const_iterator &bl)
30 {
31 DECODE_START(1, bl);
32 decode(ino, bl);
33 decode(dirino, bl);
34 decode(d_name, bl);
35 decode(d_type, bl);
36 DECODE_FINISH(bl);
37 }
38
39 void Anchor::dump(Formatter *f) const
40 {
41 f->dump_unsigned("ino", ino);
42 f->dump_unsigned("dirino", dirino);
43 f->dump_string("d_name", d_name);
44 f->dump_unsigned("d_type", d_type);
45 }
46
47 void Anchor::generate_test_instances(std::list<Anchor*>& ls)
48 {
49 ls.push_back(new Anchor);
50 ls.push_back(new Anchor);
51 ls.back()->ino = 1;
52 ls.back()->dirino = 2;
53 ls.back()->d_name = "hello";
54 ls.back()->d_type = DT_DIR;
55 }
56
57 ostream& operator<<(ostream& out, const Anchor &a)
58 {
59 return out << "a(" << a.ino << " " << a.dirino << "/'" << a.d_name << "' " << a.d_type << ")";
60 }