libvtoc: Introduce is_vol1() check

Introduce is_vol1() in vtoc.h and update the user in libzds.c

Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Eduard Shishkin
2022-11-22 12:46:25 +01:00
committed by Jan Höppner
parent 6bd93f475c
commit e09c675b70
2 changed files with 8 additions and 3 deletions

View File

@@ -97,6 +97,13 @@ typedef struct volume_label
unsigned long long formatted_blocks; /* valid when ldl_version >= f2 */
} __attribute__ ((packed)) volume_label_t;
static inline int is_vol1(char *this)
{
char vol1[] = {0xe5, 0xd6, 0xd3, 0xf1, 0x00} /* "VOL1" in EBCDIC */;
return !strncmp(this, vol1, 4);
}
typedef struct extent
{
u_int8_t typeind; /* extent type indicator */

View File

@@ -1419,7 +1419,6 @@ int lzds_dasd_read_rawvtoc(struct dasd *dasd, struct raw_vtoc *rawvtoc)
volume_label_t *vlabel = NULL;
char *trackdata = NULL;
char vol1[] = {0xe5, 0xd6, 0xd3, 0xf1, 0x00}; /* "VOL1" in EBCDIC */
errorlog_clear(dasd->log);
@@ -1431,8 +1430,7 @@ int lzds_dasd_read_rawvtoc(struct dasd *dasd, struct raw_vtoc *rawvtoc)
goto cleanup;
}
/* verify that we have a proper VOL1 label */
if (strncmp(vlabel->volkey, vol1, 4) ||
strncmp(vlabel->vollbl, vol1, 4)) {
if (!is_vol1(vlabel->volkey) || !is_vol1(vlabel->vollbl)) {
rc = EINVAL;
errorlog_add_message(
&dasd->log, NULL, rc,