summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--collage/.cvsignore2
-rw-r--r--collage/Makefile34
-rw-r--r--collage/collage.c37
-rw-r--r--collage/commands.c218
-rw-r--r--collage/commands.h9
-rw-r--r--collage/linux_fs.h151
-rwxr-xr-xcollage/mkcollagelinks6
-rw-r--r--collage/mount_by_label.c236
-rw-r--r--collage/mount_by_label.h3
9 files changed, 0 insertions, 696 deletions
diff --git a/collage/.cvsignore b/collage/.cvsignore
deleted file mode 100644
index f48ff87be..000000000
--- a/collage/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-collage
-.depend
diff --git a/collage/Makefile b/collage/Makefile
deleted file mode 100644
index 0c7ebab57..000000000
--- a/collage/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-include ../Makefile.inc
-
-ISYSLIB=isys
-
-CFLAGS = -Wall -g -O2
-LDFLAGS = -g
-LOADLIBES = -L../isys -L../isys/gzlib -l$(ISYSLIB) -lgunzip -lresolv -lz
-
-ifeq (.depend,$(wildcard .depend))
-TARGET=all
-else
-TARGET=depend all
-endif
-
-everything: $(TARGET)
-
-all: collage
-
-collage: collage.o commands.o mount_by_label.o
-
-install:
- mkdir -p $(DESTDIR)/$(RUNTIMEDIR)
- install -s collage $(DESTDIR)/$(RUNTIMEDIR)
- install mkcollagelinks $(DESTDIR)/$(RUNTIMEDIR)
-
-clean:
- rm -f collage *.o
-
-depend:
- $(CPP) -M $(CFLAGS) *.c > .depend
-
-ifeq (.depend,$(wildcard .depend))
-include .depend
-endif
diff --git a/collage/collage.c b/collage/collage.c
deleted file mode 100644
index 5bb7595e7..000000000
--- a/collage/collage.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-
-#include "commands.h"
-
-struct commandTableEntry {
- char * name;
- int (*fn)(int argc, char ** argv);
-};
-
-struct commandTableEntry commandTable[] = {
- { "mknod", mknodCommand },
- /* { "umount", umountCommand },
- { "mount", mountCommand },*/
- { "uncpio", uncpioCommand },
- { NULL, NULL }
-};
-
-int main (int argc, char ** argv) {
- int len = strlen(argv[0]);
- struct commandTableEntry * cmd;
-
- for (cmd = commandTable; cmd->name; cmd++) {
- if (!strcmp(argv[0] + len - strlen(cmd->name), cmd->name))
- break;
- }
-
- if (cmd->name)
- return cmd->fn(argc, argv);
-
- printf("collage may be run as:\n");
- for (cmd = commandTable; cmd->name; cmd++)
- printf("\t%s\n", cmd->name);
-
- return 1;
-}
-
diff --git a/collage/commands.c b/collage/commands.c
deleted file mode 100644
index 802c90a5f..000000000
--- a/collage/commands.c
+++ /dev/null
@@ -1,218 +0,0 @@
-#include <errno.h>
-#include <fcntl.h>
-#include <netdb.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <asm/page.h>
-#include <sys/swap.h>
-#include <sys/sysmacros.h>
-#include <sys/statfs.h>
-#include <unistd.h>
-
-#include "../isys/imount.h"
-#include "../isys/isys.h"
-
-#include "commands.h"
-#include "mount_by_label.h"
-#include "../isys/cpio.h"
-
-int mygethostbyname(char * host, struct in_addr * address) {
- struct hostent * hostinfo;
-
- hostinfo = gethostbyname(host);
- if (!hostinfo) return 1;
-
- memcpy(address, hostinfo->h_addr_list[0], hostinfo->h_length);
- return 0;
-}
-
-static int copyfd(int to, int from);
-
-static int copyfd(int to, int from) {
- char buf[1024];
- int size;
-
- while ((size = read(from, buf, sizeof(buf))) > 0) {
- if (write(to, buf, size) != size) {
- fprintf(stderr, "error writing output: %s\n", strerror(errno));
- return 1;
- }
- }
-
- if (size < 0) {
- fprintf(stderr, "error reading input: %s\n", strerror(errno));
- return 1;
- }
-
- return 0;
-}
-
-static int catFile(char * filename) {
- int fd;
- int rc;
-
- fd = open(filename, O_RDONLY);
- if (fd < 0) {
- fprintf(stderr, "cannot open %s: %s\n", filename, strerror(errno));
- return 1;
- }
-
- rc = copyfd(1, fd);
- close(fd);
-
- return rc;
-}
-
-#define MOUNT_USAGE fprintf(stderr, "usage: mount -t <fs> <device> <dir>\n" \
- " (if /dev/ is left off the device name, a " \
- "temporary node will be created)\n")
-
-int mountCommand(int argc, char ** argv) {
- char * dev, * dir;
- char * fs, * buf;
-
- if (argc < 2) {
- return catFile("/proc/mounts");
- } else if (argc == 3) {
- if (strchr(argv[1], ':'))
- fs = "nfs";
- else
- fs = "ext2";
- dev = argv[1];
- dir = argv[2];
- } else if (argc != 5) {
- MOUNT_USAGE;
- return 1;
- } else {
- if (strcmp(argv[1], "-t")) {
- MOUNT_USAGE;
- return 1;
- }
-
- fs = argv[2];
- dev = argv[3];
- dir = argv[4];
- }
-
- if (!strncmp(dev, "LABEL=", 6)) {
- dev = get_spec_by_volume_label(dev + 6);
- } else if (!strncmp(dev, "UUID=", 5)) {
- dev = get_spec_by_uuid(dev + 5);
- }
-
- if (!strncmp(dev, "/dev/", 5) && access(dev, X_OK)) {
- dev += 5;
- buf = alloca(strlen(dev) + 10);
- sprintf(buf, "/tmp/%s", dev);
- devMakeInode(dev, buf);
- dev = buf;
- }
-
- if (doPwMount(dev, dir, fs, 0, 1, NULL, NULL)) {
- if (doPwMount(dev, dir, fs, 1, 1, NULL, NULL)) {
- fprintf(stderr, "mount failed: %s\n", strerror(errno));
- return 1;
- }
- }
-
- return 0;
-}
-
-int umountCommand(int argc, char ** argv) {
- if (argc != 2) {
- fprintf(stderr, "umount expects a single argument\n");
- return 1;
- }
-
- if (umount(argv[1])) {
- fprintf(stderr, "error unmounting %s: %s\n", argv[1], strerror(errno));
- return 1;
- }
-
- return 0;
-}
-
-int mknodCommand(int argc, char ** argv) {
- int major, minor;
- char * path;
- int mode = 0600;
- char *end;
-
- if (argc != 5 && argc != 2) {
- fprintf(stderr, "usage: mknod <path> [b|c] <major> <minor> or mknod <path>\n");
- return 1;
- }
-
- path = argv[1];
-
- if (argc == 2) {
- end = path + strlen(path) - 1;
- while (end > path && *end != '/') end--;
- if (*end == '/') end++;
-
- if (devMakeInode(end, path)) {
- printf("failed to make inode for device %s\n", end);
- return 1;
- }
-
- return 0;
- }
-
- if (!strcmp(argv[2], "b"))
- mode |= S_IFBLK;
- else if (!strcmp(argv[2], "c"))
- mode |= S_IFCHR;
- else {
- fprintf(stderr, "unknown node type %s\n", argv[2]);
- return 1;
- }
-
- major = strtol(argv[3], &end, 0);
- if (*end) {
- fprintf(stderr, "bad major number %s\n", argv[3]);
- return 1;
- }
-
- minor = strtol(argv[4], &end, 0);
- if (*end) {
- fprintf(stderr, "bad minor number %s\n", argv[4]);
- return 1;
- }
-
- if (mknod(path, mode, makedev(major, minor))) {
- fprintf(stderr, "mknod failed: %s\n", strerror(errno));
- return 1;
- }
-
- return 0;
-}
-
-int uncpioCommand(int argc, char ** argv) {
- int rc;
- const char * fail;
- gzFile cfd;
-
- if (argc != 1) {
- fprintf(stderr, "uncpio reads from stdin");
- return 1;
- }
-
- cfd = gunzip_dopen(0);
-
- rc = myCpioInstallArchive(cfd, NULL, 0, NULL, NULL, &fail);
-
- gunzip_close(cfd);
-
- 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);
-}
diff --git a/collage/commands.h b/collage/commands.h
deleted file mode 100644
index 701dcb30f..000000000
--- a/collage/commands.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef H_MOUNT
-#define H_MOUNT
-
-int mknodCommand(int argc, char ** argv);
-int mountCommand(int argc, char ** argv);
-int umountCommand(int argc, char ** argv);
-int uncpioCommand(int argc, char ** argv);
-
-#endif
diff --git a/collage/linux_fs.h b/collage/linux_fs.h
deleted file mode 100644
index 043ac16a7..000000000
--- a/collage/linux_fs.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/* Including <linux/fs.h> became more and more painful.
- Below a very abbreviated version of some declarations,
- only designed to be able to check a magic number
- in case no filesystem type was given. */
-
-#ifndef BLKGETSIZE
-#ifndef _IO
-/* pre-1.3.45 */
-#define BLKGETSIZE 0x1260 /* return device size */
-#else
-/* same on i386, m68k, arm; different on alpha, mips, sparc, ppc */
-#define BLKGETSIZE _IO(0x12,96)
-#endif
-#endif
-
-#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
-#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
-struct minix_super_block {
- u_char s_dummy[16];
- u_char s_magic[2];
-};
-#define minixmagic(s) ((uint) s.s_magic[0] + (((uint) s.s_magic[1]) << 8))
-
-#define ISODCL(from, to) (to - from + 1)
-#define ISO_STANDARD_ID "CD001"
-struct iso_volume_descriptor {
- char type[ISODCL(1,1)]; /* 711 */
- char id[ISODCL(2,6)];
- char version[ISODCL(7,7)];
- char data[ISODCL(8,2048)];
-};
-
-#define HS_STANDARD_ID "CDROM"
-struct hs_volume_descriptor {
- char foo[ISODCL ( 1, 8)]; /* 733 */
- char type[ISODCL ( 9, 9)]; /* 711 */
- char id[ISODCL ( 10, 14)];
- char version[ISODCL ( 15, 15)]; /* 711 */
- char data[ISODCL(16,2048)];
-};
-
-#define EXT_SUPER_MAGIC 0x137D
-struct ext_super_block {
- u_char s_dummy[56];
- u_char s_magic[2];
-};
-#define extmagic(s) ((uint) s.s_magic[0] + (((uint) s.s_magic[1]) << 8))
-
-#define EXT2_PRE_02B_MAGIC 0xEF51
-#define EXT2_SUPER_MAGIC 0xEF53
-struct ext2_super_block {
- u_char s_dummy1[56];
- u_char s_magic[2];
- u_char s_dummy2[46];
- u_char s_uuid[16];
- u_char s_volume_name[16];
-};
-#define ext2magic(s) ((uint) s.s_magic[0] + (((uint) s.s_magic[1]) << 8))
-
-#define _XIAFS_SUPER_MAGIC 0x012FD16D
-struct xiafs_super_block {
- u_char s_boot_segment[512]; /* 1st sector reserved for boot */
- u_char s_dummy[60];
- u_char s_magic[4];
-};
-#define xiafsmagic(s) ((uint) s.s_magic[0] + (((uint) s.s_magic[1]) << 8) + \
- (((uint) s.s_magic[2]) << 16) + \
- (((uint) s.s_magic[3]) << 24))
-
-/* From jj@sunsite.ms.mff.cuni.cz Mon Mar 23 15:19:05 1998 */
-#define UFS_SUPER_MAGIC 0x00011954
-struct ufs_super_block {
- u_char s_dummy[0x55c];
- u_char s_magic[4];
-};
-#define ufsmagic(s) ((uint) s.s_magic[0] + (((uint) s.s_magic[1]) << 8) + \
- (((uint) s.s_magic[2]) << 16) + \
- (((uint) s.s_magic[3]) << 24))
-
-/* From Richard.Russon@ait.co.uk Wed Feb 24 08:05:27 1999 */
-#define NTFS_SUPER_MAGIC "NTFS"
-struct ntfs_super_block {
- u_char s_dummy[3];
- u_char s_magic[4];
-};
-
-/* From inspection of a few FAT filesystems - aeb */
-/* Unfortunately I find almost the same thing on an extended partition;
- it looks like a primary has some directory entries where the extended
- has a partition table: IO.SYS, MSDOS.SYS, WINBOOT.SYS */
-struct fat_super_block {
- u_char s_dummy[3];
- u_char s_os[8]; /* "MSDOS5.0" or "MSWIN4.0" or "MSWIN4.1" */
- /* mtools-3.9.4 writes "MTOOL394" */
- u_char s_dummy2[32];
- u_char s_label[11]; /* for DOS? */
- u_char s_fs[8]; /* "FAT12 " or "FAT16 " or all zero */
- /* OS/2 BM has "FAT " here. */
- u_char s_dummy3[9];
- u_char s_label2[11]; /* for Windows? */
- u_char s_fs2[8]; /* garbage or "FAT32 " */
-};
-
-#define XFS_SUPER_MAGIC "XFSB"
-#define XFS_SUPER_MAGIC2 "BSFX"
-struct xfs_super_block {
- u_char s_magic[4];
- u_char s_dummy[28];
- u_char s_uuid[16];
- u_char s_dummy2[60];
- u_char s_fname[12];
-};
-
-#define CRAMFS_SUPER_MAGIC 0x28cd3d45
-struct cramfs_super_block {
- u_char s_magic[4];
- u_char s_dummy[12];
- u_char s_id[16];
-};
-#define cramfsmagic(s) ((uint) s.s_magic[0] + (((uint) s.s_magic[1]) << 8) + \
- (((uint) s.s_magic[2]) << 16) + \
- (((uint) s.s_magic[3]) << 24))
-
-#define HFS_SUPER_MAGIC 0x4244
-struct hfs_super_block {
- u_char s_magic[2];
- u_char s_dummy[18];
- u_char s_blksize[4];
-};
-#define hfsmagic(s) ((uint) s.s_magic[0] + (((uint) s.s_magic[1]) << 8))
-#define hfsblksize(s) ((uint) s.s_blksize[0] + \
- (((uint) s.s_blksize[1]) << 8) + \
- (((uint) s.s_blksize[2]) << 16) + \
- (((uint) s.s_blksize[3]) << 24))
-
-#define HPFS_SUPER_MAGIC 0xf995e849
-struct hpfs_super_block {
- u_char s_magic[4];
- u_char s_magic2[4];
-};
-#define hpfsmagic(s) ((uint) s.s_magic[0] + (((uint) s.s_magic[1]) << 8) + \
- (((uint) s.s_magic[2]) << 16) + \
- (((uint) s.s_magic[3]) << 24))
-
-struct adfs_super_block {
- u_char s_dummy[448];
- u_char s_blksize[1];
- u_char s_dummy2[62];
- u_char s_checksum[1];
-};
-#define adfsblksize(s) ((uint) s.s_blksize[0])
diff --git a/collage/mkcollagelinks b/collage/mkcollagelinks
deleted file mode 100755
index 4da43d3fc..000000000
--- a/collage/mkcollagelinks
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash
-
-read line
-while read line; do
- ln -sf $1 $line
-done
diff --git a/collage/mount_by_label.c b/collage/mount_by_label.c
deleted file mode 100644
index b806accd9..000000000
--- a/collage/mount_by_label.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * mount_by_label.c - aeb
- *
- * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org>
- * - added Native Language Support
- * 2000-01-20 James Antill <james@and.org>
- * - Added error message if /proc/partitions cannot be opened
- * 2000-05-09 Erik Troan <ewt@redhat.com>
- * - Added cache for UUID and disk labels
- * 2000-11-07 Nathan Scott <nathans@sgi.com>
- * - Added XFS support
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "linux_fs.h"
-#include "mount_by_label.h"
-
-#define xstrdup strdup
-
-#define PROC_PARTITIONS "/proc/partitions"
-#define DEVLABELDIR "/dev"
-
-static struct uuidCache_s {
- struct uuidCache_s *next;
- char uuid[16];
- char *label;
- char *device;
-} *uuidCache = NULL;
-
-/* for now, only ext2 and xfs are supported */
-static int
-get_label_uuid(const char *device, char **label, char *uuid) {
-
- /* start with ext2 and xfs tests, taken from mount_guess_fstype */
- /* should merge these later */
- int fd;
- int rv = 1;
- size_t namesize;
- struct ext2_super_block e2sb;
- struct xfs_super_block xfsb;
-
- fd = open(device, O_RDONLY);
- if (fd < 0)
- return rv;
-
- if (lseek(fd, 1024, SEEK_SET) == 1024
- && read(fd, (char *) &e2sb, sizeof(e2sb)) == sizeof(e2sb)
- && (ext2magic(e2sb) == EXT2_SUPER_MAGIC)) {
- memcpy(uuid, e2sb.s_uuid, sizeof(e2sb.s_uuid));
- namesize = sizeof(e2sb.s_volume_name);
- if ((*label = calloc(namesize + 1, 1)) != NULL)
- memcpy(*label, e2sb.s_volume_name, namesize);
- rv = 0;
- }
- else if (lseek(fd, 0, SEEK_SET) == 0
- && read(fd, (char *) &xfsb, sizeof(xfsb)) == sizeof(xfsb)
- && (strncmp((char *) &xfsb.s_magic, XFS_SUPER_MAGIC, 4) == 0 ||
- strncmp((char *) &xfsb.s_magic, XFS_SUPER_MAGIC2,4) == 0)) {
- memcpy(uuid, xfsb.s_uuid, sizeof(xfsb.s_uuid));
- namesize = sizeof(xfsb.s_fname);
- if ((*label = calloc(namesize + 1, 1)) != NULL)
- memcpy(*label, xfsb.s_fname, namesize);
- rv = 0;
- }
-
- close(fd);
- return rv;
-}
-
-static void
-uuidcache_addentry(char *device, char *label, char *uuid) {
- struct uuidCache_s *last;
-
- if (!uuidCache) {
- last = uuidCache = malloc(sizeof(*uuidCache));
- } else {
- for (last = uuidCache; last->next; last = last->next) ;
- last->next = malloc(sizeof(*uuidCache));
- last = last->next;
- }
- last->next = NULL;
- last->device = device;
- last->label = label;
- memcpy(last->uuid, uuid, sizeof(last->uuid));
-}
-
-static void
-uuidcache_init(void) {
- char line[100];
- char *s;
- int ma, mi, sz;
- static char ptname[100];
- FILE *procpt;
- char uuid[16], *label;
- char device[110];
- int firstPass;
- int handleOnFirst;
-
- if (uuidCache)
- return;
-
- procpt = fopen(PROC_PARTITIONS, "r");
- if (!procpt) {
- static int warn = 0;
- if (!warn++)
- fprintf (stderr, "mount: could not open %s, so UUID and LABEL "
- "conversion cannot be done.\n",
- PROC_PARTITIONS);
- return;
- }
-
- for (firstPass = 1; firstPass >= 0; firstPass--) {
- fseek(procpt, 0, SEEK_SET);
-
- while (fgets(line, sizeof(line), procpt)) {
- if (sscanf (line, " %d %d %d %[^\n ]",
- &ma, &mi, &sz, ptname) != 4)
- continue;
-
- /* skip extended partitions (heuristic: size 1) */
- if (sz == 1)
- continue;
-
- /* look only at md devices on first pass */
- handleOnFirst = !strncmp(ptname, "md", 2);
- if (firstPass != handleOnFirst)
- continue;
-
- /* skip entire disk (minor 0, 64, ... on ide;
- 0, 16, ... on sd) */
- /* heuristic: partition name ends in a digit */
-
- for(s = ptname; *s; s++);
- if (isdigit(s[-1])) {
- /*
- * Note: this is a heuristic only - there is no reason
- * why these devices should live in /dev.
- * Perhaps this directory should be specifiable by option.
- * One might for example have /devlabel with links to /dev
- * for the devices that may be accessed in this way.
- * (This is useful, if the cdrom on /dev/hdc must not
- * be accessed.)
- */
- sprintf(device, "%s/%s", DEVLABELDIR, ptname);
- if (!get_label_uuid(device, &label, uuid))
- uuidcache_addentry(strdup(device), label, uuid);
- }
- }
- }
-
- fclose(procpt);
-}
-
-#define UUID 1
-#define VOL 2
-
-static char *
-get_spec_by_x(int n, const char *t) {
- struct uuidCache_s *uc;
-
- uuidcache_init();
- uc = uuidCache;
-
- while(uc) {
- switch (n) {
- case UUID:
- if (!memcmp(t, uc->uuid, sizeof(uc->uuid)))
- return xstrdup(uc->device);
- break;
- case VOL:
- if (!strcmp(t, uc->label))
- return xstrdup(uc->device);
- break;
- }
- uc = uc->next;
- }
- return NULL;
-}
-
-static u_char
-fromhex(char c) {
- if (isdigit(c))
- return (c - '0');
- else if (islower(c))
- return (c - 'a' + 10);
- else
- return (c - 'A' + 10);
-}
-
-char *
-get_spec_by_uuid(const char *s) {
- u_char uuid[16];
- int i;
-
- if (strlen(s) != 36 ||
- s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-')
- goto bad_uuid;
- for (i=0; i<16; i++) {
- if (*s == '-') s++;
- if (!isxdigit(s[0]) || !isxdigit(s[1]))
- goto bad_uuid;
- uuid[i] = ((fromhex(s[0])<<4) | fromhex(s[1]));
- s += 2;
- }
- return get_spec_by_x(UUID, uuid);
-
- bad_uuid:
- fprintf(stderr, "mount: bad UUID\n");
- exit(1);
- return NULL; /* just for gcc */
-}
-
-char *
-get_spec_by_volume_label(const char *s) {
- return get_spec_by_x(VOL, s);
-}
-
-const char *
-get_volume_label_by_spec(const char *spec) {
- struct uuidCache_s *uc;
-
- uuidcache_init();
- uc = uuidCache;
-
- while(uc) {
- if (!strcmp(spec, uc->device))
- return uc->label;
- uc = uc->next;
- }
- return NULL;
-}
diff --git a/collage/mount_by_label.h b/collage/mount_by_label.h
deleted file mode 100644
index 64bbbfa7d..000000000
--- a/collage/mount_by_label.h
+++ /dev/null
@@ -1,3 +0,0 @@
-char *get_spec_by_uuid(const char *uuid);
-char *get_spec_by_volume_label(const char *volumelabel);
-const char *get_volume_label_by_spec(const char *spec);