mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
device: Tidy DASD CDL format detection code.
This commit is contained in:
parent
6e1e0e8813
commit
65ec00ce20
@ -17,7 +17,28 @@
|
|||||||
#include "dev-type.h"
|
#include "dev-type.h"
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
typedef struct dasd_information_t {
|
#ifdef __linux__
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Interface taken from kernel header arch/s390/include/uapi/asm/dasd.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
|
||||||
|
* Copyright IBM Corp. 1999, 2000
|
||||||
|
* EMC Symmetrix ioctl Copyright EMC Corporation, 2008
|
||||||
|
* Author.........: Nigel Hislop <hislop_nigel@emc.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DASD_IOCTL_LETTER 'D'
|
||||||
|
#define DASD_API_VERSION 6
|
||||||
|
|
||||||
|
/*
|
||||||
|
* struct dasd_information2_t
|
||||||
|
* represents any data about the device, which is visible to userspace.
|
||||||
|
* including foramt and featueres.
|
||||||
|
*/
|
||||||
|
typedef struct dasd_information2_t {
|
||||||
unsigned int devno; /* S/390 devno */
|
unsigned int devno; /* S/390 devno */
|
||||||
unsigned int real_devno; /* for aliases */
|
unsigned int real_devno; /* for aliases */
|
||||||
unsigned int schid; /* S/390 subchannel identifier */
|
unsigned int schid; /* S/390 subchannel identifier */
|
||||||
@ -34,8 +55,8 @@ typedef struct dasd_information_t {
|
|||||||
unsigned int FBA_layout; /* fixed block size (like AIXVOL) */
|
unsigned int FBA_layout; /* fixed block size (like AIXVOL) */
|
||||||
unsigned int characteristics_size;
|
unsigned int characteristics_size;
|
||||||
unsigned int confdata_size;
|
unsigned int confdata_size;
|
||||||
unsigned char characteristics[64];/*from read_device_characteristics */
|
char characteristics[64]; /* from read_device_characteristics */
|
||||||
unsigned char configuration_data[256];/*from read_configuration_data */
|
char configuration_data[256]; /* from read_configuration_data */
|
||||||
unsigned int format; /* format info like formatted/cdl/ldl/... */
|
unsigned int format; /* format info like formatted/cdl/ldl/... */
|
||||||
unsigned int features; /* dasd features like 'ro',... */
|
unsigned int features; /* dasd features like 'ro',... */
|
||||||
unsigned int reserved0; /* reserved for further use ,... */
|
unsigned int reserved0; /* reserved for further use ,... */
|
||||||
@ -46,29 +67,45 @@ typedef struct dasd_information_t {
|
|||||||
unsigned int reserved5; /* reserved for further use ,... */
|
unsigned int reserved5; /* reserved for further use ,... */
|
||||||
unsigned int reserved6; /* reserved for further use ,... */
|
unsigned int reserved6; /* reserved for further use ,... */
|
||||||
unsigned int reserved7; /* reserved for further use ,... */
|
unsigned int reserved7; /* reserved for further use ,... */
|
||||||
} dasd_information_t;
|
} dasd_information2_t;
|
||||||
|
|
||||||
#define DASD_FORMAT_CDL 2
|
#define DASD_FORMAT_CDL 2
|
||||||
#define BIODASDINFO2 _IOR('D', 3, dasd_information_t)
|
|
||||||
|
/* Get information on a dasd device (enhanced) */
|
||||||
|
#define BIODASDINFO2 _IOR(DASD_IOCTL_LETTER,3,dasd_information2_t)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* End of included interface.
|
||||||
|
*/
|
||||||
|
|
||||||
int dasd_is_cdl_formatted(struct device *dev)
|
int dasd_is_cdl_formatted(struct device *dev)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
dasd_information_t dasd_info;
|
dasd_information2_t dasd_info2;
|
||||||
|
|
||||||
if (!dev_open_readonly(dev)) {
|
if (!dev_open_readonly(dev))
|
||||||
stack;
|
return_0;
|
||||||
return ret;
|
|
||||||
|
if (ioctl(dev->fd, BIODASDINFO2, &dasd_info2)) {
|
||||||
|
log_sys_error("ioctl BIODASDINFO2", dev_name(dev));
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(dev->fd, BIODASDINFO2, &dasd_info) != 0)
|
if (dasd_info2.format == DASD_FORMAT_CDL)
|
||||||
goto_out;
|
|
||||||
|
|
||||||
if (dasd_info.format == DASD_FORMAT_CDL)
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (!dev_close(dev))
|
if (!dev_close(dev))
|
||||||
stack;
|
stack;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
int dasd_is_cdl_formatted(struct device *dev)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user