Coverage Report

Created: 2025-11-16 06:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/samba/source3/lib/file_id.c
Line
Count
Source
1
/*
2
   Unix SMB/CIFS implementation.
3
4
   file_id structure handling
5
6
   Copyright (C) Andrew Tridgell 2007
7
8
   This program is free software; you can redistribute it and/or modify
9
   it under the terms of the GNU General Public License as published by
10
   the Free Software Foundation; either version 3 of the License, or
11
   (at your option) any later version.
12
13
   This program is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
18
   You should have received a copy of the GNU General Public License
19
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
*/
21
22
#include "includes.h"
23
#include "lib/file_id.h"
24
25
/*
26
  return True if two file_id structures are equal
27
 */
28
bool file_id_equal(const struct file_id *id1, const struct file_id *id2)
29
0
{
30
0
  return id1->inode == id2->inode && id1->devid == id2->devid &&
31
0
      id1->extid == id2->extid;
32
0
}
33
34
char *file_id_str_buf(struct file_id fid, struct file_id_buf *dst)
35
0
{
36
0
  snprintf(dst->buf,
37
0
     sizeof(dst->buf),
38
0
     "%"PRIu64":%"PRIu64":%"PRIu64,
39
0
     fid.devid,
40
0
     fid.inode,
41
0
     fid.extid);
42
0
  return dst->buf;
43
0
}
44
45
/*
46
  push a 16 byte version of a file id into a buffer.  This ignores the extid
47
  and is needed when dev/inodes are stored in persistent storage (tdbs).
48
 */
49
void push_file_id_16(uint8_t *buf, const struct file_id *id)
50
0
{
51
0
  SIVAL(buf,  0, id->devid&0xFFFFFFFF);
52
0
  SIVAL(buf,  4, id->devid>>32);
53
0
  SIVAL(buf,  8, id->inode&0xFFFFFFFF);
54
0
  SIVAL(buf, 12, id->inode>>32);
55
0
}