--- isys/Makefile | 2 +- isys/devnodes.c | 375 ------------------------------------------------------- isys/isys.c | 19 --- isys/isys.h | 3 - isys/isys.py | 24 ---- iutil.py | 84 ------------ 6 files changed, 1 insertions(+), 506 deletions(-) delete mode 100644 isys/devnodes.c mode change 100644 => 100755 isys/isys.py diff --git a/isys/Makefile b/isys/Makefile index 7b38cef..82dc788 100644 --- a/isys/Makefile +++ b/isys/Makefile @@ -3,7 +3,7 @@ include ../Makefile.inc CFLAGS += -I$(PYTHONINCLUDE) -I.. -DHAVE_NFS OBJECTS = nfsmount.o nfsmount_clnt.o nfsmount_xdr.o imount.o \ - smp.o devnodes.o cpio.o uncpio.o dasd.o \ + smp.o cpio.o uncpio.o dasd.o \ lang.o isofs.o dns.o linkdetect.o vio.o \ ethtool.o wireless.o eddsupport.o nl.o str.o auditd.o SOBJECTS = $(patsubst %.o,%.lo,$(OBJECTS)) diff --git a/isys/devnodes.c b/isys/devnodes.c deleted file mode 100644 index 3f0e84a..0000000 --- a/isys/devnodes.c +++ /dev/null @@ -1,375 +0,0 @@ -/* - * devnodes.c - device inode creation functions - * - * Erik Troan <ewt@xxxxxxxxxx> - * Matt Wilson <msw@xxxxxxxxxx> - * Peter Jones <pjones@xxxxxxxxxx> - * - * Copyright 1998-2005 Red Hat, Inc. - * Copyright 1996-1998 Red Hat Software, Inc. - * - * This software may be freely redistributed under the terms of the GNU - * public license. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include <stdio.h> -#include <errno.h> -#include <fcntl.h> -#include <sys/stat.h> -#include <sys/sysmacros.h> -#include <stdlib.h> -#include <limits.h> -#include <unistd.h> -#include <ctype.h> -#include <string.h> -#include <libdevmapper.h> - -struct devnum { - char * name; - short major, minor; - int isChar; -}; - -static struct devnum devices[] = { - { "aztcd", 29, 0, 0 }, - { "pcd", 46, 0, 0 }, - { "cdu31a", 15, 0, 0 }, - { "cdu535", 24, 0, 0 }, - { "cm206cd", 32, 0, 0 }, - { "fd0", 2, 0, 0 }, - { "fd1", 2, 1, 0 }, - { "gscd", 16, 0, 0 }, - { "input/mouse0", 13, 32, 1 }, - { "input/mouse1", 13, 33, 1 }, - { "input/mouse2", 13, 34, 1 }, - { "input/mouse3", 13, 35, 1 }, - { "input/event0", 13, 64, 1 }, - { "input/event1", 13, 65, 1 }, - { "input/event2", 13, 66, 1 }, - { "input/event3", 13, 67, 1 }, - { "lp0", 6, 0, 1 }, - { "lp1", 6, 1, 1 }, - { "lp2", 6, 2, 1 }, - { "mcd", 23, 0, 0 }, - { "mcdx", 20, 0, 0 }, - { "optcd", 17, 0, 0 }, - { "psaux", 10, 1, 1 }, - { "sbpcd", 25, 0, 0 }, - { "sjcd", 18, 0, 0 }, - { "ttyS0", 4, 64, 1 }, - { "ttyS1", 4, 65, 1 }, - { "ttyS2", 4, 66, 1 }, - { "ttyS3", 4, 67, 1 }, -}; - -int idemajors[] = { 3, 22, 33, 34, 56, 57, 88, 89, 90, 91 }; - -int numDevices = sizeof(devices) / sizeof(struct devnum); - -#include <linux/major.h> -/* from linux/drivers/scsi/sd.c */ -static int sd_major(int major_idx) { - switch (major_idx) { - case 0: - return SCSI_DISK0_MAJOR; - case 1 ... 7: - return SCSI_DISK1_MAJOR + major_idx - 1; - case 8 ... 15: - return SCSI_DISK8_MAJOR + major_idx - 8; - default: - /* this shouldn't happen... but if it does, return -1 */ - return -1; - } -} - -static const char digits[] = "0123456789"; - -int devMakeInode(char * devName, char * path) { - int i; - long major, minor; - int type; - char *ptr; - char *dir; - - if (!strncmp(devName, "mapper/", 7)) { - struct dm_task *task; - struct dm_info *info = alloca(sizeof *info); - - devName += 7; - if (!info || !*devName) - return -3; - - memset(info, '\0', sizeof (*info)); - task = dm_task_create(DM_DEVICE_INFO); - if (!task) - return -3; - - dm_task_set_name(task, devName); - i = dm_task_run(task); - if (i < 0) { - dm_task_destroy(task); - return -3; - } - i = dm_task_get_info(task, info); - dm_task_destroy(task); - if (i < 0) { - return -3; - } - - type = S_IFBLK; - major = info->major; - minor = info->minor; - } else if (devName[0] == 's' && devName[1] == 'd') { - /* scsi devices sda - sdp: major 8, minor 0 - 255 */ - /* scsi devices sdq - sdaf: major 65, minor 0 - 255 */ - /* scsi devices sdqg - sdav: major 66, minor 0 - 255 */ - /* etc... */ - int drive = 0; - char *num = NULL; - type = S_IFBLK; - - if (devName[3] && isdigit(devName[3])) { - drive = devName[2] - 'a'; - num = devName + 3; - } else if (devName[3] && islower(devName[3])) { - drive = ((devName[2] - 'a' + 1) * 26) + devName[3] - 'a'; - num = devName + 4; - } else - drive = devName[2] - 'a'; - - major = sd_major((drive & 0xf0) >> 4); - if (major < 0) - return major; - minor = (drive * 16) % 256; - minor += (drive & 0xfff00); - if (num && num[0] && num[1]) - minor += (num[0] - '0') * 10 + (num[1] - '0'); - else if (num && num[0]) - minor += (num[0] - '0'); - } else if (!strncmp(devName, "st", 2) || !strncmp(devName, "nst", 3)) { - char *e = NULL; - size_t s; - - s = strcspn(devName, digits); - errno = 0; - minor = strtol(devName+s, &e, 10); - if (e == devName + s || - (errno == ERANGE && - (minor == LONG_MIN || minor == LONG_MAX))) - return -1; - switch (e[0]) { - case 'a': /* "st0a" and "nst0a" */ - minor += 32; - case 'm': /* "st0m" and "nst0m" */ - minor += 32; - case 'l': /* "st0l" and "nst0l" */ - minor += 32; - case '\0': /* "st0" and "nst0" */ - break; - default: - return -1; - } - - if (devName[0] == 'n') - minor += 128; - if (minor > 255) - return -1; - - major = 9; - type = S_IFCHR; - } else if (devName[0] == 'm' && devName[1] == 'd') { - type = S_IFBLK; - major = 9; - minor = atoi(devName + 2); - } else if (devName[0] == 'x' && devName[1] == 'v' && devName[2] == 'd') { - /* xen xvd devices */ - type = S_IFBLK; - major = 202; - minor = ( devName[3] - 'a' ) * 16; - if (devName[4] && isdigit(devName[4])) { - minor += devName[4] - '0'; - } - } else if (devName[0] == 'u' && devName[1] == 'b') { - /* usb block (ub) devices */ - type = S_IFBLK; - major = 180; - minor = ( devName[2] - 'a' ) * 8; - if (devName[3] && isdigit(devName[3])) { - minor += devName[3] - '0'; - } - } else if (devName[0] == 's' && devName[1] == 'g') { - type = S_IFBLK; - major = 21; - minor = atoi(devName + 2); - } else if (!strncmp(devName, "loop", 4)) { - type = S_IFBLK; - major = 7; - minor = atoi(devName + 4); - } else if (!strncmp(devName, "scd", 3)) { - type = S_IFBLK; - major = 11; - minor = atoi(devName + 3); - } else if (devName[0] == 'h' && devName[1] == 'd') { - int drive = 0; - type = S_IFBLK; - - drive = devName[2] - 'a'; - if (drive > 19) - return -1; - - major = idemajors[drive/2]; - minor = (drive % 2) * 64; - - if (devName[3] && devName[4]) - minor += (devName[3] - '0') * 10 + (devName[4] - '0'); - else if (devName[3]) - minor += (devName[3] - '0'); - } else if (!strncmp(devName, "ram", 3)) { - type = S_IFBLK; - major = 1; - minor = 1; - if (devName[3]) - minor += devName[3] - '1'; -#if defined (__s390__) || defined (__s390x__) - } else if (!strncmp(devName, "dasd", 4) && strlen(devName) > 4) { - /* IBM Dasd Drives */ - type = S_IFBLK; - major = 94; - minor = ( devName[4] - 'a' ) * 4; - 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; - major = 95; - minor = devName[3] - 'a'; -#endif -#if defined (__powerpc__) || defined (__powerpc64__) - } else if (!strncmp(devName, "ps3d", 4)) { - type = S_IFBLK; - major = 253; /* FIXME: this is a dynamic major, but fixed enough on the limited ps3 hardware */ - minor = (devName[4] - 'a') * 16; - if ((devName[5]) && isdigit(devName[5])) - minor = minor + atoi(devName + 5); -#endif - } else if (!strncmp(devName, "rd/", 3)) { - /* dac 960 "/rd/c0d0{p1}" */ - int c, d, p, e; - c = d = p = 0; - e = sscanf(devName + 3, "c%dd%dp%d", &c, &d, &p); - type = S_IFBLK; - major = 48 + c; /* controller */ - minor = d * 8; /* disk */ - minor += p; /* partition */ - } else if (!strncmp(devName, "ida/", 4)) { - /* Compaq Smart Array "ida/c0d0{p1} */ - int c, d, p, e; - c = d = p = 0; - e = sscanf(devName + 4, "c%dd%dp%d", &c, &d, &p); - type = S_IFBLK; - major = 72 + c; /* controller */ - minor = d * 16; /* disk */ - minor += p; /* partition */ - } else if (!strncmp(devName, "cciss/", 6)) { - /* Compaq Smart Array 5300 "cciss/c0d0{p1} */ - int c, d, p, e; - c = d = p = 0; - e = sscanf(devName + 6, "c%dd%dp%d", &c, &d, &p); - type = S_IFBLK; - major = 104 + c; /* controller */ - minor = d * 16; /* disk */ - minor += p; /* partition */ - } else if (!strncmp(devName, "ataraid/", 8)) { - type = S_IFBLK; - major = 114; /* controller */ - minor = (devName[9] - '0') * 16; /* disk */ - if (strlen(devName) > 10) /* partition */ - minor += atoi(devName + 11); - } else if (!strncmp(devName, "sx8/", 4)) { - /* Promise SX8 "sx8/0{p1} */ - int d, p, e; - d = p = 0; - e = sscanf(devName + 4, "%dp%d", &d, &p); - type = S_IFBLK; - major = 160 + (d/8); /* controller */ - minor = (d % 8) * 32; /* disk */ - minor += p; /* partition */ - } else if (!strncmp(devName, "i2o/", 4)) { - /* I2O Block Device "i2o/hda */ - type = S_IFBLK; - major = 80; /* controller */ - minor = (devName[6] - 'a')*16; - if ((devName[7]) && isdigit(devName[7])) - { - minor = minor + atoi(devName + 7); - } - } else if (!strncmp(devName, "iseries/vcd", 11)) { - /* IBM virtual cdrom (iseries) */ - type = S_IFBLK; - major = 113; - minor = devName[11] - 'a'; - } else if (!strncmp(devName, "iseries/vd", 10)) { - int drive = 0; - char * num = NULL; - - /* IBM virtual disk (iseries) */ - type = S_IFBLK; - major = 112; - - if (devName[11] && isdigit(devName[11])) { - drive = devName[10] - 'a'; - num = devName + 11; - } else if (devName[11] && islower(devName[11])) { - drive = ((devName[10] - 'a' + 1) * 26) + devName[11] - 'a'; - num = devName + 12; - } else { - drive = devName[10] - 'a'; - } - - minor = (drive * 8); - if (num && num[0]) - minor += (num[0] - '0'); - } else { - for (i = 0; i < numDevices; i++) { - if (!strcmp(devices[i].name, devName)) break; - } - if (i == numDevices) return -1; - major = devices[i].major; - minor = devices[i].minor; - - if (devices[i].isChar) - type = S_IFCHR; - else - type = S_IFBLK; - } - - ptr = path; - i = 0; - while (*ptr) - if (*ptr++ == '/') - i++; - if (i > 2) { - dir = alloca(strlen(path) + 1); - strcpy(dir, path); - ptr = dir + (strlen(path) - 1); - while (*ptr != '/') - *ptr-- = '\0'; - mkdir(dir, 0644); - } - - unlink(path); - if (mknod(path, type | 0600, makedev(major, minor)) < 0) - return -2; - - return 0; -} diff --git a/isys/isys.c b/isys/isys.c index dd22669..4f9b48c 100644 --- a/isys/isys.c +++ b/isys/isys.c @@ -68,7 +68,6 @@ static PyObject * doGetOpt(PyObject * s, PyObject * args); static PyObject * doRmmod(PyObject * s, PyObject * args);*/ static PyObject * doMount(PyObject * s, PyObject * args); static PyObject * doUMount(PyObject * s, PyObject * args); -static PyObject * makeDevInode(PyObject * s, PyObject * args); static PyObject * smpAvailable(PyObject * s, PyObject * args); static PyObject * htAvailable(PyObject * s, PyObject * args); static PyObject * doSwapon(PyObject * s, PyObject * args); @@ -131,7 +130,6 @@ static PyMethodDef isysModuleMethods[] = { { "unlosetup", (PyCFunction) doUnLoSetup, METH_VARARGS, NULL }, { "ddfile", (PyCFunction) doDdFile, METH_VARARGS, NULL }, { "getopt", (PyCFunction) doGetOpt, METH_VARARGS, NULL }, - { "mkdevinode", (PyCFunction) makeDevInode, METH_VARARGS, NULL }, { "mount", (PyCFunction) doMount, METH_VARARGS, NULL }, { "smpavailable", (PyCFunction) smpAvailable, METH_VARARGS, NULL }, { "htavailable", (PyCFunction) htAvailable, METH_VARARGS, NULL }, @@ -170,23 +168,6 @@ static PyMethodDef isysModuleMethods[] = { { NULL, NULL, 0, NULL } } ; -static PyObject * makeDevInode(PyObject * s, PyObject * args) { - char * devName, * where; - - if (!PyArg_ParseTuple(args, "ss", &devName, &where)) return NULL; - - switch (devMakeInode(devName, where)) { - case -1: - PyErr_SetString(PyExc_TypeError, "unknown device"); - case -2: - PyErr_SetFromErrno(PyExc_SystemError); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - static PyObject * doDdFile(PyObject * s, PyObject * args) { int fd; int megs; diff --git a/isys/isys.h b/isys/isys.h index d49dc2d..3af91fd 100644 --- a/isys/isys.h +++ b/isys/isys.h @@ -9,9 +9,6 @@ #define EARLY_SWAP_RAM 270000 #endif -/* returns -2 for errno, -1 for unknown device */ -int devMakeInode(char * devName, char * path); - int insmod(char * modName, char * path, char ** args); int rmmod(char * modName); diff --git a/isys/isys.py b/isys/isys.py old mode 100644 new mode 100755 index eb0b4cb..c36febf --- a/isys/isys.py +++ b/isys/isys.py @@ -598,30 +598,6 @@ def getDasdState(dev): return 0 -## Create a device node. -# This method creates a device node, optionally in a directory tree other than -# /dev. Do not create device nodes in /tmp as we are trying to move away from -# using /tmp for anything other than temporary data. -# -# @param name The basename of the device node. -# @param fn An optional directory to create the new device node in. -# @return The path of the created device node. -def makeDevInode(name, fn=None): - if fn: - if fn.startswith("/tmp"): - warnings.warn("device node created in /tmp", stacklevel=2) - if os.path.exists(fn): - return fn - _isys.mkdevinode(name, fn) - return fn - path = '/dev/%s' % (name,) - try: - os.stat(path) - except OSError: - path = '/dev/%s' % (name,) - _isys.mkdevinode(name, path) - return path - ## Calculate the broadcast address of a network. # @param ip An IPv4 address as a string. # @param nm A corresponding netmask as a string. diff --git a/iutil.py b/iutil.py index ffe5d9b..f9f15bb 100644 --- a/iutil.py +++ b/iutil.py @@ -286,90 +286,6 @@ def copyDeviceNode(src, dest): os.mknod(dest, mode | type, filestat.st_rdev) -## Create the device mapper control node. -# @param root The root of the filesystem to create the device node in. -def makeDMNode(root="/"): - major = minor = None - - for (fn, devname, val) in ( ("/proc/devices", "misc", "major"), - ("/proc/misc", "device-mapper", "minor") ): - f = open(fn) - lines = f.readlines() - f.close() - for line in lines: - try: - (num, dev) = line.strip().split(" ") - except: - continue - if dev == devname: - s = "%s = int(num)" %(val,) - exec s - break - -# print "major is %s, minor is %s" %(major, minor) - if major is None or minor is None: - return - mkdirChain(root + "/dev/mapper") - try: - os.mknod(root + "/dev/mapper/control", stat.S_IFCHR | 0600, - os.makedev(major, minor)) - except: - pass - -## Make some miscellaneous character device nodes. -def makeCharDeviceNodes(): - for dev in ["input/event0", "input/event1", "input/event2", "input/event3"]: - isys.makeDevInode(dev, "/dev/%s" % (dev,)) - -## Make the device nodes for all the drives in the system. -def makeDriveDeviceNodes(): - hardDrives = isys.hardDriveDict() - for drive in hardDrives.keys(): - if drive.startswith("mapper"): - continue - isys.makeDevInode(drive, "/dev/%s" % (drive,)) - - if drive.startswith("hd"): - num = 32 - elif drive.startswith("dasd"): - num = 4 - else: - num = 16 - - if (drive.startswith("cciss") or drive.startswith("ida") or - drive.startswith("rd") or drive.startswith("sx8")): - sep = "p" - else: - sep = "" - - for i in range(1, num): - dev = "%s%s%d" % (drive, sep, i) - isys.makeDevInode(dev, "/dev/%s" % (dev,)) - - cdroms = isys.cdromList() - for drive in cdroms: - isys.makeDevInode(drive, "/dev/%s" % (drive,)) - - tapeDrives = isys.tapeDriveList() - for drive in tapeDrives: - # make all tape device variants (stX,stXl,stXm,stXa,nstX,nstXl,nstXm,nstXa) - for prefix in ("", "n"): - for postfix in ("", "l", "m", "a"): - device = "%s%s%s" % (prefix, drive, postfix) - isys.makeDevInode(device, "/dev/%s" % (device,)) - - for mdMinor in range(0, 32): - md = "md%d" %(mdMinor,) - isys.makeDevInode(md, "/dev/%s" %(md,)) - - # make the node for the device mapper - makeDMNode() - - # make loop devices - for loopMinor in range(0, 8): - loop = "loop%d" %(loopMinor,) - isys.makeDevInode(loop, "/dev/%s" %(loop,)) - ## Determine if the hardware supports iSeries storage devices. # @return 1 if so, 0 otherwise. def hasiSeriesNativeStorage(): -- 1.5.3.4 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list