2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 /* check_sysid.c - Verify and display the sysid file. */
13 /* ********************************************************************* */
15 #include <afsconfig.h>
16 #include <afs/param.h>
20 #include <afs/vldbint.h>
23 #define SYSIDMAGIC 0x88aabbcc
24 #define SYSIDVERSION 1
26 struct versionStamp
{ /* Stolen from <afs/volume.h> */
32 main(int argc
, char **argv
)
36 struct versionStamp vs
;
43 if ((argc
!= 2) || (strcmp(argv
[1], "-h") == 0)) {
44 printf("Usage: check_sysid <sysid_file>\n");
45 exit((argc
!= 2) ? 1 : 0);
48 fd
= open(argv
[1], O_RDONLY
, 0);
50 printf("Unable to open file '%s'. Errno = %d\n", argv
[1], errno
);
54 /* Read the Version Stamp. The magic and version fields are stored
55 * in host byte order. */
56 size
= read(fd
, (char *)&vs
, sizeof(vs
));
57 if (size
!= sizeof(vs
)) {
58 printf("Unable to read versionStamp. Size = %d. Errno = %d\n", size
,
61 printf("versionStamp.magic = 0x%x %s\n", vs
.magic
,
62 (vs
.magic
== SYSIDMAGIC
) ? "" : "(should be 0x88aabbc)");
63 printf("versionStamp.version = 0x%x %s\n", vs
.version
,
64 (vs
.version
== SYSIDVERSION
) ? "" : "(should be 0x1)");
66 /* Read the uuid. Portions of the uuid are stored in network
68 size
= read(fd
, (char *)&uuid
, sizeof(uuid
));
69 if (size
!= sizeof(uuid
)) {
70 printf("Unable to read afsUUID. Size = %d. Errno = %d\n", size
,
75 code
= opr_uuid_toString(&uuid
, &buffer
);
77 printf("Unable to format uuid string. code=%d\n", code
);
80 printf("UUID = %s\n", buffer
);
81 opr_uuid_freeString(buffer
);
83 /* Read the number of addresses recorded in the sysid.
84 * nentries is stored in host byte order. */
85 size
= read(fd
, (char *)&nentries
, sizeof(int));
86 if (size
!= sizeof(int)) {
87 printf("Unable to read nentries. Size = %d. Errno = %d\n", size
,
91 printf("Number of addreses = %d (0x%x)\n", nentries
, nentries
);
93 /* Now read in each of the addresses.
94 * Each address is stored in network byte order. */
95 for (i
= 0; i
< nentries
; i
++) {
96 size
= read(fd
, (char *)&addr
, sizeof(int));
97 if (size
!= sizeof(int)) {
98 printf("Unable to read IP Address %d. Size = %d. Errno = %d\n",
103 printf("Address = %d.%d.%d.%d (0x%x)\n",
104 (addr
>> 24) & 0xff, (addr
>> 16) & 0xff, (addr
>> 8) & 0xff,
105 (addr
) & 0xff, addr
);