GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/nfs4/filehandle.h
Date: 2026-10-18 02:40:11
Exec Total Coverage
Lines: 6 6 100.0%
Branches: 5 8 62.5%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
5 #ifndef CVMFS_NFS4_FILEHANDLE_H_
6 #define CVMFS_NFS4_FILEHANDLE_H_
7
8 #include <stdint.h>
9
10 #include <string>
11
12 namespace nfs4 {
13
14 /**
15 * Fixed-size, path-free NFS file handle:
16 *
17 * magic "CVN4" | version | kind | 2 reserved | fsid (8) | inode (8) |
18 * aux (4) | FNV-1a checksum (4)
19 *
20 * The handle carries no boot time, so it remains valid across server restarts
21 * as long as the backend's inode numbers are stable. For named attributes,
22 * aux holds a hash of the attribute name, which keeps the handle size fixed.
23 */
24 struct FileHandle {
25 enum Kind {
26 kObject = 1,
27 kAttrDir = 2,
28 kNamedAttr = 3,
29 };
30
31 static const unsigned kSize = 32;
32
33 6945 FileHandle() : kind(kObject), fsid(0), ino(0), aux(0) { }
34 2382 FileHandle(Kind k, uint64_t f, uint64_t i, uint32_t a = 0)
35 2382 : kind(k), fsid(f), ino(i), aux(a) { }
36
37 std::string Encode() const;
38 /** Returns false for anything that is not a well-formed handle. */
39 static bool Decode(const std::string &raw, FileHandle *fh);
40
41 120 bool operator==(const FileHandle &other) const {
42
3/4
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✓ Branch 3 taken 13 times.
120 return kind == other.kind && fsid == other.fsid && ino == other.ino
43
2/4
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
240 && aux == other.aux;
44 }
45
46 Kind kind;
47 uint64_t fsid;
48 uint64_t ino;
49 uint32_t aux;
50 };
51
52 /** Named attribute hash stored in FileHandle::aux */
53 uint32_t HashName(const std::string &name);
54
55 } // namespace nfs4
56
57 #endif // CVMFS_NFS4_FILEHANDLE_H_
58