diff options
author | Erik Troan <ewt@redhat.com> | 2000-01-01 15:43:41 +0000 |
---|---|---|
committer | Erik Troan <ewt@redhat.com> | 2000-01-01 15:43:41 +0000 |
commit | 077b49adce61105fd608933e227866f597a382a6 (patch) | |
tree | 051c812fb213cf130e03e8c1862429436f3b0f56 /isys | |
parent | c196d404837425aebfa5e32a0ffa4ec36f2c83cb (diff) | |
download | anaconda-077b49adce61105fd608933e227866f597a382a6.tar.gz anaconda-077b49adce61105fd608933e227866f597a382a6.tar.xz anaconda-077b49adce61105fd608933e227866f597a382a6.zip |
1) don't use librpm any more
2) added code to check for free space in a filesystem
Diffstat (limited to 'isys')
-rw-r--r-- | isys/Makefile | 6 | ||||
-rw-r--r-- | isys/cpio.c | 9 | ||||
-rw-r--r-- | isys/cpio.h | 89 | ||||
-rw-r--r-- | isys/isys.c | 23 | ||||
-rw-r--r-- | isys/isys.py | 10 | ||||
-rw-r--r-- | isys/otherinsmod.c | 7 |
6 files changed, 97 insertions, 47 deletions
diff --git a/isys/Makefile b/isys/Makefile index 56c76c1e6..097ee4b31 100644 --- a/isys/Makefile +++ b/isys/Makefile @@ -2,12 +2,12 @@ include ../Makefile.inc ARCH := $(patsubst i%86,i386,$(shell uname -m)) ARCH := $(patsubst sparc%,sparc,$(ARCH)) -CFLAGS = -I/usr/include/python1.5 -I.. -g -I/usr/include/rpm +CFLAGS = -I/usr/include/python1.5 -I.. -g OBJECTS = nfsmount.o dns.o mount_clnt.o mount_xdr.o imount.o \ - smp.o moduleinfo.o devnodes.o cpio.o probe.o + smp.o moduleinfo.o devnodes.o cpio.o probe.o uncpio.o STATICOBJS = otherinsmod.o STATICLIBS = ../kudzu/kudzumodule.so -LOADLIBES = -lrpm -lbz2 -lresolv -lz -lpci -lpopt +LOADLIBES = -lbz2 -lresolv -lz -lpci -lpopt SUBDIRS = modutils pci #PYTHONLIBDIR = $(DESTDIR)/Pusr/lib/python1.5/site-packages PYMODULES = _isys.so diff --git a/isys/cpio.c b/isys/cpio.c index 87631d8f6..cf8adc8c0 100644 --- a/isys/cpio.c +++ b/isys/cpio.c @@ -7,11 +7,10 @@ #include "cpio.h" -int installCpioFile(FD_t fd, char * cpioName, char * outName, int inWin) { +int installCpioFile(gzFile fd, char * cpioName, char * outName, int inWin) { struct cpioFileMapping map; int rc; const char * failedFile; - FD_t cfd; if (outName) { map.archivePath = cpioName; @@ -19,12 +18,8 @@ int installCpioFile(FD_t fd, char * cpioName, char * outName, int inWin) { map.mapFlags = CPIO_MAP_PATH; } - (void) Fflush(fd); - cfd = Fdopen(fdDup(Fileno(fd)), "r.gzdio"); - - rc = cpioInstallArchive(cfd, outName ? &map : NULL, 1, NULL, NULL, + rc = cpioInstallArchive(fd, outName ? &map : NULL, 1, NULL, NULL, &failedFile); - Fclose(cfd); if (rc || access(outName, R_OK)) { return -1; diff --git a/isys/cpio.h b/isys/cpio.h index 2ee92f1ce..07160bd27 100644 --- a/isys/cpio.h +++ b/isys/cpio.h @@ -2,18 +2,44 @@ #define H_CPIO #include <zlib.h> -#define HAVE_ZLIB_H 1 -#include <glob.h> /* XXX rpmlib.h */ -#include <dirent.h> /* XXX rpmlib.h */ +#include <sys/types.h> -#define HAVE_LIBIO 1 -#include <rpmlib.h> +/* Note the CPIO_CHECK_ERRNO bit is set only if errno is valid. These have to + be positive numbers or this setting the high bit stuff is a bad idea. */ +#define CPIOERR_CHECK_ERRNO 0x80000000 -#define CPIO_MAP_PATH (1 << 0) -#define CPIO_MAP_MODE (1 << 1) -#define CPIO_MAP_UID (1 << 2) -#define CPIO_MAP_GID (1 << 3) -#define CPIO_FOLLOW_SYMLINKS (1 << 4) /* only for building */ +#define CPIOERR_BAD_MAGIC (2 ) +#define CPIOERR_BAD_HEADER (3 ) +#define CPIOERR_OPEN_FAILED (4 | CPIOERR_CHECK_ERRNO) +#define CPIOERR_CHMOD_FAILED (5 | CPIOERR_CHECK_ERRNO) +#define CPIOERR_CHOWN_FAILED (6 | CPIOERR_CHECK_ERRNO) +#define CPIOERR_WRITE_FAILED (7 | CPIOERR_CHECK_ERRNO) +#define CPIOERR_UTIME_FAILED (8 | CPIOERR_CHECK_ERRNO) +#define CPIOERR_UNLINK_FAILED (9 | CPIOERR_CHECK_ERRNO) + +#define CPIOERR_SYMLINK_FAILED (11 | CPIOERR_CHECK_ERRNO) +#define CPIOERR_STAT_FAILED (12 | CPIOERR_CHECK_ERRNO) +#define CPIOERR_MKDIR_FAILED (13 | CPIOERR_CHECK_ERRNO) +#define CPIOERR_MKNOD_FAILED (14 | CPIOERR_CHECK_ERRNO) +#define CPIOERR_MKFIFO_FAILED (15 | CPIOERR_CHECK_ERRNO) +#define CPIOERR_LINK_FAILED (16 | CPIOERR_CHECK_ERRNO) +#define CPIOERR_READLINK_FAILED (17 | CPIOERR_CHECK_ERRNO) +#define CPIOERR_READ_FAILED (18 | CPIOERR_CHECK_ERRNO) +#define CPIOERR_COPY_FAILED (19 | CPIOERR_CHECK_ERRNO) +#define CPIOERR_INTERNAL (20 ) +#define CPIOERR_HDR_SIZE (21 ) +#define CPIOERR_UNKNOWN_FILETYPE (22 ) + + +/* Don't think this behaves just like standard cpio. It's pretty close, but + it has some behaviors which are more to RPM's liking. I tried to document + them inline in cpio.c, but I may have missed some. */ + +#define CPIO_MAP_PATH (1 << 0) +#define CPIO_MAP_MODE (1 << 1) +#define CPIO_MAP_UID (1 << 2) +#define CPIO_MAP_GID (1 << 3) +#define CPIO_FOLLOW_SYMLINKS (1 << 4) /* only for building */ struct cpioFileMapping { char * archivePath; @@ -27,37 +53,32 @@ struct cpioFileMapping { /* on cpio building, only "file" is filled in */ struct cpioCallbackInfo { char * file; - long fileSize; /* total file size */ - long fileComplete; /* amount of file unpacked */ - long bytesProcessed; /* bytes in archive read */ + long fileSize; /* total file size */ + long fileComplete; /* amount of file unpacked */ + long bytesProcessed; /* bytes in archive read */ }; -typedef struct CFD { - union { - FD_t _cfdu_fd; -#define cpioFd _cfdu._cfdu_fd - FILE * _cfdu_fp; -#define cpioFp _cfdu._cfdu_fp - FD_t _cfdu_gzfd; -#define cpioGzFd _cfdu._cfdu_gzfd - } _cfdu; - int cpioPos; - enum cpioIoType { - cpioIoTypeDebug, - cpioIoTypeFd, - cpioIoTypeFp, - cpioIoTypeGzFd, - } cpioIoType; -} CFD_t; - typedef void (*cpioCallback)(struct cpioCallbackInfo * filespec, void * data); -/* librpm provides these */ -int cpioInstallArchive(FD_t cfd, struct cpioFileMapping * mappings, +/* If no mappings are passed, this installs everything! If one is passed + it should be sorted according to cpioFileMapCmp() and only files included + in the map are installed. Files are installed relative to the current + directory unless a mapping is given which specifies an absolute + directory. The mode mapping is only used for the permission bits, not + for the file type. The owner/group mappings are ignored for the nonroot + user. If *failedFile is non-NULL on return, it should be free()d. */ +int cpioInstallArchive(gzFile stream, struct cpioFileMapping * mappings, int numMappings, cpioCallback cb, void * cbData, const char ** failedFile); +int cpioBuildArchive(int fd, struct cpioFileMapping * mappings, + int numMappings, cpioCallback cb, void * cbData, + unsigned int * archiveSize, char ** failedFile); + +/* This is designed to be qsort/bsearch compatible */ +int cpioFileMapCmp(const void * a, const void * b); + const char *cpioStrerror(int rc); -int installCpioFile(FD_t fd, char * cpioName, char * outName, int inWin); +int installCpioFile(gzFile fd, char * cpioName, char * outName, int inWin); #endif diff --git a/isys/isys.c b/isys/isys.c index 729574eac..b4c612fc2 100644 --- a/isys/isys.c +++ b/isys/isys.c @@ -6,6 +6,7 @@ #include <sys/mount.h> #include <sys/stat.h> #include <sys/time.h> +#include <sys/vfs.h> #include <unistd.h> #include "Python.h" @@ -47,12 +48,20 @@ static PyObject * doLoSetup(PyObject * s, PyObject * args); static PyObject * doUnLoSetup(PyObject * s, PyObject * args); static PyObject * doDdFile(PyObject * s, PyObject * args); static PyObject * doGetRaidSuperblock(PyObject * s, PyObject * args); +<<<<<<< isys.c +static PyObject * doDevSpaceFree(PyObject * s, PyObject * args); +======= static PyObject * doRaidStart(PyObject * s, PyObject * args); static PyObject * doRaidStop(PyObject * s, PyObject * args); +>>>>>>> 1.30 static PyMethodDef isysModuleMethods[] = { +<<<<<<< isys.c + { "devSpaceFree", (PyCFunction) doDevSpaceFree, METH_VARARGS, NULL }, +======= { "raidstop", (PyCFunction) doRaidStop, METH_VARARGS, NULL }, { "raidstart", (PyCFunction) doRaidStart, METH_VARARGS, NULL }, +>>>>>>> 1.30 { "getraidsb", (PyCFunction) doGetRaidSuperblock, METH_VARARGS, NULL }, { "losetup", (PyCFunction) doLoSetup, METH_VARARGS, NULL }, { "unlosetup", (PyCFunction) doUnLoSetup, METH_VARARGS, NULL }, @@ -948,6 +957,20 @@ static PyObject * doGetRaidSuperblock(PyObject * s, PyObject * args) { sb.raid_disks, sb.md_minor); } +static PyObject * doDevSpaceFree(PyObject * s, PyObject * args) { + char * path; + struct statfs sb; + + if (!PyArg_ParseTuple(args, "s", &path)) return NULL; + + if (statfs(path, &sb)) { + PyErr_SetFromErrno(PyExc_SystemError); + return NULL; + } + + return Py_BuildValue("i", sb.f_bfree * (sb.f_bsize / 1024) / (1024)); +} + static PyObject * doRaidStop(PyObject * s, PyObject * args) { int fd; diff --git a/isys/isys.py b/isys/isys.py index 374282c35..957f0fde2 100644 --- a/isys/isys.py +++ b/isys/isys.py @@ -3,6 +3,15 @@ import _isys import string import os +def spaceAvailable(device, fsystem = "ext2"): + makeDevInode(device, "/tmp/spaceDev") + mount("/tmp/spaceDev", "/mnt/space", fstype = fsystem) + space = _isys.devSpaceFree("/mnt/space/.") + umount("/mnt/space") + os.rmdir("/mnt/space") + os.remove("/tmp/spaceDev") + return space + def raidstop(mdDevice): makeDevInode(mdDevice, "/tmp/md") fd = os.open("/tmp/md", os.O_RDONLY) @@ -26,6 +35,7 @@ def raidsb(mdDevice): os.close(fd) return rc +>>>>>>> 1.24 def losetup(device, file): loop = os.open(device, os.O_RDONLY) targ = os.open(file, os.O_RDWR) diff --git a/isys/otherinsmod.c b/isys/otherinsmod.c index 256fbc19c..5eb65d1bd 100644 --- a/isys/otherinsmod.c +++ b/isys/otherinsmod.c @@ -3,6 +3,7 @@ #include <unistd.h> #include <zlib.h> #include <fcntl.h> +#include <stdlib.h> #include <sys/utsname.h> #include <sys/wait.h> @@ -18,7 +19,7 @@ int ourInsmodCommand(int argc, char ** argv) { char * file; char finalName[100]; char * chptr; - FD_t fd; + gzFile fd; int rc, rmObj = 0; int sparc64 = 0, i; char * ballPath = NULL; @@ -56,8 +57,8 @@ int ourInsmodCommand(int argc, char ** argv) { /* Try two balls on sparc64, one elsewhere */ for (i = 0; ; i++) { /* it might be having a ball */ - fd = Fopen(ballPath, "r.fdio"); - if (!fd || Ferror(fd)) { + fd = gzopen(ballPath, "r"); + if (!fd) { free(ballPath); return 1; } |