diff options
Diffstat (limited to 'isys')
-rw-r--r-- | isys/isys.c | 12 | ||||
-rw-r--r-- | isys/isys.py | 20 | ||||
-rw-r--r-- | isys/nfsmount.c | 4 | ||||
-rw-r--r-- | isys/smp.c | 76 | ||||
-rw-r--r-- | isys/smp.h | 1 |
5 files changed, 80 insertions, 33 deletions
diff --git a/isys/isys.c b/isys/isys.c index 9016f0509..7705fa49c 100644 --- a/isys/isys.c +++ b/isys/isys.c @@ -62,6 +62,7 @@ static PyObject * getModuleList(PyObject * s, PyObject * args); static PyObject * makeDevInode(PyObject * s, PyObject * args); static PyObject * doMknod(PyObject * s, PyObject * args); static PyObject * smpAvailable(PyObject * s, PyObject * args); +static PyObject * htAvailable(PyObject * s, PyObject * args); static PyObject * createProbedList(PyObject * s, PyObject * args); static PyObject * doChroot(PyObject * s, PyObject * args); static PyObject * doCheckBoot(PyObject * s, PyObject * args); @@ -127,6 +128,7 @@ static PyMethodDef isysModuleMethods[] = { */ { "mount", (PyCFunction) doMount, METH_VARARGS, NULL }, { "smpavailable", (PyCFunction) smpAvailable, METH_VARARGS, NULL }, + { "htavailable", (PyCFunction) htAvailable, METH_VARARGS, NULL }, { "umount", (PyCFunction) doUMount, METH_VARARGS, NULL }, { "confignetdevice", (PyCFunction) doConfigNetDevice, METH_VARARGS, NULL }, { "pumpnetdevice", (PyCFunction) doPumpNetDevice, METH_VARARGS, NULL }, @@ -764,11 +766,17 @@ static PyObject * smpAvailable(PyObject * s, PyObject * args) { if (!PyArg_ParseTuple(args, "")) return NULL; - result = detectSMP(); - return Py_BuildValue("i", detectSMP()); } +static PyObject * htAvailable(PyObject * s, PyObject * args) { + int result; + + if (!PyArg_ParseTuple(args, "")) return NULL; + + return Py_BuildValue("i", detectHT()); +} + void init_isys(void) { PyObject * m, * d; diff --git a/isys/isys.py b/isys/isys.py index a02bd4831..6cb874901 100644 --- a/isys/isys.py +++ b/isys/isys.py @@ -51,8 +51,9 @@ def raidstop(mdDevice): os.remove("/tmp/md") try: _isys.raidstop(fd) - finally: - os.close(fd) + except: + pass + os.close(fd) def raidstart(mdDevice, aMember): if raidCount.has_key(mdDevice) and raidCount[mdDevice]: @@ -67,17 +68,20 @@ def raidstart(mdDevice, aMember): os.remove("/tmp/md") try: _isys.raidstart(fd, "/tmp/member") - finally: - os.close(fd) - os.remove("/tmp/member") + except: + pass + os.close(fd) + os.remove("/tmp/member") def raidsb(mdDevice): makeDevInode(mdDevice, "/tmp/md") fd = os.open("/tmp/md", os.O_RDONLY) + rc = 0 try: rc = _isys.getraidsb(fd) - finally: - os.close(fd) + except: + pass + os.close(fd) return rc def losetup(device, file, readOnly = 0): @@ -177,6 +181,8 @@ def umount(what, removeDir = 1): def smpAvailable(): return _isys.smpavailable() +htavailable = _isys.htavailable + def chroot (path): return _isys.chroot (path) diff --git a/isys/nfsmount.c b/isys/nfsmount.c index 9a5624032..1b2ec1cea 100644 --- a/isys/nfsmount.c +++ b/isys/nfsmount.c @@ -600,8 +600,8 @@ int nfsmount(const char *spec, const char *node, int *flags, mountport); if (pm_mnt == NULL) { - fprintf(stderr, "mount: cannot access portmapper on %s: %s\n", - hostname, strerror (errno)); + /* fprintf(stderr, "mount: cannot access portmapper on %s: %s\n", + hostname, strerror (errno));*/ goto fail; } diff --git a/isys/smp.c b/isys/smp.c index 7559ea6d4..dc6213324 100644 --- a/isys/smp.c +++ b/isys/smp.c @@ -13,6 +13,7 @@ #include <sys/mman.h> #include <string.h> #include <errno.h> +#include <sys/types.h> #ifdef DIET typedef unsigned short u_short; @@ -255,28 +256,7 @@ static int intelDetectSMP(void) mpfps_t mpfps; int rc = 0; int ncpus = 0; - FILE *f; - - f = fopen("/proc/cpuinfo", "r"); - if (f) { - char buff[1024]; - - while (fgets (buff, 1024, f) != NULL) { - if (!strncmp (buff, "flags\t\t:", 8)) { - if (strstr(buff, " ht ") || - /* buff includes \n, so back up 4 bytes from the end - and check there too to catch the end case */ - !strncmp(buff + strlen(buff) - 4, " ht", 3)) { - rc = 1; - } - break; - } - } - fclose(f); - } - if (rc) - return 1; - + /* open physical memory for access to MP structures */ if ( (pfd = open( "/dev/mem", O_RDONLY )) < 0 ) { return 0; @@ -510,6 +490,58 @@ readEntry( void* entry, int size ) } } +#endif /* __i386__ */ + +#ifdef __i386__ + +static inline void cpuid(int op, int *eax, int *ebx, int *ecx, int *edx) +{ + __asm__("pushl %%ebx; cpuid; movl %%ebx,%1; popl %%ebx" + : "=a"(*eax), "=g"(*ebx), "=&c"(*ecx), "=&d"(*edx) + : "a" (op)); +} + +int detectHT(void) +{ + FILE *f; + int htflag = 0; + unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0; + int smp_num_siblings = 0; + + f = fopen("/proc/cpuinfo", "r"); + if (f) { + char buff[1024]; + + while (fgets (buff, 1024, f) != NULL) { + if (!strncmp (buff, "flags\t\t:", 8)) { + if (strstr(buff, " ht ") || + /* buff includes \n, so back up 4 bytes from the end + and check there too to catch the end case */ + !strncmp(buff + strlen(buff) - 4, " ht", 3)) { + htflag = 1; + } + break; + } + } + fclose(f); + } + if (!htflag) + return 0; + + cpuid(1, &eax, &ebx, &ecx, &edx); + smp_num_siblings = (ebx & 0xff0000) >> 16; + + if (smp_num_siblings == 2) + return 1; + return 0; +} + +#else /* ndef __i386__ */ + +int detectHT(void) +{ + return 0; +} #endif /* __i386__ */ diff --git a/isys/smp.h b/isys/smp.h index 3255cc489..e03726826 100644 --- a/isys/smp.h +++ b/isys/smp.h @@ -2,5 +2,6 @@ #define SMP_H int detectSMP(void); +int detectHT(void); #endif /* SMP_H */ |