]> git.ipfire.org Git - thirdparty/systemd.git/blame - extras/volume_id/lib/netware.c
update file headers
[thirdparty/systemd.git] / extras / volume_id / lib / netware.c
CommitLineData
674e00f6
KS
1/*
2 * volume_id - reads filesystem label and uuid
3 *
4 * Copyright (C) 2006 Kay Sievers <kay.sievers@vrfy.org>
5 *
55e9959b
KS
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
674e00f6
KS
18 */
19
20#ifndef _GNU_SOURCE
21#define _GNU_SOURCE 1
22#endif
23
674e00f6
KS
24#include <stdio.h>
25#include <stdlib.h>
26#include <unistd.h>
27#include <string.h>
28#include <errno.h>
29#include <ctype.h>
30
31#include "libvolume_id.h"
2603474f 32#include "libvolume_id-private.h"
674e00f6
KS
33
34#define NW_SUPERBLOCK_OFFSET 0x1000
35
36struct netware_super_block {
37 uint8_t SBH_Signature[4];
38 uint16_t SBH_VersionMajor;
39 uint16_t SBH_VersionMinor;
40 uint16_t SBH_VersionMediaMajor;
41 uint16_t SBH_VersionMediaMinor;
42 uint32_t SBH_ItemsMoved;
43 uint8_t SBH_InternalID[16];
172ee420
KS
44 uint32_t SBH_PackedSize;
45 uint32_t SBH_Checksum;
46 uint32_t supersyncid;
47 int64_t superlocation[4];
48 uint32_t physSizeUsed;
49 uint32_t sizeUsed;
50 uint32_t superTimeStamp;
51 uint32_t reserved0[1];
52 int64_t SBH_LoggedPoolDataBlk;
53 int64_t SBH_PoolDataBlk;
54 uint8_t SBH_OldInternalID[16];
55 uint32_t SBH_PoolToLVStartUTC;
56 uint32_t SBH_PoolToLVEndUTC;
57 uint16_t SBH_VersionMediaMajorCreate;
58 uint16_t SBH_VersionMediaMinorCreate;
59 uint32_t SBH_BlocksMoved;
60 uint32_t SBH_TempBTSpBlk;
61 uint32_t SBH_TempFTSpBlk;
62 uint32_t SBH_TempFTSpBlk1;
63 uint32_t SBH_TempFTSpBlk2;
64 uint32_t nssMagicNumber;
65 uint32_t poolClassID;
66 uint32_t poolID;
67 uint32_t createTime;
68 int64_t SBH_LoggedVolumeDataBlk;
69 int64_t SBH_VolumeDataBlk;
70 int64_t SBH_SystemBeastBlkNum;
71 uint64_t totalblocks;
72 uint16_t SBH_Name[64];
73 uint8_t SBH_VolumeID[16];
74 uint8_t SBH_PoolID[16];
75 uint8_t SBH_PoolInternalID[16];
76 uint64_t SBH_Lsn;
77 uint32_t SBH_SS_Enabled;
78 uint32_t SBH_SS_CreateTime;
79 uint8_t SBH_SS_OriginalPoolID[16];
80 uint8_t SBH_SS_OriginalVolumeID[16];
81 uint8_t SBH_SS_Guid[16];
82 uint16_t SBH_SS_OriginalName[64];
83 uint32_t reserved2[64-(2+46)];
674e00f6
KS
84} PACKED;
85
cdf18948 86int volume_id_probe_netware(struct volume_id *id, uint64_t off, uint64_t size)
674e00f6
KS
87{
88 struct netware_super_block *nw;
89
c70560fe 90 info("probing at offset 0x%llx\n", (unsigned long long) off);
674e00f6
KS
91
92 nw = (struct netware_super_block *) volume_id_get_buffer(id, off + NW_SUPERBLOCK_OFFSET, 0x200);
93 if (nw == NULL)
94 return -1;
95
96 if (memcmp(nw->SBH_Signature, "SPB5", 4) != 0)
97 return -1;
98
444f07fe 99 volume_id_set_uuid(id, nw->SBH_PoolID, 0, UUID_DCE);
674e00f6
KS
100
101 snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%02u",
102 le16_to_cpu(nw->SBH_VersionMediaMajor), le16_to_cpu(nw->SBH_VersionMediaMinor));
103
104 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
105 id->type = "nss";
106
107 return 0;
108}