General cleanup:

- clean up kernel section of minix/com.h somewhat
- remove ALLOCMEM and VM_ALLOCMEM calls
- remove non-safecopy and minix-vmd support from Inet
- remove SYS_VIRVCOPY and SYS_PHYSVCOPY calls
- remove obsolete segment encoding in SYS_SAFECOPY*
- remove DEVCTL call, svrctl(FSDEVUNMAP), map_driverX
- remove declarations of unimplemented svrctl requests
- remove everything related to swapping to disk
- remove floppysetup.sh
- remove traces of rescue device
- update DESCRIBE.sh with new devices
- some other small changes
This commit is contained in:
David van Moolenbroek
2010-01-05 19:39:27 +00:00
parent be992434e7
commit ac9ab099c8
75 changed files with 388 additions and 2178 deletions
-9
View File
@@ -128,7 +128,6 @@ ALL = \
mkfs \
mknod \
mkproto \
mkswap \
modem \
mount \
mt \
@@ -569,10 +568,6 @@ mkproto: mkproto.c
$(CCLD) -o $@ $<
@install -S 20kw $@
mkswap: mkswap.c
$(CCLD) -I$(SYS) -o $@ $<
@install -S 4kw $@
modem: modem.c
$(CCLD) -o $@ $<
@install -S 4kw $@
@@ -1026,7 +1021,6 @@ install: \
/usr/bin/mkfs \
/usr/bin/mknod \
/usr/bin/mkproto \
/usr/bin/mkswap \
/usr/bin/modem \
/usr/bin/mount \
/usr/bin/mt \
@@ -1437,9 +1431,6 @@ install: \
/usr/bin/mkproto: mkproto
install -cs -o bin $< $@
/usr/bin/mkswap: mkswap
install -cs -o bin $< $@
/usr/bin/modem: modem
install -cs -o bin $< $@
-197
View File
@@ -1,197 +0,0 @@
/* mkswap 1.0 - Initialize a swap partition or file
* Author: Kees J. Bot
* 6 Jan 2001
*/
#define nil ((void*)0)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <minix/config.h>
#include <minix/const.h>
#include <minix/type.h>
#include <minix/u64.h>
#include <minix/partition.h>
#include <minix/swap.h>
#include <servers/mfs/const.h>
#include <servers/mfs/type.h>
#include <servers/mfs/super.h>
static void usage(void)
{
fprintf(stderr, "Usage: mkswap [-f] device-or-file [size[km]]\n");
exit(1);
}
int main(int argc, char **argv)
{
int first;
int i;
char *file;
unsigned long offset, size, devsize;
int fd;
struct stat st;
ssize_t r;
struct super_block super;
swap_hdr_t swap_hdr;
static u8_t block[_MAX_BLOCK_SIZE];
first= 0;
i= 1;
while (i < argc && argv[i][0] == '-') {
char *opt= argv[i++]+1;
if (opt[0] == '-' && opt[1] == 0) break; /* -- */
while (*opt != 0) switch (*opt++) {
case 'f': first= 1; break;
default: usage();
}
}
if (i == argc) usage();
file= argv[i++];
size= 0;
if (i < argc) {
char *end;
unsigned long m;
size= strtoul(argv[i], &end, 10);
if (end == argv[i]) usage();
m= 1024;
if (*end != 0) {
switch (*end) {
case 'm': case 'M': m *= 1024; /*FALL THROUGH*/
case 'k': case 'K': end++; break;
}
}
if (*end != 0 || size == -1
|| (size * m) / m != size || (size *= m) <= SWAP_OFFSET
) {
fprintf(stderr, "mkswap: %s: Bad size\n", argv[i]);
exit(1);
}
i++;
}
if (i != argc) usage();
/* Open the device or file. */
if ((fd= open(file, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) {
fprintf(stderr, "mkswap: Can't open %s: %s\n", file, strerror(errno));
exit(1);
}
/* File or device? */
(void) fstat(fd, &st);
if (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)) {
struct partition part;
/* How big is the partition? */
if (ioctl(fd, DIOCGETP, &part) < 0) {
fprintf(stderr, "mkswap: Can't determine the size of %s: %s\n",
file, strerror(errno));
exit(1);
}
devsize= cv64ul(part.size);
offset= 0;
if (!first) {
/* Is there a file system? */
r= -1;
if (lseek(fd, SUPER_BLOCK_BYTES, SEEK_SET) == -1
|| (r= read(fd, block, _STATIC_BLOCK_SIZE)) < _STATIC_BLOCK_SIZE
) {
fprintf(stderr, "mkswap: %s: %s\n",
file, r >= 0 ? "End of file" : strerror(errno));
exit(1);
}
memcpy(&super, block, sizeof(super));
if (super.s_magic == SUPER_MAGIC) {
offset= (unsigned long) super.s_nzones * _STATIC_BLOCK_SIZE;
} else
if (super.s_magic == SUPER_V2) {
offset= (unsigned long) super.s_zones * _STATIC_BLOCK_SIZE;
} else if (super.s_magic == SUPER_V3) {
offset= (unsigned long) super.s_zones * super.s_block_size;
} else {
first= 1;
}
}
if (size == 0) size= devsize - offset;
if (size == 0 || offset + size > devsize) {
fprintf(stderr, "mkswap: There is no room on %s for ", file);
if (size > 0) fprintf(stderr, "%lu kilobytes of ", size/1024);
fprintf(stderr, "swapspace\n");
if (offset > 0) {
fprintf(stderr, "(Use the -f flag to wipe the file system)\n");
}
exit(1);
}
} else
if (S_ISREG(st.st_mode)) {
/* Write to the swap file to guarantee space for MM. */
unsigned long n;
if (size == 0) {
fprintf(stderr, "mkswap: No size specified for %s\n", file);
usage();
}
memset(block, 0, sizeof(block));
for (n= 0; n < size; n += r) {
r= size > sizeof(block) ? sizeof(block) : size;
if ((r= write(fd, block, r)) <= 0) {
fprintf(stderr, "mkswap: %s: %s\n",
file, r == 0 ? "End of file" : strerror(errno));
exit(1);
}
}
first= 1;
} else {
fprintf(stderr, "mkswap: %s is not a device or a file\n", file);
exit(1);
}
if (offset < SWAP_OFFSET) {
offset += SWAP_OFFSET;
if (size < SWAP_OFFSET) size= 0; else size -= SWAP_OFFSET;
}
swap_hdr.sh_magic[0]= SWAP_MAGIC0;
swap_hdr.sh_magic[1]= SWAP_MAGIC1;
swap_hdr.sh_magic[2]= SWAP_MAGIC2;
swap_hdr.sh_magic[3]= SWAP_MAGIC3;
swap_hdr.sh_version= SH_VERSION;
swap_hdr.sh_priority= 0;
swap_hdr.sh_offset= offset;
swap_hdr.sh_swapsize= size;
r= -1;
if (lseek(fd, SWAP_BOOTOFF, SEEK_SET) == -1
|| (r= read(fd, block, sizeof(block))) < sizeof(block)
) {
fprintf(stderr, "mkswap: %s: %s\n", file,
file, r >= 0 ? "End of file" : strerror(errno));
exit(1);
}
r= (first ? SWAP_BOOTOFF : OPTSWAP_BOOTOFF) - SWAP_BOOTOFF;
memcpy(block + r, &swap_hdr, sizeof(swap_hdr));
r= -1;
if (lseek(fd, SWAP_BOOTOFF, SEEK_SET) == -1
|| (r= write(fd, block, sizeof(block))) < sizeof(block)
) {
fprintf(stderr, "mkswap: %s: %s\n", file,
file, r >= 0 ? "End of file" : strerror(errno));
exit(1);
}
printf("%s: swapspace at offset %lu, size %lu kilobytes\n",
file, offset / 1024, size / 1024);
return 0;
}
+42 -113
View File
@@ -12,7 +12,6 @@
#include <minix/config.h>
#include <minix/const.h>
#include <minix/minlib.h>
#include <minix/swap.h>
#include <sys/svrctl.h>
#include <stdio.h>
#include "../../servers/mfs/const.h"
@@ -23,21 +22,17 @@ _PROTOTYPE(int main, (int argc, char **argv));
_PROTOTYPE(void list, (void));
_PROTOTYPE(void usage, (void));
_PROTOTYPE(void tell, (char *this));
_PROTOTYPE(void swapon, (char *file));
static u8_t MAGIC[] = { SWAP_MAGIC0, SWAP_MAGIC1, SWAP_MAGIC2, SWAP_MAGIC3 };
int main(argc, argv)
int argc;
char *argv[];
{
int i, swap, n, v, mountflags;
int i, n, v, mountflags;
char **ap, *vs, *opt, *err, *type, *args;
char special[PATH_MAX+1], mounted_on[PATH_MAX+1], version[10], rw_flag[10];
if (argc == 1) list(); /* just list /etc/mtab */
mountflags = 0;
swap = 0;
type = NULL;
args = NULL;
ap = argv+1;
@@ -46,7 +41,6 @@ char *argv[];
opt = argv[i]+1;
while (*opt != 0) switch (*opt++) {
case 'r': mountflags |= MS_RDONLY; break;
case 's': swap = 1; break;
case 't': if (++i == argc) usage();
type = argv[i];
break;
@@ -63,34 +57,25 @@ char *argv[];
*ap = NULL;
argc = (ap - argv);
if (mountflags & MS_RDONLY && swap) usage();
if (swap) {
if (argc != 2) usage();
swapon(argv[1]);
tell(argv[1]);
tell(" is swapspace\n");
} else {
if (argc != 3) usage();
if (mount(argv[1], argv[2], mountflags, type, args) < 0) {
err = strerror(errno);
std_err("mount: Can't mount ");
std_err(argv[1]);
std_err(" on ");
std_err(argv[2]);
std_err(": ");
std_err(err);
std_err("\n");
exit(1);
}
/* The mount has completed successfully. Tell the user. */
tell(argv[1]);
tell(" is read-");
tell(mountflags & MS_RDONLY ? "only" : "write");
tell(" mounted on ");
tell(argv[2]);
tell("\n");
if (argc != 3) usage();
if (mount(argv[1], argv[2], mountflags, type, args) < 0) {
err = strerror(errno);
std_err("mount: Can't mount ");
std_err(argv[1]);
std_err(" on ");
std_err(argv[2]);
std_err(": ");
std_err(err);
std_err("\n");
exit(1);
}
/* The mount has completed successfully. Tell the user. */
tell(argv[1]);
tell(" is read-");
tell(mountflags & MS_RDONLY ? "only" : "write");
tell(" mounted on ");
tell(argv[2]);
tell("\n");
/* Update /etc/mtab. */
n = load_mtab("mount");
@@ -106,29 +91,25 @@ char *argv[];
exit(1);
}
}
if (swap) {
vs = "swap";
/* For MFS, use a version number. Otherwise, use the FS type name. */
if (type == NULL || !strcmp(type, MINIX_FS_TYPE)) {
v = fsversion(argv[1], "mount");
if (v == 1)
vs = "1";
else if (v == 2)
vs = "2";
else if (v == 3)
vs = "3";
else
vs = "0";
} else {
/* For MFS, use a version number. Otherwise, use the FS type name. */
if (type == NULL || !strcmp(type, MINIX_FS_TYPE)) {
v = fsversion(argv[1], "mount");
if (v == 1)
vs = "1";
else if (v == 2)
vs = "2";
else if (v == 3)
vs = "3";
else
vs = "0";
} else {
/* Keep the version field sufficiently short. */
if (strlen(type) < sizeof(version))
vs = type;
else
vs = "-";
}
/* Keep the version field sufficiently short. */
if (strlen(type) < sizeof(version))
vs = type;
else
vs = "-";
}
n = put_mtab_entry(argv[1], swap ? "swap" : argv[2], vs,
n = put_mtab_entry(argv[1], argv[2], vs,
(mountflags & MS_RDONLY ? "ro" : "rw") );
if (n < 0) {
std_err("mount: /etc/mtab has grown too large\n");
@@ -153,15 +134,11 @@ void list()
n = get_mtab_entry(special, mounted_on, version, rw_flag);
if (n < 0) break;
write(1, special, strlen(special));
if (strcmp(version, "swap") == 0) {
tell(" is swapspace\n");
} else {
tell(" is read-");
tell(strcmp(rw_flag, "rw") == 0 ? "write" : "only");
tell(" mounted on ");
tell(mounted_on);
tell("\n");
}
tell(" is read-");
tell(strcmp(rw_flag, "rw") == 0 ? "write" : "only");
tell(" mounted on ");
tell(mounted_on);
tell("\n");
}
exit(0);
}
@@ -169,8 +146,7 @@ void list()
void usage()
{
std_err("Usage: mount [-r] [-t type] [-o options] special name\n"
" mount -s special\n");
std_err("Usage: mount [-r] [-t type] [-o options] special name\n");
exit(1);
}
@@ -180,50 +156,3 @@ char *this;
{
write(1, this, strlen(this));
}
void swapon(file)
char *file;
{
u32_t super[2][_MAX_BLOCK_SIZE / 2 / sizeof(u32_t)];
swap_hdr_t *sp;
struct mmswapon mmswapon;
int fd, r;
char *err;
if ((fd = open(file, O_RDWR)) < 0
|| lseek(fd, SUPER_BLOCK_BYTES, SEEK_SET) == -1
|| (r = read(fd, super, _STATIC_BLOCK_SIZE)) < 0
) {
err = strerror(errno);
std_err("mount: ");
std_err(file);
std_err(": ");
std_err(err);
std_err("\n");
exit(1);
}
sp = (swap_hdr_t *) &super[0];
if (memcmp(sp->sh_magic, MAGIC, sizeof(MAGIC)) != 0)
sp = (swap_hdr_t *) &super[1];
if (r == _STATIC_BLOCK_SIZE && memcmp(sp->sh_magic, MAGIC, sizeof(MAGIC)) != 0
|| sp->sh_version > SH_VERSION) {
std_err("mount: ");
std_err(file);
std_err(" is not swapspace\n");
exit(1);
}
close(fd);
mmswapon.offset = sp->sh_offset;
mmswapon.size = sp->sh_swapsize;
strncpy(mmswapon.file, file, sizeof(mmswapon.file));
mmswapon.file[sizeof(mmswapon.file)-1] = 0;
if (svrctl(MMSWAPON, &mmswapon) < 0) {
err = strerror(errno);
std_err("mount: ");
std_err(file);
std_err(": ");
std_err(err);
std_err("\n");
exit(1);
}
}