Coverage Report

Created: 2025-10-13 06:53

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/util-linux/libblkid/src/superblocks/jfs.c
Line
Count
Source
1
/*
2
 * Copyright (C) 1999 by Andries Brouwer
3
 * Copyright (C) 1999, 2000, 2003 by Theodore Ts'o
4
 * Copyright (C) 2001 by Andreas Dilger
5
 * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
6
 * Copyright (C) 2008 Karel Zak <kzak@redhat.com>
7
 *
8
 * This file may be redistributed under the terms of the
9
 * GNU Lesser General Public License.
10
 */
11
#include <stdio.h>
12
#include <stdlib.h>
13
#include <unistd.h>
14
#include <string.h>
15
#include <errno.h>
16
#include <ctype.h>
17
#include <stdint.h>
18
19
#include "superblocks.h"
20
21
struct jfs_super_block {
22
  unsigned char js_magic[4];
23
  uint32_t  js_version;
24
  uint64_t  js_size;
25
  uint32_t  js_bsize; /* 4: aggregate block size in bytes */
26
  uint16_t  js_l2bsize; /* 2: log2 of s_bsize */
27
  uint16_t  js_l2bfactor; /* 2: log2(s_bsize/hardware block size) */
28
  uint32_t  js_pbsize;  /* 4: hardware/LVM block size in bytes */
29
  uint16_t  js_l2pbsize;  /* 2: log2 of s_pbsize */
30
  uint16_t  js_pad;   /* 2: padding necessary for alignment */
31
  uint32_t  js_dummy2[26];
32
  unsigned char js_uuid[16];
33
  unsigned char js_label[16];
34
  unsigned char js_loguuid[16];
35
};
36
37
static int probe_jfs(blkid_probe pr, const struct blkid_idmag *mag)
38
0
{
39
0
  const struct jfs_super_block *js;
40
41
0
  js = blkid_probe_get_sb(pr, mag, struct jfs_super_block);
42
0
  if (!js)
43
0
    return errno ? -errno : 1;
44
0
  if (le16_to_cpu(js->js_l2bsize) > 31 || le16_to_cpu(js->js_l2pbsize) > 31)
45
0
    return 1;
46
0
  if (le32_to_cpu(js->js_bsize) != (1U << le16_to_cpu(js->js_l2bsize)))
47
0
    return 1;
48
0
  if (le32_to_cpu(js->js_pbsize) != (1U << le16_to_cpu(js->js_l2pbsize)))
49
0
    return 1;
50
0
  if ((le16_to_cpu(js->js_l2bsize) - le16_to_cpu(js->js_l2pbsize)) !=
51
0
      le16_to_cpu(js->js_l2bfactor))
52
0
    return 1;
53
54
0
  if (*((char *) js->js_label) != '\0')
55
0
    blkid_probe_set_label(pr, js->js_label, sizeof(js->js_label));
56
0
  blkid_probe_set_uuid(pr, js->js_uuid);
57
0
  blkid_probe_set_fsblocksize(pr, le32_to_cpu(js->js_bsize));
58
  blkid_probe_set_block_size(pr, le32_to_cpu(js->js_bsize));
59
0
  return 0;
60
0
}
61
62
63
const struct blkid_idinfo jfs_idinfo =
64
{
65
  .name   = "jfs",
66
  .usage    = BLKID_USAGE_FILESYSTEM,
67
  .probefunc  = probe_jfs,
68
  .minsz    = 16 * 1024 * 1024,
69
  .magics   =
70
  {
71
    { .magic = "JFS1", .len = 4, .kboff = 32 },
72
    { NULL }
73
  }
74
};
75