summaryrefslogtreecommitdiffstats
path: root/collage/commands.c
diff options
context:
space:
mode:
authorErik Troan <ewt@redhat.com>1999-08-18 01:35:39 +0000
committerErik Troan <ewt@redhat.com>1999-08-18 01:35:39 +0000
commit4fc43c11458e7a6f060ea38becbad6b9e43f38bf (patch)
tree5a77c7b3143555ea7df4be39306d32f59caf4dad /collage/commands.c
parentff20a29f09015ff6053530bc4baa4089a18d1eac (diff)
downloadanaconda-4fc43c11458e7a6f060ea38becbad6b9e43f38bf.tar.gz
anaconda-4fc43c11458e7a6f060ea38becbad6b9e43f38bf.tar.xz
anaconda-4fc43c11458e7a6f060ea38becbad6b9e43f38bf.zip
added df
Diffstat (limited to 'collage/commands.c')
-rw-r--r--collage/commands.c59
1 files changed, 58 insertions, 1 deletions
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;