From ea6e33f5a11185286c464305f6ef408ff8ff8b93 Mon Sep 17 00:00:00 2001 From: nima Date: Fri, 19 Dec 2008 13:49:19 +0000 Subject: More testing and fixes. git-svn-id: svn://svn.autonomy.net.au/python-dmidecode@127 abc39116-655e-4be6-ad55-d661dc543056 --- src/dmidecodemodule.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/dmidecodemodule.c b/src/dmidecodemodule.c index 3214308..e873c6c 100644 --- a/src/dmidecodemodule.c +++ b/src/dmidecodemodule.c @@ -157,9 +157,13 @@ static PyObject* dmidecode_get_type(PyObject *self, PyObject *args) { return Py_None; } -static PyObject* dmidecode_dump(PyObject *self, PyObject *args) { - const char *f = PyString_AsString(opt.dumpfile); - if((access(f, F_OK) != 0) || (access(f, W_OK) == 0)) +static PyObject* dmidecode_dump(PyObject *self, PyObject *null) { + const char *f; + f = opt.dumpfile ? PyString_AsString(opt.dumpfile) : opt.devmem; + struct stat buf; + stat(f, &buf); + + if((access(f, F_OK) != 0) || ((access(f, W_OK) == 0) && S_ISREG(buf.st_mode))) if(dump(PyString_AS_STRING(opt.dumpfile))) Py_RETURN_TRUE; Py_RETURN_FALSE; -- cgit