diff options
author | Erik Troan <ewt@redhat.com> | 1999-08-18 01:35:39 +0000 |
---|---|---|
committer | Erik Troan <ewt@redhat.com> | 1999-08-18 01:35:39 +0000 |
commit | 4fc43c11458e7a6f060ea38becbad6b9e43f38bf (patch) | |
tree | 5a77c7b3143555ea7df4be39306d32f59caf4dad /collage | |
parent | ff20a29f09015ff6053530bc4baa4089a18d1eac (diff) | |
download | anaconda-4fc43c11458e7a6f060ea38becbad6b9e43f38bf.tar.gz anaconda-4fc43c11458e7a6f060ea38becbad6b9e43f38bf.tar.xz anaconda-4fc43c11458e7a6f060ea38becbad6b9e43f38bf.zip |
added df
Diffstat (limited to 'collage')
-rw-r--r-- | collage/Makefile | 5 | ||||
-rw-r--r-- | collage/collage.c | 1 | ||||
-rw-r--r-- | collage/commands.c | 59 | ||||
-rw-r--r-- | collage/commands.h | 1 |
4 files changed, 65 insertions, 1 deletions
diff --git a/collage/Makefile b/collage/Makefile index d1224990c..359ce501d 100644 --- a/collage/Makefile +++ b/collage/Makefile @@ -5,3 +5,8 @@ LOADLIBES = -L../isys -lpopt -lz -lisys -lresolv -lrpm all: collage collage: collage.o commands.o idmap.o ls.o + +install: + install -s collage $(DESTDIR)/usr/bin + (a=`pwd`; cd $(DESTDIR)/usr/bin; ./collage | \ + $$a/mkcollagelinks collage) diff --git a/collage/collage.c b/collage/collage.c index ddc4ae28e..1b0d01764 100644 --- a/collage/collage.c +++ b/collage/collage.c @@ -9,6 +9,7 @@ struct commandTableEntry { }; struct commandTableEntry commandTable[] = { + { "df", dfCommand }, { "umount", umountCommand }, { "mount", mountCommand }, { "mkdir", mkdirCommand }, diff --git a/collage/commands.c b/collage/commands.c index 5dde54a64..111ad0daa 100644 --- a/collage/commands.c +++ b/collage/commands.c @@ -8,6 +8,7 @@ #include <asm/page.h> #include <sys/swap.h> #include <sys/sysmacros.h> +#include <sys/statfs.h> #include <unistd.h> #include <zlib.h> @@ -18,6 +19,7 @@ #include "idmap.h" #include "ls.h" #include "popt.h" +#include "../isys/cpio.h" static int copyfd(int to, int from); @@ -299,19 +301,74 @@ int chmodCommand(int argc, char ** argv) { return 0; } +#define CPIOERR_CHECK_ERRNO 0x00008000 + int uncpioCommand(int argc, char ** argv) { int rc; char * fail; + CFD_t cfd; if (argc != 1) { fprintf(stderr, "uncpio reads from stdin"); return 1; } - rc = cpioInstallArchive(gzdopen(0, "r"), NULL, 0, NULL, NULL, &fail); + cfd.cpioPos = 0; + cfd.cpioIoType = cpioIoTypeGzFd; + cfd.cpioGzFd = gzdFdopen(fdDup(0), "r"); + + rc = cpioInstallArchive(&cfd, NULL, 0, NULL, NULL, &fail); + + if (rc) { + fprintf(stderr, "cpio failed on %s: ", fail); + if (rc & CPIOERR_CHECK_ERRNO) + fprintf(stderr, "%s\n", strerror(errno)); + else + fprintf(stderr, "(internal)\n"); + } + return (rc != 0); } +int dfCommand(int argc, char ** argv) { + int fd; + char * buf = alloca(2048); + char * end; + struct statfs fs; + int i; + + if ((fd = open("/proc/mounts", O_RDONLY)) < 0) { + perror("failed to open /proc/mounts"); + return 1; + } + + i = read(fd, buf, 2048); + buf[i] = '\0'; + + printf("%-30s %-10s %-10s %-10s\n", + "Mount Point", "1k-blocks", "Used", "Available"); + + while (buf && *buf) { + end = strchr(buf, ' '); + if (!end) return 1; + buf = end + 1; + + end = strchr(buf, ' '); + if (!end) return 1; + *end = '\0'; + + statfs(buf, &fs); + + printf("%-30s %-10d %-10d %-10d\n", + buf, fs.f_blocks, fs.f_blocks - fs.f_bfree, fs.f_bfree); + + buf = strchr(end + 1, '\n'); + if (buf) buf++; + } + + return 0; +} + int lsCommand(int argc, char ** argv) { poptContext optCon; int flags = 0; diff --git a/collage/commands.h b/collage/commands.h index 0b9172b0e..b4ce97353 100644 --- a/collage/commands.h +++ b/collage/commands.h @@ -3,6 +3,7 @@ int catCommand(int argc, char ** argv); int chmodCommand(int argc, char ** argv); +int dfCommand(int argc, char ** argv); int lsmodCommand(int argc, char ** argv); int mkdirCommand(int argc, char ** argv); int mknodCommand(int argc, char ** argv); |