DataMuseum.dk

Presents historical artifacts from the history of:

Commodore CBM-900

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Commodore CBM-900

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦30556e4bf⟧ TextFile

    Length: 817 (0x331)
    Types: TextFile
    Notes: UNIX file
    Names: »mknod.c«

Derivation

└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
    └─⟦f4b8d8c84⟧ UNIX V7 Filesystem
        └─ ⟦this⟧ »cmd/mknod.c« 

TextFile

/*
 * Make a special file
 */
#include <stdio.h>
#include <ino.h>
#include <stat.h>

main(argc, argv)
register char **argv;
{
	register int mode;
	register int addr;

	if (argc < 3)
		usage();
	switch (argv[2][0]) {
	case 'b':
		if (argc != 5)
			usage();
		mode = IFBLK;
		addr = makedev(atoi(argv[3]), atoi(argv[4]));
		break;
	case 'c':
		if (argc != 5)
			usage();
		mode = IFCHR;
		addr = makedev(atoi(argv[3]), atoi(argv[4]));
		break;
	case 'p':
		if (argc != 3)
			usage();
		mode = IFPIPE;
		addr = 0;
		break;
	default:
		usage();
	}
	mode |= 0666;
	if (mknod(argv[1], mode, addr) < 0) {
		fprintf(stderr, "mknod: cannot create node %s\n", argv[1]);
		return (1);
	}
	return (0);
}

/*
 * Print out a usage message.
 */
usage()
{
	fprintf(stderr, "usage: mknod <name> [bcp] <major> <minor>\n");
	exit(1);
}