diff options
author | Jeremy Katz <katzj@redhat.com> | 2003-03-21 00:09:53 +0000 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2003-03-21 00:09:53 +0000 |
commit | c29f0955045cdd02965a14300ce5e99364db2d1b (patch) | |
tree | d84a948b5288d9b0b9bd28649f608b8df9f18ea0 /isys | |
parent | 720f69db5a6df4a3d6afe90ea228b5a90fe41333 (diff) | |
download | anaconda-c29f0955045cdd02965a14300ce5e99364db2d1b.tar.gz anaconda-c29f0955045cdd02965a14300ce5e99364db2d1b.tar.xz anaconda-c29f0955045cdd02965a14300ce5e99364db2d1b.zip |
merge taroon branch up until now. tagged as before-taroon-merge before and
will be tagged after-taroon-merge after. taroon at this point is tagged
taroon-merge-point for where to base merges from in the future
Diffstat (limited to 'isys')
-rw-r--r-- | isys/Makefile | 2 | ||||
-rw-r--r-- | isys/devnodes.c | 9 | ||||
-rw-r--r-- | isys/gzlib/Makefile | 2 | ||||
-rw-r--r-- | isys/isys.c | 19 | ||||
-rw-r--r-- | isys/isys.py | 6 | ||||
-rw-r--r-- | isys/lang.c | 9 | ||||
-rw-r--r-- | isys/probe.c | 209 | ||||
-rw-r--r-- | isys/probe.h | 57 |
8 files changed, 266 insertions, 47 deletions
diff --git a/isys/Makefile b/isys/Makefile index c5b6454ea..673ee934f 100644 --- a/isys/Makefile +++ b/isys/Makefile @@ -47,7 +47,7 @@ all: subdirs $(PYMODULES) libisys.a $(DIETLIB) $(DIET) $(CC) -c $(CFLAGS) -DGZLIB=1 -DDIET=1 "-Du_char=unsigned char" -o $@ $< _isys.so: isys.lo $(SOBJECTS) - gcc -shared -g -o $@ isys.lo $(SOBJECTS) $(LOADLIBES) + gcc -shared -g -fPIC -o $@ isys.lo $(SOBJECTS) $(LOADLIBES) _silo.so: silo.c gcc -shared $(CFLAGS) -fpic -o $@ silo.c ../balkan/libbalkan.a diff --git a/isys/devnodes.c b/isys/devnodes.c index e24b9e8c2..c130499e0 100644 --- a/isys/devnodes.c +++ b/isys/devnodes.c @@ -170,8 +170,13 @@ int devMakeInode(char * devName, char * path) { type = S_IFBLK; major = 94; minor = ( devName[4] - 'a' ) * 4; - if (devName[5] && isdigit(devName[5]) ) - minor += devName[5] - '0'; + if (devName[5] && isalpha(devName[5])) { + minor += 26 * 4 + ( devName[5] - 'a' ) * 4; + if (devName[6] && isdigit(devName[6]) ) + minor += devName[6] - '0'; + } else if (devName[5] && isdigit(devName[5])) { + minor += devName[5] - '0'; + } } else if (!strncmp(devName, "mnd", 4)) { /* IBM MiniDisk Drives */ type = S_IFBLK; diff --git a/isys/gzlib/Makefile b/isys/gzlib/Makefile index e959dc542..231098874 100644 --- a/isys/gzlib/Makefile +++ b/isys/gzlib/Makefile @@ -1,6 +1,6 @@ include ../../Makefile.inc -CFLAGS += -I . -Os -g -Wall +CFLAGS += -I . -Os -fPIC -g -Wall SOURCES = bits.c gzip.c inflate.c lzw.c trees.c unzip.c util.c zip.c binding.c \ deflate.c zip.c OBJS = $(patsubst %.c,%.o,$(SOURCES)) diff --git a/isys/isys.c b/isys/isys.c index 02ffe0d45..21bc300d7 100644 --- a/isys/isys.c +++ b/isys/isys.c @@ -100,6 +100,8 @@ static PyObject * py_bind_textdomain_codeset(PyObject * o, PyObject * args); static PyObject * getLinkStatus(PyObject * s, PyObject * args); static PyObject * hasIdeRaidMagic(PyObject * s, PyObject * args); static PyObject * start_bterm(PyObject * s, PyObject * args); +static PyObject * py_getDasdPorts(PyObject * s, PyObject * args); +static PyObject * py_isUsableDasd(PyObject * s, PyObject * args); static PyMethodDef isysModuleMethods[] = { { "ejectcdrom", (PyCFunction) doEjectCdrom, METH_VARARGS, NULL }, @@ -149,6 +151,8 @@ static PyMethodDef isysModuleMethods[] = { { "getLinkStatus", (PyCFunction) getLinkStatus, METH_VARARGS, NULL }, { "hasIdeRaidMagic", (PyCFunction) hasIdeRaidMagic, METH_VARARGS, NULL }, { "startBterm", (PyCFunction) start_bterm, METH_VARARGS, NULL }, + { "getDasdPorts", (PyCFunction) py_getDasdPorts, METH_VARARGS, NULL}, + { "isUsableDasd", (PyCFunction) py_isUsableDasd, METH_VARARGS, NULL}, { NULL } } ; @@ -701,9 +705,7 @@ static PyObject * probedListScsi(probedListObject * o, PyObject * args) { static PyObject * probedListDasd(probedListObject * o, PyObject * args) { if (!PyArg_ParseTuple(args, "")) return NULL; -#if defined (__s390__) || defined (__s390x__) kdFindDasdList(&o->list, 0); -#endif Py_INCREF(Py_None); return Py_None; @@ -1371,6 +1373,19 @@ static PyObject * getLinkStatus(PyObject * s, PyObject * args) { return Py_BuildValue("i", ret); } +static PyObject * py_getDasdPorts(PyObject * o, PyObject * args) { + if (!PyArg_ParseTuple(args, "")) return NULL; + + return Py_BuildValue("s", getDasdPorts()); +} + +static PyObject * py_isUsableDasd(PyObject * o, PyObject * args) { + char *devname; + if (!PyArg_ParseTuple(args, "s", &devname)) + return NULL; + return Py_BuildValue("i", isUsableDasd(devname)); +} + static PyObject * printObject (PyObject * o, PyObject * args) { PyObject * obj; char buf[256]; diff --git a/isys/isys.py b/isys/isys.py index f6450681a..2ddb44e1c 100644 --- a/isys/isys.py +++ b/isys/isys.py @@ -304,6 +304,12 @@ def cdromList(): list.sort() return list +def getDasdPorts(): + return _isys.getDasdPorts() + +def isUsableDasd(device): + return _isys.isUsableDasd(device) + def makeDevInode(name, fn=None): if fn: _isys.mkdevinode(name, fn) diff --git a/isys/lang.c b/isys/lang.c index 74e09a53c..684ae2247 100644 --- a/isys/lang.c +++ b/isys/lang.c @@ -25,6 +25,9 @@ int isysLoadFont(void) { gzFile stream; int rc; +#if defined (__s390__) || defined (__s390x__) + return 0; +#endif stream = gunzip_open("/etc/screenfont.gz"); if (!stream) return -EACCES; @@ -56,6 +59,9 @@ int isysLoadFont(void) { int isysSetUnicodeKeymap(void) { int console; +#if defined (__s390__) || defined (__s390x__) + return 0; +#endif console = open("/dev/console", O_RDWR); if (console < 0) return -EACCES; @@ -76,6 +82,9 @@ int loadKeymap(gzFile stream) { int magic; short keymap[NR_KEYS]; +#if defined (__s390__) || defined (__s390x__) + return 0; +#endif if (gunzip_read(stream, &magic, sizeof(magic)) != sizeof(magic)) return -EIO; diff --git a/isys/probe.c b/isys/probe.c index 71df5ceab..4d37e13a8 100644 --- a/isys/probe.c +++ b/isys/probe.c @@ -9,6 +9,10 @@ #include <string.h> #include <sys/ioctl.h> #include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/ioctl.h> +#include <linux/fs.h> #include "isys.h" #include "probe.h" @@ -152,6 +156,170 @@ bye: return 0; } +#if defined(__s390__) || defined(__s390x__) +/* s390 stuff to detect DASDs */ +int vtoc_read_volume_label (int fd, unsigned long vlabel_start, + volume_label_t *vlabel) { + int rc; + if (lseek(fd, vlabel_start, SEEK_SET) < 0) { + /* fprintf(stderr, "Could not read volume label.\n"); */ + return 2; + } + rc = read(fd, vlabel, sizeof(volume_label_t)); + if (rc != sizeof(volume_label_t)) { + /* fprintf(stderr, "Could not read volume label, DASD is probably unformatted\n"); */ + return 1; + } + return 0; +} + +int read_vlabel(dasd_information_t *dasd_info, int fd, int blksize, volume_label_t *vlabel) { + volume_label_t tmp; + unsigned long pos; + int ret; + + pos = dasd_info->label_block * blksize; + + memset(vlabel, 0, sizeof(volume_label_t)); + if ((strncmp(dasd_info->type, "ECKD", 4) == 0) && + (!dasd_info->FBA_layout)) { + /* OS/390 and zOS compatible disk layout */ + return vtoc_read_volume_label(fd, pos, vlabel); + } + else { + /* standard LINUX disk layout */ + ret = vtoc_read_volume_label(fd, pos, &tmp); + if(!ret) { + memcpy(vlabel->vollbl, &tmp, sizeof(tmp)-4); + return 0; + } + return ret; + } +} +#endif + +int isUsableDasd(char *device) { +#if !defined(__s390__) && !defined(__s390x__) + return 0; +#else + char devname[16]; + char label[5], v4_hex[9]; + char v4ebcdic_hex[] = "e5d6d3f1"; /* VOL1 */ + char l4ebcdic_hex[] = "d3d5e7f1"; /* LNX1 */ + int f, ret, blksize; + dasd_information_t dasd_info; + volume_label_t vlabel; + memset(&dasd_info, 0, sizeof(dasd_info)); + strcpy(devname, "/dev/"); + strcat(devname, device); + devMakeInode(device, devname); + if((f = open(devname, O_RDONLY)) == -1) { + unlink(devname); + return 0; + } + if (ioctl(f, BLKSSZGET, &blksize) != 0) { + close(f); + unlink(devname); + /* fprintf(stderr, "Could not retrieve blocksize information!\n"); */ + return 0; + } + if (ioctl(f, BIODASDINFO, &dasd_info) != 0) { + close(f); + unlink(devname); + /* fprintf(stderr, "Could not retrieve disk information!\n"); */ + return 0; + } + ret = read_vlabel(&dasd_info, f, blksize, &vlabel); + + if (ret == 2) { + close(f); + unlink(devname); + return 0; + } else if (ret == 1) { /* probably unformatted DASD */ + close(f); + unlink(devname); + /* fprintf(stderr, "Found a usable device: %s\n", devname); */ + return 1; + } + memset(label, 0, 5); + memset(v4_hex, 0, 9); + strncpy(label, vlabel.volkey, 4); + sprintf(v4_hex, "%02x%02x%02x%02x", label[0], label[1], label[2], label[3]); + if(!strncmp(v4_hex, v4ebcdic_hex, 9) || !strncmp(v4_hex, l4ebcdic_hex, 9)) { + /* fprintf(stderr, "Found a usable device: %s\n", devname); */ + return 1; + } + return 0; +#endif +} + +char *getDasdPorts() { +#if !defined(__s390__) && !defined(__s390x__) + return 0; +#else + char * line, *ports = NULL; + char devname[7]; + char port[6]; + FILE *fd; + int ret; + fd = fopen ("/proc/dasd/devices", "r"); + if(!fd) { + return NULL; + } + line = (char *)malloc(100*sizeof(char)); + while (fgets (line, 100, fd) != NULL) { + if ((strstr(line, "unknown") != NULL)) { + continue; + } + ret = sscanf (line, "%[A-Za-z0-9](ECKD) at ( %*d: %*d) is %s : %*s", port, devname); + if (ret == 2) { + if(!ports) { + ports = (char *)malloc(strlen(port) + 1); + strcpy(ports, port); + } else { + ports = (char *)realloc(ports, strlen(ports) + strlen(port) + 2); + strcat(ports, ","); + strcat(ports, port); + } + } + } + if (fd) fclose(fd); + return ports; +#endif +} + +int kdFindDasdList(struct knownDevices * devices, int code) { + char devname[7]; + char *line; + int ret; + FILE *fd; + + struct kddevice device; + + fd = fopen ("/proc/dasd/devices", "r"); + if(!fd) { + return 0; + } + + line = (char *)malloc(100*sizeof(char)); + while (fgets (line, 100, fd) != NULL) { + ret = sscanf (line, "%*[A-Za-z0-9](ECKD) at ( %*d: %*d) is %s : %*s", + devname); + if (ret == 1 && !deviceKnown(devices, devname) + && isUsableDasd(devname)) { + device.code = code; + device.class = CLASS_HD; + device.name = strdup(devname); + device.model = strdup("IBM DASD"); + addDevice(devices, device); + } + } + if (fd) fclose(fd); + qsort(devices->known, devices->numKnown, sizeof(*devices->known), + sortDevices); + return 0; +} + int kdFindIdeList(struct knownDevices * devices, int code) { return kdFindFilteredIdeList(devices, code, NULL); } @@ -408,47 +576,6 @@ bye: return val; } -#if defined (__s390__) || defined (__s390x__) -int kdFindDasdList(struct knownDevices * devices, int code) { - /* patch for s390 by Oliver Paukstadt <oliver.paukstadt@millenux.com> */ - /* based upon code by Erik Tews <erik.tews@gmx.net> */ - FILE * fd; - struct kddevice device; - char line[200]; - char name[10]; - char status[10]; - char model[30]; - - if (access("/proc/dasd/devices", R_OK)) return 0; - /* a system without /proc/dasd/devices is nothing to worry about */ - - fd = fopen ("/proc/dasd/devices", "r"); - if (fd == NULL) return 1; - - /* Every line in this file is a harddisk */ - while ((fgets(line, 190, fd)) != NULL) { - int num; - num = sscanf(line, "%*X %*[(A-Z)] at (%*d:%*d) is %[a-z0-9] : %s ", - name, status); - /* Take every dasd, formated and unformated */ - - if ((num == 2) && (strlen(name) <= 6) && !deviceKnown(devices, name)) { - snprintf(model, sizeof(model), "IBM DASD (%s)", status); - device.class = CLASS_HD; - device.name = strdup(name); - device.model = strdup(model); - device.code = code; - addDevice(devices, device); - } - } - fclose (fd); - - qsort(devices->known, devices->numKnown, sizeof(*devices->known), - sortDevices); - return 0; -} -#endif - struct knownDevices kdInit(void) { struct knownDevices kd; diff --git a/isys/probe.h b/isys/probe.h index 90a4ee4c0..f3886f0d7 100644 --- a/isys/probe.h +++ b/isys/probe.h @@ -3,6 +3,9 @@ #include "kudzu/kudzu.h" +#define DASD_IOCTL_LETTER 'D' +#define BIODASDINFO _IOR(DASD_IOCTL_LETTER,1,dasd_information_t) + struct kddevice { char * name; /* malloced */ char * model; @@ -16,12 +19,65 @@ struct knownDevices { int numKnownAlloced; }; +#if defined(__s390__) || defined(__s390x__) +/* + * struct dasd_information_t + * represents any data about the data, which is visible to userspace + */ +typedef struct dasd_information_t { + unsigned int devno; /* S/390 devno */ + unsigned int real_devno; /* for aliases */ + unsigned int schid; /* S/390 subchannel identifier */ + unsigned int cu_type : 16; /* from SenseID */ + unsigned int cu_model : 8; /* from SenseID */ + unsigned int dev_type : 16; /* from SenseID */ + unsigned int dev_model : 8; /* from SenseID */ + unsigned int open_count; + unsigned int req_queue_len; + unsigned int chanq_len; + char type[4]; /* from discipline.name, 'none' for unknown */ + unsigned int status; /* current device level */ + unsigned int label_block; /* where to find the VOLSER */ + unsigned int FBA_layout; /* fixed block size (like AIXVOL) */ + unsigned int characteristics_size; + unsigned int confdata_size; + char characteristics[64]; /* from read_device_characteristics */ + char configuration_data[256]; /* from read_configuration_data */ +} dasd_information_t; + +typedef struct cchhb +{ + u_int16_t cc; + u_int16_t hh; + u_int8_t b; +} __attribute__ ((packed)) cchhb_t; + +typedef struct volume_label +{ + char volkey[4]; /* volume key = volume label */ + char vollbl[4]; /* volume label */ + char volid[6]; /* volume identifier */ + u_int8_t security; /* security byte */ + cchhb_t vtoc; /* VTOC address */ + char res1[5]; /* reserved */ + char cisize[4]; /* CI-size for FBA,... */ + /* ...blanks for CKD */ + char blkperci[4]; /* no of blocks per CI (FBA), blanks for CKD */ + char labperci[4]; /* no of labels per CI (FBA), blanks for CKD */ + char res2[4]; /* reserved */ + char lvtoc[14]; /* owner code for LVTOC */ + char res3[29]; /* reserved */ +} __attribute__ ((packed)) volume_label_t; +#endif + + /* 0 if the device should be filtered from the list, 1 if it should be included */ typedef int (*kdFilterType)(const struct kddevice * dev); struct knownDevices kdInit(void); int kdFindNetList(struct knownDevices * devices, int code); +int kdFindDasdList(struct knownDevices * devices, int code); int kdFindIdeList(struct knownDevices * devices, int code); int kdFindFilteredIdeList(struct knownDevices * devices, int code, kdFilterType filter); @@ -29,5 +85,6 @@ int kdFindScsiList(struct knownDevices * devices, int code); void kdFree(struct knownDevices * devices); void kdAddDevice(struct knownDevices * devices, enum deviceClass devClass, char * devName, char * devModel); +char *getDasdPorts(); #endif |