bigbiff bigbiff | e60683a | 2013-02-22 20:55:50 -0500 | [diff] [blame] | 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 | { |
| 39 | struct jfs_super_block *js; |
| 40 | |
| 41 | js = blkid_probe_get_sb(pr, mag, struct jfs_super_block); |
| 42 | if (!js) |
bigbiff | 7b4c7a6 | 2015-01-01 19:44:14 -0500 | [diff] [blame] | 43 | return errno ? -errno : 1; |
bigbiff bigbiff | e60683a | 2013-02-22 20:55:50 -0500 | [diff] [blame] | 44 | if (le32_to_cpu(js->js_bsize) != (1U << le16_to_cpu(js->js_l2bsize))) |
| 45 | return 1; |
| 46 | if (le32_to_cpu(js->js_pbsize) != (1U << le16_to_cpu(js->js_l2pbsize))) |
| 47 | return 1; |
| 48 | if ((le16_to_cpu(js->js_l2bsize) - le16_to_cpu(js->js_l2pbsize)) != |
| 49 | le16_to_cpu(js->js_l2bfactor)) |
| 50 | return 1; |
| 51 | |
| 52 | if (strlen((char *) js->js_label)) |
| 53 | blkid_probe_set_label(pr, js->js_label, sizeof(js->js_label)); |
| 54 | blkid_probe_set_uuid(pr, js->js_uuid); |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | |
| 59 | const struct blkid_idinfo jfs_idinfo = |
| 60 | { |
| 61 | .name = "jfs", |
| 62 | .usage = BLKID_USAGE_FILESYSTEM, |
| 63 | .probefunc = probe_jfs, |
| 64 | .minsz = 16 * 1024 * 1024, |
| 65 | .magics = |
| 66 | { |
| 67 | { .magic = "JFS1", .len = 4, .kboff = 32 }, |
| 68 | { NULL } |
| 69 | } |
| 70 | }; |
| 71 | |