889 Commits

Author SHA1 Message Date
Ben Gras
116fcea5be include netdrv_tg3 on cd 2012-02-26 23:36:00 +01:00
Tomas Hruby
d991abdd34 Revert "SMP - no_apic=0 and acpi=1 set when CONFIG_SMP=y"
This reverts commit c468f4efa5.

Since we use the new boot loader, this hack is no longer necessary.
2012-02-24 14:58:48 +01:00
Antoine Leca
dd9c147444 Cosmetic boot fix.
The NetBSD boot loader loads automatically the kernel module appropriate
for the detected root file system; it is preset at "ffs".  The MINIX3fs
support does not reset the underlying global variable, since there are
no use for this on MINIX.  As a result, the boot loader searches for
/ffs.kmod, and issues two warnings about "module failure to open/load."
2012-02-24 13:29:58 +01:00
Ben Gras
60a4f87b0b fix for -lsys assert(): call panic()
. call panic() instead of abort() so that stacktraces are printed
	. also call printf(..) instead of fprintf(stderr, ..)
2012-02-24 13:10:27 +01:00
Ben Gras
16a468ccec start modules at 16MB
. keep more memory free below 16MB for e.g. lance
2012-02-24 11:51:07 +01:00
Arun Thomas
f55f1f3e52 kernel: Update copyright date 2012-02-22 16:39:41 +01:00
Ben Gras
47627954a0 allow elvis to be invoked as ex 2012-02-22 01:52:20 +01:00
Arun Thomas
72cab7a281 mkimage: use a lower start address 2012-02-21 15:52:18 +01:00
Thomas Veerman
93a8d9f260 VFS: fix last_dir not returning last directory
If the provided path was only a single component (i.e., without
slashes), then last_dir would return early and skip the symlink
detection (i.e., check whether the path ends in a symlink and resolve
that first before returning). This bug triggered an assert in open
which expects that an advance after an last_dir (with VMNT_WRITE lock)
does not yield another vmnt lock.
2012-02-21 10:22:45 +00:00
Ben Gras
665ce9d4e1 try multiple reset methods
. fixes reboot-hang under vbox
	. makes experience nicer under vmware
	. taken from netbsd reset code
2012-02-20 23:54:28 +01:00
Thomas Veerman
3b3ea9dc32 VFS: remove erroneous assert
The assert was meant as an additional check to the assert in link.c:198.
The reasoning behind the assert in link.c:198 is that once you've
obtained a write lock on a vmnt, you can't get an additional read lock
on the same vmnt. However, that does not always hold for the assert in
path.c:281 where the situation could be that you've obtained a read lock
and managed to get another read lock (this is possible). In other words,
the assert in path.c:281 is not the right place to check for that
situation.
2012-02-20 14:16:19 +00:00
Ben Gras
bab9a671ef pkgin_cd clarification in motd 2012-02-18 01:17:32 +01:00
Ben Gras
8ef86ffe84 better cpp 2012-02-17 23:53:44 +01:00
Ben Gras
61cb2ba2de x11 on cd needs perl, drop groff for space 2012-02-17 23:53:44 +01:00
Thomas Veerman
c540bcb001 VFS: various select fixes
- Fix locking bug when unable to send DEV_SELECT request. Upon failure
  VFS tried to cancel the select operation, but this failed due to trying
  to lock a filp that was already locked to send the request in the first
  place. Do_select_request now handles locking of filps itself instead of
  relying on the caller to do it.  This fixes a crash when killing INET.
- Fix failure to revive a process after a non-blocking select operation
  yielded no ready select operations when replying DEV_SEL_REPL1.
- Improve readability by using OK, SUSPEND, and standard error values as
  results instead of having separate macros in select.
- Don't print not having a driver for a major device; after killing a driver
  select will trigger this printf.
2012-02-17 21:09:07 +00:00
Thomas Veerman
4c156d8a32 test set: remove GCC specificity 2012-02-17 17:22:37 +00:00
Arun Thomas
5d958f894f servers: fix clang warnings in iso9660fs and vm 2012-02-17 16:48:40 +01:00
Ben Gras
957f4181c0 /usr/lib/cpp script to invoke clang -E
. mainly to keep X working
2012-02-17 15:15:31 +00:00
Arun Thomas
96940bcd57 kernel/utility.c: fix implicit decl warnings 2012-02-17 15:30:03 +01:00
Ben Gras
5b2ae44f78 Fixes to allow versionless packages on cd 2012-02-17 14:26:46 +00:00
Antoine Leca
ab0a67f7af Use objcopy to build ramdisk object
. during build, uses much less memory,
	  disk space, and time
	. lets us throw out bintoc
2012-02-17 12:56:38 +00:00
Ben Gras
5a645f22a8 gzip boot modules.
. import gzip
2012-02-17 12:32:35 +00:00
Arun Thomas
ff56906879 Remove obsolete INSTALLFLAGS from makefiles 2012-02-16 23:26:38 +01:00
Arun Thomas
74caf0e21f mkboot: ensure image target dir is cleaned up 2012-02-16 23:08:22 +01:00
Arun Thomas
274212e760 Strip only the image binaries 2012-02-16 19:15:32 +01:00
Ben Gras
0bf3f4c52a fix shell tests - no cc or aal 2012-02-16 12:10:39 +00:00
Ben Gras
39fea0a5b9 install library manpages
. harmonize bsd.lib.mk and bsd.man.mk with netbsd files
	. throw out minix section 3 (library calls) manpages,
	  replaced by netbsd ones that are now installed
2012-02-16 01:48:46 +00:00
Ben Gras
3919b46a4d no symlink for dropped manpage 2012-02-16 00:52:19 +00:00
Antoine Leca
3fb8cb760c More cleaning up 2012-02-15 19:04:58 +00:00
David van Moolenbroek
1ead18e447 libblockdriver: attribute usage bugfix 2012-02-15 14:23:30 +01:00
Evgeniy Ivanov
9ab3cf37ce updateboot script for netbsd bootloader 2012-02-15 03:51:27 +01:00
Ben Gras
47c1f10835 re-enable update-superblock check
This reverts commit cdbc4bfb13.
2012-02-15 03:46:01 +01:00
Ben Gras
bb364f9cc8 simplify chrootmake.sh
. just use make world
2012-02-15 01:19:12 +01:00
David van Moolenbroek
342171fa9e Remove elle(1) editor, due to an incompatible license 2012-02-14 19:13:17 +01:00
Thomas Veerman
0491126758 Don't update mtab upon mounting procfs
It causes an ugly error message when booting from cd and it gets
overwritten by `printroot >/etc/mtab` in /etc/rc anyway.
2012-02-14 17:23:36 +00:00
Ben Gras
a8b1dd7809 Added UPDATING note about newer clang required. 2012-02-14 16:42:58 +01:00
David van Moolenbroek
0f940cc58a user(8): remove output file from source 2012-02-14 15:49:04 +01:00
Antoine Leca
f4ffbc6072 Make ELF kernel boot faster 2012-02-14 14:52:15 +01:00
Evgeniy Ivanov
c9f65d5ae6 update_bootcfg script
. script to make neat menu entries for all /boot/minix/* dirs
	  in /boot.cfg, read by new bootloader
	. invoked when new images are created
2012-02-14 14:52:14 +01:00
Ben Gras
2fe8fb192f Full switch to clang/ELF. Drop ack. Simplify.
There is important information about booting non-ack images in
docs/UPDATING. ack/aout-format images can't be built any more, and
booting clang/ELF-format ones is a little different. Updating to the
new boot monitor is recommended.

Changes in this commit:

	. drop boot monitor -> allowing dropping ack support
	. facility to copy ELF boot files to /boot so that old boot monitor
	  can still boot fairly easily, see UPDATING
	. no more ack-format libraries -> single-case libraries
	. some cleanup of OBJECT_FMT, COMPILER_TYPE, etc cases
	. drop several ack toolchain commands, but not all support
	  commands (e.g. aal is gone but acksize is not yet).
	. a few libc files moved to netbsd libc dir
	. new /bin/date as minix date used code in libc/
	. test compile fix
	. harmonize includes
	. /usr/lib is no longer special: without ack, /usr/lib plays no
	  kind of special bootstrapping role any more and bootstrapping
	  is done exclusively through packages, so releases depend even
	  less on the state of the machine making them now.
	. rename nbsd_lib* to lib*
	. reduce mtree
2012-02-14 14:52:02 +01:00
Evgeniy Ivanov
2487445f5f make panic() work for multiboot/elf case
. we cannot use the boot monitor to print the system diag buffer
	. for serial, we do nothing, just reset, everything is already printed
	. for not-serial, we print the current diag buffer using direct video
	  memory access from the kernel
2012-02-14 14:48:10 +01:00
Ben Gras
a73c217bf6 clang compile fixes 2012-02-14 14:05:52 +01:00
Ben Gras
f94e915e33 release: fix for rm -rf
. new rm can return failure exit code
2012-02-14 14:05:52 +01:00
Evgeniy Ivanov
f6c5d09978 ELF hardlinks in /boot for compatibility with old boot. 2012-02-14 12:53:34 +01:00
Thomas Veerman
80c4685324 VFS: replace VFS with AVFS 2012-02-13 16:53:21 +00:00
Thomas Veerman
bba63ef665 libmthread: fix typo in comments 2012-02-13 13:50:32 +00:00
Thomas Veerman
accaae9b2c libmthread: add guard pages to stacks
Add guard pages to the top of the stack to catch overflow errors.
Moreover, fix a bug where libmthread would keep using a stack that was
just deallocated; a detached thread would deallocate its own stack after
it was finished running).
2012-02-13 13:50:31 +00:00
Thomas Veerman
0949f5b342 libmthread: don't free() user allocated stack space 2012-02-13 13:50:13 +00:00
David van Moolenbroek
de89517711 libblockdriver: increase stack size to 8KB per thread 2012-02-11 15:16:22 +01:00
Ben Gras
35abd4867a silence makewhatis in daily script 2012-02-10 17:25:48 +01:00
Antoine Leca
f87b9a3d2d sys: move some include dirs
. sys/machine should be sys/arch/i386
2012-02-10 17:02:47 +01:00
Antoine Leca
02b46221dd .gitignore: add another generated directory 2012-02-10 17:02:04 +01:00
Thomas Veerman
0c99f4f4b7 AVFS: reinitialize lookup object before reuse 2012-02-10 09:50:21 +00:00
Antoine Leca
e93c1c9f28 Also clean share/*, including zoneinfo 2012-02-10 00:46:55 +01:00
Evgeniy Ivanov
3ab668c366 Fix shutdown message in setup.sh 2012-02-09 18:54:54 +01:00
Evgeniy Ivanov
1ae162d673 Proper banner for CD. 2012-02-09 18:54:54 +01:00
Evgeniy Ivanov
61a29c4291 Warn users about non NetBSD mbr.
New boot doesn't work with old mbr, when there are multiple MINIX
partitions. Warn user about it and suggest to install new mbr.
2012-02-09 18:54:53 +01:00
Evgeniy Ivanov
6f88dc8713 Support reinstall and new boot. 2012-02-09 18:54:52 +01:00
Evgeniy Ivanov
d4ddfeb2c0 Build both old boot and new boot (for setup). 2012-02-09 18:54:51 +01:00
Evgeniy Ivanov
5a46076652 Build release CD based on new boot.
Also add stuff for usb stick and hdemu.
2012-02-09 18:54:50 +01:00
Antoine Leca
3f2ab5b34b writeisofs: also boots plain binaries with -B
With -n -b file, a.out boot images can be used for CD booting;
with the new -n -B file option, plain binary (like bootxx_cd9660)
can be used instead.
Restore working the -h and -f options while there.
And add a new -F option for 2.8MB floppy image.
2012-02-09 18:54:49 +01:00
Antoine Leca
2ae897db7b writeisofs: improve compatibility
Register file timestamps
Remember the path tables in the primary descriptor
Put the size of the parent directory in the \1 entry, not own size
Allow the use of -b option without -a

Notes:
* Still missing the man page
* Filenames are still trimmed to 12 characters, because of
  8.3 MS-DOS inherited compatibility (ISO9660 level 1);
  also note that 7.4 or 9.2 filenames are accepted though
* Final . at end of filenames without extension is still missing
* VMS-compatible ;1 version suffix is still omitted
* Limit of 65,535 directories in path tables is not checked
2012-02-09 18:54:49 +01:00
Evgeniy Ivanov
13d8a6969a Add new boot to the setup. 2012-02-09 18:54:48 +01:00
Evgeniy Ivanov
68bd32bedb Build ELF for release (chrootmake). 2012-02-09 18:54:47 +01:00
Antoine Leca
7a60d6d33f Switch part/autopart to new mbr bootblock 2012-02-09 18:54:46 +01:00
Ben Gras
636264c1c6 Fixes for loading kernel with multiboot
While parsing command line, only consider "variable=value" to
be part of environment.

Patch by Antoine Leca.
2012-02-09 18:54:45 +01:00
Evgeniy Ivanov
3dd49be938 Allow human readable name for the root device.
Instead of using rootdev= or ramimagedev= in the boot monitor
which are changed to numbers and cannot be used with other
loaders, rootdevname= or ramimagename= are (MINIX-style)
device names always stored as strings.

Patch by Antoine Leca.
2012-02-09 18:54:45 +01:00
Evgeniy Ivanov
8979450631 Rotate kernels/images/modules.
Kernels and system services are stored in a single directory in the
/boot/minix/ and rotated like /boot/images. /boot/minix_latest slink
is created automatically.
System serives are prefixed by "modNN_" to allow to easily load them
using "mod*" pattern.
2012-02-09 18:54:44 +01:00
Evgeniy Ivanov
60a2ce010a Integrate new boot stuff into build scheme.
- Build sys with everything else.
- Gitignore files built by new boot stuff.
2012-02-09 18:54:43 +01:00
Evgeniy Ivanov
7f2d47d84c Remove libkern, leave just header.
Boot stuff dependencies from NetBSD.

Patch by Antoine Leca. Relocated to src/sys.

The port is using the same libminc.a as usual MINIX services (and does
not use NetBSD libkern); the headers imported from NetBSD sys/ tree
have been kept to a minimum (still numbers higher than 30 though.)

Note the peculiar way to use libraries (libsa, libi386, etc.): the
source code is shared, but each component builds its own copy of the
library, with its own set of preprocessor defines.
2012-02-09 18:54:42 +01:00
Evgeniy Ivanov
002fecdd9e Port cdboot. 2012-02-09 18:54:41 +01:00
Evgeniy Ivanov
174e3c15af Import cdboot. 2012-02-09 18:54:40 +01:00
Evgeniy Ivanov
81d26afebe Port MBR.
Patch by Antoine LECA.
2012-02-09 18:54:39 +01:00
Evgeniy Ivanov
6acebc04b6 Import sys/arch/i386/stand/mbr. 2012-02-09 18:54:39 +01:00
Evgeniy Ivanov
fa6c4a2580 Port installboot as installboot_nbsd and rename the old one.
Also following functionality was added:
- Add install_master to the installboot from NetBSD.
- Check if enough space for bootxx.

Old installboot was renamed to installboot_minix.
2012-02-09 18:54:24 +01:00
Evgeniy Ivanov
9f8e6353e5 Import usr.sbin/installboot. 2012-02-09 18:48:13 +01:00
Evgeniy Ivanov
4c4c045f87 Port bootxx. 2012-02-09 18:48:13 +01:00
Evgeniy Ivanov
602233213e Adjust boot from NetBSD.
- Add load_mods command to boot2 (load_mods /dir/mod*).
- Rename resulting binary to boot_monitor.
- Change default banner when used in MINIX.
2012-02-09 18:48:13 +01:00
Evgeniy Ivanov
f119e63750 Fix bug in libsa/ls. 2012-02-09 18:48:13 +01:00
Evgeniy Ivanov
58a2b0008e Initial import of libsa, libkern, bootxx, boot. 2012-02-09 18:48:13 +01:00
Thomas Veerman
972a791882 AVFS/APFS: small cleanup 2012-02-09 16:33:24 +00:00
Thomas Veerman
abd6043a2f AVFS: fix various system call interruption issues
- When cancelling ioctls, VFS did not remember which file descriptor
   to cancel and sent bogus to the driver.
 - Select state was not cleaned up when select()ing process was
   interrupted.
 - Process trying to do a system call at the exact same time as a user
   trying to interrupt the process, could cause the system call worker
   thread to overwrite state belonging to the worker thread trying to
   exit the process. This led to hanging threads and eventual system hang
   when this happens often enough.
2012-02-09 14:24:28 +00:00
Thomas Veerman
4498750810 libchardriver: fix open reply for async devices 2012-02-09 14:17:54 +00:00
Ben Gras
cc1ae59c9b -lminixutil link fixes
. not available and not needed for clang
2012-02-06 16:08:29 +01:00
Evgeniy Ivanov
65f97ea344 Enlarge ramdisk size (blocks). 2012-02-06 16:07:55 +01:00
Tomas Hruby
14fc51e8aa NBSD INCLUDES - fixed missing vm_remap_ro() proto 2012-02-03 20:06:21 +00:00
Ben Gras
1eea0f5680 inet: strncmp() fix 2012-02-03 14:49:18 +01:00
Ben Gras
cdbc4bfb13 temporarily disable update-superblock check
. incompatible with installboot -d FSDEV on mounted filesystems
	. should be re-enabled when netbsd boot loader is default
2012-02-02 15:04:51 +01:00
Thomas Veerman
b33f504e8f APFS: fix link issue when compiling with Clang 2012-02-02 15:00:01 +00:00
Thomas Veerman
a65ff8a1aa INET: fix 'improved' assert 2012-02-02 11:53:52 +00:00
Thomas Veerman
23491b7f46 Remove unused variables 2012-02-02 10:47:06 +00:00
Thomas Veerman
224a0f6e90 INET: fix a few GCC compilation warnings 2012-02-01 13:24:28 +00:00
Thomas Veerman
71634240a0 libpuffs: make GCC happy 2012-02-01 13:23:33 +00:00
Thomas Veerman
4d3a0887b4 AVFS: only put mount point when it was used as one
When a mount operation fails and the FS exits, free_proc could try and
clean up resources associated with the mount point before the mount
thread itself can do that. However, the clean up procedure should only
clean up resources that were actually in use.
2012-02-01 13:22:53 +00:00
Thomas Veerman
d4cdd59eaa service: allow starting service with user's realuid 2012-02-01 13:21:56 +00:00
Thomas Veerman
d5210e9bdd e1000: reset hardware before stopping 2012-01-30 16:47:11 +00:00
Thomas Veerman
a87ec6840f INET: remove erroneous assert
The queue may contain established connections which have
tc_connInprogress clear.
2012-01-30 16:09:08 +00:00
Thomas Veerman
1ff24e3f2f Don't panic on a misconfigured machine 2012-01-30 15:16:20 +00:00
Thomas Veerman
1fc399a5c1 Add permission test for bind and socket
Also, apply forbidden patch to VFS from AVFS (fixes hanging test56 if
it has the permission test).
2012-01-30 15:16:20 +00:00
Thomas Veerman
9330d92639 INET: drop privileges upon startup 2012-01-30 15:16:20 +00:00
Thomas Veerman
becf700bc2 APFS: drop privileges upon startup
Move SERVICE_LOGIN to rs.h global header so it's accessible for all.
2012-01-30 15:16:20 +00:00
Thomas Veerman
9233fdb359 AVFS: make forbidden check for specific proc instead of fp 2012-01-30 15:16:20 +00:00
Thomas Veerman
0e537f1085 AVFS: initialize root FS before receiving new work 2012-01-30 15:16:20 +00:00
Thomas Veerman
0bd011affd PM: extend srv_fork to set a specific UID
Currently, all servers and drivers run as root as they are forks of
RS. srv_fork now tells PM with which credentials to run the resulting
fork. Subsequently, PM lets VFS now as well.

This patch also fixes the following bugs:
 - RS doesn't initialize the setugid variable during exec, causing the
   servers and drivers to run setuid rendering the srv_fork extension
   useless.
 - PM erroneously tells VFS to run processes setuid. This doesn't
   actually lead to setuid processes as VFS sets {r,e}uid and {r,e}gid
   properly before checking PM's approval.
2012-01-30 15:16:19 +00:00
Erik van der Kouwe
4bee3cff2e Prevent the ramdisk makefile from failing if the last image is not ELF 2012-01-27 13:10:00 +01:00
Tomas Hruby
5c0927e108 SMP - clock calibration spurious IRQ deadlock fix
- this patch fixes a deadlock which may occur if we get a
   spurious interrupt while calibrating clocks during the boot
   time. Since we never handle interrupts while in the kernel
   (BKL locked) the interrupt code locks the lock. This is a
   different situation, a corner case, boot time only. We do not
   return to userspace but to the kernel, so the BKL is not
   unlocked. So we need irq handler which leaves the BKL
   unlocked.  The clock handler does it already, this patch adds
   a dummy spurious irq handler for the same reason. It is better
   to handle the situation this way to keep the normal runtime
   code simple.
2012-01-26 11:39:40 +00:00
Tomas Hruby
c468f4efa5 SMP - no_apic=0 and acpi=1 set when CONFIG_SMP=y
- this is a temporary change which makes images compiled for SMP
  boot in SMP mode by default.

- this change is needed until we can configure the multiboot
  images from the boot loader again.
2012-01-25 19:02:13 +00:00
Tomas Hruby
9e1d244cbe Revert 93b9873a56
- non need to have free PDEs per CPU since we only run one
  instance of the kernel at any time
2012-01-25 18:59:18 +00:00
Ben Gras
57b2fe851c mtree: zoneinfo dirs 2012-01-20 19:13:25 +01:00
Antoine Leca
57794c6690 Don't overwrite old mv, ln, cp, etc man pages with new rm 2012-01-20 09:48:48 +00:00
Thomas Veerman
e894c9e1b5 Don't print events that happen often 2012-01-19 17:06:14 +00:00
Thomas Veerman
700641afb8 lseek should not yield a negative file position 2012-01-19 16:48:01 +00:00
Thomas Veerman
5691dca9f4 Don't try to find file position beyond double indirect blocks 2012-01-19 16:47:47 +00:00
Thomas Veerman
ddbdca6cdb Add support for survival of crashed FSs
When an FS crashes, VFS will clean up resources tied to that FS:
 - Pending requests to the FS are canceled (i.e., fail with EIO)
 - Threads waiting for a reply are stopped (i.e., fail with EIO)
 - Open files are marked invalid. Future operations on a file descriptor
   will cause EBADF errors.
 - vmnt entry is cleared, so in-flight system calls that got past the
   file descriptor check but not yet talking to the crashed FS, will
   fail with EIO.
 - The reference counter of the mount point is decreased, effectively
   removing the crashed FS from the file system tree. Descendants of
   this part of the tree are unreachable by means of a path, but can
   still be unmounted by feeding the block special file to unmount(2).

This patch also gets rid of the "not a known driver endpoint" messages
during shutdown.
2012-01-19 14:21:46 +00:00
Ben Gras
dd59d50944 mfs: mark blocks clean when invalidated
. it could happen that newly filled blocks were still marked
	  dirty
	. causing unnecessary i/o and the new warning of the superblock
	  being written
2012-01-18 17:51:04 +01:00
Thomas Veerman
a6d0ee24c3 Use correct value for _NSIG
User processes can send signals with number up to _NSIG. There are a few
signal numbers above that used by the kernel, but should explicitly not
be included in the range or range checks in PM will fail.

The system processes use a different version of sigaddset, sigdelset,
sigemptyset, sigfillset, and sigismember which does not include a range
check on signal numbers (as opposed to the normal functions used by normal
processes).

This patch unbreaks test37 when the boot image is compiled with GCC/Clang.
2012-01-16 11:42:29 +00:00
Thomas Veerman
a282e942bf INET: initialize timer to not-in-use 2012-01-16 11:09:46 +00:00
Thomas Veerman
e35528ae79 New zoneinfo port from NetBSD 2012-01-16 11:03:25 +00:00
Thomas Veerman
e257c999b8 Replace rm and rmdir with NetBSD version 2012-01-16 10:46:14 +00:00
Thomas Veerman
f18dab92bf Remove unused variable 2012-01-16 10:12:29 +00:00
Thomas Veerman
078adc7ed7 Increase thread stack space for GCC compiled images 2012-01-16 10:12:29 +00:00
Thomas Veerman
e6c98c3c55 AVFS: Return actual last dir when path is named by a symlink
Last_dir didn't consider paths that end in a symlink and hence didn't
actually return the last_dir when provided with one. For example,
/var/log is a symlink to /usr/log. Issuing `>/var/log' would trigger
an assert in AVFS, because /var/ is not the actual last directory; /usr/
is.

Last_dir now verifies the final component is not a symlink. If it is, it
follows the symlink and restarts finding of the last the directory.
2012-01-16 10:12:29 +00:00
David van Moolenbroek
c89aaf7a87 vfs/avfs: renumber stat calls so as to be unique
The old stat call numbers are still supported for a while.
2012-01-14 00:27:07 +01:00
David van Moolenbroek
2c685f34e0 Cut PM out of the adddma/deldma/getdma call path 2012-01-14 00:27:06 +01:00
David van Moolenbroek
8cb7ba7951 Remove obsolete PROCSTAT/getsigset call. 2012-01-14 00:27:06 +01:00
Jan Wieck
2fe79d0b76 Implement AcpiOsStall, AcpiOsSleep, AcpiOsGetTimer
- change AcpiOsRemoveInterruptHandler() to print a warning
  instead of panic.

- we do the same in AcpiOsInstallInterruptHandler().

Signed-off-by: Tomas Hruby <thruby@few.vu.nl>
2012-01-13 18:57:53 +00:00
Ben Gras
4668b84158 vm_remap_ro
- allows shared memory to be mapped in readonly

- ben@minix3.org & tom@minix3.org
2012-01-13 11:30:01 +00:00
Tomas Hruby
88f990e122 VM - vm_unmap() takes SELF as valid argument 2012-01-13 11:30:01 +00:00
Tomas Hruby
974452d4dd VM - clear vminhibit iff it was set 2012-01-13 11:30:01 +00:00
Tomas Hruby
758d788bbe SMP - asyn send SMP safe
- we must not deliver messages from/to unstable address spaces.
  In such a case, we must postpone the delivery. To make sute
  that a process which is expecting an asynchronous message does
  not starve, we must remember that we skipped delivery of some
  messages and we must try to deliver again once the source
  address space is stable again.
2012-01-13 11:30:01 +00:00
Tomas Hruby
0bb56e0e04 SMP - smp_schedule()
- always issues an IPI
2012-01-13 11:30:01 +00:00
Tomas Hruby
41bd5f2fc6 SMP - cpu_is_idle made volatile 2012-01-13 11:30:00 +00:00
Tomas Hruby
8fa95abae4 SMP - fixed usage of stale TLB entries
- when kernel copies from userspace, it must be sure that the TLB
  entries are not stale and thus the referenced memory is correct

- everytime we change a process' address space we set p_stale_tlb
  bits for all CPUs.

- Whenever a cpu finds its bit set when it wants to access the
  process' memory, it refreshes the TLB

- it is more conservative than it needs to be but it has low
  overhead than checking precisely
2012-01-13 11:30:00 +00:00
Tomas Hruby
0a55e63413 SMP - fixed IPI livelock
- two CPUs can issue IPI to each other now without any hazzard

- we must be able to handle synchronous scheduling IPIs from
  other CPUs when we are waiting for attention from another one.
  Otherwise we might livelock.

- necessary barriers to prevent reordering
2012-01-13 11:30:00 +00:00
Tomas Hruby
0468fca72b SMP - do_update fix
- adjust_proc_slot() must preserve scheduling info, for example
  on which cpu the process should run

- do_update() - consitency check
2012-01-13 11:30:00 +00:00
Tomas Hruby
192db70960 KERNEL - cause SIGSEGV if bad pointer to kernel 2012-01-13 11:30:00 +00:00
Tomas Hruby
c82a5dd3e3 KERNEL - mini_senda simplification 2012-01-13 11:29:59 +00:00
Tomas Hruby
e4d46a2146 KERNEL - has_pending() not exposed
- has_pending() takes a special argument that tells the code
  whether we are scanning for asynchronous message or something
  else.

- has_pending() is not used directly anymore

- the new functions are wrappings around has_pending() to make
  the use more comfortable.

- these functions should become static inline eventually
2012-01-13 11:29:59 +00:00
Tomas Hruby
8d0a1f71bf KERNEL - do_privctl() fix
- after a driver is restarted, do not register permissions
  which are already set again.
2012-01-13 11:29:59 +00:00
Arun Thomas
fecaba7ff1 Increase ramdisk size for clang 2012-01-12 17:01:48 +01:00
Antoine Leca
36d29dedd5 Allow clang for kernel compilation
Remove .ident sections, and force separations of .text and
.data sections into separate program headers, for the benefit
of the check done by MINIX boot monitor in multiboot mode.
2012-01-12 13:36:22 +01:00
Thomas Veerman
a4d01f8a83 Fix tll state bug
When a lock has read-serialized and read-only locks, releasing the read-
serialized lock would not set the state to read-only when no other locks
were pending.
2012-01-12 11:30:24 +00:00
Ben Gras
af6c39fb9b /etc/shells 2012-01-11 15:23:05 +01:00
Ben Gras
7cd4002083 vm: clear map cache after kernel requests
. fixes a dirty tlb situation (i.e. random crashes)
	  on some hardware, seemingly new intel architectures
	  (e.g. my desktop i7 machine)
2012-01-11 01:15:35 +01:00
Ben Gras
0bb4bb9d51 move pax and chmod for useradd 2012-01-11 00:26:09 +01:00
David van Moolenbroek
11c15db517 rc: transitional fix for old fstab 2012-01-10 15:05:50 +01:00
Evgeniy Ivanov
d6c5a1280e Convert s_block_size on MFSv3.
On MFSv3 s_block_size is stored on disk, hence bytes should be converted
on big endian.
2012-01-08 23:52:57 +04:00
Ben Gras
99c3099c32 another UPDATING tweak 2012-01-08 16:34:46 +00:00
Ben Gras
2ea10eeb75 added etcforce to UPDATING 2012-01-08 15:56:31 +00:00
Ben Gras
3e4fa99098 Added UPDATING about mfs clean flag changes. 2012-01-06 00:28:08 +01:00
David van Moolenbroek
c25e2eb0cf avfs: fix for root file system not being unmounted
Also no longer have avfs crash whenever a file system server crashes.
2012-01-04 14:10:10 +01:00
David van Moolenbroek
c21cdd3154 sys/queue.h: add LIST_FOREACH_SAFE to netbsd copy 2011-12-23 19:05:09 +01:00
David van Moolenbroek
3e46876a73 hgfs: fix atime/mtime attribute setting bug
Reported and investigated by Antoine Leca.
2011-12-23 19:02:57 +01:00
David van Moolenbroek
80b03d929d hgfs: resolve gcc -W warnings 2011-12-23 19:01:56 +01:00
David van Moolenbroek
472a91708a Move hgfs.h to minix includes directory 2011-12-23 19:01:14 +01:00
Ben Gras
51de979ed9 fix for checking CLEAN-ness of ramdisk image
. pre-cleanflag ("old") mkfs generates without CLEAN flag,
	  causing boot not working because imgrd disappears after 1st
	  close
	. fixed sanity check for this situation
	. disable imgrd disappearing in memory driver so
	  readonly mount succeeds in case it happens anyway
2011-12-23 15:10:01 +01:00
Ben Gras
94715d8e54 import netbsd ext2fs fsck and newfs 2011-12-22 23:07:23 +01:00
Ben Gras
4d4057d8a2 netbsd fsck driver import
. fsck driver parses /etc/fstab and invokes sub-fscks
	. further simplifies fs handling in rc
2011-12-22 23:07:15 +01:00
Ben Gras
6b6d114a21 import netbsd libprop 2011-12-22 18:03:13 +01:00
Ben Gras
59ff5cbd87 mfs: clean flag
. also implement now-possible fsck -p option
    	. allows unconditional fsck -p invocation at startup,
    	  only checking each filesystem if not marked clean
    	. mounting unclean is allowed but is forced readonly
    	. updating the superblock while mounted is now not
    	  allowed by mfs - must be done (e.g. by fsck.mfs)
    	  on an unmounted fs
	. clean flag is unset by mfs on mounting, and set by
	  mfs on clean unmounting (if clean flag was set at
	  mount time)

Signed-off-by: Ben Gras <ben@minix3.org>
2011-12-22 16:53:32 +01:00
Ben Gras
9a664b4984 mfs: restore readonly mounting
. use dirty marking hooks to check and warn
	  when inodes/bufs are marked dirty on a readonly
	  mounted fs
	. add readonly mount checks to restore readonly
	  mounting

Signed-off-by: Ben Gras <ben@minix3.org>
2011-12-22 01:29:27 +01:00
Ben Gras
9b7d357ca1 mfs: use macros to mark blocks and inodes dirty
. No functional change
	. Only serves to get hooks to do checks in
	. e.g. should things be marked dirty when we are
	  mounted readonly

Signed-off-by: Ben Gras <ben@minix3.org>
2011-12-22 01:29:27 +01:00
Ben Gras
34a8901eb8 vfs,avfs: verify an interpreter was found on #! line
. if not, NULL *interp is dereferenced
2011-12-21 23:44:13 +01:00
Thomas Veerman
3fb6c995e0 Make all tests use common.c
This will make sure that all file descriptors are closed through
the use of the start() function.
2011-12-21 12:59:22 +00:00
Thomas Veerman
de5a9a3e8b AVFS: Use scratchpad instead of m_in to pass around file descriptors
Some code relies on having the file descriptor in m_in.fd. Consequently,
m_in is not only used to provide syscall parameters from user space to
VFS, but also as a global variable to store temporary data within VFS.
This has the ugly side effect that m_in gets overwritten during core
dumping.*

To work around this problem VFS now uses a so called "scratchpad" to
store temporary data that has to be globally accessible. This is a simple
table indexed by process number, just like fproc. The scratchpad allows
us to store the buffer pointer and buffer size for suspended system calls
(i.e., read, write, open, lock) instead of using fproc. This makes fproc
a bit smaller and fproc iterators a bit faster. Moreover, suspension of
processes becomes simpler altogether and suspended operations on pipes
are now less of a special case.

* This patch fixes a bug where due to unexpected m_in overwriting a
coredump would fail, and consequently resources are leaked. The coredump
was triggered with:
$ a() { a; }
$ a
2011-12-21 10:52:51 +00:00
Thomas Veerman
c89bc85009 Don't repeat out-of-space messages
This patch makes PFS, EXT2 and MFS print only once that they're out of
space. After freeing up space and running out of space again, the message
will be printed again also.
2011-12-21 10:47:28 +00:00
Thomas Veerman
54c0eb9aa6 Compare read/write buf size against SSIZE_MAX instead of "< 0"
The nbyte in read(int fildes, void *buf, size_t nbyte) is unsigned,
so although technically we're doing the same comparison, this is more
in line with POSIX.

The comparison was moved to read_write as that routine is used within
VFS to let it VFS write out coredumps.
2011-12-21 10:46:09 +00:00
Thomas Veerman
9f9f893123 Mark filp as in use on fd dup'ing 2011-12-21 10:45:29 +00:00
Tomas Hruby
71533c8a83 ACPI - fixed initialization of pci briges irqtable
- if no IRQ table is found, we report that ACPI cannot map IRQ
  correctly

- fixes mapping of IRQs in KVM because in this case we just fall
  through and use the IRQ configured by BIOS. PCI still reports
  that it failed to use ACPI. It is a hint if things go wrong.
2011-12-20 13:10:36 +00:00
Tomas Hruby
b73089ce3e ACPI extended irq - fixed uninitialized variable 2011-12-20 13:08:45 +00:00
Tomas Hruby
aca5862db1 SMP - kernel links again 2011-12-20 13:05:25 +00:00
Tomas Hruby
9cd53f1cc0 SMP - fixed compilation and removed warnings 2011-12-20 12:58:20 +00:00
David van Moolenbroek
84662ec4b3 libsys: unbreak getidle() 2011-12-16 16:06:09 +00:00
Ben Gras
eccb2d685c tty timeout bugfix
. timeouts were always delivered to console
	. Fix by Lucio Tomarchio
2011-12-16 09:54:20 +01:00
Ben Gras
668fa5cf2a nbsd.config: make timezone explicit 2011-12-14 17:02:31 +01:00
Ben Gras
194e51aff0 workaround for cvs not handling many args 2011-12-14 01:14:36 +01:00
David van Moolenbroek
c5fae8a617 dec21140A: change debugging key to Shift+F7 2011-12-12 16:45:45 +01:00
Raja Appuswamy
8ab7667da4 ahci: NCQ support 2011-12-12 14:13:05 +01:00
Thomas Veerman
94da86cbee Discard process' pending request upon incoming PM request
When a process wants something done from VFS, but VFS has no worker
threads available, the request is stored and executed later. However,
when PM also sends a request for that process at the same time, discard
the pending request from the process and give priority to PM. The request
PM sends is either an EXIT or a DUMPCORE request, so we're not interested
in executing the pending request anyway.
2011-12-12 08:20:35 +00:00
David van Moolenbroek
e7db2d3588 Add fbd -- Faulty Block Device driver
This driver can be loaded as an overlay on top of a real block
device, and can then be used to generate block-level failures for
certain transfer requests. Specifically, a rule-based system allows
the user to introduce (overt and silent) data corruption and errors.

It exposes itself through /dev/fbd, and a file system can be mounted
on top of it. The new fbdctl(8) tool can be used to control the
driver; see ``man fbdctl'' for details. It also comes with a test
set, located in test/fbdtest.
2011-12-11 22:45:46 +01:00
David van Moolenbroek
f65e531ee4 blocktest: support for stateless driver restarts 2011-12-11 22:41:51 +01:00
David van Moolenbroek
4005bba437 libblockdriver: clear IPC only on stateful restart
This removes a race condition when the block driver performs a
complete restart after a crash (the new default). If any user of
the driver finds out its new endpoint and sends a request to the
new driver instance before this instance has had the chance to
initialize, then its initialization would clear all IPC state and
thereby erroneously cancel the incoming request. Clearing IPC
state is only desired upon a stateful restart (where the driver's
endpoint is retained). This information is now passed to and used
by libblockdriver accordingly.
2011-12-11 22:36:19 +01:00
David van Moolenbroek
95d1f25b28 blocktest: resolve label/minor in userland
The test script now resolves the device node into a <label,minor>
pair, so that the blocktest driver itself no longer has to. This
removes blocktest's dependency on VFS' internal data structures.

Also allow blocktest to be linked using with gcc/clang.
2011-12-11 22:35:37 +01:00
David van Moolenbroek
35cf8beb33 procfs: add /proc/dmap 2011-12-11 22:35:33 +01:00
David van Moolenbroek
aa712e7e73 IS: unbreak F6 2011-12-11 22:34:54 +01:00
David van Moolenbroek
6f374faca5 Add "expected size" parameter to getsysinfo()
This patch provides basic protection against damage resulting from
differently compiled servers blindly copying tables to one another.
In every getsysinfo() call, the caller is provided with the expected
size of the requested data structure. The callee fails the call if
the expected size does not match the data structure's actual size.
2011-12-11 22:34:14 +01:00
David van Moolenbroek
9701e9dfd2 Servers: cleanup of some gcc -W warnings 2011-12-11 22:33:37 +01:00
David van Moolenbroek
c6459e8ec1 acpi: resolve warnings 2011-12-10 16:14:23 +01:00
Thomas Veerman
26d359a30c Properly unlock on mount failure 2011-12-09 15:47:42 +00:00
Thomas Veerman
5cbbfc69e7 Change asserts with side effects into panics 2011-12-09 14:46:10 +00:00
Thomas Veerman
706873142e Fix dangling symlink resolving for AVFS and add test61 2011-12-09 10:34:23 +00:00
Ben Gras
21168577a5 add -L for future compiler-rt lib location 2011-12-08 18:07:57 +01:00
Thomas Veerman
0a61519eea Provide core dumping support for AVFS 2011-12-08 10:47:11 +00:00
Thomas Veerman
5acd97c7e0 Enable GCOV always 2011-12-07 15:20:26 +00:00
Thomas Veerman
1adb3b60be Fix test43 for GCC/Clang 2011-12-07 15:17:38 +00:00
David van Moolenbroek
cb98b586fd btrace: gcc fix 2011-12-07 11:52:40 +01:00
Ben Gras
3b0ee3f234 fix bzip2 location in nbsd_ports 2011-12-06 16:22:54 +01:00
Ben Gras
1c3c4d73ef add previous stat symbols as aliases
. renaming them causes fallout
	. only use the new ones though
2011-12-06 16:03:58 +01:00
David van Moolenbroek
67c012b3fc printer: perform probe on startup
This stops the printer driver from hanging the entire system when
/dev/lp is opened on systems that do not have a parallel port. With
this change, the printer driver shuts down immediately after loading
on such systems.
2011-12-05 16:28:10 +01:00
David van Moolenbroek
ed007ca416 libbdev: extended version
This version of libbdev support asynchronous communication,
recovery after driver restarts, and retrying of failed transfer
operations.
2011-12-05 16:28:09 +01:00
David van Moolenbroek
9221586f37 vfs/avfs: req_newdriver should use fs_sendrec
Using sendrec directly only results in problems. While it is not
clear whether using fs_sendrec is the best option, it is at least
an improvement.

Also remove some legacy cruft.
2011-12-05 16:28:09 +01:00
David van Moolenbroek
e379e0936e Make block drivers restart with new endpoint 2011-12-05 16:28:08 +01:00
David van Moolenbroek
2f622b3a51 SEF: default to endpoint-changing restart 2011-12-05 16:28:07 +01:00
David van Moolenbroek
ba19c83fd6 RS: support for endpoint-changing driver restarts 2011-12-05 16:28:07 +01:00
David van Moolenbroek
01015cc0e2 init: write boot entry to root wtmp
This unbreaks the fsck check on startup.
2011-12-05 13:56:16 +01:00
David van Moolenbroek
2a7bc122c1 .gitignore: add more generated files 2011-12-03 23:04:45 +01:00
Raja Appuswamy
f9d1614e6d libmthread: add mthread_event_fire_all 2011-12-01 14:53:20 +01:00
David van Moolenbroek
8a0b9de41a libblockdriver: allow for mixed sync/async replies 2011-11-30 19:07:04 +01:00
David van Moolenbroek
db087efac4 VFS/FS: REQ_NEW_DRIVER now provides a label 2011-11-30 19:05:26 +01:00
Thomas Veerman
41e69065b9 Fix stat symbols 2011-11-30 11:17:13 +00:00
David van Moolenbroek
c9ba1ad75d libpuffs: remove unused block device code 2011-11-29 16:56:52 +01:00
Raja Appuswamy
03a8d06668 adding rwlock and event support to mthread 2011-11-29 14:35:22 +01:00
David van Moolenbroek
e2758c6759 libblockdriver: allow for not handling partitions
Each block driver now gets to specify whether it is a disk block
driver, which implies it wants the library to handle getting and
setting partitions for it.
2011-11-28 16:42:35 +01:00
Ben Gras
a03f679e88 Don't run package rc's when booting from cd. 2011-11-28 14:32:18 +01:00
Ben Gras
c40c9f7ed0 etc: Make fixes
. leave out obsolete binary_sizes*
	. really force targets
2011-11-28 14:32:18 +01:00
Thomas Veerman
fb50da9dad Fine grained compatibility with _RENAMEd symbols
The NetBSD libc provides a mechanism to have versions of system calls.
By 'renaming' symbols to a new version, freshly compiled programs will
automatically use the new symbol iff they use the proper header files. The
old, not renamed, version of the symbol will still exist (after being moved
to the compat directory), so old programs can still link.

Since MINIX doesn't support dynamic linking, the whole rename mechanism
doesn't really work for us. However, removing it would create a huge diff
with the current NetBSD libc.

A lot of the compat code relies on things we don't (seem to) have, and
therefore does not get built and linked. This causes trouble for tools like
autoconf, which will fail to find the renamed symbols. For example,
currently select gets renamed to __select50 in libc. Autoconf looks for
'select' and doesn't find it and reports we don't have it. This is where
the compat.S stub comes into play: it generates the old symbols and jumps to
the new symbols. However, as this is done in one object file, all renamed
symbols get linked together, causing binaries to be huge. This patch fixes
that by generating an object file for each renamed symbol.

This patch also makes the MISSING_SYSCALLS more complete and marginally
reduces the diff with NetBSD.
2011-11-28 10:12:44 +00:00
Thomas Veerman
92b61c816d Fix many more comiler warnings
Most warnings were harmless, some real bugs. Test set should now compile
cleanly with ack, gcc, and clang.
2011-11-28 10:07:55 +00:00
Thomas Veerman
b4fb061802 Implement issetugid syscall
Implement issetugid syscall and provide a test. This gets rid of the
scary "Unsecure. Implement me" warning during compilation.
2011-11-28 10:03:43 +00:00
Ben Gras
ef99a7a3dc vm: report cropped region sizes
. when reporting on regions, only report part of the
	  region (addr and length) that really has memory mapped
	  into it
	. to minimise core files
2011-11-26 15:12:17 +00:00
Joseph Koshy
39b1aee2e1 fix rm -f
"/bin/rm" should not issue a usage message if the "-f" option was
    specified.
2011-11-25 17:49:09 +01:00
David van Moolenbroek
fd4c2b74f3 Add block device tracing facility
The implementation is in libblockdriver, and works transparently for
all block drivers. The new btrace(8) tool can be used to control block
tracing; see ``man btrace'' for details.
2011-11-25 13:47:21 +01:00
David van Moolenbroek
a9f89a7290 vfs/avfs: map O_ACCMODE to R_BIT|W_BIT on recovery 2011-11-24 13:57:36 +01:00
David van Moolenbroek
e8f944d3ca avfs: unbreak process termination on PM_DUMPCORE 2011-11-24 13:04:52 +01:00
David van Moolenbroek
0aa01a2dce Add vbox -- VirtualBox time sync driver
Sets time forward to match the host time.

Started automatically if the corresponding device is present.
2011-11-23 18:15:43 +01:00
David van Moolenbroek
b4d9ac91ba FS servers: fix dependencies broken in git-af01bda 2011-11-23 17:03:16 +01:00
Ben Gras
1062293981 change rc defaults reading
. always install them (overwrite)
	. source minix one from /etc/defaults/rc.conf
	  so that it'll get read on existing installs
	  without overwriting rc.conf (doesn't happen by default
	  as it's user-editable), needed for new netconf system
	. reported by Tenkawa
2011-11-23 15:36:51 +00:00
Ben Gras
79853dc9bc netconf: run lspci earlier for netconf -c
. Reported by Tenkawa
2011-11-23 15:24:42 +00:00
David van Moolenbroek
5a70f42ab6 gcore: uninitialized variable fix and cleanup 2011-11-23 15:56:13 +01:00
David van Moolenbroek
9874865a6f ahci: FUA (force-write) support 2011-11-23 15:40:38 +01:00
David van Moolenbroek
b4d909d415 Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.

The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.

After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
  in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
  reintroduced

As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.

Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-23 14:06:37 +01:00
Ben Gras
7643f2b25e compile fix (gdb, binutils) 2011-11-23 13:35:50 +01:00
Arun Thomas
fa00de707c small ramdisk: install all password-related files 2011-11-23 10:28:00 +01:00
David van Moolenbroek
1e1db53986 Introduce sys_getregs call, and let vfs use it 2011-11-22 02:07:33 +01:00
Adriana Szekeres
c30f014a89 gcore command to coredump a process 2011-11-22 22:07:41 +01:00
Adriana Szekeres
eaa29370f4 ELF core files 2011-11-22 22:07:40 +01:00
Arun Thomas
ebdac755af ramdisk: install all password-related files 2011-11-22 19:58:45 +01:00
Arun Thomas
32aabfab40 ramdisk: build pwd_mkdb 2011-11-22 16:45:17 +01:00
Ben Gras
cd107a5ac3 fxp: add device id in the right place 2011-11-22 11:17:49 +01:00
Ben Gras
81bdb22b0c fxp: add device id for LU82551IT
Contributed by Roman Ignatov
2011-11-22 11:09:42 +01:00
David van Moolenbroek
f29ba928cc isofs: unbreak lseek 2011-11-22 11:46:55 +01:00
Ben Gras
8b69d04fff csu: add code to call constructors to be used by clang
. clang-linked binaries were not calling global constructors, as the
	  code to do so wasn't in csu/ and linked
	. it does work for gcc as it uses its self-supplied crt{begin,end} code
	. this commit copies netbsd's crt{begin,end}.S, which contains
	  constructor/destructor calling code, called from .init and .fini
	  sections already accumulated by the linker. the _init function was already
	  called by the C startup code before calling main.
	. based on work by Antoine Leca
2011-11-20 20:20:51 +01:00
Thomas Cort
0c9b539a35 compat.S: add getpwnam() alias.
Needed for finding getpwnam() when a prototype is not given.
2011-11-20 18:36:42 +01:00
Ben Gras
c24d15b2db pm: add mproc table sanity check feature
. make procfs check it
	. detects pm/procfs mismatches
	. was triggered by ack/clang pm/procfs:
	  add padding to mproc struct to align ack/clang layout
	  to fix this
2011-11-18 17:18:10 +01:00
Ben Gras
b1eba81b9d simplify build logic a bit
. always compile acpi, with clang, so never have
	  build/clean inconsistencies; can be enabled (i.e. run
	  at boot time) by setting acpi variable in the boot monitor
	. always strip binaries with the right strip cmd, so never
	  have ack/elf strip inconsistencies
2011-11-18 17:11:17 +01:00
Arun Thomas
3f9ef4ac46 make: set MACHINE_ARCH variable
Also, modify sys.mk so we continue to build with -O
2011-11-18 16:22:25 +01:00
Ben Gras
f379b3eecb remove ftpd200 2011-11-18 12:19:50 +01:00
Ben Gras
ee8602a486 minor bugfixes caught by clang warnings 2011-11-18 12:18:23 +01:00
Ben Gras
79285c3664 libarchive: not for ack
. fixes compile error due to missing bzlib.h for ack
	. one less ack library
2011-11-18 11:49:21 +01:00
Vivek Prakash
79bfef9aab import NetBSD bzip2 and libbz2 2011-11-18 11:11:04 +01:00
Ben Gras
349a158056 base system hooks for pkgsrc drivers
. rc script and service know to look in /usr/pkg/.. for
	  extra binaries and conf files
	. service split into parsing config and doing RS request
	  so that a new utility (printconfig) can just print the
	  config in machine-parseable format for netconf integration
	. converted all base system eth drivers/netconf
2011-11-16 16:18:21 +01:00
Ben Gras
2c57ee566b pwcache_userdb alias.
. mainly so configure can find it without the prototype.
2011-11-16 12:59:40 +01:00
David van Moolenbroek
34c14b1cab More cleanup: no more CMOS and SCSI ioctls 2011-11-16 11:50:53 +01:00
Vivek Prakash
c4bce95897 Define flags in sys/stat.h 2011-11-15 17:14:57 +01:00
Ben Gras
41f823ae4c release.sh: add -e
. allows extra files in release for flexibility
	. written by Jan Wieck
2011-11-15 14:18:56 +01:00
Ben Gras
0811b47a71 df: add case for MFSv3
. fix for FSes mounted with '-t mfs' syntax
2011-11-14 22:18:31 +00:00
Ben Gras
5c00743626 Switch to NetBSD passwd format
Based on work by Vivek Prakash and Gianluca Guida.

See UPDATING about caveats on currently existing accounts.

	. restores netbsd libc pwcache functions
2011-11-14 14:47:42 +00:00
Ben Gras
cedeabb357 mainstream-format fstab format
. detect both formats in /etc/rc
	. generate new format in setup
	. obsoletes /etc/fstab.local: everything can go in /etc/fstab
	. put shutdown/reboot/halt and a copy of /usr/adm/wtmp
	  (/etc/wtmp) on root FS so that we can do shutdown checks before
	  mounting /usr
	. new fstab format makes getfsent() and friends work
2011-11-14 14:47:28 +00:00
Thomas Veerman
4311136125 Fix compiler warnings 2011-11-14 14:21:39 +00:00
Thomas Veerman
490e0de548 Import librefuse and libpuffs
Import libpuffs and our port of libpuffs. The port was done as part of
GSoC 2011 FUSE project, done by Evgeniy Ivanov. The librefuse import
did not require any porting efforts. Libpuffs has been modified to
understand our VFS-FS protocol and translate between that and PUFFS. As
an example that it works, fuse-ntfs-3g from pkgsrc can be compiled and
used to mount ntfs partitions:
mount -t ntfs-3g <device> <mountpoint>

FUSE only works with the asynchronous version of VFS. See <docs/UPDATING> on
how to run AVFS.

This patch further includes some changes to mount(1) and mount(2) so it's
possible to use file systems provided by pkgsrc (note: manual modifications
to /etc/system.conf are still needed. There has been made an exception for
fuse-ntfs-3g, so it already as an entry).
2011-11-14 11:53:05 +00:00
Thomas Veerman
a209c3ae12 Fix a ton of compiler warnings
This patch fixes most of current reasons to generate compiler warnings.
The changes consist of:
 - adding missing casts
 - hiding or unhiding function declarations
 - including headers where missing
 - add __UNCONST when assigning a const char * to a char *
 - adding missing return statements
 - changing some types from unsigned to signed, as the code seems to want
   signed ints
 - converting old-style function definitions to current style (i.e.,
   void func(param1, param2) short param1, param2; {...} to
   void func (short param1, short param2) {...})
 - making the compiler silent about signed vs unsigned comparisons. We
   have too many of those in the new libc to fix.

A number of bugs in the test set were fixed. These bugs were never
triggered with our old libc. Consequently, these tests are now forced to
link with the new libc or they will generate errors (in particular tests 43
and 55).

Most changes in NetBSD libc are limited to moving aroudn "#ifndef __minix"
or stuff related to Minix-specific things (code in sys-minix or gen/minix).
2011-11-14 10:07:49 +00:00
David van Moolenbroek
85b8fbe72b More cleanup of minix/com.h. 2011-11-11 13:53:29 +01:00
David van Moolenbroek
b477504754 ps(1): remove outdated comment 2011-11-11 11:37:44 +01:00
David van Moolenbroek
7207cf2e37 ps(1) man page: mem/kmem are no longer used 2011-11-11 11:34:50 +01:00
David van Moolenbroek
b1855cdcf2 Change default pager to less(1)
For one thing, less(1) provides better interaction with git.
2011-11-10 16:58:46 +01:00
David van Moolenbroek
af01bda509 libbdev: initial version
The "bdev" library provides basic primitives for file systems to talk
to block device drivers, hiding the details of the underlying protocol
and interaction model.

This version of libbdev is rather basic. It is planned to support the
following features in the long run:

 - asynchronous requests and replies;
 - recovery support for underlying block drivers;
 - retrying of failed I/O requests.

The commit also changes our block-based file systems (mfs, ext2, isofs)
to make use of libbdev.
2011-11-09 14:43:25 +01:00
David van Moolenbroek
0bb27bb0b1 Servers: remove ABI comment 2011-11-07 22:24:59 +01:00
David van Moolenbroek
b02c260ecb Miscellaneous legacy cleanup 2011-11-07 22:20:55 +01:00
Ben Gras
3fbb50397c stopgap local fstab
. /etc/fstab.local to list user-defined filesystems
	. /usr/etc/rc reads it and runs type-specific fsck if necessary
	. also type-specific mount
2011-11-07 20:37:12 +01:00
David van Moolenbroek
0f3423cd75 Kernel: fix compilation with DEBUG_RACE on 2011-11-07 19:59:02 +01:00
David van Moolenbroek
a80eb6545a blocktest: add system.conf file, too 2011-11-07 18:26:16 +01:00
David van Moolenbroek
2602861f23 Move optset.c into libsys; remove redundant copies 2011-11-07 16:16:08 +01:00
David van Moolenbroek
fc34180cca Add "blocktest" test, for testing block drivers
The test is located in test/blocktest. It requires hand-editing of
its configuration, and is not part of any automated test set.
2011-11-07 14:55:55 +01:00
David van Moolenbroek
ff542f0b27 atl2: prevent compiler memory access misordering
While no problems have been observed in practice yet, modern compilers
may reorder memory access operations, and that could lead to problems
with memory-mapped I/O typically done by drivers. This patch prevents
any potentially problematic reordering by the compiler in the ATL2
driver.

In addition, this patch removes a number of gcc/clang warnings.
2011-11-07 14:25:09 +01:00
Ben Gras
c83a90e2f1 mfs: ditch global readahead 2011-11-06 19:15:12 +01:00
David van Moolenbroek
47aad344c3 Drivers: fix issues introduced by commit b198207 2011-11-04 23:54:04 +01:00
David van Moolenbroek
5320333614 ahci: prevent compiler memory access misordering
While no problems have been observed in practice yet, modern compilers
may reorder memory access operations, and that could lead to problems
with memory-mapped I/O typically done by drivers. This patch prevents
any potentially problematic reordering by the compiler in the AHCI
driver.
2011-11-04 14:13:24 +01:00
David van Moolenbroek
e1d867b686 ahci/libdriver: multithreading support
This patch adds support for executing multiple concurrent requests on
different devices on the same AHCI controller. The libdriver library
has been extended to include a generic multithreading interface, and
the AHCI driver has been extended to make use of this interface.

The original version of this code has been written by Arne Welzel.
2011-11-04 09:37:53 +00:00
David van Moolenbroek
0812293b47 procfs: fix for PID reuse between updates
In certain cases, a process ID may be reused between two lazy updates
of procfs's PID table. If the new associated process slot has a lower
index than the old one, this will trigger an assert in vtreefs, as the
new PID name entry is added before the old one is removed. This patch
fixes the problem by always first removing old PID name entries before
adding new ones.

Bug reported by Stephen Hatton.
2011-11-01 23:50:55 +00:00
David van Moolenbroek
8b00ebde78 Kernel: remove unused MF_ASYNMSG 2011-11-01 19:21:19 +00:00
Arun Thomas
d134121b09 Install servers in GCC/clang case 2011-11-02 18:46:06 +01:00
Arun Thomas
8b4492ed1c kernel: remove unused var 2011-11-02 18:45:08 +01:00
Arun Thomas
62841e2935 pm: remove dead minix_munmap functions 2011-11-02 18:43:59 +01:00
David van Moolenbroek
1992529666 Kernel: fix for senda erroneously setting errors
Bug reported and fixed by Arne Welzel.
2011-10-31 18:43:37 +00:00
Thomas Veerman
65e54c23e3 PFS is also a system proc 2011-10-28 12:49:47 +00:00
Thomas Veerman
febb4403ff Reenable backcall detection 2011-10-27 15:29:37 +00:00
Thomas Veerman
823e42c3e3 Make AVFS deal intelligently with back calling FSes
PUFFS file systems need to make back calls for every operation we
send to them. Consequently, they cannot handle block reads and writes
themselves. Instead, the root file system has to do it (for now).

When the mount operation causes an FS to make a back call, AVFS now
concludes that every block read and write for that FS has to go
through the root file system.
2011-10-27 15:29:23 +00:00
Antoine LECA
b1c2329954 clean up PM_SCHEDULED 2011-10-25 16:37:21 +00:00
Thomas Veerman
9e21d55e37 err_code has to be preserved as well. Short term fix 2011-10-25 12:12:20 +00:00
Ben Gras
ca3fe9fdab fix typo 2011-10-25 00:05:38 +02:00
Ben Gras
5cdc54a699 Clarify install instructions.
Thanks to Chris Johns for feedback.
2011-10-23 16:19:13 -07:00
Ben Gras
391372193c release: by default leave src/.git
. facilitates easy updates of installs
	. removal can be restored with release.sh -m
2011-10-07 13:56:55 +00:00
Ben Gras
586776e98b use generic gcc* in man.conf
. catches all gcc versions
	. also neatly handles the case in which there are no
	  gcc versions (makewhatis doesn't complain)
2011-10-06 19:00:16 +00:00
Antoine LECA
de346b24e8 fix compile of test23 2011-10-06 18:54:08 +00:00
Antoine LECA
230dd159df dec21140A driver warnings fix 2011-09-29 17:37:47 +00:00
Ben Gras
f2e991439e mdocml/man: dummy cleandepend target 2011-09-28 15:36:24 +00:00
Ben Gras
0c3983b25a update/fix manpage support
. add bsd-style MLINKS to minix man set, restoring aliases
	  (e.g. man add64 -> int64)
	. update daily cron script to run makewhatis and restore makewhatis
	  in man Makefile (makedb), restores functionality of man -k
	. netbsd imports of man, mdocml, makewhatis, libutil, apropos
	. update man.conf with manpage locations, restoring man [-s] <section>
	. throws out some obsolete manpages
2011-09-28 15:24:15 +00:00
Thomas Veerman
8c9e62b299 Revert to using flushtlb instead of invlpg
Somehow the usage of invlpg causes Minix to crash on Qemu. Reverting
temporarily until we have a proper fix.
2011-09-27 15:15:51 +00:00
Ben Gras
bc0a39238e worldstone benchmark script
. also imports seq(1) to help it
	. add -C option to time(1) to print tsc difference
	. increase col width for ministat for tsc numbers
2011-09-24 14:49:55 +00:00
Ben Gras
49532259e5 mfs: improve & simplify secondary cache logic
. fixes "!" errors when booting from cd
2011-09-23 15:02:20 +00:00
Arun Thomas
05341dfeb0 sef: build sef_debug_header only when needed 2011-09-19 18:17:45 +02:00
Ben Gras
833183a9e1 vm: undo accidental JUNKFREE on 2011-09-19 15:36:46 +00:00
Arun Thomas
f71ec49525 kernel: Remove legacy boot vars from pre_init 2011-09-19 16:39:51 +02:00
Ben Gras
1dfd43ac27 boot e820 memory detection fixes 2011-09-19 13:36:03 +00:00
Arun Thomas
cb54d96eec Remove legacy boot monitor vars 2011-09-16 20:10:47 +02:00
Arun Thomas
46581e701a Add MKBOOTPARAM option 2011-09-16 17:31:07 +02:00
Arun Thomas
92fa3189ab MKSYSDEBUG: conditionally compile more debug code 2011-09-16 15:25:26 +02:00
Thomas Veerman
90cde23c19 Cleanup more resources upon exit 2011-09-16 10:16:57 +00:00
Thomas Veerman
1c928cf61a Remove debug print 2011-09-16 10:16:32 +00:00
Thomas Veerman
200b9d7339 Unmap drivers upon exit 2011-09-16 10:16:00 +00:00
Thomas Veerman
203937456e Fix off-by-one errors and increase PATH_MAX to 1024
In some places it was assumed that PATH_MAX does not include a
terminating null character.

Increases PATH_MAX to 1024 to get in sync with NetBSD. Required some
rewriting in AVFS to keep memory usage low (the stack in use by a thread
is very small).
2011-09-12 09:00:24 +00:00
Ben Gras
98233fa144 ext2: replace debug printf by assert 2011-09-09 16:33:55 +00:00
Ben Gras
4857d5d554 add -lminixfs with fs support routines
. move cache size heuristic from mfs there
	  so mfs and ext2 can share it
	. add vfs credentials retrieving function, with
	  backwards compatability from previous struct
	  format, to be used by both ext2 and mfs
	. fix for ext2 - STATICINIT was fed no.
	  of bytes instead of no. of elements, overallocating
	  memory by a megabyte or two for the superblock
2011-09-08 16:52:13 +00:00
Thomas Veerman
ce1a2793f9 Fix off-by-one error 2011-09-08 15:10:57 +00:00
Thomas Veerman
d4b72e81b2 Cleanup servers to make GCC/Clang a little happier 2011-09-08 13:57:03 +00:00
Thomas Veerman
f78fb05676 Check group range for sanity 2011-09-08 12:23:03 +00:00
Arun Thomas
8a0901c4cb Add MKTRACE 2011-09-07 17:52:48 +02:00
Thomas Veerman
35d86581e5 Backwards compatibility fixup for GCC/Clang 2011-09-06 12:36:16 +00:00
Thomas Veerman
7db039347a Make AVFS resilient against failing back calls 2011-09-06 10:38:16 +00:00
Thomas Veerman
8a266a478e Increase gid_t and uid_t to 32 bits
Increase gid_t and uid_t to 32 bits and provide backwards compatibility
where needed.
2011-09-05 13:56:14 +00:00
Thomas Veerman
fde9a258d0 Make dev_t 32-bits and provide backwards compatibility 2011-09-05 08:52:57 +00:00
Ben Gras
e68cf3bf89 add /etc/rc.subr and /etc/rc.conf 2011-09-04 20:40:42 +00:00
Arun Thomas
4ca68d42a0 Add MKLIVEUPDATE and MKSTATECTL 2011-09-02 16:57:22 +02:00
Ben Gras
86b5fa5102 get rid of leftover _DIRENT_NAME_LEN=61 2011-09-01 16:27:28 +00:00
Ben Gras
a7590083f1 sort is not a nbsd port (yet) 2011-09-01 16:14:04 +00:00
Ben Gras
7b6c90125c nbsd_fetch: force cvs to use ssh 2011-09-01 15:48:24 +00:00
Ben Gras
ad0c787900 define MSG_*
. these are not actually supported at runtime
	. will allow packages to compile easier, and still work
	  in some cases (e.g. glib2)
2011-09-01 13:03:15 +00:00
Ben Gras
121d8aba4d release.sh: undo tarup add 2011-08-31 22:00:42 +00:00
Antoine Leca
9df7ce09aa Range-check values building mbdev in boot monitor 2011-08-31 15:04:38 +02:00
Arun Thomas
5cddf6dce8 libsys: don't pull in strerror 2011-08-30 21:10:34 +02:00
Evgeniy Ivanov
4806f7c308 Fix ext2 symlink bug.
rip->i_size is a target length without trailing '\0'.

Reported by Ben Gras.
2011-08-29 21:54:25 +00:00
Thomas Veerman
7f24c2b3ca Unverbose mount 2011-08-26 15:49:37 +00:00
Thomas Veerman
78183bddff Let FSes exit themselves upon system shutdown
During shutdown all processes are semi-exited and FSes are unmounted.
This semi-exit causes trouble for FUSE mounts as they still need access
to file descriptors and working directory in order to unmount.
2011-08-26 15:17:53 +00:00
Thomas Veerman
27a2afc1e7 Clean up tests and do runtime test for max name length
- Remove unused code
- Use standard functions declared in common.c
- Change tests to do a runtime test for the max name length of a path
  component (aka NAME_MAX). The actual value might differ from the hard
  coded NAME_MAX depending on the file system used.
2011-08-26 13:16:16 +00:00
Thomas Veerman
8a73de51f1 Tell VFS how many requests an FS can handle concurrently 2011-08-26 12:47:43 +00:00
Thomas Veerman
30be017762 Store and use max concurrent requests 2011-08-26 12:47:43 +00:00
Vivek Prakash
12d9a08f0d import NetBSD mkdir
. add symlink from old location /usr/bin/mkdir for
	  for compatability
2011-08-25 14:35:12 +00:00
Thomas Veerman
c78308f469 Increase max number of arguments 2011-08-22 13:44:24 +00:00
Thomas Veerman
e09714ab53 Turn off block read debugs and turn on mount debugs 2011-08-22 13:24:35 +00:00
Thomas Veerman
4ee157f5ce Report error instead panicing 2011-08-22 13:08:38 +00:00
Thomas Veerman
1f28a4b83e Remove verbosity 2011-08-22 13:08:03 +00:00
Thomas Veerman
68011701bd Reduce block special file (thread) lock scope 2011-08-22 11:51:29 +00:00
Thomas Veerman
55d926cbaa Allow block special files to be file locked 2011-08-22 11:51:01 +00:00
Thomas Veerman
63a49a4b90 Add entry for ntfs-3g 2011-08-22 11:50:26 +00:00
Thomas Veerman
ae2159c371 Fix locking issues with back calls from FSes 2011-08-19 14:17:35 +00:00
Ben Gras
195190912f malloc build fixes 2011-08-18 22:30:51 +00:00
Ben Gras
e81a0fd9c1 use minix malloc
. default jemalloc is not too easy to compile without threads
	  libraries/types
	. non-default malloc has odd virtual address space binge problem
	. switch to ack/minix malloc in old libc for now
2011-08-18 21:52:09 +00:00
Arun Thomas
43e574558f tools/Makefile: tweak AVFS/APFS logic
-Fixes GCC/clang build issue
2011-08-18 18:54:52 +02:00
Ben Gras
88e57eee69 make time functions pass PCTS test
. fixes a problem in building gawk wanting to provide
	  its own mktime otherwise
2011-08-18 14:02:57 +00:00
Arun Thomas
27c0e801f2 Cleaner MKSYSDEBUG option 2011-08-18 15:21:29 +02:00
Ben Gras
6811647e20 mtree: skip all major-0 devices, not just (0,1) 2011-08-18 13:05:27 +00:00
Ben Gras
cc64313b80 is: stopgap for broken _USEVFS check 2011-08-17 16:27:46 +00:00
Ben Gras
f984dbba70 increase system-wide filename limit to 255
. move mfs-specific struct, constants to mfs/, so
	  mfs-specific, on-disk format structs and consts are
	  fully isolated from generic structs and functions
	. removes de and readfs utils
2011-08-17 16:00:01 +00:00
Thomas Veerman
e2bdf44720 Update UPDATING document on how to build AVFS 2011-08-17 13:53:22 +00:00
Thomas Veerman
a18a007361 Range fix from PFS 2011-08-17 13:42:38 +00:00
Thomas Veerman
a6bd3f4a22 Merge AVFS and APFS 2011-08-17 13:40:36 +00:00
Ben Gras
ee48228aa0 pfs: fix range check
. debugged and fixed by Jan Wieck
2011-08-17 12:39:33 +00:00
Ben Gras
e187d30348 add mail group 2011-08-17 11:38:41 +00:00
Ben Gras
e3dafb45b4 add postfix, postgresql users 2011-08-17 08:42:59 +00:00
Evgeniy Ivanov
bc434254ea MFS: optimize dentry acllocation.
When search for free slot always cache position of last allocated slot,
so next time when need to allocate new slot, we can search from that
position.
2011-08-17 08:41:35 +00:00
Ben Gras
164789226c install: correct error message 2011-08-16 20:40:52 +00:00
Arun Thomas
593e3221fc Rename MKDEBUG to MKSYSDEBUG 2011-08-16 22:30:10 +02:00
Ben Gras
1f198f75d7 pre-install pkg_tarup 2011-08-16 15:24:59 +00:00
Arun Thomas
40592de32d Optionally disable kernel debug code 2011-08-16 17:18:55 +02:00
Ben Gras
4c3e216cbd release.sh: generic package names 2011-08-15 21:46:23 +00:00
Ben Gras
2e84a3f594 release.sh: minor -L fix 2011-08-15 21:40:14 +00:00
Evgeniy Ivanov
13ded5339f Fix ext2 dentry allocation glitch.
When remove dentry, check if cached position is greater than removed
one.
2011-08-15 17:33:51 +00:00
Evgeniy Ivanov
426cddbb30 Add missing put_inode().
Fixes bug from a9a45cddc.
2011-08-15 16:20:06 +00:00
Ben Gras
65de5d71a9 test set build fixes for clang/gcc 2011-08-15 16:07:21 +00:00
Thomas Cort
940bbe18b6 mkdir: allow 'mkdir -p' with trailing '/'
Let's suppose that /usr/tmp exists and one wants /usr/tmp/a/b
If one runs "mkdir -p /usr/tmp/a/b/" (the '/' at the end is
important), then a "File exists" error comes up. Example:

$ rm -rf /usr/tmp/a
$ mkdir -p /usr/tmp/a/b/
/usr/tmp/a/b/: File exists

This breaks gcc47 installation when C++ is enabled, and this
isn't the behaviour of mkdir on NetBSD nor Linix.

This patch fixes the above issue by dropping the trailing '/'.
2011-08-15 09:14:36 +00:00
Ben Gras
58c4a9b5f4 kernel: don't use -ffreestanding
. workaround for clang's stdint.h __STDC_HOSTED__ test
	  that causes the host stdint.h to be ignored for -ffreestanding,
	  causing a type to be double-defined in the kernel
2011-08-13 11:04:37 +00:00
Ben Gras
ca5e8b2c2d kernel: show segment-adjusted pagefault addr 2011-08-12 15:16:52 +00:00
Arun Thomas
7b70f548e4 minlib: Add vm_query_exit 2011-08-12 17:15:42 +02:00
Ben Gras
35cc7fbeb8 kernel: invlpg facility
. only use for single-page invalidations initially
	. shows tiny but statistically significant performance
	  improvement; will be more helpful in certain VM debug
	  modes
2011-08-12 13:08:27 +00:00
Evgeniy Ivanov
55c6f3f507 Fix bugs in ext2 found by clang static analyzer 2011-08-12 12:38:53 +00:00
Arun Thomas
9602f63a72 pm: remove dead function 2011-08-11 17:51:27 +02:00
Evgeniy Ivanov
a9a45cddc4 Fix bugs found in MFS by clang static analyzer. 2011-08-10 20:47:16 +00:00
Ben Gras
10375d2629 don't keep minix-port.patch files in repo
. causes git noise, and unnecessary conflicts
	. are easily generated with 'make nbsd_diff' in tools/
2011-08-10 13:38:12 +00:00
Ben Gras
cd05a95afc recognize ccc-analyzer as gnu-style compiler
. for clang static analysis
2011-08-10 10:39:45 +00:00
Ben Gras
3a44cd477b tty: handle REVIVE case on console device
. can happen on e.g. ^S
	. reported by Stephen Hatton
2011-08-09 16:59:01 +00:00
Arun Thomas
86b061078b Build gcov code only if MKCOVERAGE is yes 2011-08-09 10:39:33 +02:00
Arun Thomas
4dece73bf0 bsd.prog.mk: skip 'install -S' rule for GCC/clang 2011-08-08 14:18:25 +02:00
Ben Gras
4a8ceeebff allow bind() with addr len >= sizeof(sockaddr_in)
. specifically, if it's struct sockaddr, which is
	  1 byte larger than sockaddr_in
	. unbreaks some applications
	. debugged and solved by Jan Wieck
2011-08-05 22:58:03 +02:00
Ben Gras
d477a9ed82 vm/ipc: only report signals when it matters to ipc
. ipc wants to know about processes that get
	  signals, so that it can break blocking ipc operations
	. doing it for every single signal is wasteful
	  and causes the annoying 'no slot for signals' message
	. this fix tells vm on a per-process basis it (ipc)
	  wants to be notified, i.e. only when it does any ipc calls
	. move ipc config to separate config file while we're at it
2011-08-05 20:52:32 +00:00
Arun Thomas
862fb8354d minix.ack.mk: use CPPFLAGS for ACK asm files 2011-08-05 14:16:48 +02:00
Ben Gras
c484bc1dc8 unbreak oxpcie in kernel 2011-08-04 17:26:39 +00:00
Ben Gras
1abfde0e03 remove info after #undef _POSIX_TIMERS 2011-08-04 18:11:16 +02:00
Ben Gras
3977443581 terminfo fixes
. add TERM=minix to builtin terms
	. regenerate compiled-in compile_terms.c
	. fix terminfo db path
	. update termcap command
	. By Antoine Leca
2011-08-04 16:50:57 +00:00
Ben Gras
b9d027bfe2 release.sh: fix -l, add -L option for local packages
. by Jan Wieck
2011-08-03 12:53:01 +02:00
Ben Gras
a99a4b2a05 added missing m_closefrom.c 2011-08-03 12:51:28 +02:00
Ben Gras
c4ea2a195c getsid() implementation 2011-08-02 22:16:59 +02:00
Ben Gras
c0bb1ba1b1 closefrom() as library call 2011-08-02 22:16:58 +02:00
Arun Thomas
d69519f86a kernel: don't build cprofile code by default 2011-08-02 15:25:54 +02:00
Arun Thomas
aaefc6f838 Add MKMCONTEXT option 2011-08-02 13:57:31 +02:00
Ben Gras
989934b37c rename -lutil to -lminixutil
. in preparation for netbsd -lutil
2011-08-01 14:32:14 +02:00
Ben Gras
ed651fafef don't define _POSIX_TIMERS 2011-08-01 13:17:47 +02:00
Arun Thomas
f985ecba0d MKEMBED is now MKSMALL 2011-08-01 11:05:17 +02:00
Arun Thomas
ae561b8f12 Add MKAPIC and MKACPI options 2011-07-31 16:22:43 +02:00
Arun Thomas
fcc2c77af2 ramdisk: For MKEMBED, skip ext2, achi, and acpi 2011-07-30 13:16:16 +02:00
Arun Thomas
1a8cf59d04 Add MKWATCHDOG option 2011-07-29 20:37:39 +02:00
Ben Gras
89f0baab63 add /var/tmp/ for groff 2011-07-28 17:12:57 +02:00
Ben Gras
914d02825f libvassert: vmware VAssert support.
- BSD-licensed Code gratefully taken from the project at
	  http://en.sourceforge.jp/projects/sfnet_vassertlinuxsdk/

	- For more information on vmware VAssert, a powerful debugging
	  facility usable under vmware, see:
	  www.vmware.com/pdf/ws65_vassert_programming.pdf
2011-07-28 03:23:10 +00:00
Ben Gras
f614d0015a mk: single mk fragment for new libc
. allow commands to use it by setting NEED_NBSDLIBC
	. also add mkfiles to clean and cleandepend so they
	  don't break on missing new mkfiles
2011-07-27 18:23:36 +02:00
Arun Thomas
3ca141ab81 Remove legacy swapfs utility 2011-07-27 17:16:17 +02:00
Thomas Veerman
7588db2691 Add support for VFS-FS transaction IDs 2011-07-27 15:49:42 +00:00
Thomas Veerman
ece4c9d565 Add DEV_CLONE_A dev type 2011-07-27 12:23:03 +00:00
Thomas Veerman
9b43de2cb3 Clean up mthread 2011-07-27 09:30:26 +00:00
Antoine Leca
b67a7fca8c ash: don't rely on libc signal names
The bsd signal names are out-of-order compared to the minix ones.

I found out (the hard way) that the (MINIX-descending) ordered list of
signals in <sys/signal.h> does not match the (BSD-descending) ordered
list of signals in usr/src/lib/libc/nbsd_libc/gen/sig{name,list}.c

Beyond being unfortunate, it prevents the trap command of ash to handle
correctly a named signal; a funny test case is
        #!/bin/sh
        trap 'echo trapping signal BUS' BUS
        trap 'echo trapping signal 10 (USR1)' 10
        trap # show me what is currently trapped

As a quick workaround, I disabled the use of the libc-provided
sys_sig{name,list} arrays for ash, and reverted to the hand-made array
which is used by the less capable MINIX libc. It allowed me to use
pkgsrc.
2011-07-26 18:59:52 +02:00
Ben Gras
d810ebe67b add /etc/resolv.conf pointing to minix nonamed
. needed for netbsd libc dns resolution
	. points to minix nonamed
	. /etc/resolv.conf should have the real info
	  (written by netconf / dhcp client)
	. nonamed should be phased out but will probably
	  be around for the 'old' libc
2011-07-26 18:03:04 +02:00
Arun Thomas
6d1095db1e test: define NETBSD_SOURCE for gcc/clang 2011-07-26 16:52:43 +02:00
Arun Thomas
530bd5d486 vfs/rs: for ELF, sep_id should be 0 2011-07-26 15:21:07 +02:00
Arun Thomas
3b08b34ceb Fix test2.sh
-strings is now found in /usr/pkg/bin
2011-07-26 13:50:57 +02:00
Arun Thomas
93bb4036ce Remove bigmake, binsizes, packman 2011-07-26 13:38:27 +02:00
Arun Thomas
2a9322a117 Remove advent and ttt 2011-07-26 11:37:18 +02:00
Arun Thomas
8a8f27951b sys.mk: Check that MKEMBED is defined 2011-07-26 11:26:26 +02:00
Arun Thomas
1d45d57e40 Add MKEMBED option 2011-07-26 08:54:32 +02:00
Arun Thomas
3a69da5f86 usr.bin/Makefile: cosmetic change
-Move mkimage to list of MINIX commands
2011-07-25 11:50:46 +02:00
Arun Thomas
2ad6214ef0 Add sort to nbsd_ports list 2011-07-25 11:43:44 +02:00
Ben Gras
51ffecc181 import elf-only -lcurses
. abandons mixer, gomoku, talk, talkd, top from base system
	. compile top with clang so no ack-compiled program
	  needs -lcurses any more
2011-07-25 11:08:17 +02:00
Vivek Prakash
1ea07af9da Replace uniq with NetBSD version 2011-07-24 21:40:02 +02:00
Arun Thomas
e376fd97ac Skip ACK libs building with GCC/clang 2011-07-24 18:47:07 +02:00
Ben Gras
d2897e946f release.sh: jail building adjustments 2011-07-22 22:10:21 +02:00
Arun Thomas
1e56737131 bsd.prog.mk: include minix.gcov.mk 2011-07-22 18:00:09 +02:00
Arun Thomas
06617e7fdf Import NetBSD mkdep 2011-07-22 17:28:27 +02:00
Ben Gras
01b152d6d9 kernel: add prototype for inkernel_disaster 2011-07-22 15:19:40 +02:00
Ben Gras
b984fa41df Revert "print kernel stacktrace for exceptions in kernel"
This reverts commit eff1369cab.

This was in a working branch and I only intended to commit
exception.c. But I committed the exact inverse. Sorry.
2011-07-22 15:01:44 +02:00
Ben Gras
04d2db3c44 world: add etcfiles
. avoids future UPDATING entries (for hierarchy extensions
	  necessary for make world to work)
2011-07-22 14:57:55 +02:00
Arun Thomas
b7b7b3e63f add vfork to namespace.h 2011-07-22 14:07:04 +02:00
Erik van der Kouwe
dcc683b4ae Also compile the kernel as i586 (instead of i386) 2011-07-22 13:16:10 +02:00
Ben Gras
eff1369cab print kernel stacktrace for exceptions in kernel
fpu alignment check feature, checksum feature
2011-07-22 11:03:45 +00:00
Ben Gras
7ee78ffb82 kernel: improve exception debug printing
. fold 2 exception-in-kernel cases (pagefault and rest)
	  into 1
	. for exceptions that occur in kernel, don't just print
	  kernel stacktrace (typically that is just the exception
	  handler) but also the stacktrace of when the exception
	  happened
2011-07-22 10:57:08 +00:00
Erik van der Kouwe
e3d0bb59ab Avoid MMX and SSE instructions in the MINIX programs and libraries 2011-07-22 11:59:31 +02:00
Thomas Veerman
ea1971bd21 Forgot to rename mmap to minix_mmap 2011-07-22 10:15:47 +00:00
Arun Thomas
f9ccc501f8 Add vfork() system call
-Same semantics as fork() as it's really just a stub
-Eases porting of BSD utilities
2011-07-22 10:55:30 +02:00
Arun Thomas
159b8f71b7 Use 'strip -s' for ELF image 2011-07-22 07:52:34 +02:00
Arun Thomas
db5c83c918 Remove strings(1) 2011-07-21 19:06:06 +02:00
Ben Gras
1341e4aa02 rename size to acksize
.  in keeping with the pattern: elf/binutils tools have
	   regular names, ack tools have 'exceptional' names
2011-07-21 14:31:17 +02:00
Ben Gras
3dd7649ae7 RS: fix bug that overflows r_argv[]
. reported and debugged by Arne Welzel
	. problem is if there are too many args
	. there is a check, but then unconditional NULL termination
2011-07-21 08:08:22 +02:00
Ben Gras
000a9d36be cleanup of libterminfo introduction
. don't install minix <termcap.h> as libterminfo
	  has its own (but still install it in /usr/include.ack)
	. forget minix termcap functions in -lcompat_minix
	. make commands use -lterminfo in netbsd libc compile mode
2011-07-20 18:39:02 +02:00
Arun Thomas
0cd71233e0 release.sh: USB build fix
-Update stat syntax
2011-07-20 16:57:51 +02:00
Arun Thomas
70712c015e release.sh: add missing bootstrap util 2011-07-20 16:03:06 +02:00
Ben Gras
f789fee254 import netbsd sed
. speeds up mkdep (i.e. world builds) significantly
	. have to keep minix /bin/sed for a while because previous
	  usr/etc/rc depends on it
	. force mkdep to use /usr/bin/sed for speedup
2011-07-20 15:14:48 +02:00
Arun Thomas
2a2f25bf29 release.sh: Add date to image name 2011-07-20 11:47:09 +02:00
Arun Thomas
0d9095d116 Fix ISO building
-Update release.sh to use new stat syntax
-Add missing utils to release bootstrap dirs
-Remove needless dependency in ramdisk Makefile
2011-07-20 10:36:37 +02:00
Arun Thomas
3eb22ca4d1 MK option to build only system image programs 2011-07-20 09:57:46 +02:00
Antoine LECA
afd132adc9 share/mk: use original stat -qf 2011-07-19 18:38:06 +02:00
Arun Thomas
5df8be8e7a buildsystem: use dependall target
Improves cache locality by grouping together dependency generation
with building for each program instead of doing a whole-tree dep
generation phase followed by a whole-tree build phase
2011-07-19 15:28:20 +02:00
Erik van der Kouwe
b1408f61b4 Sanity checks prevent VM panic for mmap, vm_remap and map_phys 2011-07-19 08:58:01 +02:00
Arun Thomas
c356e9997e kernel: fix GCC warnings 2011-07-18 19:44:59 +02:00
Vivek Prakash
51e66a47d8 import libterminfo, terminfo.db and stat command 2011-07-18 16:17:14 +02:00
Vivek Prakash
49cab1c73c import NetBSD stat 2011-07-18 16:16:57 +02:00
Ben Gras
832f7f99fd vm: munmap fix leftover 2011-07-18 12:03:58 +02:00
Ben Gras
d83af38877 import ministat utility from freebsd 2011-07-16 17:21:11 +02:00
Ben Gras
cb7a3b0299 mmap rename fix for netbsd libc 2011-07-16 16:52:21 +02:00
Ben Gras
02081e4b62 rename mmap() and munmap()
. it's a good extra interface to have but doesn't
	  meet standardised functionality
	. applications (in pkgsrc) find it and expect
	  full functionality the minix mmap doesn't offter
	. on the whole probably better to hide these functions
	  (mmap and friends) until they are grown up; the base system
	  can use the new minix_* names
2011-07-16 13:01:19 +02:00
Thomas Cort
76356eed97 compat.S: add shmctl(2) 2011-07-16 11:23:05 +02:00
Ben Gras
85f6d866e6 rename mmap MAP_SHARED to MAP_IPC_SHARED
. MAP_SHARED was used to implement sysv shared memory
	. used to signal shareable memory region to VM
	. assumptions about this situation break when processes
	  use MAP_SHARED for its normal, standardised meaning
2011-07-15 18:10:50 +02:00
Evgeniy Ivanov
255ae85b1e Fix time modification on truncate()
POSIX truncate specification says "Upon successful completion, if
the *file size is changed*, this function shall mark for update the
st_ctime and st_mtime fields of the file." This patch prevents
changing of the date fields when the size stays the same.
2011-07-15 14:21:05 +00:00
Thomas Veerman
902e0e27e0 Don't panic if owner has vanished before reply 2011-07-15 14:11:34 +00:00
Ben Gras
bd6944ea49 top: larger size field 2011-07-15 14:15:15 +02:00
Ben Gras
044cd57720 release.sh: jail precaution 2011-07-14 18:36:40 +02:00
Ben Gras
6cdcbc06d5 release.sh: jail install
. Feature to do a 'release' into a permanent
	  and usable FS hierarchy, usable with chroot
	. Just like the temporary staging hierarchy really
	. Useful to checking out and building the latest
	  version of minix from a host minix; to
	  (1) make an uptodate minix jail, and
	  (2) make a sterile, reproducible jail environment, and
	  (3) use as disposable environment in which moving /usr/pkg
	      is ok
	  (i.e. pkgsrc bulk builds)
2011-07-14 16:28:39 +02:00
Thomas Cort
bb9fb905a1 Move uid/gid<=>name functions into libcompat_minix 2011-07-14 03:07:22 +02:00
Ben Gras
4691eeae9f generate sys_errlist without holes
. strerror() assumes this
	. remove generated libminc/errlist.c
	. errno's in <sys/errno.h> have to be in sorted order
	. filtering out some errno.h in Makefile lets us use near-stock
	  errlist.awk
2011-07-13 23:42:07 +02:00
Thomas Cort
42c2ae9786 compat.S: add setlocale(3) 2011-07-13 21:38:05 +02:00
Ben Gras
ebffaa4250 import libcrypt
. move crypt() from minix-specific to netbsd -lcrypt
2011-07-13 18:19:27 +02:00
Ben Gras
6c9aa8a9ca don't declare closefrom()
Please enter the commit message for your changes. Lines starting
2011-07-13 14:38:52 +02:00
Erik van der Kouwe
66bc7580c7 Fix e1000 bug introduced in 123cf7 2011-07-13 11:36:10 +02:00
Ben Gras
253c293213 mfs<->vfs stat fallback for old vfs 2011-07-12 18:09:52 +02:00
Evgeniy Ivanov
ef0a265086 New stat structure.
* VFS and installed MFSes must be in sync before and after this change *

Use struct stat from NetBSD. It requires adding new STAT, FSTAT and LSTAT
syscalls. Libc modification is both backward and forward compatible.

Also new struct stat uses modern field sizes to avoid ABI
incompatibility, when we update uid_t, gid_t and company.
Exceptions are ino_t and off_t in old libc (though paddings added).
2011-07-12 16:39:55 +02:00
Evgeniy Ivanov
48331843ea Update minix-port.patch. 2011-07-12 16:39:55 +02:00
Arun Thomas
8a5484202c Support for 82801CAM PRO/100 VE
Contributed by Jan Wieck
2011-07-11 21:10:28 +02:00
Evgeniy Ivanov
5da4a0bd56 Move minimal libc from libsys into separate lib.
Now users can choose between libsys, libsys + libminc and
libsys + libc. E.g. PUFFS/FUSE servers need libsys + libc while
old servers can use libsys + libminc.
2011-07-09 22:32:38 +02:00
Ben Gras
c63a0cfddc protect ioctl() with __BEGIN/__END_DECLS for C++ 2011-07-09 16:12:40 +02:00
Ben Gras
898d9f97f6 libm: remove debug statements 2011-07-09 16:12:14 +02:00
Arun Thomas
b956c8735e Fix GCC image building 2011-07-09 15:04:42 +02:00
Tomas Hruby
a97a80178e E1000 - Intel 82571EB Gigabit Ethernet Controller 2011-07-08 20:31:21 +02:00
Tomas Hruby
6dea092dec E1000 - pci probing
- once we know it is not an Intel device, it is not a match
2011-07-08 20:31:21 +02:00
Tomas Hruby
123cf7fe37 E1000 - reading EEPROM
- once the DONE bit is set, we already have the data
2011-07-08 20:31:21 +02:00
Tomas Hruby
48a4ff2307 E1000 - fixed reading MAC from EEPROM
- makes case which is correct according to Intel docs the default
2011-07-08 20:31:21 +02:00
Antoine Leca
e582fc2a6f Force SPROFILE=1 while compiling profile command 2011-07-08 20:31:21 +02:00
Tomas Hruby
d75138be00 E1000 - fixed reading/writing device registers
- the pointers must be flagged as volatile because otherwise they
  might be "optimized" by a compiler. It is a common good
  practice to access the registers this way, the keyword is in C
  for a reason.

- for instance, in eeprom_eerd() when polling a register the
  compiler, under certain conditions, may decide upon the first
  read and if it does not break the loop it assumes that the
  value is not going to change and thus stays in an infinite
  loop.
2011-07-08 20:31:21 +02:00
Arun Thomas
170457b73f profile.h: Don't hide structs and macros 2011-07-08 18:10:56 +02:00
Arun Thomas
084f96981b Disable sprofile by default
-Reduces kernel memory usage
2011-07-08 17:28:58 +02:00
Ben Gras
9aa4fb0dc6 update nbsd port patch files 2011-07-08 16:51:20 +02:00
Ben Gras
a4ac03c188 libm: add i387/ dir, fix test51 compilation
. if $MACHINE_ARCH is unknown, use $MACHINE like in libc
	. fixes test51 compilation for gcc/clang (with other compile
	  and link fixes)
2011-07-08 16:34:40 +02:00
Ben Gras
cf7f7d0ef1 nbsd libc: global constructors run sanity check 2011-07-08 16:34:40 +02:00
Thomas Veerman
b61266eb51 Fix compiler warnings and mutex deadlock 2011-07-08 13:59:07 +00:00
Ben Gras
25bd2bd8fa world: add servers install target
. previously happened for install in tools/
  . reported by Evgeniy Ivanov
2011-07-07 23:06:00 +02:00
Thomas Cort
f66e550c80 namespace.h: add entry for shutdown(2) 2011-07-07 18:47:06 +02:00
Ben Gras
545ac12f3d nbsd libc: no alias for getpw* minix compat symbols 2011-07-06 19:02:17 +02:00
Ben Gras
9fdd167da4 nbsd libc: disable i386 exec*() optimisation 2011-07-06 11:36:24 +02:00
Ben Gras
afc8f3defa compat.S: succincter and without mktemp 2011-07-05 16:17:29 +02:00
Ben Gras
434119ab89 stopgap measure to define originals of __RENAMEd symbols 2011-07-05 15:07:59 +02:00
Ben Gras
a9d15dd3e4 pm, vfs: don't print something for bogus calls 2011-07-05 13:21:48 +02:00
Vivek Prakash
97c7d358ea Replace indent with NetBSD version
- minix-port.patch is empty as it compiles unchanged
2011-07-05 12:37:57 +02:00
Ben Gras
4e37b49261 descr: add -I to mask forget /usr/include for ack 2011-07-04 16:16:10 +02:00
Ben Gras
f3d5a9dc61 Reduce compiler/libraries/headers cases to only two
1. ack, a.out, minix headers (moved to /usr/include.ack),
	   minix libc
	2. gcc/clang, elf, netbsd headers (moved to /usr/include),
	   netbsd libc (moved to /usr/lib)

So this obsoletes the /usr/netbsd hierarchy.

No special invocation for netbsd libc necessary - it's always used
for gcc/clang.
2011-07-04 04:09:52 +02:00
Ben Gras
a0e986b1f9 new mtree script
. skip /proc (allow make etcfiles without unmounting /proc)
  . bit more readable
2011-07-04 03:04:52 +02:00
Ben Gras
9c01ceb576 introduce sqrt_approx() in -lsys
. use this to avoid -lm dependency in mfs
2011-07-04 02:51:12 +02:00
Ben Gras
cf3b75c687 tools/Makefile: don't install servers (workaround)
. if the build target is invoked again for the install target, the
     stack sizes aren't set properly. A workaround is to only build
     and not install the servers. (Installing them doesn't really make
     sense anyway.)
2011-07-03 15:01:18 +02:00
Ben Gras
86a226680b vfs: don't SUSPEND for unknown calls
. returning ENOSYS helps for implementing
	  new calls with forwards compatability
2011-07-02 17:19:13 +02:00
Arun Thomas
03ff167d4d Add bin/ hierarchy 2011-07-01 18:43:15 +02:00
Arun Thomas
49a93d54be Update minix-port.patch 2011-07-01 17:53:12 +02:00
Arun Thomas
db0be09803 release.sh: Add /bin/rm to bootstrap 2011-06-30 14:00:24 +02:00
Arun Thomas
35305f8f7c release.sh: install(1) should go in /bin 2011-06-30 13:42:43 +02:00
Thomas Cort
66b369c62c opendir(3): on success, don't clobber errno
The opendir(3) function was setting errno to ENOTDIR even
when the directory existed and was opened successfully. This
caused git to falsely detect an error.

This change moves the errno assignment into the failure code
block. It also adds a test to test24 to check for errno
changing when opendir(3) returns success.
2011-06-29 19:58:41 +02:00
Ben Gras
82932c0d6b new gcc mkheaders location
. Try to be flexible about it this time
2011-06-29 19:35:23 +02:00
Ben Gras
83b3a3df74 release.sh: add /usr/pkg/bin to $PATH for clang 2011-06-29 19:24:50 +02:00
Arun Thomas
881431bf7e Remove obsolete m4 Makefile 2011-06-29 17:45:24 +02:00
Arun Thomas
5971d0532c GCC build option for elf libs and usr.bin 2011-06-29 10:32:37 +02:00
Arun Thomas
ecb1c96fc5 Build libelf and mkimage in world 2011-06-29 09:33:40 +02:00
Arun Thomas
2e8d1eda1b Replace m4 with NetBSD version
-Create usr.bin hierarchy
-Update minix-port.patch to include m4
2011-06-29 09:33:30 +02:00
Vivek Prakash
ef60bcc0a6 Updated hier(7) man page to conform 3.1.8 2011-06-28 22:53:36 +02:00
Arun Thomas
cf04da3ebe Restore stripping of elf binaries in ramdisk 2011-06-28 17:49:45 +02:00
Arun Thomas
9902a435cd Simplify ELF library build logic
-Remove obsolete clang-libraries and gnu-libraries targets
-Buildworld now builds elf-libraries as well
2011-06-28 17:27:50 +02:00
Ben Gras
d0d7b43342 minix.libc.mk: simpler netbsd libc invocation
. startup files being mentioned explicitly confuses libtool
2011-06-28 17:17:44 +02:00
Arun Thomas
daa14edc0d kernel: make clang-buildable 2011-06-28 15:34:19 +02:00
Arun Thomas
08c8ee9f52 docs/UPDATING: use date of push for newest entry 2011-06-28 12:03:11 +02:00
Arun Thomas
e8777fd906 docs/UPDATING: revise date in newest entry 2011-06-28 11:59:35 +02:00
Thomas Cort
55c7e24c74 use ${PKGPATH} instead of ${CATEGORIES}/${PKGBASE}
Some packages are in multiple categories (one example is
devel/libgetopt). This broke the IF statement because
${CATEGORIES} got expanded to "cat1 cat2". The proper
variable to use is PKGPATH.
2011-06-27 21:18:47 +02:00
Thomas Cort
69bf8e4f71 add pkgsrc hooks for building pkgs w/nbsd_libc
Add two makefiles to manage compiling packages with NetBSD libc.

  *  minix.libc.mk contains the proper CFLAGS/LDFLAGS
  *  pkgsrchooks.mk contains the logic for setting the flags.
  *  update bmake

Several pkg-config files were added to help pkgsrc learn about
the c, minlib, and compat_minix libraries.
2011-06-27 15:10:34 +02:00
Ben Gras
ec84a2cfa5 .gitignore: add obj-elfbase-nbsd 2011-06-25 18:05:01 +02:00
Arun Thomas
93ae43f577 boot: Add multiboot support
Not yet fully spec-compliant; work in progress
2011-06-24 17:21:51 +02:00
Ben Gras
e785381d4d introduce option to time assert()s
. remove a few asserts in the kernel and 64bi library
    that are not compatible with the timing code
  . change the TIME_BLOCKS code a little to work in-kernel
2011-06-24 16:00:42 +02:00
Ben Gras
aba3746220 release.sh: update location of install cmd 2011-06-24 12:17:24 +02:00
Ben Gras
dc1da4a881 undo spurious UPDATING entry 2011-06-24 12:15:58 +02:00
Gianluca Guida
cc17b27a2b Build NetBSD libc library in world in ELF mode.
3 sets of libraries are built now:
  . ack: all libraries that ack can compile (/usr/lib/i386/)
  . clang+elf: all libraries with minix headers (/usr/lib/)
  . clang+elf: all libraries with netbsd headers (/usr/netbsd/)

Once everything can be compiled with netbsd libraries and headers, the
/usr/netbsd hierarchy will be obsolete and its libraries compiled with
netbsd headers will be installed in /usr/lib, and its headers
in /usr/include. (i.e. minix libc and current minix headers set
will be gone.)

To use the NetBSD libc system (libraries + headers) before
it is the default libc, see:
   http://wiki.minix3.org/en/DevelopersGuide/UsingNetBSDCode
This wiki page also documents the maintenance of the patch
files of minix-specific changes to imported NetBSD code.

Changes in this commit:
  . libsys: Add NBSD compilation and create a safe NBSD-based libc.
  . Port rest of libraries (except libddekit) to new header system.
  . Enable compilation of libddekit with new headers.
  . Enable kernel compilation with new headers.
  . Enable drivers compilation with new headers.
  . Port legacy commands to new headers and libc.
  . Port servers to new headers.
  . Add <sys/sigcontext.h> in compat library.
  . Remove dependency file in tree.
  . Enable compilation of common/lib/libc/atomic in libsys
  . Do not generate RCSID strings in libc.
  . Temporarily disable zoneinfo as they are incompatible with NetBSD format
  . obj-nbsd for .gitignore
  . Procfs: use only integer arithmetic. (Antoine Leca)
  . Increase ramdisk size to create NBSD-based images.
  . Remove INCSYMLINKS handling hack.
  . Add nbsd_include/sys/exec_elf.h
  . Enable ELF compilation with NBSD libc.
  . Add 'make nbsdsrc' in tools to download reference NetBSD sources.
  . Automate minix-port.patch creation.
  . Avoid using fstavfs() as it is *extremely* slow and unneeded.
  . Set err() as PRIVATE to avoid name clash with libc.
  . [NBSD] servers/vm: remove compilation warnings.
  . u32 is not a long in NBSD headers.
  . UPDATING info on netbsd hierarchy
  . commands fixes for netbsd libc
2011-06-24 11:46:30 +02:00
Ben Gras
e3f68488ee fix many clang warnings in lib/ 2011-06-23 19:25:36 +02:00
Antoine Leca
6d8d7a88b2 libc!setmode.c: Avoid #if inside macro call
#if inside macro call is undefined behaviour under the C standard
(3.8.3 paragraph 10 for C90, 6.8.10 paragraph 11 for C99).
The same effect can be achieved with a slightly more verbose construct,
putting the whole macro call inside the #ifdef/#else/#endif.
2011-06-23 17:54:17 +02:00
Antoine Leca
3b82f9106d fix clang warnings in boot (edparams)
. add missing prototypes for recently added functions.
2011-06-23 13:42:33 +02:00
Antoine LECA
6edbcbf9a3 sys.mk: Improved defaults (sys.mk) for make(1)
. Handle more compiler names, including most cross-compilers.
  . Allows to use acd(1) and [whatever-]acc to designate ACK compiler.
  . Do not abort (on COMPILER_TYPE not defined) if the compiler name
    is not recognized.
2011-06-22 23:35:26 +02:00
Erik van der Kouwe
35b203fdb1 Initialize NMI watchdog only once, after enabling paging 2011-06-22 17:56:57 +02:00
Ben Gras
fa0fe45103 top: one sanity check endpoint->slot number 2011-06-22 15:49:42 +02:00
Arun Thomas
67c2d2fa54 Remove obsolete mkdist script 2011-06-22 11:15:00 +02:00
Ben Gras
25e9d7317c make /usr/include/i386 2011-06-21 17:28:43 +02:00
Erik van der Kouwe
6e0f3b3bda Split off sys_umap_remote from sys_umap
sys_umap now supports only:
- looking up the physical address of a virtual address in the address space
  of the caller;
- looking up the physical address of a grant for which the caller is the
  grantee.

This is enough for nearly all umap users. The new sys_umap_remote supports
lookups in arbitrary address spaces and grants for arbitrary grantees.
2011-06-10 14:28:20 +00:00
Thomas Cort
25d26d76fd A few aesthetic changes to make the minix port more acceptable
to upstream.

  - revert to upstream version of function prototypes for
    setting the uid and gid fields of the archive_entry.
  - move uid/gid overflow checks into header_common().
  - use archive_set_error() instead of fprintf() for getting
    error message text back to the main program.
2011-06-10 00:40:22 +02:00
Ben Gras
b19820774e fixed clang warnings in drivers/
. changed debug statements system for audio/ to do so
2011-06-09 16:57:51 +02:00
Ben Gras
a77c2973b3 fix clang warnings -R in kernel/ and servers/ 2011-06-09 16:09:13 +02:00
Ben Gras
d34ab6de9f commands: fix clang errors 2011-06-09 08:27:49 +02:00
Erik van der Kouwe
b08dff6011 Remove unused duplicate grant code in umap 2011-06-09 05:06:34 +00:00
Erik van der Kouwe
1e5f9dfa14 Make sys_umap on grants check grantee 2011-06-09 05:05:20 +00:00
Erik van der Kouwe
419dadf528 Remove redundant atwini code, use PIO for bad DMA 2011-06-08 19:24:41 +00:00
Erik van der Kouwe
c2da8cb535 Globally enable -Wall warnings for GCC 2011-06-08 19:21:03 +00:00
Ben Gras
900a273d3d chrootmake: obj-* cleanup instead of just obj-ack 2011-06-08 16:19:09 +02:00
Gianluca Guida
30fa6d8e03 Properly overwrite LIBDIR in mk scripts. 2011-06-08 15:47:37 +02:00
Ben Gras
d490669430 prepare for netbsd libc/headers
. mtree entries for /usr/netbsd
  . install(1) fix for relative symlinks by Antoine Leca
2011-06-07 15:23:23 +00:00
Ben Gras
230b7775fe changes for detecting and building for clang/binutils elf
and minor fixes:
 . add ack/clean target to lib, 'unify' clean target
 . add includes as library dependency
 . mk: exclude warning options clang doesn't have in non-gcc
 . set -e in lib/*.sh build files
 . clang compile error circumvention (disable NOASSERTS for release builds)
2011-06-07 16:49:52 +02:00
Thomas Cort
ef257bcc1b /etc/group: add 'games' group
Several pkgsrc packages under the games category won't install
without a games group. This change adds the group with gid 13,
the default games gid on NetBSD.
2011-06-07 16:48:48 +02:00
Ben Gras
f011d59d67 release.sh, tell_config: variables from /usr/src 2011-06-07 14:34:14 +02:00
Thomas Cort
4a5ca363b5 libarchive: fix bad timestamp bug caused by bit shift.
The file timestamps in archives created by libarchive all had
dates in the year 2038. It was caused by a bit shift in
archive_write_set_format_ustar which shifted 1 instead of 1ull.
2011-06-06 20:52:22 +02:00
Ben Gras
c02833ced6 <timers.h> - add feature to time a code block
. also minor compile fixes for it
2011-06-06 09:04:11 +02:00
Ben Gras
cb13f32a7c release.sh fixes, updates, improvements for git, usb, readability 2011-06-01 22:53:49 +02:00
Ben Gras
fb53eb09cf boot/cdbootblock: use AFLAGS instead of CPPFLAGS
. this unbreaks building the .iso
2011-06-01 22:53:48 +02:00
Erik van der Kouwe
0cb22acbda Fix VM -Wall warnings and enable -Werror 2011-06-01 11:30:58 +02:00
Thomas Cort
f7c1307878 Add chmod o-w /usr
After the default install, /usr was world writable. perl refused to
install itself into /usr with that permission. This fixes the permissions.
2011-05-26 08:22:57 +02:00
Tomas Hruby
423be1545c Fix for SPROFILE == 0
- contributed by Antoine Leca
2011-05-25 09:42:11 +02:00
Tomas Hruby
5582aae6d6 LWIP - removed __unused where inappropriate 2011-05-25 09:41:19 +02:00
Gianluca Guida
aff45df1af libcompat: Add net/gen stub headers.
This helps reducing patching when compiling legacy minix net utils.
2011-05-24 16:54:11 +02:00
Arun Thomas
2a839c735e Import libelf from elftoolchain r1525 2011-05-21 19:15:26 +02:00
Ben Gras
314d09adf7 fix clang warnings in servers/ 2011-05-12 22:23:02 +02:00
Ben Gras
674cd6fd48 larger i/o buffer for exec()
. makes exec() for large executables (e.g. clang, gcc)
    significantly faster

Thanks to Antoine Leca.
2011-05-12 19:12:28 +02:00
Tomas Hruby
bed9e48c12 APIC timer needs rearming before halting the cpu
- time stops if there is no activity and the timer expired before
  we halted the cpu

- restart_local_timer() checks if the timer has expired and if so it
  restarts it

- we do the same when switching back to userspace
2011-05-11 11:54:23 +02:00
Tomas Hruby
f5a1e58f59 PCI - do not panic when ACPI cannot map bridges
- when ACPI does not find mappings for pci brdiges, do no panic,
  only report a warning and continue to a fallback which uses
  only the root bus IRQ routing table. Fail only if that is not
  present.
2011-05-06 17:41:14 +02:00
Arun Thomas
350b60661a ELF multiboot support 2011-05-04 18:51:43 +02:00
Ben Gras
455b809b17 made boot/ into hierarchy of programs
work of Antoine Leca
2011-04-28 01:33:23 +02:00
Erik van der Kouwe
e969b5e11b Remote unused segctl kernel call 2011-04-26 23:28:23 +02:00
Ben Gras
7db58ddc19 OBJDIR-clean generating of .gitignore
By Antoine Leca
2011-04-25 14:18:36 +02:00
Erik van der Kouwe
c50ec2b4e2 fix missing return statement in nonamed causing network failure after 300s when compiling with GCC 2011-04-21 19:14:25 +00:00
Thomas Veerman
20a04a068d Generate .gitignore file for tools directory 2011-04-21 13:20:55 +00:00
Thomas Veerman
22049c1ec3 Enable generation of .gitignore file for the test dir 2011-04-21 13:20:13 +00:00
Thomas Veerman
827daf1fca Make test40 behave
Make test40 behave better. It should create its own subdirectory to
conduct its tests and should not write to /tmp. Also, the master-slave
terminal pair it tries to open might be in use; it should try to obtain
another pair. These changes allow the test to be run multiple times
simultaneously from different paths (to test select() more intensively).
2011-04-21 13:18:00 +00:00
David van Moolenbroek
196de8bc40 sprofalyze.pl: fix for forked-nonexeced processes 2011-04-20 21:39:13 +00:00
Ben Gras
2b09bfde6d kernel: fix logic error in the case vm_lookup fails 2011-04-20 10:17:08 +00:00
David van Moolenbroek
46cee00ad8 Kernel: try_async/try_one fixes
- skip processes that are not asynsending to the target
- do not clear whole asynsend table upon IPC permission error
- be more accepting when one table entry is bogus later on
2011-04-18 22:56:34 +00:00
David van Moolenbroek
afb8067c4f dhcpd: fix newly introduced ACK warnings 2011-04-16 11:13:31 +00:00
David van Moolenbroek
020277a38f libmthread: support for thread-local storage (keys/specifics) 2011-04-14 11:54:43 +00:00
Tomas Hruby
dc8ee363db SMP - INIT IPI deasserting fix
When deasserting the INIT IPI the DM field must be zero
2011-04-13 16:57:43 +00:00
Thomas Veerman
b1a60476c0 Return errors directly instead of using errno 2011-04-13 14:01:13 +00:00
Thomas Veerman
aba392e630 Clean up and fix multiple bugs in select:
- Remove redundant code.
 - Always wait for the initial reply from an asynchronous select request,
   even if the select has been satisfied on another file descriptor or
   was canceled due to a serious error.
 - Restart asynchronous selects if upon reply from the driver turns out
   that there are deferred operations (and do not forget we're still
   interested in the results of the deferred operations).
 - Do not hang a non-blocking select when another blocking select on
   the same filp is still blocking.
 - Split blocking operations in read, write, and exceptions (i.e.,
   blocking on read does not imply the write will block as well).
 - Some loops would iterate over OPEN_MAX file descriptors instead of
   the "highest" file descriptor.
 - Use proper internal error return values.
 - A secondary reply from a synchronous driver is essentially the same
   as from an asynchronous driver (the only difference being how the 
   answer is received). Merge.
 - Return proper error code after a driver failure.
 - Auto-detect whether a driver is synchronous or asynchronous.
 - Remove some code duplication.
 - Clean up code (coding style, add missing comments, put all select
   related code together).
2011-04-13 13:25:34 +00:00
Thomas Veerman
f0740680cd Do not print an error message when a binary is corrupt 2011-04-12 13:09:19 +00:00
David van Moolenbroek
c51cd5fe91 Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.

From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:

- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
  when setting REP_ENDPT, matching requests in CANCEL calls, getting
  DEV_SELECT flags, and retrieving of the real user process's endpoint
  in DEV_OPEN.

The changes in this patch are binary backward compatible.
2011-04-11 17:35:05 +00:00
Gianluca Guida
4e86b0d53f Move back resolv.h, nameser.h and netdb.h as they conflict with NetBSD headers and libc. 2011-04-08 18:50:58 +00:00
David van Moolenbroek
c4928b2df9 libsys: fix micro_delay() 2011-04-08 16:57:44 +00:00
Thomas Veerman
2cde22ee10 Enable a process to find out what the error code was when delivery of an
asynchronous message resulted in an error.

The model here is that:
 - Iff a sender wishes to be notified, the sender MUST check for errors
   BEFORE sending another asynchronous message.

The reason is that in order to remember the error code, we can't clean up
the message table and hence we risk running out of table space. This is
less of a problem when the sender enables notifications only for errors.
2011-04-08 15:23:12 +00:00
Thomas Veerman
7457cbe62f Enable sending a notification when sending of an asynchronous message was
completed (successfully or not). AMF_NOTIFY_ERR can be used if the sender 
only wishes to be notified in case of an error (e.g., EDEADSRCDST). A new
endpoint ASYNCM will be the sender of the notification.
2011-04-08 15:14:48 +00:00
Thomas Veerman
16e0e9370e Use a bitmap for pending asynchronous messages instead of a global flag.
That way it works similar to pending notifications.
2011-04-08 15:03:33 +00:00
Thomas Veerman
9db2311b22 Reduce the number of copies done by the kernel when handling retrieval and
delivery of asynchronous messages.
2011-04-08 14:53:55 +00:00
Tomas Hruby
8200e91073 Fixed smp compilation
- missing u64.h include after 64bit routines for gcc got inlined
2011-04-08 11:52:30 +00:00
Arun Thomas
cd9b4b46f4 libexec: return physaddr info from ELF headers 2011-04-07 12:22:36 +00:00
Tomas Hruby
b2c2dc72bc LWIP - Fix for dhcpd broadcast to work after boot
Dhcp only works if devices are configured with a broadcast source
address at the begining as it currently uses raw ip sockets and the
sockets sets the source address. It is a quick hack and proper hdcpd
fix is preferable
2011-04-07 07:44:27 +00:00
Tomas Hruby
0039e02339 LWIP - scripts
This changes to the boot scripts allow switching to lwip simply by
setting lwip=yes  in the boot monitor.
2011-04-07 07:44:23 +00:00
Tomas Hruby
8171eb0b3d LWIP - dhcpd --lwip
A sort of quick hack for dhcpd to work as a client with lwip server.

- The functionality is not changed unless --lwip switch is supplied.
  dhcpd does not use broadcast udp sockets but some sort of raw
  sockets and changes their behavior during their life by ioctls.

- I thought there is no need to polute lwip just to make dhcp client
  work. Instead I decided to twist the client a little bit.

- It is so far the only big collision I found between inet and lwip.
2011-04-07 07:44:17 +00:00
Tomas Hruby
dca25a1b39 LWIP - the lwip server
The server implements inet-like interface to vfs and drivers. The core
functionality is contained in the liblwip.
2011-04-07 07:44:11 +00:00
Tomas Hruby
abab24b785 LWIP - liblwip
lwip-1.4.0-rc1 imported as liblwip
2011-04-07 07:43:36 +00:00
Tomas Hruby
77172e23f7 LWIP - udp_io_hdr.h
lwip server needs to include struct udp_io_hdr but must not include
struct udp-hdr as it conflicts with its internal type. So it is split
into to files now.
2011-04-07 07:43:03 +00:00
Gianluca Guida
3bbd454578 [NBSD libc] Various fixes. 2011-04-06 15:59:10 +00:00
David van Moolenbroek
8e5cad159f mkfs.mfs: use bitchunk_t (reported by Maurizio Lombardi) 2011-04-05 19:42:08 +00:00
David van Moolenbroek
53ad9d83b9 libvtreefs: return OK from REQ_INHIBREAD (this unbreaks grep on /proc) 2011-03-31 16:23:00 +00:00
David van Moolenbroek
8a925dcf90 tail(1): write partial last line also with -f 2011-03-25 10:59:48 +00:00
David van Moolenbroek
28f2a169da VFS: bugfixes for handling block-special files:
- on driver restarts, reopen devices on a per-file basis, not per-mount
- do not assume that there is just one vnode per block-special device
- update block-special files in the uncommon mounting success paths, too
- upon mount, sync but also invalidate affected buffers on the root FS
- upon unmount, check whether a vnode is in use before updating it
2011-03-25 10:56:43 +00:00
David van Moolenbroek
14e641cb8c PFS: UDS code cleanup:
- coalesce lots of duplicate code
- avoid using errno as much as possible
- fix bugs in some error handling cases
2011-03-25 10:52:53 +00:00
David van Moolenbroek
7a9e3651fd drivers/sb16: delete altogether; the latest copy is in drivers/audio/sb16 2011-03-25 10:48:16 +00:00
David van Moolenbroek
294112db54 misc drivers: remove more non-safecopy support 2011-03-25 10:45:57 +00:00
David van Moolenbroek
f56c4001d5 TTY/LOG driver cleanup:
- remove non-safecopy support from TTY
- make TTY warning-free with gcc -Wall
- remove obsolete diagnostics support
2011-03-25 10:43:24 +00:00
Gianluca Guida
9caa53e8d9 Add libasyn, asynchio support for netbsd libc. 2011-03-23 15:28:22 +00:00
Gianluca Guida
15e58909b6 NBSD includes: Include sys/reboot.h in unistd.h
Minix expect RBT_* ops to be defined in unistd.h.
2011-03-22 14:54:38 +00:00
Gianluca Guida
878ba523ac Add libminlib for NBSD libc compilation.
This library includes various random and minix-specific functions
included in the Minix libc. Most of them should be part of libsys,
and in general it would be nice to extinguish this library over
time.
2011-03-22 13:47:35 +00:00
Gianluca Guida
6bcf58bab8 Add libcompat_minix for NBSD libc
libcompat_minix is a compatibility layer meant to let existing commands to work
with the new libc.
2011-03-18 16:08:26 +00:00
Gianluca Guida
0dc9e0996a Import unmodified NetBSD's libm for compiling with new libc.
As the current libc includes a libm implementation, with the new libc
this is needed. Unneeded (for the moment) archs have been removed.
2011-03-18 15:52:16 +00:00
Gianluca Guida
6f4e3dd910 Move elf headers in common/include and libexec.h in lib/libexec.
It also fixes elf headers for NBSD compilation.
2011-03-18 15:13:05 +00:00
Thomas Veerman
c8d0edc06a - Refactor mthread structure fields to prevent name clashes
- Remove sanity checks for initialized mutexes and condition variables. This
  significantly boosts performance. The checks can be turned back on by
  compiling libmthread with MTHREAD_STRICT. According to POSIX operations on
  uninitialized variables are a MAY fail if, therefore allowing this
  optimization.
- Test59 has to be accommodated to the lack of sanity checks on uninitialized
  variables in the library. It specifically tests for them and will run into
  segfaults when the checks are absent in the library.
- Fix a few bugs related to the scheduler
- Do some general code cleanups
2011-03-18 10:29:54 +00:00
Erik van der Kouwe
03a7d0e8ae Add cttybaud boot monitor variable to control speed of serial console (combine with ctty 0) 2011-03-16 12:25:10 +00:00
Ben Gras
5f1ab506c8 remove some debugging output from vm/region.c
- don't print verbose process map when legitimate errors occur
2011-03-16 11:57:35 +00:00
Thomas Veerman
898cce256f Add support for the 82567LM flavor of e1000 2011-03-15 10:04:35 +00:00
Thomas Veerman
ba8af817fc Fix compilation error. Does not need ansi.h header. 2011-03-10 14:10:16 +00:00
Ben Gras
db8c7af0b8 release.sh: explicitly use the pkgin pkg_install pkg_add
. when switching from the base pkg_install to the pkgin pkg_install,
    the version number changed, causing a compatability problem if the
    old base system binary was inadvertently left behind.

  . this change checks for that situation by specifically invoking
    the pkgin instance of pkg_install and telling the user to install
    it if it doesn't exist.
2011-03-10 12:54:58 +00:00
Dirk Vogt
97980446a4 Cleaning up Makefiles (thx antoine) 2011-03-07 13:54:17 +00:00
Dirk Vogt
aca0749d71 Small fix, implemented getvid/did 2011-03-07 13:31:48 +00:00
Gianluca Guida
f19a4bf1c4 Various fixes for NBSD include.
This patch include various fixes to NBSD includes.

- unistd.h: Avoid different linkages on non-_NETBSD_SOURCE 
 compilation;
- stdlib.h: remove devname declaration.
- sys/select.h: Add _MINIX specific flags.
- limits.h: Add SYMLOOP_MAX and SYMLINK_MAX
- time.h: Fix CLOCKS_PER_SEC and remove BSD's timer_t, as it
  confuses minix own specific timers.
- utmp.h: Set Minix-specific paths and use Minix utmp format.
- param.h: Do not set BSD4_4, as this mostly means sa_len in
  struct sock_addr.
- arch/i386/include/param.h: include <machine/vmparam.h> to 
  add PAGE_SIZE and related macros, defined round_page() and
  trunc_page() for minix compatibility.

- dirent.h: remove DIRBLKSIZ and fix d_ino/d_fileno.
- sys/dir.h: ADD from existing includes and edit include
  conditions.
- sys/dirent.h: include <minix/dirent.h>, fix d_ino/d_fileno.

- sys/fd_set.h: set default FD_SETSIZE at __MINIX_OPENMAX, as 
  the default NetBSD value is too big and cause vfs to return
  an error.
- sys/cdefs.h: Always include <minix/ansi.h>

- minix/paths.h: Add Minix-specific paths.
- minix/dirent.h: ADD, keep only "direct" and "flex"definitions.
- minix/types.h: include <minix/ansi.h>

- sys/Makefile: add sys/dirent.h and statfs.h (forgot!)
- minix/Makefile: add minix/dirent.h

   nbsd_include/minix-port.patch updated accordingly.
2011-03-04 23:15:48 +00:00
Gianluca Guida
693842c855 Sync NBSD libc errno.h with minix errno.h
This patch fixes some wrong error code number in nbsd libc's sys/errno.h
and adds new ones.

As in NetBSD the errno.h is used to automatically generate errlist.c array,
EBADCPU set to 1000 to be a bit too large, so we instruct the awk script
to stop at EDEADEPT (ELAST).
2011-03-04 22:37:43 +00:00
Gianluca Guida
b87af1c325 Fix stat, add fstat and other NBSD libc fixes.
This patch changes the NBSD libc stat implemenation and adds
fstat (and headers), taken from current libc.
It also adds weaks alias to functions in the resolver that
were removed from public use in NetBSD but that are still
used by Minix, and fixes a NetBSD non-REENTRANT bug in
in gen/initdir.c.
2011-03-04 22:31:31 +00:00
Gianluca Guida
98af1ee195 NBSD libc: fix forgot weak_alias
This patch add a few weak_alias forgotten, so that non-internal
symbols are defined to be used from application.

Modifying only the minix-specific part, this patch needs no update
to minix-port.patch.
2011-03-03 16:44:18 +00:00
Gianluca Guida
6567e50a6f mk scripts: add flag for compiling with nbsd libc.
This patch changes the system mk scripts to enable compilation
of programs using the BSD make system to compile with the new
libc.

In details, it does the following:

- it always defines the __MINIX make variable. This can be used,
 in porting applications, to specialize Makefiles for Minix.

 - If the environment variable NBSD is set to something different
  than 'no' and if the compiler is not ack, set NBSD_LIBC to 'yes'.
  This will set the destination lib directory to '/usr/netbsd/lib' 
  and set up CPPFLAGS and LDFLAGS to use new libc's includes and
  library directory.
2011-03-03 16:41:19 +00:00
Gianluca Guida
f4814901af Move even more includes to common/include.
This patch moves more includes (most of them, to tell the truth) to
common/include directory. This completes the list of includes needed
to compile current trunk with the new libc (but to do that you need
more patches in queue).

This patch also contains some modification (for compilation with new
headers) to the common includes under __NBSD_LIBC, the define used
in mk script to specialize compilation with new includes.
2011-03-03 16:39:02 +00:00
Ben Gras
493ea15714 rename aligned() macro to _minix_aligned 2011-03-02 16:05:59 +00:00
Ben Gras
c90cdadcfb auto-tune mfs cache size based on FS usage and remaining system memory 2011-02-28 14:19:19 +00:00
Ben Gras
b6f25271a9 only declare builtin prototypes in C mode 2011-02-28 11:01:31 +00:00
Ben Gras
81b63473c0 minor fix for clang - do_unbind() becomes void 2011-02-27 00:10:33 +00:00
Arun Thomas
685b44e22d Update docs/UPDATING 2011-02-26 23:01:27 +00:00
Arun Thomas
25a790a631 VM and kernel support for ELF 2011-02-26 23:00:55 +00:00
Ben Gras
813ba29677 build fix 2011-02-26 11:42:25 +00:00
Ben Gras
09a652926f don't define CHIP at all any more, just use the namespace-trained name 2011-02-26 10:28:48 +00:00
David van Moolenbroek
61ad5f9b94 Kernel: small comment fix (Bug#562, reported by Ryan Riley) 2011-02-25 16:46:30 +00:00
Dirk Vogt
dd4b0b7646 fix rs/service data structures (add devman_id) 2011-02-25 16:15:54 +00:00
Ben Gras
a1e64f6afd add /usr/include/ddekit dirs 2011-02-25 15:42:53 +00:00
Dirk Vogt
e94953a396 added libddekit 2011-02-25 12:40:31 +00:00
Dirk Vogt
3c9012886f added DDEkit headers 2011-02-25 12:31:20 +00:00
Dirk Vogt
8c8e44d0ae libdevman: IPC wrapper for devman 2011-02-25 12:28:07 +00:00
Dirk Vogt
77fa5b4116 incoporate davman into server/rs 2011-02-25 12:25:03 +00:00
Dirk Vogt
c192577b58 forgot to add devman to system.conf 2011-02-23 14:50:31 +00:00
Ben Gras
beac6b15c9 fix for elf2aout
introduced while making the diff with the original prettier :/
2011-02-23 14:24:17 +00:00
Dirk Vogt
00dcbb9dc6 Added Device Manager (USB hotplug support) 2011-02-23 13:48:03 +00:00
Arun Thomas
bac0222eec ramdisk: Add procfs to ramdisk
-Prevents kernel/procfs mismatches
-Also, strip ELF binaries in ramdisk
2011-02-23 13:05:28 +00:00
Arun Thomas
2bc8ac55ce service: Improve failure message 2011-02-23 12:55:10 +00:00
Ben Gras
659dd75c78 elf2out from netbsd (ported for minix aout) 2011-02-23 12:21:21 +00:00
Erik van der Kouwe
36f9c1155a Restart process after response from async driver on non-blocking select 2011-02-23 10:27:48 +00:00
Dirk Vogt
344c18cf73 procfs: only initialize the first time procfs is mounte 2011-02-22 18:03:33 +00:00
Dirk Vogt
0908191386 _mount.c: don't check for excutable if MS_EXISTING is set 2011-02-22 17:59:08 +00:00
Dirk Vogt
083d30afbb added libusb, a IPC abstraction lib for USB stuff 2011-02-22 10:23:38 +00:00
Gianluca Guida
dc75514afc Set MACHINE_ARCH and MACHINE_CPU to in NBSD libc Makefile 2011-02-22 09:22:26 +00:00
Gianluca Guida
7193ee9890 Add Minix-specific siglist.c 2011-02-22 09:19:14 +00:00
Gianluca Guida
8aa9382e58 Simplify (and fix) NBSD libc's weak references of getcwd. 2011-02-22 09:08:24 +00:00
Ben Gras
0b920bb1cd clang - let buildsystem figure out how to invoke AR, etc., for clang too. 2011-02-22 01:08:29 +00:00
Gianluca Guida
7b9d99251f Fix signal handling in NBSD libc.
lib/nbsd_libc/minix-port.patch updated.
2011-02-21 18:06:54 +00:00
Ben Gras
0e8d574ebd add clean clang libraries target 2011-02-21 16:07:22 +00:00
Ben Gras
cba6e667da clang: support for building elf using temporary elf-targeted binutils. 2011-02-21 16:06:58 +00:00
Dirk Vogt
b9b9cb8a62 Add usb message types to com.h 2011-02-21 15:16:29 +00:00
Ben Gras
c6e6aa8850 mark forked process as such in the kernel p_name
. helps debugging output; you can see the difference
    between parent and child easily (it's sometimes 
    confusing to see an expected endpoint number with
    an unexpected name, i.e. before exec())
  . when processes crash after fork and before exec, it's
    an instant hint that that's what's going on, instead of
    it being the parent (endpoint numbers don't usually convey
    this)
  . name returns to 'normal' after exec(), so *F isn't visible
    normally at all. (Except for for RS which forks apparently.)
2011-02-21 15:05:32 +00:00
Dirk Vogt
55ccdba0f6 USB chapter 9 definitions 2011-02-21 14:09:08 +00:00
Gianluca Guida
4cf101caae Add NBSD-like Minix system includes. 2011-02-21 13:13:55 +00:00
Ben Gras
5518fe9be1 grep - letting calloc() return NULL for 0 storage makes grep "" work 2011-02-20 13:34:53 +00:00
Ben Gras
32f3d9842d pm - sys_sigsend can fail legitimately
. specifically, if a signal handler can't be invoked due
    to process memory, EFAULT is returned from the kernel.
    don't panic() then.
2011-02-18 15:44:54 +00:00
Dirk Vogt
8f860a27d1 Increase maximum filename length for /sys/ 2011-02-18 12:47:25 +00:00
Gianluca Guida
4f294c247f Add NBSDLibc Minix specific files.
This patch mainly copies and modifies files existing in
the current libc implementing minix specific functions.

To keep consisten with the NetBSD libc, we remove 
namespace stubs and we use "namespace.h" and weak
links.
2011-02-17 17:11:09 +00:00
Ben Gras
d6e6ee3043 cleantmp.c - protect against double definition of NDEBUG 2011-02-16 19:04:29 +00:00
Ben Gras
287fee89cb add NOASSERTS make flag that disables assert()s (NDEBUG=1).
. made some checks in vfs/vnode.c also respond to NDEBUG=1.
  . turned on in release builds
2011-02-16 18:58:30 +00:00
Gianluca Guida
7840456b77 Clean up NetBSD includes Minix port.
This patch add the proper .if/.else/.endif to the Makefiles, 
and cleans a bit some includes.

The patch containing all changes required by Minix is 
nbsd_include/minix-port.patch
2011-02-15 20:16:12 +00:00
Gianluca Guida
2635038e5c Fix NetBSD a.out bug in common/libc and port Makefile
This patch includes the required modifications (summarized
in common/lib/libc/minix-port.patch) to make the common
part of the NetBSD libc to compile and work under Minix.
2011-02-15 20:12:04 +00:00
Gianluca Guida
3c9575aadc Clean up NetBSD libc Minix port.
This patch add the proper .if/.else/.endif to the Makefiles, add places I forgot #ifdef __minix and remove newlines.
2011-02-15 16:31:16 +00:00
Gianluca Guida
ad4dda469f Port NetBSD libc functions to Minix.
This patch contains changes to NetBSD libc code base to make it
compile and work on Minix. Some of them are due to actual NetBSD
libc bugs, as we're compiling it in non-reentrant mode and with
a.out support, something not exactly frequent in NetBSD.
Others are proper fixes to port it to Minix (mostly sa_len
parameter missing in socket and a few mmap from files).
2011-02-15 12:19:40 +00:00
Gianluca Guida
58153774b1 This patch modifies the NetBSD basic includes to be Minix
compatible. There are also changes in the make file, mostly to
let them install in /usr/netbsd/include.
2011-02-15 12:03:42 +00:00
Gianluca Guida
b6cbf7203b Import unmodified NetBSD libc in trunk
This patch imports the unmodified current version of NetBSD libc.
The NetBSD includes are in /nbsd_include, while the libc code itself is 
split between lib/nbsd_libc and common/lib/libc.
2011-02-14 19:36:03 +00:00
Gianluca Guida
43d1edf88c Unbreak build by fixing typo.
Sorry.
2011-02-14 15:15:12 +00:00
Gianluca Guida
f7d5c8ff8d Use __NBSD_LIBC to specialize common headers for NetBSD headers compilation.
This patch contains the required changes (under __NBSD_LIBC definition) of the common headers to compile the NetBSD libc.
2011-02-14 15:10:57 +00:00
Gianluca Guida
05480c229a Move network includes and lib.h into common/include subdir.
This patch moves further includes (the network part and lib.h) in common/.
It is the last part to get the netbsd libc to compile under minix. Further moves will be needed as we get the netbsd libc to compile minix itself.

Also, this patch add #ifndef's to termios.h, as it create problems with netbsd's namespace.h.
2011-02-14 12:49:18 +00:00
Ben Gras
c7b2b11ec2 vm: only suspend and resume process with vmctls in pt_writemap in smp mode 2011-02-11 14:56:52 +00:00
Ben Gras
341f8682f2 usr/Makefile: added missing sh minibootstrap.sh 2011-02-10 17:00:02 +00:00
Ben Gras
3beb81a5d0 memory driver: munmap() imgrd after first close.
(that munmap() range not supported yet by vm.)
2011-02-10 15:39:56 +00:00
Ben Gras
9ef5859996 take pkgsrc.conf out of the base system.
. use bmake for pkgsrc instead, reads mk.conf from /usr/pkg/etc/mk.conf
  . tracking bmake from pkgsrc eases tracking pkgsrc
  . further disentangles pkgsrc from base system, reducing maintenance
    burden of pkgsrc
2011-02-10 15:05:18 +00:00
Ben Gras
a909eaa9b1 minor release.sh fixes and tweaks
- pre-install bmake for further (future) base/pkgsrc disentanglement          
- print url properly for pre-install source                                   
- correct <minix/sys_config.h> source location
2011-02-09 16:48:10 +00:00
Ben Gras
dce5e09683 top - able to account kernel cpu time to process 2011-02-08 14:00:48 +00:00
Ben Gras
ab73ac3b6f procfs - export extra kernel time accounting fields 2011-02-08 13:59:21 +00:00
Ben Gras
07bfb4f4e4 kernel - account for kernel cpu time (ipc, kcalls) in caller 2011-02-08 13:58:32 +00:00
Ben Gras
b2d1109737 kernel - change print*() functions for ipc to generic ipc hook functions.
- used to implement ipc stats tracking code
2011-02-08 13:54:33 +00:00
Gianluca Guida
fa59fc6eb4 Move shared headers in common/include
Headers that will be shared between old includes and NetBSD-like includes
are moved into common/include tree. They are still copied in /usr/include
in 'make includes', so compilation and programs aren't be affected.
2011-02-06 22:59:02 +00:00
Ben Gras
0203ea37bf include - throw out gettiminglocks stuff from include 2011-02-04 13:42:54 +00:00
Ben Gras
95702f970b kernel - doesn't do lock timings any more 2011-02-04 13:42:17 +00:00
Ben Gras
0a70e23d1d is - no more getlocktimings. 2011-02-04 13:34:43 +00:00
Erik van der Kouwe
b096b323d1 Fix comment mutilated by find/replace 2011-02-02 14:53:49 +00:00
Ben Gras
914cdb5997 /usr/Makefile - automatically update pkgin database too. 2011-01-31 16:53:53 +00:00
Ben Gras
06aab2c6ed /usr/Makefile - automatically install git 2011-01-31 00:58:50 +00:00
Ben Gras
dee29bbd3c some extra math functions from netbsd for netpbm. 2011-01-30 23:40:51 +00:00
Ben Gras
d5322973fa always define PKG_TOOLS_BIN 2011-01-30 23:36:45 +00:00
Ben Gras
4fc9428808 <ansi.h> -> <minix/ansi.h> 2011-01-28 11:50:47 +00:00
Ben Gras
dc1cc91df1 <ansi.h> -> <minix/ansi.h> 2011-01-28 11:35:02 +00:00
Ben Gras
e912f6ac38 take pkg_install out of the base system and pre-install it using the
pkgsrc binary packages.

rationale:
  . pkg_install (which is the pkg_* tools) is entangled with pkgsrc,
    not with minix, so tracking it from pkgsrc (easier than with
    base system) makes more sense
  . simplifies upstreaming minix specific changes for pkg_* tools
  . reduce pkgsrc-in-basesystem maintenance burden
2011-01-28 00:02:27 +00:00
Ben Gras
b0aea49465 update package names in packages.install to new pkgsrc versions 2011-01-27 23:59:02 +00:00
Arun Thomas
6e86430130 Remove code for kernel task stack initialization
We no longer have kernel tasks, so this code is unnecessary
2011-01-27 12:18:33 +00:00
Ben Gras
0874fa9321 add minix3.org pkgsrc mirror as backup source 2011-01-26 17:02:54 +00:00
Ben Gras
e50070e3b3 added uint typedef declaration in <minix/types.h>
. needed for xmlrpc (needed for cmake (needed for compiler-rt))
2011-01-26 14:36:19 +00:00
Ben Gras
7b2d6c3c98 added <complex.h> (needed for compiler-rt) 2011-01-26 14:35:34 +00:00
David van Moolenbroek
9c7dcbfec3 Kernel: fix clearing IPC references resulting in system crash 2011-01-18 10:18:08 +00:00
Erik van der Kouwe
04229f0581 Servers request TSC freq from kernel rather than each one measuring it individually 2011-01-11 11:03:37 +00:00
David van Moolenbroek
9b8f37bb27 RS: don't share executable images with a dead process 2011-01-07 17:10:12 +00:00
David van Moolenbroek
16895b67ce RS: move setuid() hack to where it belongs.. again. 2011-01-07 17:09:30 +00:00
David van Moolenbroek
410699874c DS: fix regression in ds_subscribe regex construction 2011-01-07 17:07:46 +00:00
David van Moolenbroek
dbcca28c19 DS: update subscriptions for deleted keys upon process exit 2011-01-07 17:06:24 +00:00
David van Moolenbroek
efca30b081 Kernel: fix notification delivery to non-ANY receivers 2011-01-07 17:04:43 +00:00
David van Moolenbroek
561acfb618 remove fsck1 altogether 2010-12-21 11:00:13 +00:00
David van Moolenbroek
5d8d5e0c3a change bitchunk_t from 16-bit to 32-bit 2010-12-21 10:44:45 +00:00
David van Moolenbroek
d23c3d110e sys/queue.h: add LIST_FOREACH_SAFE 2010-12-20 23:52:53 +00:00
Arun Thomas
361f377493 Fix multiboot for ACK-built images
Move the profiling buffer to the end of the data segment
2010-12-17 13:47:11 +00:00
David van Moolenbroek
b6f3b7e7f6 Kernel: statistical profiling fixes
- create name entries for forked processes as well;
- create name entries only for system processes.
2010-12-16 09:46:26 +00:00
Ben Gras
f0f34dd8d9 vfs - use a static buffer instead of malloc()+free(), solving
recently appeared ENOMEM problems during exec().
2010-12-15 14:43:59 +00:00
Erik van der Kouwe
7aab862a06 Workaround for circular dependency problem in pkgadd 2010-12-11 18:20:31 +00:00
Arun Thomas
4fe0dfa9aa libc and csu updates for ELF 2010-12-10 23:04:04 +00:00
Arun Thomas
d824b54d82 csu/build support for ELF 2010-12-10 22:20:12 +00:00
David van Moolenbroek
a53d925844 mkfifo.c: fix ack warning 2010-12-10 15:21:59 +00:00
Arun Thomas
7ff2db1dd6 unstack: ELF support 2010-12-10 15:18:30 +00:00
Arun Thomas
691030d5ce file(1): Add ELF support 2010-12-10 15:18:28 +00:00
Arun Thomas
11904c0435 Fix libname in bsd.prog.mk 2010-12-10 09:33:48 +00:00
Arun Thomas
372b873413 VFS/RS support for ELF 2010-12-10 09:27:56 +00:00
David van Moolenbroek
9639af49d2 RS: fix IPC privilege computation bug
Take into account the ALL and ALL_SYS cases when constructing proper
symmetrical IPC send masks. Fix system.conf accordingly, to keep
userland processes from sending to several non-interface servers and
drivers. Also fix IS's F4 formatting.
2010-12-08 14:54:08 +00:00
David van Moolenbroek
7bef45ad3b system.conf: base ipc permissions on process names rather than labels
From now on, the "ipc" directive in system.conf refers to process names
instead of labels, similar to the "control" directive. The old, more
fine-grained approach is deemed unnecessary and cumbersome at this time.

As side effects, this patch unbreaks late IPC permission computation as
well as the filter driver.
2010-12-07 12:16:31 +00:00
David van Moolenbroek
a7285dfabc Kernel/RS: fix permission computation with 32+ system processes 2010-12-07 10:32:42 +00:00
David van Moolenbroek
6bf3c91a0a RS: do not restart file systems 2010-12-03 13:19:15 +00:00
Arun Thomas
cc26fb5ec4 vfs: terminate string in rdlink_direct
Fixes test56 when compiled with GCC.
2010-12-01 16:24:50 +00:00
Erik van der Kouwe
cbf7d8f735 Fix missing parenthesis (suggested by Antoine Leca) 2010-11-29 08:30:30 +00:00
Ben Gras
d1cfc50811 mkboot: include git id in image name if available. 2010-11-25 15:25:17 +00:00
Dirk Vogt
5e1e763506 removed unneeded global var 2010-11-24 16:30:13 +00:00
Dirk Vogt
46ec37365e don't send FS_READY anymore 2010-11-24 16:29:50 +00:00
Ben Gras
d87559f9b9 Fix for objdir feature of BSD make
contributed by Antoine Leca.
2010-11-24 13:44:42 +00:00
Dirk Vogt
9ed280d1ec decouple file system server start/termination from mount/umount 2010-11-23 19:34:56 +00:00
Arun Thomas
41ae712b50 pkgsrc: Update git repo info 2010-11-23 11:12:06 +00:00
Arun Thomas
6b5c8751da Add machine/param.h 2010-11-23 11:05:09 +00:00
Arun Thomas
7a4149a3f5 For GCC/clang, don't build in ACK int64 routines 2010-11-19 12:36:44 +00:00
Arun Thomas
4c0cc2719e Allow for overriding GCC var in test Makefile 2010-11-19 10:33:26 +00:00
Arun Thomas
cfc1fe2ead kernel: Use LIBDIR var in Makefile
Instead of using a hard-coded path, use the LIBDIR variable so
the library path can be overridden.
2010-11-19 10:28:17 +00:00
Tomas Hruby
504abf4b34 Inlining 64bit integer handling functions
- if gcc/clang is used the C functions that use long long can be
  inlined to get better performance (yes, it makes difference)
2010-11-18 16:37:40 +00:00
Tomas Hruby
3ff6f21b51 kernel/debug.c includes u64.h (fix) 2010-11-18 15:12:01 +00:00
Dirk Vogt
6208131459 libdriver without mandatory driver main loop 2010-11-17 15:10:20 +00:00
Dirk Vogt
c22564335f Added possibility to inject input events to tty
M    include/Makefile
A    include/minix/input.h
M    include/minix/com.h
M    drivers/tty/keyboard.c
M    drivers/tty/tty.c
M    drivers/tty/tty.h
M    include/minix/syslib.h
M    lib/libsys/Makefile
A    lib/libsys/input.c
2010-11-17 14:53:07 +00:00
Ben Gras
4ee146c00a revert r8783, as those entries are auto-generated now 2010-11-17 14:29:32 +00:00
Ben Gras
371624e0ec . auto-generate per-directory .gitignore files based on $(CLEANFILES)
. gitignore .gitignore files except for the root one.
2010-11-17 14:28:23 +00:00
Ben Gras
f3e1b1c226 Updated some CLEANFILES macros in Makefiles. 2010-11-17 14:27:23 +00:00
Arun Thomas
8ccfb29765 Update gitignore 2010-11-15 15:59:59 +00:00
Arun Thomas
8173242e01 Remove redundant sha2 code from inet 2010-11-15 11:10:02 +00:00
Arun Thomas
f0ab18377d GCC/clang: int64 routines in C 2010-11-12 18:38:10 +00:00
Erik van der Kouwe
afeb246328 Remove global variable 'i' 2010-11-11 14:12:48 +00:00
Ben Gras
fd2b22474f update for releases with git. 2010-11-11 02:00:12 +00:00
Arun Thomas
aaaad89244 Use int64 functions consistently
Instead of manipulating the u64_t type directly, use the
ex64hi()/ex64lo()/make64() functions.
2010-11-07 23:35:29 +00:00
Arun Thomas
a575be430d Import mkfifo(1) from NetBSD 2010-11-06 20:43:49 +00:00
Arun Thomas
8f0846e68c Import mktemp(1) from NetBSD 2010-11-06 20:41:51 +00:00
Arun Thomas
998af6f111 Move minix/paths.h to paths.h
Also, merge in relevant macros from NetBSD
2010-11-06 20:40:15 +00:00
Ben Gras
0e6dcf027f .gitignore: also ignore CVS and .svn dirs
- to make importing from cvs and svn repos smoother
2010-11-04 21:11:33 +00:00
Arun Thomas
40fb96b838 Remove revision IDs from files 2010-11-04 01:13:59 +00:00
Ben Gras
16493465f9 add top-level .gitignore. 2010-11-02 22:43:25 +00:00
Ben Gras
efcfaf4b96 stdio: split vsprintf and vsnprintf
- workaround for linking problems
2010-11-02 22:05:40 +00:00
Ben Gras
51d9144e9f stdio/freopen.c: fill __iotab table with stream pointer
- lets fclose()d and then freopen()ed streams be fclose()d again
    without error
2010-11-02 22:02:50 +00:00
Ben Gras
09569d399f stdio/fclose.c: reset _buf
- if the stream gets freopen()ed, avoid buffer being seen as valid
2010-11-02 22:01:47 +00:00
Ben Gras
515e8d075f kernel: limit stacktrace depth to 50.
- Unlikely to discard useful information and avoids long
    system lockups on machines configured to print system output to serial.
2010-11-02 21:27:04 +00:00
Tomas Hruby
3c6274b8be /proc/cpuinfo
- when /proc/cpuinfo is read procfs retrievs information about cpus
  from the kernel, formats it and prints it
2010-10-26 21:08:00 +00:00
Tomas Hruby
ac780f36a0 sys_getcpuinfo() 2010-10-26 21:07:50 +00:00
Tomas Hruby
c9bfb13cdb Kernel keeps information about each cpu
- kernel maintains a cpu_info array which contains various
  information about each cpu as filled when each cpu boots

- the information contains idetification, features etc.
2010-10-26 21:07:27 +00:00
Tomas Hruby
9e01a83636 SMP - reduced TLB flushing
- flush TLB of processes only if the page tables has been changed and
  the page tables of this process are already loaded on this cpu which
  means that there might be stale entries in TLB. Until now SMP was
  always flushing TLB to make sure everything is consistent.
2010-10-25 16:21:23 +00:00
Tomas Hruby
7f7822aebd Fixed unixbench Run script
- perl path has changed
2010-10-25 08:32:14 +00:00
Tomas Hruby
5b832396f5 if verbore=1 tell us who registers which irq handler
- a useful piece of information when debugging
2010-10-21 17:07:12 +00:00
Tomas Hruby
40bfed28cd ACPI pci-to-pci bridges
- every pci device which implements _PRT acpi method is considered to
  be a pci-to-pci bridge

- acpi driver constructs a hierarchy of pci-to-pci bridges

- when pci driver identifies a pci-to-pci bridge it tells acpi driver
  what is the primary and the secondary bus for this device

- when pci requests IRQ routing information from acpi, it passes the
  bus number too to be able to identify the device accurately
2010-10-21 17:07:09 +00:00
Tomas Hruby
98c93e76d7 Zero no more hardwired as BSP apic id
- the BSP apic id is written in the io apic redirection entries to
  deliver the interrupts to BSP
2010-10-21 17:07:07 +00:00
Tomas Hruby
de1bcaa69a VM implicitly aligns mappings to a page
- problem when a PCI BAR is not aligned

- together with  David v. Moolenboek
2010-10-21 17:07:05 +00:00
Tomas Hruby
a1eefc013e single shot timer interrupts fix
- accidentaly this wasn't part of the SMP merge and the implementation
  remained uncomplete with the timer keeping ticking periodically

- APIC timer is set for a signel shot and restarted everytime it
  expires. This way we can keep the AP's trully idle

- the timer is restarted a little later before leaving to userspace

- LAPIC_TIMER_ICR is written before LAPIC_LVTTR so the newest value is
  used
2010-10-21 17:07:01 +00:00
Tomas Hruby
ebbc730fc3 spurious and error interrupt apic handlers
- fixed spurious and error interrupt handlers

- not to hog the system the warning isn't reported every time, just
  once every 100 times, similarly for the spurious PIC interrupts
2010-10-19 17:07:21 +00:00
Tomas Hruby
f42b90806a BSP apic id
- BSP apic id used uninitialized causes problems
2010-10-19 17:07:19 +00:00
Tomas Hruby
e6b1a30a26 panic in dummy apic handlers
- as panic can do the same as printf now, let's rather panic when a
  dummy apic interrupt vector handler is hit
2010-10-19 17:07:17 +00:00
Tomas Hruby
2419ab589d Fixed BKL statistics 2010-10-19 17:07:11 +00:00
Tomas Hruby
7fddd8358d PCI driver debug output fix
- bus number (busnr) must be used instead of internal busind
2010-10-19 10:30:15 +00:00
Tomas Hruby
8145b458d6 A klib.S include fix
- by Antoine Leca
2010-10-15 22:21:01 +00:00
Tomas Hruby
613ff40936 acpi driver Makefile fix
- by Antoine Leca
2010-10-15 22:20:01 +00:00
Ben Gras
b0d7ce8d09 <minix/hash.h> 2010-10-15 11:25:40 +00:00
Ben Gras
ddde360e3e vm - hash table for block cache 2010-10-15 09:10:14 +00:00
Ben Gras
cb2e3a98a2 vm - fix for not placing region outside requested mmap addr 2010-10-15 09:09:29 +00:00
Erik van der Kouwe
431a5a556d e1000: add 82574L ethernet adapter (thx Niek for your comments) 2010-10-15 08:53:22 +00:00
Ben Gras
e743f940d4 profile command - correct logic error
- this caused profile to complain about frequency when
    no command (start, stop) was given.
2010-10-12 11:26:47 +00:00
Ben Gras
b653422883 mfs - no more WRITE_IMMED 2010-10-11 15:35:43 +00:00
Ben Gras
26de8dd299 change SSIZE_MAX to INT_MAX instead of 32767.
With this change, suggested by Gautam Tirumala, ports for pkgin and
pkg_install are cleaner and so easier to upstream.  Presumably other
ports will be smoother too.

There doesn't seem to be a reason SSIZE_MAX was so small to begin with.
2010-10-10 22:33:23 +00:00
Erik van der Kouwe
9235536f38 Fix select-related bugs: missing cancellations led to potentially forgetting notifies, especially in the case of async drivers 2010-10-08 12:50:52 +00:00
Erik van der Kouwe
470a185909 Add libdriver support for async ioctl replies 2010-10-08 09:33:18 +00:00
Ben Gras
a3f2df124c vm optimisation - maintain hint for new virtual region position. 2010-10-07 10:04:05 +00:00
Ben Gras
e0ac271e5a include <sys/cdefs.h> in <minix/sysutil> (clang fix) 2010-10-06 13:09:49 +00:00
Erik van der Kouwe
ada0b4ca04 Fix warnings due to missing __dead attribute on exit 2010-10-05 07:25:47 +00:00
Erik van der Kouwe
591201c1a0 Fix warnings in libmthread 2010-10-04 20:19:40 +00:00
Ben Gras
c521f2a138 kernel: fix idle time accounting. 2010-10-04 19:12:55 +00:00
Erik van der Kouwe
b0eaf0bc27 make system server vprintf check for NULL 2010-10-04 17:53:18 +00:00
Erik van der Kouwe
7bc944c8a9 fflush is neither needed nor allowed in system srvers, which is where SEF is used 2010-10-04 17:38:53 +00:00
Arun Thomas
40ccb7ed54 Add include/memory.h
Some ports expect that it exists.
2010-10-04 13:37:46 +00:00
Ben Gras
98ddbffe6e dis386 - a disassembler for ack
- it can disassemble object files (dis386o) and executables
    (dis386a)
  - only useful for as long as we still have ack
2010-10-04 13:26:53 +00:00
Ben Gras
e2570d9b1b vm: optimisation: avl tree for virtual regions
- regions were preivous stored in a linked list, as 'normally'
    there are just 2 or 3 (text, data, stack), but that's slow
    if lots of regions are made with mmap()

  - measurable performance improvement with gcc and clang
2010-10-04 11:41:10 +00:00
Ben Gras
36189370a5 vm: don't check the range of memory during sanity checking
- too many false positives due to memory that is mapped in
    legitimately (acpi, i/o devices)
2010-10-04 11:38:33 +00:00
Arun Thomas
677d80b781 Remove urlget
This patch gets rid of urlget. It's not used for anything now, since pkgin
uses fetch.

Arun
2010-10-02 18:24:53 +00:00
Ben Gras
68de328ac1 make the asynsend table size NPROCS-dependent.
this is a fix for e.g. the situation where lots of processes die
instantly, and PM has to send an asyn msg for each one to VFS, and
panics if there are too many. there are likely more situations in
which this table should be dependent on the no. of processes.

reported by pikpik on #minix3.
2010-10-01 14:39:04 +00:00
Thomas Veerman
a7072a5e1c Revamp the mthread library and update test59
Before, the 'main thread' of a process was never taken into account anywhere in
the library, causing mutexes not to work properly (and consequently, neither
did the condition variables). For example, if the 'main thread' (that is, the
thread which is started at the beginning of a process; not a spawned thread by
the library) would lock a mutex, it wasn't actually locked.
2010-09-30 13:44:13 +00:00
David van Moolenbroek
3736ce3f55 hgfs: do not return negative file sizes in stat (reported by Antoine Leca) 2010-09-27 13:19:25 +00:00
Tomas Hruby
1786291e32 Watchdog and kernel profiling for AMD
- a different set of MSRs and performance counters is used on AMD

- when initializing NMI watchdog the test for Intel architecture
  performance counters feature only applies to Intel now

- NMI is enabled if the CPU belongs to a family which has the
  performance counters that we use
2010-09-23 14:42:30 +00:00
Tomas Hruby
274fcf8d1f neg64() makes a 64bit integer negative
- neg64(a) == -a

- although we only support 64 bit unsigned arithmetics sometimes it's good to
  have a 2-complement negative number
2010-09-23 14:42:26 +00:00
Tomas Hruby
8eece1c00c CPU type detection
- sometimes the system needs to know precisely on what type of cpu is
  running. The cpu type id detected during arch specific
  initialization and kept in the machine structure for later use.

- as a side-effect the information is exported to userland
2010-09-23 14:42:19 +00:00
Ben Gras
6e385a1b01 cprofalyze - perl path fix. 2010-09-23 13:49:52 +00:00
Tomas Hruby
9cf2c02c47 Long (32 char) symbol names in sprofalyze 2010-09-23 10:49:58 +00:00
Tomas Hruby
de96892970 sprofalyze only warns when executables don't exist
- e.g. when acpi is not compiled, now we can include it

- the script still fails if a symbol from a non existent binary is
  found in the profile log
2010-09-23 10:49:57 +00:00
Tomas Hruby
45d3ef7b3c sprofalyze detects what nm to use 2010-09-23 10:49:55 +00:00
Tomas Hruby
ef92583c3a Busy idle loop when profiling
- the Intel architecture cycle counter (performance counter) does not
  count when the CPU is idle therefore we use busy loop instead of
  halting the cpu when there is nothing to schedule

- the downside is that handling interrupts may be accounted as idle
  time if a sample is taken before we get out of the nested trap and
  pick a new process
2010-09-23 10:49:52 +00:00
Tomas Hruby
d2b56f60da sprofile exports kernel sample entries
- in case of kernel hit while proc_ptr is IDLE, account for idle time
  instead of taking kernel sample
2010-09-23 10:49:50 +00:00
Tomas Hruby
87c576584d Internal 64M buffer for profiling
- when profiling is compiled in kernel includes a 64M buffer for
  sample

- 64M is the default used by profile tool as its buffer

- when using nmi profiling it is not possible to always copy sample
  stright to userland as the nmi may (and does) happen in bad moments

- reduces sampling overhead as samples are copied out only when
  profiling stops
2010-09-23 10:49:48 +00:00
Tomas Hruby
e63b85a50b NMI sampling
- if profile --nmi kernel uses NMI watchdog based sampling based on
  Intel architecture performance counters

- using NMI makes kernel profiling possible

- watchdog kernel lockup detection is disabled while sampling as we
  may get unpredictable interrupts in kernel and thus possibly many
  false positives

- if watchdog is not enabled at boot time, profiling enables it and
  turns it of again when done
2010-09-23 10:49:45 +00:00
Tomas Hruby
74c5cd7668 The profile utility can set the sprofiling mode
- profile --nmi | --rtc sets the profiling mode

- --rtc is default, uses BIOS RTC, cannot profile kernel the presetted
  frequency values apply

- --nmi is only available in APIC mode as it uses the NMI watchdog, -f
  allows any frequency in Hz

- both modes use compatible data structures
2010-09-23 10:49:42 +00:00
Tomas Hruby
db12229ce3 New profile protocol
- when kernel profiles a process for the first time it saves an entry
  describing the process [endpoint|name]

- every profile sample is only [endpoint|pc]

- profile utility creates a table of endpoint <-> name relations and
  translates endpoints of samples into names and writing out the
  results to comply with the processing tools

- "task" endpoints like KERNEL are negative thus we must cast it to
  unsigned when hashing
2010-09-23 10:49:39 +00:00
Tomas Hruby
123a968be3 32bit process flags
- we are running out of space in 16bit flags
2010-09-23 10:49:36 +00:00
David van Moolenbroek
adbc4e4ea7 libsys: tsc_to_micros support for large TSC delta values 2010-09-23 09:26:42 +00:00
Thomas Veerman
62aba4396e Get rid of erroneous define 2010-09-23 08:52:49 +00:00
Ben Gras
d55eab30fa includes - minor compile fixes. 2010-09-22 14:31:51 +00:00
Ben Gras
82d576c9ca enable_fpu_exception() - only write cr0 if bit isn't already on.
(NMI profiling results indicate this both is relatively expensive and
happens a lot unnecessarily if the fpu is in use.)
2010-09-22 14:31:06 +00:00
Tomas Hruby
b0572bfd1e No need to scan devices in PIC mode 2010-09-22 08:01:43 +00:00
Tomas Hruby
2d1c8849d8 Remove unnecessary TLB flushes
- this should be only for SMP
2010-09-22 08:01:36 +00:00
Ben Gras
df9928711b UPDATING - warning about /usr/gnu/lib 2010-09-21 12:46:55 +00:00
Thomas Veerman
12e167f672 Add libmthread and test59 to test the implementation 2010-09-21 12:22:38 +00:00
Ben Gras
3cc13b29f0 include minix 'all' package. 2010-09-20 15:09:32 +00:00
Ben Gras
250fb23dc0 lib/libsys/gcov.c - fix gcc warning 2010-09-20 11:36:41 +00:00
Ben Gras
300773cdca . forget obsolete /usr/local/bin in $PATH
. update release.sh's notion of where packages are
  . update release.sh's notion of how many files are on root
    as -xdev won't work anymore to separate /usr from /
2010-09-20 11:07:53 +00:00
Tomas Hruby
08bf4dec4f Fixed comments in watchdog 2010-09-19 23:23:44 +00:00
Tomas Hruby
e9ecba9fc7 fix - forgotten debug print 2010-09-19 15:54:31 +00:00
Tomas Hruby
a665ae3de1 Userspace scheduling - exporting stats
- contributed by Bjorn Swift

- adds process accounting, for example counting the number of messages
  sent, how often the process was preemted and how much time it spent
  in the run queue. These statistics, along with the current cpu load,
  are sent back to the user-space scheduler in the Out Of Quantum
  message.

- the user-space scheduler may choose to make use of these statistics
  when making scheduling decisions. For isntance the cpu load becomes
  especially useful when scheduling on multiple cores.
2010-09-19 15:52:12 +00:00
Ben Gras
3306687363 pkgsrc: save binary packages in arch- and osversion dependent dir. 2010-09-17 14:31:54 +00:00
Thomas Veerman
af73996d51 Fix failing unmount attempt at shutdown after running test58 2010-09-17 09:34:36 +00:00
David van Moolenbroek
831faf58f3 another sprofalyze.pl update 2010-09-17 09:25:10 +00:00
Tomas Hruby
c811aa21aa sprofalyze.pl update 2010-09-17 08:09:04 +00:00
Tomas Hruby
13bda81ee0 Fixed FPU for single cpu 2010-09-16 09:51:45 +00:00
Tomas Hruby
72cc01ff48 apic_timer_x
- set the apic_timer_x factor variable to slowdown apic timer in
  virtual machines
2010-09-16 07:18:47 +00:00
Tomas Hruby
159ca9c8c7 Fixed unintentionally removed world target in Makefile 2010-09-15 14:18:39 +00:00
Tomas Hruby
4ee139b0be SMP - all process have pagetables
- all processes have private pagetables if CONFIG_SMP is set

- this make possible to safely schedule PM, RS, VFS anywhere
2010-09-15 14:11:30 +00:00
Tomas Hruby
5b8b623765 SMP - lazy FPU
- when a process is migrated to a different CPU it may have an active
  FPU context in the processor registers. We must save it and migrate
  it together with the process.
2010-09-15 14:11:25 +00:00
Tomas Hruby
1f89845bb2 SMP - can boot even if some cpus fail to boot
- EBADCPU is returned is scheduler tries to run a process on a CPU
  that either does not exist or isn't booted

- this change was originally meant to deal with stupid cpuid
  instruction which provides totally useless information about
  hyper-threading and MPS which does not deal with ht at all. ACPI
  provides correct information. If ht is turned off it looks like some
  CPUs failed to boot.  Nevertheless this patch may be handy for
  testing/benchmarking in the future.
2010-09-15 14:11:21 +00:00
Tomas Hruby
421f324baa SMP - Make sure that VM does not change pt of a process while kernel copies 2010-09-15 14:11:19 +00:00
Tomas Hruby
e4283176ae SMP - Force TLB flush before scheduling a process
- this makes sure that each process always run with updated TLB

- this is the simplest way how to achieve the consistency. As it means
  significant performace degradation when not require, this is nto the
  final solution and will be refined
2010-09-15 14:11:17 +00:00
Tomas Hruby
6513d20744 SMP - Process is stopped when VM modifies the page tables
- RTS_VMINHIBIT flag is used to stop process while VM is fiddling with
  its pagetables

- more generic way of sending synchronous scheduling events among cpus

- do the x-cpu smp sched calls only if the target process is runnable.
  If it is not, it cannot be running and it cannot become runnable
  this CPU holds the BKL
2010-09-15 14:11:12 +00:00
Tomas Hruby
906a81a1c7 SMP - runctl() can stop across cpus
- if stopping a process that runs on a different CPU we tell the
  remote cpu to do that
2010-09-15 14:11:09 +00:00
Tomas Hruby
e2701da5a9 SMP - Single shot local timer
- APIC timer always reprogrammed if expired

- timer tick never happens when in kernel => never immediate return
  from userspace to kernel because of a buffered interrupt

- renamed argument to lapic_set_timer_one_shot()

- removed arch_ prefix from timer functions
2010-09-15 14:11:06 +00:00
Tomas Hruby
e87d29171f SMP - Compiles for both single and multi processor again
- this patch adds various fixes as some of the previous patches break
  compilations without CONFIG_SMP being set
2010-09-15 14:11:03 +00:00
Tomas Hruby
454589debd SMP - Print cpu of the process
- adds '4' to print processes assigned to each cpu without printing
  the process it is blocked on (a lightweight '1')
2010-09-15 14:11:01 +00:00
Tomas Hruby
0ac9b6d4cf SMP - trully idle APs
- any cpu can use smp_schedule() to tell another cpu to reschedule

- if an AP is idle, it turns off timer as there is nothing to
  preempt, no need to wakeup just to go back to sleep again

- if a cpu makes a process runnable on an idle cpu, it must wake it up
  to reschedule
2010-09-15 14:10:57 +00:00
Tomas Hruby
387e1835d1 SMP - BSP halts APs before shutting down 2010-09-15 14:10:54 +00:00
Tomas Hruby
311f145bc7 SMP - Balancing run queues for SMP
- it preempts running processes though :( this is not the final
  solution
2010-09-15 14:10:51 +00:00
Tomas Hruby
06b6e5624a SMP - Changed prototype of sys_schedule()
- sys_schedule can change only selected values, -1 means that the
  current value should be kept unchanged. For instance we mostly want
  to change the scheduling quantum and priority but we want to keep
  the process at the current cpu

- RS can hand off its processes to scheduler

- service can read the destination cpu from system.conf

- RS can pass the information farther
2010-09-15 14:10:42 +00:00
Tomas Hruby
c554aef0e1 SMP - BKL statistics
- pressing 'B' on the serial cnsole prints statistics for BKL per cpu.

- 'b' resets the counters

- it presents number of cycles each CPU spends in kernel, how many
  cycyles it spends spinning while waiting for the BKL

- it shows optimistic estimation in how many cases we get the lock
  immediately without spinning. As the test is not atomic the lock may
  be already held by some other cpu before we actually try to acquire
  it.
2010-09-15 14:10:37 +00:00
Tomas Hruby
93b9873a56 SMP - Free PDE slots are split among CPU
- cross-address space copies use these slots to map user memory for
  kernel. This avoid any collisions between CPUs

- well, we only have a single CPU running at a time, this is just to
  be safe for the future
2010-09-15 14:10:36 +00:00
Tomas Hruby
1e273f640e SMP - Scheduler can assign process to a cpu
- machine information contains the number of cpus and the bsp id

- a dummy SMP scheduler which keeps all system processes on BSP and
  all other process on APs. The scheduler remembers how many processes
  are assigned to each CPU and always picks the one with the least
  processes for a new process.
2010-09-15 14:10:33 +00:00
Tomas Hruby
9e12630d75 SMP - APs are fully enabled
- apic_send_ipi() to send inter-processor interrupts (IPIs)

- APIC IPI schedule and halt handlers to signal x-cpu that a cpu shold
  reschedule or halt

- various little changes to let APs run

- no processes are scheduled at the APs and therefore they are idle
  except being interrupted by a timer time to time
2010-09-15 14:10:30 +00:00
Tomas Hruby
d37b7ebc0b SMP - CPU local cycles accounting
- tsc_ctr_switch is made cpu local

- although an x86 specific variable it must be declared globaly as the
  cpulocal implementation does not allow otherwise
2010-09-15 14:10:27 +00:00
Tomas Hruby
67f039540c SMP - proc_ptr and bill_ptr initialization
- they should point somewhere
2010-09-15 14:10:24 +00:00
Tomas Hruby
865e21b884 SMP - CPU local idle stub
- each CPU has its own pseudo idle process and its structure

- idle cycles accounting is agregated when exporting to userspace
2010-09-15 14:10:21 +00:00
Tomas Hruby
fac5fbfdbf SMP - CPU local run queues
- each CPU has its own runqueues

- processes on BSP are put on the runqueues later after a switch to
  the final stack when cpuid works to avoid special cases

- enqueue() and dequeue() use the run queues of the cpu the process is
  assigned to

- pick_proc() uses the local run queues

- printing of per-CPU run queues ('2') on serial console
2010-09-15 14:10:18 +00:00
Tomas Hruby
ad73a4f50c SMP - CPU and CPU mask for processes
- each process has associated information about the cpu it is currently
  scheduled on and the mask of cpus it is allowed to use.
2010-09-15 14:10:16 +00:00
Tomas Hruby
9b6d66c787 SMP - BSP waits until the APs finish their booting
- APs configure local timers

- while configuring local APIC timer the CPUs fiddle with the interrupt
  handlers. As the interrupt table is shared the BSP must not run
2010-09-15 14:10:12 +00:00
Tomas Hruby
b7aed08e65 SMP - Only a single APIC timer handler
- bsp_timer_int_handler() and ap_timer_int_handler() unified into
  timer_int_handler()

- global realtime updated only on BSP
2010-09-15 14:10:09 +00:00
Tomas Hruby
85cca7096f SMP - The slave CPUs turn paging on
- APs wait until BSP turns paging on, it is not possible to safely
  execute any code on APs until we can turn paging on as well as it
  must be done synchronously everywhere

- APs turn paging on but do not continue and wait
2010-09-15 14:10:07 +00:00
Tomas Hruby
6aa26565e6 SMP - Big kernel lock (BKL)
- to isolate execution inside kernel we use a big kernel lock
  implemented as a spinlock

- the lock is acquired asap after entering kernel mode and released as
  late as possible. Only one CPU as a time can execute the core kernel
  code

- measurement son real hw show that the overhead of this lock is close
  to 0% of kernel time for the currnet system

- the overhead of this lock may be as high as 45% of kernel time in
  virtual machines depending on the ratio between physical CPUs
  available and emulated CPUs. The performance degradation is
  significant
2010-09-15 14:10:03 +00:00
Tomas Hruby
a42ab504a0 SMP - Kernel is loaded above 1M by default
- the 16-bit trampoline must be within the first megabyte of physical
  memory thus the smp trampoline is copied explicitly below 1M
2010-09-15 14:10:00 +00:00
Tomas Hruby
62c666566e SMP - We boot APs
- kernel detects CPUs by searching ACPI tables for local apic nodes

- each CPU has its own TSS that points to its own stack. All cpus boot
  on the same boot stack (in sequence) but switch to its private stack
  as soon as they can.

- final booting code in main() placed in bsp_finish_booting() which is
  executed only after the BSP switches to its final stack

- apic functions to send startup interrupts

- assembler functions to handle CPU features not needed for single cpu
  mode like memory barries, HT detection etc.

- new files kernel/smp.[ch], kernel/arch/i386/arch_smp.c and
  kernel/arch/i386/include/arch_smp.h

- 16-bit trampoline code for the APs. It is executed by each AP after
  receiving startup IPIs it brings up the CPUs to 32bit mode and let
  them spin in an infinite loop so they don't do any damage.

- implementation of kernel spinlock

- CONFIG_SMP and CONFIG_MAX_CPUS set by the build system
2010-09-15 14:09:52 +00:00
Tomas Hruby
13a0d5fa5e SMP - Cpu local variables
- most global variables carry information which is specific to the
  local CPU and each CPU must have its own copy

- cpu local variable must be declared in cpulocal.h between
  DECLARE_CPULOCAL_START and DECLARE_CPULOCAL_END markers using
  DECLARE_CPULOCAL macro

- to access the cpu local data the provided macros must be used

	get_cpu_var(cpu, name)
	get_cpu_var_ptr(cpu, name)

	get_cpulocal_var(name)
	get_cpulocal_var_ptr(name)

- using this macros makes future changes in the implementation
  possible

- switching to ELF will make the declaration of cpu local data much
  simpler, e.g.

  CPULOCAL int blah;

  anywhere in the kernel source code
2010-09-15 14:09:46 +00:00
Tomas Hruby
2a2a19e542 proc_init()
- code that initializes proc.c structures removed from main() and placed in
  proc_init() function
2010-09-15 14:09:43 +00:00
Tomas Hruby
ce4fd0c0fb Enable paging - some more code reshuffling 2010-09-15 14:09:41 +00:00
Tomas Hruby
6c3b981cd6 arch proto.h renamed to arch_proto.h
- the file moved to the arch include dir
2010-09-15 14:09:36 +00:00
Ben Gras
467a01024e bump trunk version to 3.1.9
make issue.install not include version
2010-09-15 08:47:42 +00:00
Ben Gras
2065c9982b include - minor compile fixes (including <ansi.h> in files that use it)
workaround for kernel/debug.h that causes <ansi.h> to be included in mpx.S
indirectly.
2010-09-15 08:47:10 +00:00
David van Moolenbroek
354da24f5b make getsysinfo() a system-land call 2010-09-14 21:50:05 +00:00
David van Moolenbroek
d299a6422b make all other commands use ProcFS 2010-09-14 21:31:56 +00:00
David van Moolenbroek
33b131766f make top(1) use ProcFS 2010-09-14 21:30:23 +00:00
David van Moolenbroek
40c8a7062c make ps(1) use ProcFS 2010-09-14 21:29:40 +00:00
David van Moolenbroek
d7b10963c2 make library calls use ProcFS 2010-09-14 21:28:34 +00:00
David van Moolenbroek
d269f5fb90 ProcFS integration 2010-09-14 21:27:31 +00:00
David van Moolenbroek
2c5c5c06ea ProcFS server, by Alen Stojanov and David van Moolenbroek 2010-09-14 21:25:25 +00:00
David van Moolenbroek
3eb65448a6 VM: expose secondary cache size 2010-09-14 21:22:56 +00:00
David van Moolenbroek
7763fd67c7 PM: save process frame length 2010-09-14 21:21:54 +00:00
Ben Gras
a5a8c57fe7 add EHOSTDOWN errno. 2010-09-14 11:51:41 +00:00
Ben Gras
eaa37fd21c make, lib changes to make gcc/clang format libraries in /usr/lib instead of /usr/gnu/lib. 2010-09-13 16:37:02 +00:00
Ben Gras
23311d9819 lib: fixes to make clang not error 2010-09-13 15:50:54 +00:00
Ben Gras
b7eb096088 Makefiles: remove -D__minix for assembly invocations.
They seem to be redundant (for gcc+ack+clang) and produce
very messy warnings (for clang, due to it already being defined).
2010-09-13 13:36:29 +00:00
Arun Thomas
7c3cfbde1a Update PATHs for llvm and X11 2010-09-12 17:56:53 +00:00
Arun Thomas
9375cc8e1f Remove packit/packman from Makefile 2010-09-12 16:53:45 +00:00
Arun Thomas
42a522f0e8 Remove packman and packit manpages 2010-09-12 13:55:00 +00:00
8144 changed files with 905178 additions and 229510 deletions

39
.gitignore vendored Normal file
View File

@@ -0,0 +1,39 @@
cscope.*
*.swap
.*.sw[po]
.sw[po]
*~
*.orig
*.diff
*.patch
*.rej
*.[1-9].gz
*.o
*.[psS]o
*.a
*.d
.depend
nbsdsrc/*
tools/revision
TAGS
tags
GPATH
GRTAGS
GSYMS
GTAGS
\#*#
CVS
!/.gitignore
.gitignore
.svn
minix-port.patch
*.worldstone.log
.worldstone*
usr.bin/mdocml/man/*.7
etc/passwd
etc/pwd.db
etc/spwd.db
tools/image
tools/kernel
share/zoneinfo/builddir
lib/libc/compat__*

106
Makefile
View File

@@ -1,5 +1,7 @@
# Master Makefile to compile everything in /usr/src except the system.
.include <bsd.own.mk>
MAKE=make
usage:
@@ -13,10 +15,7 @@ usage:
@echo " make libraries # Compile and install libraries"
@echo " make commands # Compile all, commands, but don't install"
@echo " make install # Compile and install commands"
@echo " make depend # Generate required .depend files"
@echo " make gnu-includes # Install include files for GCC"
@echo " make gnu-libraries # Compile and install libraries for GCC"
@echo " make clang-libraries # Compile and install libraries for GCC with clang"
@echo " make clean # Remove all compiler results"
@echo ""
@echo "Run 'make' in tools/ to create a new MINIX configuration."
@@ -30,73 +29,96 @@ usage:
# 'make install' target.
#
# etcfiles has to be done first.
.if ${COMPILER_TYPE} == "ack"
world: mkfiles includes depend libraries install etcforce
.elif ${COMPILER_TYPE} == "gnu"
world: mkfiles includes depend gnu-libraries install etcforce
.endif
world: mkfiles etcfiles includes libraries dep-all install etcforce
mkfiles:
make -C share/mk install
includes:
$(MAKE) -C include includes
$(MAKE) -C lib includes
$(MAKE) -C lib includes NBSD_LIBC=yes
MKHEADERSS=/usr/pkg/gcc*/libexec/gcc/*/*/install-tools/mkheaders
gnu-includes: includes
SHELL=/bin/sh; for d in $(MKHEADERSS); do if [ -f $$d ] ; then sh -e $$d ; fi; done
libraries: includes
$(MAKE) -C lib build_ack
MKHEADERS411=/usr/gnu/libexec/gcc/i386-pc-minix/4.1.1/install-tools/mkheaders
MKHEADERS443=/usr/gnu/libexec/gcc/i686-pc-minix/4.4.3/install-tools/mkheaders
MKHEADERS443_PKGSRC=/usr/pkg/gcc44/libexec/gcc/i686-pc-minix/4.4.3/install-tools/mkheaders
gnu-includes: includes
SHELL=/bin/sh; if [ -f $(MKHEADERS411) ] ; then sh -e $(MKHEADERS411) ; fi
SHELL=/bin/sh; if [ -f $(MKHEADERS443) ] ; then sh -e $(MKHEADERS443) ; fi
SHELL=/bin/sh; if [ -f $(MKHEADERS443_PKGSRC) ] ; then sh -e $(MKHEADERS443_PKGSRC) ; fi
gnu-libraries: gnu-includes
$(MAKE) -C lib build_gnu
clang-libraries: includes
$(MAKE) -C lib build_clang
$(MAKE) -C lib dependall install
commands: includes libraries
$(MAKE) -C commands all
$(MAKE) -C bin all
$(MAKE) -C sbin all
$(MAKE) -C usr.bin all
$(MAKE) -C libexec all
$(MAKE) -C usr.sbin all
depend::
$(MAKE) -C boot depend
$(MAKE) -C commands depend
$(MAKE) -C kernel depend
$(MAKE) -C servers depend
$(MAKE) -C drivers depend
dep-all:
$(MAKE) -C sys dependall
$(MAKE) -C commands dependall
$(MAKE) -C bin dependall
$(MAKE) -C sbin dependall
$(MAKE) -C usr.bin dependall
$(MAKE) -C libexec dependall
$(MAKE) -C usr.sbin dependall
$(MAKE) -C kernel dependall
$(MAKE) -C servers dependall
$(MAKE) -C drivers dependall
etcfiles::
etcfiles:
$(MAKE) -C etc install
etcforce::
etcforce:
$(MAKE) -C etc installforce
all::
$(MAKE) -C boot all
all:
$(MAKE) -C sys all
$(MAKE) -C commands all
$(MAKE) -C bin all
$(MAKE) -C sbin all
$(MAKE) -C usr.bin all
$(MAKE) -C libexec all
$(MAKE) -C usr.sbin all
$(MAKE) -C tools all
install::
$(MAKE) -C boot install
install:
$(MAKE) -C sys install
$(MAKE) -C libexec install
$(MAKE) -C man install makedb
$(MAKE) -C commands install
$(MAKE) -C bin install
$(MAKE) -C sbin install
$(MAKE) -C usr.bin install
$(MAKE) -C usr.sbin install
$(MAKE) -C servers install
$(MAKE) -C share install
$(MAKE) -C tools install
clean::
$(MAKE) -C boot clean
clean: mkfiles
$(MAKE) -C sys clean
$(MAKE) -C commands clean
$(MAKE) -C bin clean
$(MAKE) -C sbin clean
$(MAKE) -C usr.bin clean
$(MAKE) -C libexec clean
$(MAKE) -C usr.sbin clean
$(MAKE) -C share clean
$(MAKE) -C tools clean
$(MAKE) -C lib clean_gnu
$(MAKE) -C lib clean_ack
$(MAKE) -C lib clean
$(MAKE) -C test clean
cleandepend::
$(MAKE) -C boot cleandepend
cleandepend: mkfiles
$(MAKE) -C lib cleandepend
$(MAKE) -C sys cleandepend
$(MAKE) -C commands cleandepend
$(MAKE) -C bin cleandepend
$(MAKE) -C sbin cleandepend
$(MAKE) -C usr.bin cleandepend
$(MAKE) -C libexec cleandepend
$(MAKE) -C usr.sbin cleandepend
$(MAKE) -C tools cleandepend
# Warn usage change
elf-libraries:
echo "That target is just libraries now."
false

View File

@@ -1,4 +1,4 @@
#!/usr/bin/perl -w
#!/usr/pkg/bin/perl -w
use strict;

View File

@@ -932,9 +932,9 @@ SPDP dtime()
return q;
}
#else
#include <unistd.h>
#include <sys/types.h>
#include <sys/times.h>
#include <minix/sysinfo.h>
#include <time.h>
struct tms tms;
@@ -945,7 +945,7 @@ SPDP dtime(void)
int secs, msecs;
u32_t system_hz;
times(&tms);
getsysinfo_up(PM_PROC_NR, SIU_SYSTEMHZ, sizeof(system_hz), &system_hz);
system_hz = (u32_t) sysconf(_SC_CLK_TCK);
secs = tms.tms_utime / system_hz;
q = secs;
tms.tms_utime -= secs * system_hz;

7
bin/Makefile Normal file
View File

@@ -0,0 +1,7 @@
# Makefile for bin
.include <bsd.own.mk>
SUBDIR= mkdir rm rmdir date
.include <bsd.subdir.mk>

4
bin/Makefile.inc Normal file
View File

@@ -0,0 +1,4 @@
CPPFLAGS+= -D_NETBSD_SOURCE
BINDIR?=/bin

15
bin/date/Makefile Normal file
View File

@@ -0,0 +1,15 @@
# $NetBSD: Makefile,v 1.15 2011/08/14 10:53:16 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= date
SRCS= date.c netdate.c
DPADD+= ${LIBUTIL}
LDADD+= -lutil
CPPFLAGS+=-I${.CURDIR}
TZDIR= /usr/share/zoneinfo
CPPFLAGS+= -DHAVE_ADJTIME=0 -DTZDIR=\"$(TZDIR)\"
COPTS.date.c = -Wno-format-nonliteral
.include <bsd.prog.mk>

244
bin/date/date.1 Normal file
View File

@@ -0,0 +1,244 @@
.\" $NetBSD: date.1,v 1.41 2010/02/04 22:56:11 wiz Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" the Institute of Electrical and Electronics Engineers, Inc.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)date.1 8.3 (Berkeley) 4/28/95
.\"
.Dd November 15, 2006
.Dt DATE 1
.Os
.Sh NAME
.Nm date
.Nd display or set date and time
.Sh SYNOPSIS
.Nm
.Op Fl ajnu
.Op Fl d Ar date
.Op Fl r Ar seconds
.Op Cm + Ns Ar format
.Sm off
.Oo Oo Oo Oo Oo Oo
.Ar CC Oc
.Ar yy Oc
.Ar mm Oc
.Ar dd Oc
.Ar HH Oc Ar MM Oo
.Li \&. Ar SS Oc Oc
.Sm on
.Sh DESCRIPTION
.Nm
displays the current date and time when invoked without arguments.
Providing arguments will format the date and time in a user-defined
way or set the date.
Only the superuser may set the date.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl a
Use
.Xr adjtime 2
to change the local system time slowly,
maintaining it as a monotonically increasing function.
.Fl a
implies
.Fl n .
.It Fl d Ar date
Parse the provided human-described date and time and display the result without
actually changing the system clock.
(See
.Xr parsedate 3
for examples.)
.It Fl j
Parse the provided canonical representation of date and time (described below)
and display the result without actually changing the system clock.
.It Fl n
The utility
.Xr timed 8
is used to synchronize the clocks on groups of machines.
By default, if
timed
is running,
.Nm
will set the time on all of the machines in the local group.
The
.Fl n
option stops
.Nm
from setting the time for other than the current machine.
.It Fl r Ar seconds
Print out the date and time that is
.Ar seconds
from the Epoch.
.It Fl u
Display or set the date in
.Tn UTC
(universal) time.
.El
.Pp
An operand with a leading plus
.Pq Cm +
sign signals a user-defined format
string which specifies the format in which to display the date and time.
The format string may contain any of the conversion specifications described
in the
.Xr strftime 3
manual page, as well as any arbitrary text.
A \*[Lt]newline\*[Gt] character is always output after the characters
specified by the format string.
The format string for the default display is:
.Bd -literal -offset indent
%a %b %e %H:%M:%S %Z %Y
.Ed
.Pp
If an operand does not have a leading plus sign, it is interpreted as
a value for setting the system's notion of the current date and time.
The canonical representation for setting the date and time is:
.Pp
.Bl -tag -width Ds -compact -offset indent
.It Ar CC
The first two digits of the year (the century).
.It Ar yy
The second two digits of the year.
If
.Ar yy
is specified, but
.Ar CC
is not, a value for
.Ar yy
between 69 and 99 results in a
.Ar CC
value of 19.
Otherwise, a
.Ar CC
value of 20 is used.
.It Ar mm
The month of the year, from 01 to 12.
.It Ar dd
The day of the month, from 01 to 31.
.It Ar HH
The hour of the day, from 00 to 23.
.It Ar MM
The minute of the hour, from 00 to 59.
.It Ar SS
The second of the minute, from 00 to 61.
.El
.Pp
Everything but the minutes is optional.
.Pp
Time changes for Daylight Saving and Standard time and leap seconds
and years are handled automatically.
.Sh ENVIRONMENT
The following environment variables affect the execution of
.Nm :
.Bl -tag -width iTZ
.It Ev TZ
The timezone to use when displaying dates.
See
.Xr environ 7
for more information.
.El
.Sh FILES
.Bl -tag -width /var/log/messages -compact
.It Pa /etc/localtime
Symlink pointing to system's default timezone information file in
.Pa /usr/share/zoneinfo
directory.
.It Pa /var/log/wtmp
A record of date resets and time changes.
.It Pa /var/log/messages
A record of the user setting the time.
.El
.Sh EXAMPLES
The command:
.Bd -literal -offset indent
date '+DATE: %m/%d/%y%nTIME: %H:%M:%S'
.Ed
.Pp
will display:
.Bd -literal -offset indent
DATE: 11/21/87
TIME: 13:36:16
.Ed
.Pp
The command:
.Bd -literal -offset indent
date 8506131627
.Ed
.Pp
sets the date to
.Dq Li "June 13, 1985, 4:27 PM" .
.Pp
The command:
.Bd -literal -offset indent
date 1432
.Ed
.Pp
sets the time to
.Li "2:32 PM" ,
without modifying the date.
.Sh DIAGNOSTICS
Exit status is 0 on success, 1 if unable to set the date, and 2
if able to set the local date, but unable to set it globally.
.Pp
Occasionally, when
.Xr timed 8
synchronizes the time on many hosts, the setting of a new time value may
require more than a few seconds.
On these occasions,
.Nm
prints:
.Ql Network time being set .
The message
.Ql Communication error with timed
occurs when the communication
between
.Nm
and
timed
fails.
.Sh SEE ALSO
.Xr adjtime 2 ,
.Xr gettimeofday 2 ,
.Xr settimeofday 2 ,
.Xr parsedate 3 ,
.Xr strftime 3 ,
.Xr utmp 5 ,
.Xr timed 8
.Rs
.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD"
.%A R. Gusella
.%A S. Zatti
.Re
.Sh STANDARDS
The
.Nm
utility is expected to be compatible with
.St -p1003.2 .

350
bin/date/date.c Normal file
View File

@@ -0,0 +1,350 @@
/* $NetBSD: date.c,v 1.60 2011/08/27 12:55:09 joerg Exp $ */
/*
* Copyright (c) 1985, 1987, 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
__COPYRIGHT(
"@(#) Copyright (c) 1985, 1987, 1988, 1993\
The Regents of the University of California. All rights reserved.");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)date.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: date.c,v 1.60 2011/08/27 12:55:09 joerg Exp $");
#endif
#endif /* not lint */
#include <sys/param.h>
#include <sys/time.h>
#include <ctype.h>
#include <err.h>
#include <fcntl.h>
#include <errno.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <time.h>
#include <tzfile.h>
#include <unistd.h>
#include <util.h>
#include "extern.h"
static time_t tval;
static int aflag, jflag, rflag, nflag;
__dead static void badformat(void);
__dead static void badtime(void);
__dead static void badvalue(const char *);
static void setthetime(const char *);
__dead static void usage(void);
int
main(int argc, char *argv[])
{
char *buf;
size_t bufsiz;
const char *format;
int ch;
long long val;
struct tm *tm;
setprogname(argv[0]);
(void)setlocale(LC_ALL, "");
while ((ch = getopt(argc, argv, "ad:jnr:u")) != -1) {
switch (ch) {
case 'a': /* adjust time slowly */
aflag = 1;
nflag = 1;
break;
case 'd':
#ifndef __minix
rflag = 1;
tval = parsedate(optarg, NULL, NULL);
if (tval == -1)
#endif
badarg: errx(EXIT_FAILURE,
"Cannot parse `%s'", optarg);
break;
case 'j': /* don't set time */
jflag = 1;
break;
case 'n': /* don't set network */
nflag = 1;
break;
case 'r': /* user specified seconds */
errno = 0;
val = strtoll(optarg, &buf, 0);
if (optarg[0] == '\0' || *buf != '\0')
goto badarg;
if (errno == ERANGE && (val == LLONG_MAX ||
val == LLONG_MIN))
err(EXIT_FAILURE, "Bad number `%s'", optarg);
rflag = 1;
tval = (time_t)val;
break;
case 'u': /* do everything in UTC */
(void)setenv("TZ", "UTC0", 1);
break;
default:
usage();
}
}
argc -= optind;
argv += optind;
if (!rflag && time(&tval) == -1)
err(EXIT_FAILURE, "time");
/* allow the operands in any order */
if (*argv && **argv == '+') {
format = *argv;
++argv;
} else
format = "+%a %b %e %H:%M:%S %Z %Y";
if (*argv) {
setthetime(*argv);
++argv;
}
if (*argv && **argv == '+')
format = *argv;
if ((buf = malloc(bufsiz = 1024)) == NULL)
goto bad;
if ((tm = localtime(&tval)) == NULL)
err(EXIT_FAILURE, "localtime %lld failed", (long long)tval);
while (strftime(buf, bufsiz, format, tm) == 0)
if ((buf = realloc(buf, bufsiz <<= 1)) == NULL)
goto bad;
(void)printf("%s\n", buf + 1);
free(buf);
return 0;
bad:
err(EXIT_FAILURE, "Cannot allocate format buffer");
}
static void
badformat(void)
{
warnx("illegal time format");
usage();
}
static void
badtime(void)
{
errx(EXIT_FAILURE, "illegal time");
/* NOTREACHED */
}
static void
badvalue(const char *param)
{
warnx("invalid %s supplied", param);
usage();
}
#define ATOI2(s) ((s) += 2, ((s)[-2] - '0') * 10 + ((s)[-1] - '0'))
static void
setthetime(const char *p)
{
struct timeval tv;
time_t new_time;
struct tm *lt;
const char *dot, *t;
size_t len;
int yearset;
for (t = p, dot = NULL; *t; ++t) {
if (isdigit((unsigned char)*t))
continue;
if (*t == '.' && dot == NULL) {
dot = t;
continue;
}
badformat();
}
if ((lt = localtime(&tval)) == NULL)
err(EXIT_FAILURE, "localtime %lld failed", (long long)tval);
lt->tm_isdst = -1; /* Divine correct DST */
if (dot != NULL) { /* .ss */
len = strlen(dot);
if (len != 3)
badformat();
++dot;
lt->tm_sec = ATOI2(dot);
if (lt->tm_sec > 61)
badvalue("seconds");
} else {
len = 0;
lt->tm_sec = 0;
}
yearset = 0;
switch (strlen(p) - len) {
case 12: /* cc */
lt->tm_year = ATOI2(p) * 100 - TM_YEAR_BASE;
if (lt->tm_year < 0)
badtime();
yearset = 1;
/* FALLTHROUGH */
case 10: /* yy */
if (yearset) {
lt->tm_year += ATOI2(p);
} else {
yearset = ATOI2(p);
if (yearset < 69)
lt->tm_year = yearset + 2000 - TM_YEAR_BASE;
else
lt->tm_year = yearset + 1900 - TM_YEAR_BASE;
}
/* FALLTHROUGH */
case 8: /* mm */
lt->tm_mon = ATOI2(p);
if (lt->tm_mon > 12 || lt->tm_mon == 0)
badvalue("month");
--lt->tm_mon; /* time struct is 0 - 11 */
/* FALLTHROUGH */
case 6: /* dd */
lt->tm_mday = ATOI2(p);
switch (lt->tm_mon) {
case 0:
case 2:
case 4:
case 6:
case 7:
case 9:
case 11:
if (lt->tm_mday > 31 || lt->tm_mday == 0)
badvalue("day of month");
break;
case 3:
case 5:
case 8:
case 10:
if (lt->tm_mday > 30 || lt->tm_mday == 0)
badvalue("day of month");
break;
case 1:
if (lt->tm_mday > 29 || lt->tm_mday == 0 ||
(lt->tm_mday == 29 &&
!isleap(lt->tm_year + TM_YEAR_BASE)))
badvalue("day of month");
break;
default:
badvalue("month");
break;
}
/* FALLTHROUGH */
case 4: /* hh */
lt->tm_hour = ATOI2(p);
if (lt->tm_hour > 23)
badvalue("hour");
/* FALLTHROUGH */
case 2: /* mm */
lt->tm_min = ATOI2(p);
if (lt->tm_min > 59)
badvalue("minute");
break;
case 0: /* was just .sss */
if (len != 0)
break;
/* FALLTHROUGH */
default:
badformat();
}
/* convert broken-down time to UTC clock time */
if ((new_time = mktime(lt)) == -1)
badtime();
/* if jflag is set, don't actually change the time, just return */
if (jflag) {
tval = new_time;
return;
}
/* set the time */
if (nflag || netsettime(new_time)) {
logwtmp("|", "date", "");
#if HAVE_ADJTIME
if (aflag) {
tv.tv_sec = new_time - tval;
tv.tv_usec = 0;
if (adjtime(&tv, NULL))
err(EXIT_FAILURE, "adjtime");
}
#else
if (aflag) {
err(EXIT_FAILURE, "no adjtime");
}
#endif
else {
tval = new_time;
tv.tv_sec = tval;
tv.tv_usec = 0;
if (settimeofday(&tv, NULL))
err(EXIT_FAILURE, "settimeofday");
}
logwtmp("{", "date", "");
}
if ((p = getlogin()) == NULL)
p = "???";
syslog(LOG_AUTH | LOG_NOTICE, "date set by %s", p);
}
static void
usage(void)
{
(void)fprintf(stderr,
"Usage: %s [-ajnu] [-d date] [-r seconds] [+format]",
getprogname());
(void)fprintf(stderr, " [[[[[[CC]yy]mm]dd]HH]MM[.SS]]\n");
exit(EXIT_FAILURE);
/* NOTREACHED */
}

39
bin/date/extern.h Normal file
View File

@@ -0,0 +1,39 @@
/* $NetBSD: extern.h,v 1.8 2006/11/17 22:11:28 christos Exp $ */
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)extern.h 8.1 (Berkeley) 5/31/93
*/
#ifndef _EXTERN_H_
#define _EXTERN_H_
int netsettime(time_t);
#endif /* !_EXTERN_H_ */

200
bin/date/netdate.c Normal file
View File

@@ -0,0 +1,200 @@
/* $NetBSD: netdate.c,v 1.30 2011/01/29 02:16:52 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)netdate.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: netdate.c,v 1.30 2011/01/29 02:16:52 christos Exp $");
#endif
#endif /* not lint */
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#define TSPTYPES
#include <protocols/timed.h>
#include <err.h>
#include <errno.h>
#include <poll.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "extern.h"
#define WAITACK 2000 /* milliseconds */
#define WAITDATEACK 5000 /* milliseconds */
static const char *
tsp_type_to_string(const struct tsp *msg)
{
unsigned i;
i = msg->tsp_type;
return i < TSPTYPENUMBER ? tsptype[i] : "unknown";
}
/*
* Set the date in the machines controlled by timedaemons by communicating the
* new date to the local timedaemon. If the timedaemon is in the master state,
* it performs the correction on all slaves. If it is in the slave state, it
* notifies the master that a correction is needed.
* Returns 0 on success. Returns > 0 on failure.
*/
int
netsettime(time_t tval)
{
struct sockaddr_in dest;
struct tsp msg;
char hostname[MAXHOSTNAMELEN];
struct servent *sp;
struct pollfd ready;
int found, s, timed_ack, waittime;
if ((sp = getservbyname("timed", "udp")) == NULL) {
warnx("udp/timed: unknown service");
return 2;
}
(void)memset(&dest, 0, sizeof(dest));
#ifdef BSD4_4
dest.sin_len = sizeof(dest);
#endif
dest.sin_family = AF_INET;
dest.sin_port = sp->s_port;
dest.sin_addr.s_addr = htonl(INADDR_ANY);
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s == -1) {
if (errno != EAFNOSUPPORT)
warn("timed");
return 2;
}
#ifdef IP_PORTRANGE
{
static const int on = IP_PORTRANGE_LOW;
if (setsockopt(s, IPPROTO_IP, IP_PORTRANGE, &on,
sizeof(on)) == -1) {
warn("setsockopt");
goto bad;
}
}
#endif
msg.tsp_type = TSP_SETDATE;
msg.tsp_vers = TSPVERSION;
if (gethostname(hostname, sizeof(hostname)) == -1) {
warn("gethostname");
goto bad;
}
(void)strlcpy(msg.tsp_name, hostname, sizeof(msg.tsp_name));
msg.tsp_seq = htons((in_port_t)0);
msg.tsp_time.tv_sec = htonl((in_addr_t)tval); /* XXX: y2038 */
msg.tsp_time.tv_usec = htonl((in_addr_t)0);
if (connect(s, (const void *)&dest, sizeof(dest)) == -1) {
warn("connect");
goto bad;
}
if (send(s, &msg, sizeof(msg), 0) == -1) {
if (errno != ECONNREFUSED)
warn("send");
goto bad;
}
timed_ack = -1;
waittime = WAITACK;
ready.fd = s;
ready.events = POLLIN;
loop:
found = poll(&ready, 1, waittime);
{
socklen_t len;
int error;
len = sizeof(error);
if (getsockopt(s, SOL_SOCKET, SO_ERROR, &error, &len) == -1) {
warn("getsockopt");
goto bad;
}
if (error) {
if (error != ECONNREFUSED) {
errno = error;
warn("send (delayed error)");
}
goto bad;
}
}
if (found > 0 && ready.revents & POLLIN) {
ssize_t ret;
if ((ret = recv(s, &msg, sizeof(msg), 0)) == -1) {
if (errno != ECONNREFUSED)
warn("recv");
goto bad;
} else if ((size_t)ret < sizeof(msg)) {
warnx("recv: incomplete packet");
goto bad;
}
msg.tsp_seq = ntohs(msg.tsp_seq);
msg.tsp_time.tv_sec = ntohl(msg.tsp_time.tv_sec);
msg.tsp_time.tv_usec = ntohl(msg.tsp_time.tv_usec);
switch (msg.tsp_type) {
case TSP_ACK:
timed_ack = TSP_ACK;
waittime = WAITDATEACK;
goto loop;
case TSP_DATEACK:
(void)close(s);
return 0;
default:
warnx("wrong ack received from timed: %s",
tsp_type_to_string(&msg));
timed_ack = -1;
break;
}
}
if (timed_ack == -1)
warnx("can't reach time daemon, time set locally");
bad:
(void)close(s);
return 2;
}

7
bin/mkdir/Makefile Normal file
View File

@@ -0,0 +1,7 @@
# $NetBSD: Makefile,v 1.8 1997/07/20 22:37:21 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= mkdir
SYMLINKS= $(BINDIR)/$(PROG) /usr/bin/$(PROG)
.include <bsd.prog.mk>

94
bin/mkdir/mkdir.1 Normal file
View File

@@ -0,0 +1,94 @@
.\" $NetBSD: mkdir.1,v 1.16 2003/08/07 09:05:16 agc Exp $
.\"
.\" Copyright (c) 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" the Institute of Electrical and Electronics Engineers, Inc.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)mkdir.1 8.2 (Berkeley) 1/25/94
.\"
.Dd January 25, 1994
.Dt MKDIR 1
.Os
.Sh NAME
.Nm mkdir
.Nd make directories
.Sh SYNOPSIS
.Nm
.Op Fl p
.Op Fl m Ar mode
.Ar directory_name ...
.Sh DESCRIPTION
.Nm
creates the directories named as operands, in the order specified,
using mode
.Li rwxrwxrwx (\&0777)
as modified by the current
.Xr umask 2 .
.Pp
The options are as follows:
.Pp
.Bl -tag -width indent
.It Fl m
Set the file permission bits of the final created directory to
the specified mode.
The mode argument can be in any of the formats specified to the
.Xr chmod 1
utility.
If a symbolic mode is specified, the operation characters
.Dq +
and
.Dq -
are interpreted relative to an initial mode of
.Dq a=rwx .
.It Fl p
Create intermediate directories as required.
If this option is not specified, the full path prefix of each
operand must already exist.
Intermediate directories are created with permission bits of
.Li rwxrwxrwx (\&0777)
as modified by the current umask, plus write and search
permission for the owner.
Do not consider it an error if the argument directory already exists.
.El
.Pp
The user must have write permission in the parent directory.
.Sh EXIT STATUS
.Nm
exits 0 if successful, and \*[Gt]0 if an error occurred.
.Sh SEE ALSO
.Xr chmod 1 ,
.Xr rmdir 1 ,
.Xr mkdir 2 ,
.Xr umask 2
.Sh STANDARDS
The
.Nm
utility is expected to be
.St -p1003.2
compatible.

224
bin/mkdir/mkdir.c Normal file
View File

@@ -0,0 +1,224 @@
/* $NetBSD: mkdir.c,v 1.37 2008/07/20 00:52:40 lukem Exp $ */
/*
* Copyright (c) 1983, 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1983, 1992, 1993\
The Regents of the University of California. All rights reserved.");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)mkdir.c 8.2 (Berkeley) 1/25/94";
#else
__RCSID("$NetBSD: mkdir.c,v 1.37 2008/07/20 00:52:40 lukem Exp $");
#endif
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <err.h>
#include <errno.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int mkpath(char *, mode_t, mode_t);
void usage(void);
int main(int, char *[]);
int
main(int argc, char *argv[])
{
int ch, exitval, pflag;
void *set;
mode_t mode, dir_mode;
setprogname(argv[0]);
(void)setlocale(LC_ALL, "");
/*
* The default file mode is a=rwx (0777) with selected permissions
* removed in accordance with the file mode creation mask. For
* intermediate path name components, the mode is the default modified
* by u+wx so that the subdirectories can always be created.
*/
mode = (S_IRWXU | S_IRWXG | S_IRWXO) & ~umask(0);
dir_mode = mode | S_IWUSR | S_IXUSR;
pflag = 0;
while ((ch = getopt(argc, argv, "m:p")) != -1)
switch (ch) {
case 'p':
pflag = 1;
break;
case 'm':
if ((set = setmode(optarg)) == NULL) {
err(EXIT_FAILURE, "Cannot set file mode `%s'",
optarg);
/* NOTREACHED */
}
mode = getmode(set, S_IRWXU | S_IRWXG | S_IRWXO);
free(set);
break;
case '?':
default:
usage();
/* NOTREACHED */
}
argc -= optind;
argv += optind;
if (*argv == NULL) {
usage();
/* NOTREACHED */
}
for (exitval = EXIT_SUCCESS; *argv != NULL; ++argv) {
#ifdef notdef
char *slash;
/* Kernel takes care of this */
/* Remove trailing slashes, per POSIX. */
slash = strrchr(*argv, '\0');
while (--slash > *argv && *slash == '/')
*slash = '\0';
#endif
if (pflag) {
if (mkpath(*argv, mode, dir_mode) < 0)
exitval = EXIT_FAILURE;
} else {
if (mkdir(*argv, mode) < 0) {
warn("%s", *argv);
exitval = EXIT_FAILURE;
} else {
/*
* The mkdir() and umask() calls both honor
* only the file permission bits, so if you try
* to set a mode including the sticky, setuid,
* setgid bits you lose them. So chmod().
*/
if ((mode & ~(S_IRWXU|S_IRWXG|S_IRWXO)) != 0 &&
chmod(*argv, mode) == -1) {
warn("%s", *argv);
exitval = EXIT_FAILURE;
}
}
}
}
exit(exitval);
/* NOTREACHED */
}
/*
* mkpath -- create directories.
* path - path
* mode - file mode of terminal directory
* dir_mode - file mode of intermediate directories
*/
int
mkpath(char *path, mode_t mode, mode_t dir_mode)
{
struct stat sb;
char *slash;
int done, rv;
done = 0;
slash = path;
for (;;) {
slash += strspn(slash, "/");
slash += strcspn(slash, "/");
done = (*slash == '\0');
*slash = '\0';
rv = mkdir(path, done ? mode : dir_mode);
if (rv < 0) {
/*
* Can't create; path exists or no perms.
* stat() path to determine what's there now.
*/
int sverrno;
sverrno = errno;
if (stat(path, &sb) < 0) {
/* Not there; use mkdir()s error */
errno = sverrno;
warn("%s", path);
return -1;
}
if (!S_ISDIR(sb.st_mode)) {
/* Is there, but isn't a directory */
errno = ENOTDIR;
warn("%s", path);
return -1;
}
} else if (done) {
/*
* Created ok, and this is the last element
*/
/*
* The mkdir() and umask() calls both honor only the
* file permission bits, so if you try to set a mode
* including the sticky, setuid, setgid bits you lose
* them. So chmod().
*/
if ((mode & ~(S_IRWXU|S_IRWXG|S_IRWXO)) != 0 &&
chmod(path, mode) == -1) {
warn("%s", path);
return -1;
}
}
if (done) {
break;
}
*slash = '/';
}
return 0;
}
void
usage(void)
{
(void)fprintf(stderr, "usage: %s [-p] [-m mode] dirname ...\n",
getprogname());
exit(EXIT_FAILURE);
/* NOTREACHED */
}

6
bin/rm/Makefile Normal file
View File

@@ -0,0 +1,6 @@
# $NetBSD: Makefile,v 1.9 1997/07/20 22:37:50 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= rm
.include <bsd.prog.mk>

207
bin/rm/rm.1 Normal file
View File

@@ -0,0 +1,207 @@
.\" $NetBSD: rm.1,v 1.24 2006/09/02 23:28:32 wiz Exp $
.\"
.\" Copyright (c) 1990, 1993, 1994, 2003
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" the Institute of Electrical and Electronics Engineers, Inc.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)rm.1 8.5 (Berkeley) 12/5/94
.\"
.Dd August 25, 2006
.Dt RM 1
.Os
.Sh NAME
.Nm rm
.Nd remove directory entries
.Sh SYNOPSIS
.Nm
.Op Fl f | Fl i
.Op Fl dPRrvW
.Ar
.Sh DESCRIPTION
The
.Nm
utility attempts to remove the non-directory type files specified on the
command line.
If the permissions of the file do not permit writing, and the standard
input device is a terminal, the user is prompted (on the standard error
output) for confirmation.
.Pp
The options are as follows:
.Bl -tag -width flag
.It Fl d
Attempt to remove directories as well as other types of files.
.It Fl f
Attempt to remove the files without prompting for confirmation,
regardless of the file's permissions.
If the file does not exist, do not display a diagnostic message or modify
the exit status to reflect an error.
The
.Fl f
option overrides any previous
.Fl i
options.
.It Fl i
Request confirmation before attempting to remove each file, regardless of
the file's permissions, or whether or not the standard input device is a
terminal.
The
.Fl i
option overrides any previous
.Fl f
options.
.It Fl P
Overwrite regular files before deleting them.
Files are overwritten three times, first with the byte pattern 0xff,
then 0x00, and then with random data, before they are deleted.
Some care is taken to ensure that the data are actually written to
disk, but this cannot be guaranteed, even on traditional filesystems;
on log-structured filesystems or if any block-journaling scheme is
in use, this option is completely useless.
If the file cannot be
overwritten, it will not be removed.
.It Fl R
Attempt to remove the file hierarchy rooted in each file argument.
The
.Fl R
option implies the
.Fl d
option.
If the
.Fl i
option is specified, the user is prompted for confirmation before
each directory's contents are processed (as well as before the attempt
is made to remove the directory).
If the user does not respond affirmatively, the file hierarchy rooted in
that directory is skipped.
.Pp
.It Fl r
Equivalent to
.Fl R .
.It Fl v
Cause
.Nm
to be verbose, showing files as they are processed.
.It Fl W
Attempts to undelete the named files.
Currently, this option can only be used to recover
files covered by whiteouts.
.El
.Pp
The
.Nm
utility removes symbolic links, not the files referenced by the links.
.Pp
It is an error to attempt to remove the files ``.'' and ``..''.
.Sh EXIT STATUS
The
.Nm
utility exits 0 if all of the named files or file hierarchies were removed,
or if the
.Fl f
option was specified and all of the existing files or file hierarchies were
removed.
If an error occurs,
.Nm
exits with a value \*[Gt]0.
.Sh EXAMPLES
.Nm
uses
.Xr getopt 3
standard argument processing.
Removing filenames that begin with a dash
.Pq e.g., Ar -file
in the current directory which might otherwise be taken as option flags to
.Nm
can be accomplished as follows:
.Pp
.Ic "rm -- -file"
.Pp
or
.Pp
.Ic "rm ./-file"
.Sh SEE ALSO
.Xr rmdir 1 ,
.Xr undelete 2 ,
.Xr unlink 2 ,
.Xr fts 3 ,
.Xr getopt 3 ,
.Xr symlink 7
.Sh BUGS
The
.Fl P
option assumes that the underlying file system is a fixed-block file
system.
FFS is a fixed-block file system, LFS is not.
In addition, only regular files are overwritten, other types of files
are not.
Recent research indicates that as many as 35 overwrite passes with
carefully chosen data patterns may be necessary to actually prevent
recovery of data from a magnetic disk.
Thus the
.Fl P
option is likely both insufficient for its design purpose and far
too costly for default operation.
However, it will at least prevent the recovery of data from FFS
volumes with
.Xr fsdb 8 .
.Sh COMPATIBILITY
The
.Nm
utility differs from historical implementations in that the
.Fl f
option only masks attempts to remove non-existent files instead of
masking a large variety of errors.
.Pp
Also, historical
.Bx
implementations prompted on the standard output,
not the standard error output.
.Sh STANDARDS
The
.Nm
utility is expected to be
.St -p1003.2
compatible.
The
.Fl v
option is an extension.
.Pp
The
.Fl P
option attempts to conform to U.S. DoD 5220-22.M, "National Industrial
Security Program Operating Manual" ("NISPOM") as updated by Change
2 and the July 23, 2003 "Clearing \*[Am] Sanitization Matrix".
However, unlike earlier revisions of NISPOM, the 2003 matrix imposes
requirements which make it clear that the standard does not and
can not apply to the erasure of individual files, in particular
requirements relating to spare sector management for an entire
magnetic disk.
.Em Because these requirements are not met, the
.Fl P
.Em option does not conform to the standard .

605
bin/rm/rm.c Normal file
View File

@@ -0,0 +1,605 @@
/* $NetBSD: rm.c,v 1.50 2011/08/29 14:48:46 joerg Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994, 2003
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1990, 1993, 1994\
The Regents of the University of California. All rights reserved.");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)rm.c 8.8 (Berkeley) 4/27/95";
#else
__RCSID("$NetBSD: rm.c,v 1.50 2011/08/29 14:48:46 joerg Exp $");
#endif
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <fts.h>
#include <grp.h>
#include <locale.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static int dflag, eval, fflag, iflag, Pflag, stdin_ok, vflag, Wflag;
static int check(char *, char *, struct stat *);
static void checkdot(char **);
static void rm_file(char **);
static int rm_overwrite(char *, struct stat *);
static void rm_tree(char **);
__dead static void usage(void);
#ifdef __minix
# ifndef O_SYNC
# define O_SYNC 0
# endif
# ifndef O_RSYNC
# define O_RSYNC 0
# endif
#endif
/*
* For the sake of the `-f' flag, check whether an error number indicates the
* failure of an operation due to an non-existent file, either per se (ENOENT)
* or because its filename argument was illegal (ENAMETOOLONG, ENOTDIR).
*/
#define NONEXISTENT(x) \
((x) == ENOENT || (x) == ENAMETOOLONG || (x) == ENOTDIR)
/*
* rm --
* This rm is different from historic rm's, but is expected to match
* POSIX 1003.2 behavior. The most visible difference is that -f
* has two specific effects now, ignore non-existent files and force
* file removal.
*/
int
main(int argc, char *argv[])
{
int ch, rflag;
setprogname(argv[0]);
(void)setlocale(LC_ALL, "");
Pflag = rflag = 0;
while ((ch = getopt(argc, argv, "dfiPRrvW")) != -1)
switch (ch) {
case 'd':
dflag = 1;
break;
case 'f':
fflag = 1;
iflag = 0;
break;
case 'i':
fflag = 0;
iflag = 1;
break;
case 'P':
Pflag = 1;
break;
case 'R':
case 'r': /* Compatibility. */
rflag = 1;
break;
case 'v':
vflag = 1;
break;
case 'W':
Wflag = 1;
break;
case '?':
default:
usage();
}
argc -= optind;
argv += optind;
if (argc < 1) {
if (fflag)
return 0;
usage();
}
checkdot(argv);
if (*argv) {
stdin_ok = isatty(STDIN_FILENO);
if (rflag)
rm_tree(argv);
else
rm_file(argv);
}
exit(eval);
/* NOTREACHED */
}
static void
rm_tree(char **argv)
{
FTS *fts;
FTSENT *p;
int flags, needstat, rval;
/*
* Remove a file hierarchy. If forcing removal (-f), or interactive
* (-i) or can't ask anyway (stdin_ok), don't stat the file.
*/
needstat = !fflag && !iflag && stdin_ok;
/*
* If the -i option is specified, the user can skip on the pre-order
* visit. The fts_number field flags skipped directories.
*/
#define SKIPPED 1
flags = FTS_PHYSICAL;
if (!needstat)
flags |= FTS_NOSTAT;
#ifndef __minix
if (Wflag)
flags |= FTS_WHITEOUT;
#endif
if ((fts = fts_open(argv, flags, NULL)) == NULL)
err(1, "fts_open failed");
while ((p = fts_read(fts)) != NULL) {
switch (p->fts_info) {
case FTS_DNR:
if (!fflag || p->fts_errno != ENOENT) {
warnx("%s: %s", p->fts_path,
strerror(p->fts_errno));
eval = 1;
}
continue;
case FTS_ERR:
errx(EXIT_FAILURE, "%s: %s", p->fts_path,
strerror(p->fts_errno));
/* NOTREACHED */
case FTS_NS:
/*
* FTS_NS: assume that if can't stat the file, it
* can't be unlinked.
*/
if (fflag && NONEXISTENT(p->fts_errno))
continue;
if (needstat) {
warnx("%s: %s", p->fts_path,
strerror(p->fts_errno));
eval = 1;
continue;
}
break;
case FTS_D:
/* Pre-order: give user chance to skip. */
if (!fflag && !check(p->fts_path, p->fts_accpath,
p->fts_statp)) {
(void)fts_set(fts, p, FTS_SKIP);
p->fts_number = SKIPPED;
}
continue;
case FTS_DP:
/* Post-order: see if user skipped. */
if (p->fts_number == SKIPPED)
continue;
break;
default:
if (!fflag &&
!check(p->fts_path, p->fts_accpath, p->fts_statp))
continue;
}
rval = 0;
/*
* If we can't read or search the directory, may still be
* able to remove it. Don't print out the un{read,search}able
* message unless the remove fails.
*/
switch (p->fts_info) {
case FTS_DP:
case FTS_DNR:
rval = rmdir(p->fts_accpath);
if (rval != 0 && fflag && errno == ENOENT)
continue;
break;
#ifndef __minix
case FTS_W:
rval = undelete(p->fts_accpath);
if (rval != 0 && fflag && errno == ENOENT)
continue;
break;
#endif
default:
if (Pflag) {
if (rm_overwrite(p->fts_accpath, NULL))
continue;
}
rval = unlink(p->fts_accpath);
if (rval != 0 && fflag && NONEXISTENT(errno))
continue;
break;
}
if (rval != 0) {
warn("%s", p->fts_path);
eval = 1;
} else if (vflag)
(void)printf("%s\n", p->fts_path);
}
if (errno)
err(1, "fts_read");
fts_close(fts);
}
static void
rm_file(char **argv)
{
struct stat sb;
int rval;
char *f;
/*
* Remove a file. POSIX 1003.2 states that, by default, attempting
* to remove a directory is an error, so must always stat the file.
*/
while ((f = *argv++) != NULL) {
/* Assume if can't stat the file, can't unlink it. */
if (lstat(f, &sb)) {
if (Wflag) {
#ifdef __minix
sb.st_mode = S_IWUSR|S_IRUSR;
#else
sb.st_mode = S_IFWHT|S_IWUSR|S_IRUSR;
#endif
} else {
if (!fflag || !NONEXISTENT(errno)) {
warn("%s", f);
eval = 1;
}
continue;
}
} else if (Wflag) {
warnx("%s: %s", f, strerror(EEXIST));
eval = 1;
continue;
}
if (S_ISDIR(sb.st_mode) && !dflag) {
warnx("%s: is a directory", f);
eval = 1;
continue;
}
#ifndef __minix
if (!fflag && !S_ISWHT(sb.st_mode) && !check(f, f, &sb))
#else
if (!fflag && !check(f, f, &sb))
#endif
continue;
#ifndef __minix
if (S_ISWHT(sb.st_mode))
rval = undelete(f);
else
#endif
if (S_ISDIR(sb.st_mode))
rval = rmdir(f);
else {
if (Pflag) {
if (rm_overwrite(f, &sb))
continue;
}
rval = unlink(f);
}
if (rval && (!fflag || !NONEXISTENT(errno))) {
warn("%s", f);
eval = 1;
}
if (vflag && rval == 0)
(void)printf("%s\n", f);
}
}
/*
* rm_overwrite --
* Overwrite the file 3 times with varying bit patterns.
*
* This is an expensive way to keep people from recovering files from your
* non-snapshotted FFS filesystems using fsdb(8). Really. No more. Only
* regular files are deleted, directories (and therefore names) will remain.
* Also, this assumes a fixed-block file system (like FFS, or a V7 or a
* System V file system). In a logging file system, you'll have to have
* kernel support.
*
* A note on standards: U.S. DoD 5220.22-M "National Industrial Security
* Program Operating Manual" ("NISPOM") is often cited as a reference
* for clearing and sanitizing magnetic media. In fact, a matrix of
* "clearing" and "sanitization" methods for various media was given in
* Chapter 8 of the original 1995 version of NISPOM. However, that
* matrix was *removed from the document* when Chapter 8 was rewritten
* in Change 2 to the document in 2001. Recently, the Defense Security
* Service has made a revised clearing and sanitization matrix available
* in Microsoft Word format on the DSS web site. The standardization
* status of this matrix is unclear. Furthermore, one must be very
* careful when referring to this matrix: it is intended for the "clearing"
* prior to reuse or "sanitization" prior to disposal of *entire media*,
* not individual files and the only non-physically-destructive method of
* "sanitization" that is permitted for magnetic disks of any kind is
* specifically noted to be prohibited for media that have contained
* Top Secret data.
*
* It is impossible to actually conform to the exact procedure given in
* the matrix if one is overwriting a file, not an entire disk, because
* the procedure requires examination and comparison of the disk's defect
* lists. Any program that claims to securely erase *files* while
* conforming to the standard, then, is not correct. We do as much of
* what the standard requires as can actually be done when erasing a
* file, rather than an entire disk; but that does not make us conformant.
*
* Furthermore, the presence of track caches, disk and controller write
* caches, and so forth make it extremely difficult to ensure that data
* have actually been written to the disk, particularly when one tries
* to repeatedly overwrite the same sectors in quick succession. We call
* fsync(), but controllers with nonvolatile cache, as well as IDE disks
* that just plain lie about the stable storage of data, will defeat this.
*
* Finally, widely respected research suggests that the given procedure
* is nowhere near sufficient to prevent the recovery of data using special
* forensic equipment and techniques that are well-known. This is
* presumably one reason that the matrix requires physical media destruction,
* rather than any technique of the sort attempted here, for secret data.
*
* Caveat Emptor.
*
* rm_overwrite will return 0 on success.
*/
static int
rm_overwrite(char *file, struct stat *sbp)
{
struct stat sb;
int fd, randint;
char randchar;
fd = -1;
if (sbp == NULL) {
if (lstat(file, &sb))
goto err;
sbp = &sb;
}
if (!S_ISREG(sbp->st_mode))
return 0;
/* flags to try to defeat hidden caching by forcing seeks */
if ((fd = open(file, O_RDWR|O_SYNC|O_RSYNC, 0)) == -1)
goto err;
#define RAND_BYTES 1
#define THIS_BYTE 0
#define WRITE_PASS(mode, byte) do { \
off_t len; \
size_t wlen, i; \
char buf[8 * 1024]; \
\
if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET)) \
goto err; \
\
if (mode == THIS_BYTE) \
memset(buf, byte, sizeof(buf)); \
for (len = sbp->st_size; len > 0; len -= wlen) { \
if (mode == RAND_BYTES) { \
for (i = 0; i < sizeof(buf); \
i+= sizeof(u_int32_t)) \
*(int *)(buf + i) = arc4random(); \
} \
wlen = len < (off_t)sizeof(buf) ? (size_t)len : sizeof(buf); \
if ((size_t)write(fd, buf, wlen) != wlen) \
goto err; \
} \
sync(); /* another poke at hidden caches */ \
} while (/* CONSTCOND */ 0)
#define READ_PASS(byte) do { \
off_t len; \
size_t rlen; \
char pattern[8 * 1024]; \
char buf[8 * 1024]; \
\
if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET)) \
goto err; \
\
memset(pattern, byte, sizeof(pattern)); \
for(len = sbp->st_size; len > 0; len -= rlen) { \
rlen = len < (off_t)sizeof(buf) ? (size_t)len : sizeof(buf); \
if((size_t)read(fd, buf, rlen) != rlen) \
goto err; \
if(memcmp(buf, pattern, rlen)) \
goto err; \
} \
sync(); /* another poke at hidden caches */ \
} while (/* CONSTCOND */ 0)
/*
* DSS sanitization matrix "clear" for magnetic disks:
* option 'c' "Overwrite all addressable locations with a single
* character."
*/
randint = arc4random();
randchar = *(char *)&randint;
WRITE_PASS(THIS_BYTE, randchar);
/*
* DSS sanitization matrix "sanitize" for magnetic disks:
* option 'd', sub 2 "Overwrite all addressable locations with a
* character, then its complement. Verify "complement" character
* was written successfully to all addressable locations, then
* overwrite all addressable locations with random characters; or
* verify third overwrite of random characters." The rest of the
* text in d-sub-2 specifies requirements for overwriting spared
* sectors; we cannot conform to it when erasing only a file, thus
* we do not conform to the standard.
*/
/* 1. "a character" */
WRITE_PASS(THIS_BYTE, 0xff);
/* 2. "its complement" */
WRITE_PASS(THIS_BYTE, 0x00);
/* 3. "Verify 'complement' character" */
READ_PASS(0x00);
/* 4. "overwrite all addressable locations with random characters" */
WRITE_PASS(RAND_BYTES, 0x00);
/*
* As the file might be huge, and we note that this revision of
* the matrix says "random characters", not "a random character"
* as the original did, we do not verify the random-character
* write; the "or" in the standard allows this.
*/
if (close(fd) == -1) {
fd = -1;
goto err;
}
return 0;
err: eval = 1;
warn("%s", file);
if (fd != -1)
close(fd);
return 1;
}
static int
check(char *path, char *name, struct stat *sp)
{
int ch, first;
char modep[15];
/* Check -i first. */
if (iflag)
(void)fprintf(stderr, "remove '%s'? ", path);
else {
/*
* If it's not a symbolic link and it's unwritable and we're
* talking to a terminal, ask. Symbolic links are excluded
* because their permissions are meaningless. Check stdin_ok
* first because we may not have stat'ed the file.
*/
if (!stdin_ok || S_ISLNK(sp->st_mode) ||
!(access(name, W_OK) && (errno != ETXTBSY)))
return (1);
strmode(sp->st_mode, modep);
if (Pflag) {
warnx(
"%s: -P was specified but file could not"
" be overwritten", path);
return 0;
}
(void)fprintf(stderr, "override %s%s%s:%s for '%s'? ",
modep + 1, modep[9] == ' ' ? "" : " ",
user_from_uid(sp->st_uid, 0),
group_from_gid(sp->st_gid, 0), path);
}
(void)fflush(stderr);
first = ch = getchar();
while (ch != '\n' && ch != EOF)
ch = getchar();
return (first == 'y' || first == 'Y');
}
/*
* POSIX.2 requires that if "." or ".." are specified as the basename
* portion of an operand, a diagnostic message be written to standard
* error and nothing more be done with such operands.
*
* Since POSIX.2 defines basename as the final portion of a path after
* trailing slashes have been removed, we'll remove them here.
*/
#define ISDOT(a) ((a)[0] == '.' && (!(a)[1] || ((a)[1] == '.' && !(a)[2])))
static void
checkdot(char **argv)
{
char *p, **save, **t;
int complained;
complained = 0;
for (t = argv; *t;) {
/* strip trailing slashes */
p = strrchr(*t, '\0');
while (--p > *t && *p == '/')
*p = '\0';
/* extract basename */
if ((p = strrchr(*t, '/')) != NULL)
++p;
else
p = *t;
if (ISDOT(p)) {
if (!complained++)
warnx("\".\" and \"..\" may not be removed");
eval = 1;
for (save = t; (t[0] = t[1]) != NULL; ++t)
continue;
t = save;
} else
++t;
}
}
static void
usage(void)
{
(void)fprintf(stderr, "usage: %s [-f|-i] [-dPRrvW] file ...\n",
getprogname());
exit(1);
/* NOTREACHED */
}

6
bin/rmdir/Makefile Normal file
View File

@@ -0,0 +1,6 @@
# $NetBSD: Makefile,v 1.8 1997/07/20 22:37:52 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= rmdir
.include <bsd.prog.mk>

90
bin/rmdir/rmdir.1 Normal file
View File

@@ -0,0 +1,90 @@
.\" $NetBSD: rmdir.1,v 1.15 2003/08/07 09:05:29 agc Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" the Institute of Electrical and Electronics Engineers, Inc.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)rmdir.1 8.1 (Berkeley) 5/31/93
.\"
.Dd May 31, 1993
.Dt RMDIR 1
.Os
.Sh NAME
.Nm rmdir
.Nd remove directories
.Sh SYNOPSIS
.Nm
.Op Fl p
.Ar directory ...
.Sh DESCRIPTION
The rmdir utility removes the directory entry specified by
each
.Ar directory
argument, provided it is empty.
.Pp
Arguments are processed in the order given.
In order to remove both a parent directory and a subdirectory
of that parent, the subdirectory
must be specified first so the parent directory
is empty when
.Nm
tries to remove it.
.Pp
The following option is available:
.Bl -tag -width Ds
.It Fl p
Each
.Ar directory
argument is treated as a pathname of which all
components will be removed, if they are empty,
starting with the last most component.
(See
.Xr rm 1
for fully non-discriminant recursive removal.)
.El
.Sh EXIT STATUS
The
.Nm
utility exits with one of the following values:
.Bl -tag -width Ds
.It Li \&0
Each directory entry specified by a dir operand
referred to an empty directory and was removed
successfully.
.It Li \&\*[Gt]\&0
An error occurred.
.El
.Sh SEE ALSO
.Xr rm 1
.Sh STANDARDS
The
.Nm
utility is expected to be
.St -p1003.2
compatible.

121
bin/rmdir/rmdir.c Normal file
View File

@@ -0,0 +1,121 @@
/* $NetBSD: rmdir.c,v 1.26 2011/08/29 14:49:38 joerg Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\
The Regents of the University of California. All rights reserved.");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)rmdir.c 8.3 (Berkeley) 4/2/94";
#else
__RCSID("$NetBSD: rmdir.c,v 1.26 2011/08/29 14:49:38 joerg Exp $");
#endif
#endif /* not lint */
#include <sys/param.h>
#include <err.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static int rm_path(char *);
__dead static void usage(void);
int
main(int argc, char *argv[])
{
int ch, errors, pflag;
setprogname(argv[0]);
(void)setlocale(LC_ALL, "");
pflag = 0;
while ((ch = getopt(argc, argv, "p")) != -1)
switch(ch) {
case 'p':
pflag = 1;
break;
case '?':
default:
usage();
}
argc -= optind;
argv += optind;
if (argc == 0)
usage();
for (errors = 0; *argv; argv++) {
/* We rely on the kernel to ignore trailing '/' characters. */
if (rmdir(*argv) < 0) {
warn("%s", *argv);
errors = 1;
} else if (pflag)
errors |= rm_path(*argv);
}
exit(errors);
/* NOTREACHED */
}
static int
rm_path(char *path)
{
char *p;
while ((p = strrchr(path, '/')) != NULL) {
*p = 0;
if (p[1] == 0)
/* Ignore trailing '/' on deleted name */
continue;
if (rmdir(path) < 0) {
warn("%s", path);
return (1);
}
}
return (0);
}
static void
usage(void)
{
(void)fprintf(stderr, "usage: %s [-p] directory ...\n", getprogname());
exit(1);
/* NOTREACHED */
}

View File

@@ -1,97 +0,0 @@
# Makefile for the boot monitor package.
# XXX: Can only be built with ACK currently
CC:=${CC:C/^gcc/cc/}
COMPILER_TYPE:=ack
PROGS= bootblock cdbootblock boot masterboot \
jumpboot installboot edparams dosboot mkfile
SRCS.bootblock= bootblock.s
CPPFLAGS.bootblock.s= ${I86CPPFLAGS}
LDFLAGS.bootblock= ${I86LDFLAGS}
BINDIR.bootblock= /usr/mdec
MAN.bootblock=
SRCS.cdbootblock= cdbootblock.s
CPPFLAGS.cdbootblock.s= ${I86CPPFLAGS} -DCDBOOT
LDFLAGS.cdbootblock= ${I86LDFLAGS}
BINDIR.cdbootblock= /usr/mdec
MAN.cdbootblock=
SRCS.boot= boothead.s boot.c bootimage.c rawfs86.c
CPPFLAGS.boothead.s= ${I86CPPFLAGS}
CPPFLAGS.boot.c= ${I86CPPFLAGS}
CPPFLAGS.bootimage.c= ${I86CPPFLAGS}
CPPFLAGS.rawfs86.c= ${I86CPPFLAGS}
LDFLAGS.boot= ${I86LDFLAGS}
DPADD.boot= ${LIBSYS}
LDADD.boot= -lsys
BINDIR.boot= /usr/mdec
MAN.boot=
realall: .PHONY bootsize
bootsize: boot
${INSTALL} -S 22kb boot
SRCS.masterboot= masterboot.s
CPPFLAGS.masterboot.s= ${I86CPPFLAGS}
LDFLAGS.masterboot= ${I86LDFLAGS}
BINDIR.masterboot= /usr/mdec
MAN.masterboot=
SRCS.jumpboot= jumpboot.s
CPPFLAGS.jumpboot.s= ${I86CPPFLAGS}
LDFLAGS.jumpboot= ${I86LDFLAGS}
BINDIR.jumpboot= /usr/mdec
MAN.jumpboot=
SRCS.installboot= installboot.c rawfs.c
BINDIR.installboot= /usr/bin
MAN.installboot=
SRCS.edparams= edparams.c rawfs.c
CPPFLAGS.edparams.c= -DUNIX
BINDIR.edparams= /usr/bin
MAN.edparams=
SRCS.dosboot= doshead.s dosboot.o bootimage.o rawfs86.o
CPPFLAGS.dosboot.c= -DDOS $(I86CPPFLAGS)
LDADD.dosboot= ${I86LDFLAGS} -lsys
BINDIR.dosboot= /usr/mdec
CPPFLAGS.doshead.s= -mi386
MAN.dosboot=
SRCS.mkfile= mkfhead.s mkfile.c
CPPFLAGS.mkfile.s= ${I86CPPFLAGS}
LDADD.mkfile= ${I86LDFLAGS} -lsys
BINDIR.mkfile= /usr/mdec
MAN.mkfile=
rawfs86.c: rawfs.c
ln -f rawfs.c rawfs86.c
edparams.c: boot.c
ln -f boot.c edparams.c
dosboot.c: boot.c
ln -f boot.c dosboot.c
cdbootblock.s: bootblock.s
ln -f bootblock.s cdbootblock.s
mkfile.com: mkfile
boot.com: dosboot
./a.out2com dosboot boot.com
CPPFLAGS= -I${MINIXSRCDIR}
AFLAGS= -I${MINIXSRCDIR}
I86CPPFLAGS= -mi86 -Was-ncc
I86LDFLAGS= -mi86 -Was-ncc -.o -com
STRIPFLAG= -s
CLEANFILES+= rawfs86.c edparams.c cdbootblock.s dosboot.c
.include <bsd.prog.mk>

View File

@@ -1,25 +0,0 @@
#!/bin/sh
#
# a.out2com - Minix a.out to DOS .COM Author: Kees J. Bot
# 17 Jun 1995
# Transform a Minix a.out to the COM format of MS-DOS,
# the executable must be common I&D with 256 scratch bytes at the start of
# the text segment to make space for the Program Segment Prefix. The Minix
# a.out header and these 256 bytes are removed to make a COM file.
case $# in
2) aout="$1"
com="$2"
;;
*) echo "Usage: $0 <a.out> <dos.com>" >&2
exit 1
esac
size "$aout" >/dev/null || exit
set `size "$aout" | sed 1d`
count=`expr \( $1 + $2 - 256 + 31 \) / 32`
exec dd if="$aout" of="$com" bs=32 skip=9 count=$count conv=silent
#
# $PchId: a.out2com,v 1.3 1998/08/01 09:13:01 philip Exp $

View File

@@ -1,128 +0,0 @@
/* A small utility to append an a.out header to an arbitrary file. This allows
* inclusion of arbitrary data in the boot image, so that it is magically
* loaded as a RAM disk. The a.out header is structured as follows:
*
* a_flags: A_IMG to indicate this is not an executable
*
* Created: April 2005, Jorrit N. Herder
*/
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <a.out.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <string.h>
#include <unistd.h>
#define INPUT_FILE 1
#define OUTPUT_FILE 2
/* Report problems. */
static void report(const char *problem, const char *message)
{
fprintf(stderr, "%s:\n", problem);
fprintf(stderr, " %s\n\n", message);
}
static int copy_data(int srcfd, int dstfd)
{
char buf[8192];
ssize_t n;
int total=0;
/** FIXME: handle error from read() */
/* Copy the little bytes themselves. (Source from cp.c). */
while ((n= read(srcfd, buf, sizeof(buf))) > 0) {
char *bp = buf;
ssize_t r = 0;
/** FIXME: handle error from write() */
while (n > 0 && (r= write(dstfd, bp, n)) > 0) {
bp += r;
n -= r;
total += r;
}
if (r == 0) {
fprintf(stderr, "Warning: EOF writing to output file.\n");
return(-1);
}
}
return(total);
}
/* Main program. */
int main(int argc, char **argv)
{
struct exec aout;
struct stat stin;
int fdin, fdout;
char * bp;
int n,r;
int total_size;
/* Check if command line arguments are present, or print usage. */
if (argc!=3) {
printf("Invalid arguments. Usage:\n");
printf(" %s <input_file> <output_file>\n",argv[0]);
return(1);
}
/* Check if we can open the input and output file. */
if (stat(argv[INPUT_FILE], &stin) != 0) {
report("Couldn't get status of input file", strerror(errno));
return(1);
}
if ((fdin = open(argv[INPUT_FILE], O_RDONLY)) < 0) {
report("Couldn't open input file", strerror(errno));
return(1);
}
if ((fdout = open(argv[OUTPUT_FILE], O_WRONLY|O_CREAT|O_TRUNC,
stin.st_mode & 0777)) < 0) {
report("Couldn't open output file", strerror(errno));
return(1);
}
/* Copy input file to output file, but leave space for a.out header. */
lseek(fdout, sizeof(aout), SEEK_SET);
total_size = copy_data(fdin, fdout);
if (total_size < 0) {
report("Aborted", "Output file may be truncated.");
return(1);
} else if (total_size == 0) {
report("Aborted without prepending header", "No data in input file.");
return(1);
}
/* Build a.out header and write to output file. */
memset(&aout, 0, sizeof(struct exec));
aout.a_magic[0] = A_MAGIC0;
aout.a_magic[1] = A_MAGIC1;
aout.a_flags |= A_IMG;
aout.a_hdrlen = sizeof(aout);
aout.a_text = 0;
aout.a_data = total_size;
aout.a_bss = 0;
aout.a_total = aout.a_hdrlen + aout.a_data;
bp = (char *) &aout;
n = sizeof(aout);
lseek(fdout, 0L, SEEK_SET);
while (n > 0 && (r= write(fdout, bp, n)) > 0) {
bp += r;
n -= r;
}
printf("Prepended data file (%d bytes) with a.out header (%u bytes).\n",
total_size, sizeof(aout));
printf("Done.\n");
return(0);
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,231 +0,0 @@
/* boot.h - Info between different parts of boot. Author: Kees J. Bot
*/
#ifndef DEBUG
#define DEBUG 0
#endif
/* Constants describing the metal: */
#define SECTOR_SIZE 512
#define SECTOR_SHIFT 9
#define RATIO(b) ((b) / SECTOR_SIZE)
#define PARAMSEC 1 /* Sector containing boot parameters. */
#define DSKBASE 0x1E /* Floppy disk parameter vector. */
#define DSKPARSIZE 11 /* There are this many bytes of parameters. */
#define ESC '\33' /* Escape key. */
#define HEADERPOS 0x00600L /* Place for an array of struct exec's. */
#define FREEPOS 0x08000L /* Memory from FREEPOS to caddr is free to
* play with.
*/
#if BIOS
#define MSEC_PER_TICK 55 /* Clock does 18.2 ticks per second. */
#define TICKS_PER_DAY 0x1800B0L /* After 24 hours it wraps. */
#endif
#if UNIX
#define MSEC_PER_TICK 1000 /* Clock does 18.2 ticks per second. */
#define TICKS_PER_DAY 86400L /* Doesn't wrap, but that doesn't matter. */
#endif
#define BOOTPOS 0x07C00L /* Bootstraps are loaded here. */
#define SIGNATURE 0xAA55 /* Proper bootstraps have this signature. */
#define SIGNATOFF 510 /* Offset within bootblock. */
/* BIOS video modes. */
#define MONO_MODE 0x07 /* 80x25 monochrome. */
#define COLOR_MODE 0x03 /* 80x25 color. */
/* Variables shared with boothead.s: */
#ifndef EXTERN
#define EXTERN extern
#endif
typedef struct vector { /* 8086 vector */
u16_t offset;
u16_t segment;
} vector;
EXTERN vector rem_part; /* Boot partition table entry. */
EXTERN u32_t caddr, daddr; /* Code and data address of the boot program. */
EXTERN u32_t runsize; /* Size of this program. */
EXTERN u16_t device; /* Drive being booted from. */
EXTERN u16_t cddevice; /* Drive that is CD if known. */
#define CDNAME "cd" /* Name of the CD device. */
typedef struct { /* One chunk of free memory. */
u32_t base; /* Start byte. */
u32_t size; /* Number of bytes. */
} memory;
typedef struct { /* One chunk of free memory. */
u32_t base_lo; /* Start byte. */
u32_t base_hi;
u32_t size_lo; /* Number of bytes. */
u32_t size_hi; /* Number of bytes. */
u32_t type;
u32_t acpi_attrs;
} e820_memory;
EXTERN memory mem[3]; /* List of available memory. */
EXTERN e820_memory emem[16]; /* List of available memory. */
EXTERN int mem_entries;
EXTERN int mon_return; /* Monitor stays in memory? */
EXTERN int cdbooted; /* Did we boot from CD? (Set by boothead.s.) */
typedef struct bios_env
{
u16_t ax;
u16_t bx;
u16_t cx;
u16_t flags;
} bios_env_t;
#define FL_CARRY 0x0001 /* carry flag */
/* Functions defined by boothead.s: */
void exit(int code);
/* Exit the monitor. */
u32_t mon2abs(void *ptr);
/* Local monitor address to absolute address. */
u32_t vec2abs(vector *vec);
/* Vector to absolute address. */
void raw_copy(u32_t dstaddr, u32_t srcaddr, u32_t count);
/* Copy bytes from anywhere to anywhere. */
u16_t get_word(u32_t addr);
/* Get a word from anywhere. */
void put_word(u32_t addr, u16_t word);
/* Put a word anywhere. */
void relocate(void);
/* Switch to a copy of this program. */
int dev_open(void), dev_close(void);
/* Open device and determine params / close device. */
int dev_boundary(u32_t sector);
/* True if sector is on a track boundary. */
int readsectors(u32_t bufaddr, u32_t sector, u8_t count);
/* Read 1 or more sectors from "device". */
int writesectors(u32_t bufaddr, u32_t sector, u8_t count);
/* Write 1 or more sectors to "device". */
int biosreadsectors(u32_t bufaddr, u32_t sector, u8_t count);
int getch(void);
/* Read a keypress. */
void scan_keyboard(void);
/* Read keypress directly from kb controller. */
void ungetch(int c);
/* Undo a keypress. */
int escape(void);
/* True if escape typed. */
void putch(int c);
/* Send a character to the screen. */
#if BIOS
void pause(void);
/* Wait for an interrupt. */
void serial_init(int line);
#endif /* Enable copying console I/O to a serial line. */
void set_mode(unsigned mode);
void clear_screen(void);
/* Set video mode / clear the screen. */
u16_t get_bus(void);
/* System bus type, XT, AT, or MCA. */
u16_t get_video(void);
/* Display type, MDA to VGA. */
u32_t get_tick(void);
/* Current value of the clock tick counter. */
void bootstrap(int device, struct part_entry *entry);
/* Execute a bootstrap routine for a different O.S. */
void minix(u32_t koff, u32_t kcs, u32_t kds,
char *bootparams, size_t paramsize, u32_t aout);
/* Start Minix. */
void int15(bios_env_t *);
/* Shared between boot.c and bootimage.c: */
/* Sticky attributes. */
#define E_SPECIAL 0x01 /* These are known to the program. */
#define E_DEV 0x02 /* The value is a device name. */
#define E_RESERVED 0x04 /* May not be set by user, e.g. 'boot' */
#define E_STICKY 0x07 /* Don't go once set. */
/* Volatile attributes. */
#define E_VAR 0x08 /* Variable */
#define E_FUNCTION 0x10 /* Function definition. */
/* Variables, functions, and commands. */
typedef struct environment {
struct environment *next;
char flags;
char *name; /* name = value */
char *arg; /* name(arg) {value} */
char *value;
char *defval; /* Safehouse for default values. */
} environment;
EXTERN environment *env; /* Lists the environment. */
char *b_value(const char *name); /* Get/set the value of a variable. */
int b_setvar(int flags, char *name, char *value);
void b_unset(const char *name);
void parse_code(char *code); /* Parse boot monitor commands. */
extern int fsok; /* True if the boot device contains an FS. */
EXTERN u32_t lowsec; /* Offset to the file system on the boot device. */
/* Called by boot.c: */
void bootminix(void); /* Load and start a Minix image. */
/* Called by bootimage.c: */
void readerr(off_t sec, int err);
/* Report a read error. */
char *ul2a(u32_t n, unsigned b), *ul2a10(u32_t n);
/* Transform u32_t to ASCII at base b or base 10. */
long a2l(const char *a);
/* Cheap atol(). */
unsigned a2x(const char *a);
/* ASCII to hex. */
dev_t name2dev(char *name);
/* Translate a device name to a device number. */
int numprefix(char *s, char **ps);
/* True for a numeric prefix. */
int numeric(char *s);
/* True for a numeric string. */
char *unix_err(int err);
/* Give a descriptive text for some UNIX errors. */
int run_trailer(void);
/* Run the trailer function. */
#if DOS
/* The monitor runs under MS-DOS. */
extern char PSP[256]; /* Program Segment Prefix. */
EXTERN char *vdisk; /* Name of the virtual disk. */
EXTERN char *drun; /* Initial command from DOS command line. */
#else
/* The monitor uses only the BIOS. */
#define DOS 0
#endif
void readblock(off_t, char *, int);
void delay(const char *);
/*
* $PchId: boot.h,v 1.12 2002/02/27 19:42:45 philip Exp $
*/

View File

@@ -1,256 +0,0 @@
#
! Bootblock 1.5 - Minix boot block. Author: Kees J. Bot
! 21 Dec 1991
!
! When the PC is powered on, it will try to read the first sector of floppy
! disk 0 at address 0x7C00. If this fails due to the absence of flexible
! magnetic media, it will read the master boot record from the first sector
! of the hard disk. This sector not only contains executable code, but also
! the partition table of the hard disk. When executed, it will select the
! active partition and load the first sector of that at address 0x7C00.
! This file contains the code that is eventually read from either the floppy
! disk, or the hard disk partition. It is just smart enough to load /boot
! from the boot device into memory at address 0x10000 and execute that. The
! disk addresses for /boot are patched into this code by installboot as 24-bit
! sector numbers and 8-bit sector counts above enddata upwards. /boot is in
! turn smart enough to load the different parts of the Minix kernel into
! memory and execute them to finally get Minix started.
!
LOADOFF = 0x7C00 ! 0x0000:LOADOFF is where this code is loaded
BOOTSEG = 0x1000 ! Secondary boot code segment.
#ifdef CDBOOT
BOOTOFF = 0x0050 ! Offset into /boot above header
#else
BOOTOFF = 0x0030 ! Offset into /boot above header
#endif
BUFFER = 0x0600 ! First free memory
#ifndef CDBOOT /* just constants, but make no sense for CDs */
LOWSEC = 8 ! Offset of logical first sector in partition
! table
! Variables addressed using bp register
lowsec = 2 ! Offset of boot partition within drive
secpcyl = 6 ! Sectors per cylinder = heads * sectors
#endif
device = 0 ! The boot device
.text
! Start boot procedure.
boot:
xor ax, ax ! ax = 0x0000, the vector segment
mov ds, ax
cli ! Ignore interrupts while setting stack
mov ss, ax ! ss = ds = vector segment
mov sp, #LOADOFF ! Usual place for a bootstrap stack
sti
push ax
push ax ! Push a zero lowsec(bp)
push dx ! Boot device in dl will be device(bp)
mov bp, sp ! Using var(bp) is one byte cheaper then var.
push es
push si ! es:si = partition table entry if hard disk
mov di, #LOADOFF+sectors ! char *di = sectors;
#ifndef CDBOOT
testb dl, dl ! Winchester disks if dl >= 0x80
jge floppy
#endif
winchester:
#ifndef CDBOOT
! Get the offset of the first sector of the boot partition from the partition
! table. The table is found at es:si, the lowsec parameter at offset LOWSEC.
eseg
les ax, LOWSEC(si) ! es:ax = LOWSEC+2(si):LOWSEC(si)
mov lowsec+0(bp), ax ! Low 16 bits of partitions first sector
mov lowsec+2(bp), es ! High 16 bits of partitions first sector
! Get the drive parameters, the number of sectors is bluntly written into the
! floppy disk sectors/track array.
movb ah, #0x08 ! Code for drive parameters
int 0x13 ! dl still contains drive
andb cl, #0x3F ! cl = max sector number (1-origin)
movb (di), cl ! Number of sectors per track
incb dh ! dh = 1 + max head number (0-origin)
#endif
jmp loadboot
#ifndef CDBOOT
! Floppy:
! Execute three read tests to determine the drive type. Test for each floppy
! type by reading the last sector on the first track. If it fails, try a type
! that has less sectors. Therefore we start with 1.44M (18 sectors) then 1.2M
! (15 sectors) ending with 720K/360K (both 9 sectors).
next: inc di ! Next number of sectors per track
floppy: xorb ah, ah ! Reset drive
int 0x13
movb cl, (di) ! cl = number of last sector on track
cmpb cl, #9 ! No need to do the last 720K/360K test
je success
! Try to read the last sector on track 0
mov es, lowsec(bp) ! es = vector segment (lowsec = 0)
mov bx, #BUFFER ! es:bx buffer = 0x0000:0x0600
mov ax, #0x0201 ! Read sector, #sectors = 1
xorb ch, ch ! Track 0, last sector
xorb dh, dh ! Drive dl, head 0
int 0x13
jc next ! Error, try the next floppy type
success:movb dh, #2 ! Load number of heads for multiply
#endif
loadboot:
! Load /boot from the boot device
#ifndef CDBOOT
movb al, (di) ! al = (di) = sectors per track
mulb dh ! dh = heads, ax = heads * sectors
mov secpcyl(bp), ax ! Sectors per cylinder = heads * sectors
#endif
mov ax, #BOOTSEG ! Segment to load /boot into
mov es, ax
xor bx, bx ! Load first sector at es:bx = BOOTSEG:0x0000
mov si, #LOADOFF+addresses ! Start of the boot code addresses
load:
mov ax, 1(si) ! Get next sector number: low 16 bits
movb dl, 3(si) ! Bits 16-23 for your up to 8GB partition
xorb dh, dh ! dx:ax = sector within partition
#ifndef CDBOOT
add ax, lowsec+0(bp)
adc dx, lowsec+2(bp)! dx:ax = sector within drive
cmp dx, #[1024*255*63-255]>>16 ! Near 8G limit?
jae bigdisk
div secpcyl(bp) ! ax = cylinder, dx = sector within cylinder
xchg ax, dx ! ax = sector within cylinder, dx = cylinder
movb ch, dl ! ch = low 8 bits of cylinder
divb (di) ! al = head, ah = sector (0-origin)
xorb dl, dl ! About to shift bits 8-9 of cylinder into dl
shr dx, #1
shr dx, #1 ! dl[6..7] = high cylinder
orb dl, ah ! dl[0..5] = sector (0-origin)
movb cl, dl ! cl[0..5] = sector, cl[6..7] = high cyl
incb cl ! cl[0..5] = sector (1-origin)
movb dh, al ! dh = al = head
movb dl, device(bp) ! dl = device to read
movb al, (di) ! Sectors per track - Sector number (0-origin)
subb al, ah ! = Sectors left on this track
cmpb al, (si) ! Compare with # sectors to read
jbe read ! Cant read past the end of a cylinder?
movb al, (si) ! (si) < sectors left on this track
read: push ax ! Save al = sectors to read
movb ah, #0x02 ! Code for disk read (all registers in use now!)
int 0x13 ! Call the BIOS for a read
pop cx ! Restore al in cl
jmp rdeval
#endif
bigdisk:
movb cl, (si) ! Number of sectors to read
push si ! Save si
mov si, #LOADOFF+ext_rw ! si = extended read/write parameter packet
movb 2(si), cl ! Fill in # blocks to transfer
mov 4(si), bx ! Buffer address
mov 8(si), ax ! Starting block number = dx:ax
mov 10(si), dx
movb dl, device(bp) ! dl = device to read
movb ah, #0x42 ! Extended read
int 0x13
pop si ! Restore si to point to the addresses array
!jmp rdeval
rdeval:
jc error ! Jump on disk read error
movb al, cl ! Restore al = sectors read
addb bh, al ! bx += 2 * al * 256 (add bytes read)
addb bh, al ! es:bx = where next sector must be read
#ifdef CDBOOT
addb bh, al ! For CDs, a sector is 2048 bytes, so
addb bh, al ! do this 6 more times to get byte count.
addb bh, al
addb bh, al
addb bh, al
addb bh, al
#endif
add 1(si), ax ! Update address by sectors read
adcb 3(si), ah ! Don't forget bits 16-23 (add ah = 0)
subb (si), al ! Decrement sector count by sectors read
jnz load ! Not all sectors have been read
add si, #4 ! Next (address, count) pair
cmpb ah, (si) ! Done when no sectors to read
jnz load ! Read next chunk of /boot
done:
! Call /boot, assuming a long a.out header (48 bytes). The a.out header is
! usually short (32 bytes), but to be sure /boot has two entry points:
! One at offset 0 for the long, and one at offset 16 for the short header.
! Parameters passed in registers are:
!
! dl = Boot-device.
! es:si = Partition table entry if hard disk.
!
pop si ! Restore es:si = partition table entry
pop es ! dl is still loaded
jmpf BOOTOFF, BOOTSEG ! jmp to sec. boot (skipping header).
! Read error: print message, hang forever
error:
mov si, #LOADOFF+errno+1
prnum: movb al, ah ! Error number in ah
andb al, #0x0F ! Low 4 bits
cmpb al, #10 ! A-F?
jb digit ! 0-9!
addb al, #7 ! 'A' - ':'
digit: addb (si), al ! Modify '0' in string
dec si
movb cl, #4 ! Next 4 bits
shrb ah, cl
jnz prnum ! Again if digit > 0
mov si, #LOADOFF+rderr ! String to print
print: lodsb ! al = *si++ is char to be printed
testb al, al ! Null byte marks end
hang: jz hang ! Hang forever waiting for CTRL-ALT-DEL
movb ah, #0x0E ! Print character in teletype mode
mov bx, #0x0001 ! Page 0, foreground color
int 0x10 ! Call BIOS VIDEO_IO
jmp print
.data
rderr: .ascii "Read error "
errno: .ascii "00 \0"
errend:
! Floppy disk sectors per track for the 1.44M, 1.2M and 360K/720K types:
sectors:
.data1 18, 15, 9
! Extended read/write commands require a parameter packet.
ext_rw:
.data1 0x10 ! Length of extended r/w packet
.data1 0 ! Reserved
.data2 0 ! Blocks to transfer (to be filled in)
.data2 0 ! Buffer address offset (tbfi)
.data2 BOOTSEG ! Buffer address segment
.data4 0 ! Starting block number low 32 bits (tbfi)
.data4 0 ! Starting block number high 32 bits
.align 2
addresses:
! The space below this is for disk addresses for a 38K /boot program (worst
! case, i.e. file is completely fragmented). It should be enough.

File diff suppressed because it is too large Load Diff

View File

@@ -1,857 +0,0 @@
/* bootimage.c - Load an image and start it. Author: Kees J. Bot
* 19 Jan 1992
*/
#define BIOS 1 /* Can only be used under the BIOS. */
#define nil 0
#define _POSIX_SOURCE 1
#define _MINIX 1
#include <stddef.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <string.h>
#include <errno.h>
#include <a.out.h>
#include <minix/config.h>
#include <minix/const.h>
#include <minix/type.h>
#include <minix/syslib.h>
#include <minix/tty.h>
#include <sys/video.h>
#include <kernel/const.h>
#include <kernel/type.h>
#include <machine/partition.h>
#include "rawfs.h"
#include "image.h"
#include "boot.h"
static int block_size = 0;
static int verboseboot = VERBOSEBOOT_QUIET;
#define DEBUG_PRINT(params, level) do { \
if (verboseboot >= (level)) printf params; } while (0)
#define DEBUGBASIC(params) DEBUG_PRINT(params, VERBOSEBOOT_BASIC)
#define DEBUGEXTRA(params) DEBUG_PRINT(params, VERBOSEBOOT_EXTRA)
#define DEBUGMAX(params) DEBUG_PRINT(params, VERBOSEBOOT_MAX)
extern int serial_line;
extern u16_t vid_port; /* Video i/o port. */
extern u32_t vid_mem_base; /* Video memory base address. */
extern u32_t vid_mem_size; /* Video memory size. */
#define click_shift clck_shft /* 7 char clash with click_size. */
/* Some kernels have extra features: */
#define K_I386 0x0001 /* Make the 386 transition before you call me. */
#define K_CLAIM 0x0002 /* I will acquire my own bss pages, thank you. */
#define K_CHMEM 0x0004 /* This kernel listens to chmem for its stack size. */
#define K_HIGH 0x0008 /* Load mm, fs, etc. in extended memory. */
#define K_HDR 0x0010 /* No need to patch sizes, kernel uses the headers. */
#define K_RET 0x0020 /* Returns to the monitor on reboot. */
#define K_INT86 0x0040 /* Requires generic INT support. */
#define K_MEML 0x0080 /* Pass a list of free memory. */
#define K_BRET 0x0100 /* New monitor code on shutdown in boot parameters. */
#define K_KHIGH 0x0200 /* Load kernel in extended memory. */
#define K_ALL 0x03FF /* All feature bits this monitor supports. */
/* Data about the different processes. */
#define PROCESS_MAX 16 /* Must match the space in kernel/mpx.x */
#define KERNEL_IDX 0 /* The first process is the kernel. */
#define FS 2 /* The third must be fs. */
struct process { /* Per-process memory adresses. */
u32_t entry; /* Entry point. */
u32_t cs; /* Code segment. */
u32_t ds; /* Data segment. */
u32_t data; /* To access the data segment. */
u32_t end; /* End of this process, size = (end - cs). */
} process[PROCESS_MAX];
int n_procs; /* Number of processes. */
/* Magic numbers in process' data space. */
#define MAGIC_OFF 0 /* Offset of magic # in data seg. */
#define CLICK_OFF 2 /* Offset in kernel text to click_shift. */
#define FLAGS_OFF 4 /* Offset in kernel text to flags. */
#define KERNEL_D_MAGIC 0x526F /* Kernel magic number. */
/* Offsets of sizes to be patched into kernel and fs. */
#define P_SIZ_OFF 0 /* Process' sizes into kernel data. */
#define P_INIT_OFF 4 /* Init cs & sizes into fs data. */
#define between(a, c, z) ((unsigned) ((c) - (a)) <= ((z) - (a)))
void pretty_image(const char *image)
/* Pretty print the name of the image to load. Translate '/' and '_' to
* space, first letter goes uppercase. An 'r' before a digit prints as
* 'revision'. E.g. 'minix/1.6.16r10' -> 'Minix 1.6.16 revision 10'.
* The idea is that the part before the 'r' is the official Minix release
* and after the 'r' you can put version numbers for your own changes.
*/
{
int up= 0, c;
while ((c= *image++) != 0) {
if (c == '/' || c == '_') c= ' ';
if (c == 'r' && between('0', *image, '9')) {
printf(" revision ");
continue;
}
if (!up && between('a', c, 'z')) c= c - 'a' + 'A';
if (between('A', c, 'Z')) up= 1;
putch(c);
}
}
#define RAW_ALIGN 16
#define BUFSIZE_ZEROS 128
void raw_clear(u32_t addr, u32_t count)
/* Clear "count" bytes at absolute address "addr". */
{
static char zerosdata[BUFSIZE_ZEROS + RAW_ALIGN];
char *zeros = zerosdata + RAW_ALIGN - (unsigned) &zerosdata % RAW_ALIGN;
u32_t dst;
u32_t zct;
zct= BUFSIZE_ZEROS;
if (zct > count) zct= count;
raw_copy(addr, mon2abs(zeros), zct);
count-= zct;
while (count > 0) {
dst= addr + zct;
if (zct > count) zct= count;
raw_copy(dst, addr, zct);
count-= zct;
zct*= 2;
}
}
/* Align a to a multiple of n (a power of 2): */
#define align(a, n) (((u32_t)(a) + ((u32_t)(n) - 1)) & ~((u32_t)(n) - 1))
unsigned click_shift;
unsigned click_size; /* click_size = Smallest kernel memory object. */
unsigned k_flags; /* Not all kernels are created equal. */
u32_t reboot_code; /* Obsolete reboot code return pointer. */
int params2params(char *params, size_t psize)
/* Repackage the environment settings for the kernel. */
{
size_t i, n;
environment *e;
char *name, *value;
dev_t dev;
i= 0;
for (e= env; e != nil; e= e->next) {
name= e->name;
value= e->value;
if (!(e->flags & E_VAR)) continue;
if (e->flags & E_DEV) {
if ((dev= name2dev(value)) == -1) return 0;
value= ul2a10((u16_t) dev);
}
n= i + strlen(name) + 1 + strlen(value) + 1;
if (n < psize) {
strcpy(params + i, name);
strcat(params + i, "=");
strcat(params + i, value);
}
i= n;
}
if (!(k_flags & K_MEML)) {
/* Require old memory size variables. */
value= ul2a10((mem[0].base + mem[0].size) / 1024);
n= i + 7 + 1 + strlen(value) + 1;
if (n < psize) {
strcpy(params + i, "memsize=");
strcat(params + i, value);
}
i= n;
value= ul2a10(mem[1].size / 1024);
n= i + 7 + 1 + strlen(value) + 1;
if (n < psize) {
strcpy(params + i, "emssize=");
strcat(params + i, value);
}
i= n;
}
if (i >= psize) {
printf("Too many boot parameters\n");
return 0;
}
params[i]= 0; /* End marked with empty string. */
return 1;
}
void patch_sizes(void)
/* Patch sizes of each process into kernel data space, kernel ds into kernel
* text space, and sizes of init into data space of fs. All the patched
* numbers are based on the kernel click size, not hardware segments.
*/
{
u16_t text_size, data_size;
int i;
struct process *procp, *initp;
u32_t doff;
if (k_flags & K_HDR) return; /* Uses the headers. */
/* Patch text and data sizes of the processes into kernel data space.
*/
doff= process[KERNEL_IDX].data + P_SIZ_OFF;
for (i= 0; i < n_procs; i++) {
procp= &process[i];
text_size= (procp->ds - procp->cs) >> click_shift;
data_size= (procp->end - procp->ds) >> click_shift;
/* Two words per process, the text and data size: */
put_word(doff, text_size); doff+= 2;
put_word(doff, data_size); doff+= 2;
initp= procp; /* The last process must be init. */
}
if (k_flags & (K_HIGH|K_MEML)) return; /* Doesn't need FS patching. */
/* Patch cs and sizes of init into fs data. */
put_word(process[FS].data + P_INIT_OFF+0, initp->cs >> click_shift);
put_word(process[FS].data + P_INIT_OFF+2, text_size);
put_word(process[FS].data + P_INIT_OFF+4, data_size);
}
int selected(const char *name)
/* True iff name has no label or the proper label. */
{
char *colon, *label;
int cmp;
if ((colon= strchr(name, ':')) == nil) return 1;
if ((label= b_value("label")) == nil) return 1;
*colon= 0;
cmp= strcmp(label, name);
*colon= ':';
return cmp == 0;
}
static u32_t proc_size(const struct image_header *hdr)
/* Return the size of a process in sectors as found in an image. */
{
u32_t len= hdr->process.a_text;
if (hdr->process.a_flags & A_PAL) len+= hdr->process.a_hdrlen;
if (hdr->process.a_flags & A_SEP) len= align(len, SECTOR_SIZE);
len= align(len + hdr->process.a_data, SECTOR_SIZE);
return len >> SECTOR_SHIFT;
}
off_t image_off, image_size;
u32_t (*vir2sec)(u32_t vsec); /* Where is a sector on disk? */
u32_t file_vir2sec(u32_t vsec)
/* Translate a virtual sector number to an absolute disk sector. */
{
off_t blk;
if(!block_size) { errno = 0; return -1; }
if ((blk= r_vir2abs(vsec / RATIO(block_size))) == -1) {
errno= EIO;
return -1;
}
return blk == 0 ? 0 : lowsec + blk * RATIO(block_size) + vsec % RATIO(block_size);
}
u32_t flat_vir2sec(u32_t vsec)
/* Simply add an absolute sector offset to vsec. */
{
return lowsec + image_off + vsec;
}
char *get_sector(u32_t vsec)
/* Read a sector "vsec" from the image into memory and return its address.
* Return nil on error. (This routine tries to read an entire track, so
* the next request is usually satisfied from the track buffer.)
*/
{
u32_t sec;
int r;
#define SECBUFS 16
static char bufdata[SECBUFS * SECTOR_SIZE + RAW_ALIGN];
static size_t count; /* Number of sectors in the buffer. */
static u32_t bufsec; /* First Sector now in the buffer. */
char *buf = bufdata + RAW_ALIGN - (unsigned) &bufdata % RAW_ALIGN;
if (vsec == 0) count= 0; /* First sector; initialize. */
if ((sec= (*vir2sec)(vsec)) == -1) return nil;
if (sec == 0) {
/* A hole. */
count= 0;
memset(buf, 0, SECTOR_SIZE);
return buf;
}
/* Can we return a sector from the buffer? */
if ((sec - bufsec) < count) {
return buf + ((size_t) (sec - bufsec) << SECTOR_SHIFT);
}
/* Not in the buffer. */
count= 0;
bufsec= sec;
/* Read a whole track if possible. */
while (++count < SECBUFS && !dev_boundary(bufsec + count)) {
vsec++;
if ((sec= (*vir2sec)(vsec)) == -1) break;
/* Consecutive? */
if (sec != bufsec + count) break;
}
/* Actually read the sectors. */
if ((r= readsectors(mon2abs(buf), bufsec, count)) != 0) {
readerr(bufsec, r);
count= 0;
errno= 0;
return nil;
}
return buf;
}
int get_clickshift(u32_t ksec, struct image_header *hdr)
/* Get the click shift and special flags from kernel text. */
{
char *textp;
if ((textp= get_sector(ksec)) == nil) return 0;
if (hdr->process.a_flags & A_PAL) textp+= hdr->process.a_hdrlen;
click_shift= * (u16_t *) (textp + CLICK_OFF);
k_flags= * (u16_t *) (textp + FLAGS_OFF);
if ((k_flags & ~K_ALL) != 0) {
printf("%s requires features this monitor doesn't offer\n",
hdr->name);
return 0;
}
if (click_shift < HCLICK_SHIFT || click_shift > 16) {
printf("%s click size is bad\n", hdr->name);
errno= 0;
return 0;
}
click_size= 1 << click_shift;
return 1;
}
int get_segment(u32_t *vsec, long *size, u32_t *addr, u32_t limit)
/* Read *size bytes starting at virtual sector *vsec to memory at *addr. */
{
char *buf;
size_t cnt, n;
cnt= 0;
while (*size > 0) {
if (cnt == 0) {
if ((buf= get_sector((*vsec)++)) == nil) return 0;
cnt= SECTOR_SIZE;
}
if (*addr + click_size > limit)
{
DEBUGEXTRA(("get_segment: out of memory; "
"addr=0x%lx; limit=0x%lx; size=%lx\n",
*addr, limit, size));
errno= ENOMEM;
return 0;
}
n= click_size;
if (n > cnt) n= cnt;
DEBUGMAX(("raw_copy(0x%lx, 0x%lx/0x%x, 0x%lx)... ",
*addr, mon2abs(buf), buf, n));
raw_copy(*addr, mon2abs(buf), n);
DEBUGMAX(("done\n"));
*addr+= n;
*size-= n;
buf+= n;
cnt-= n;
}
/* Zero extend to a click. */
n= align(*addr, click_size) - *addr;
DEBUGMAX(("raw_clear(0x%lx, 0x%lx)... ", *addr, n));
raw_clear(*addr, n);
DEBUGMAX(("done\n"));
*addr+= n;
*size-= n;
return 1;
}
static void restore_screen(void)
{
struct boot_tty_info boot_tty_info;
u32_t info_location;
#define LINES 25
#define CHARS 80
static u16_t consolescreen[LINES][CHARS];
/* Try and find out what the main console was displaying
* by looking into video memory.
*/
info_location = vid_mem_base+vid_mem_size-sizeof(boot_tty_info);
raw_copy(mon2abs(&boot_tty_info), info_location,
sizeof(boot_tty_info));
if(boot_tty_info.magic == TTYMAGIC) {
if((boot_tty_info.flags & (BTIF_CONSORIGIN|BTIF_CONSCURSOR)) ==
(BTIF_CONSORIGIN|BTIF_CONSCURSOR)) {
int line;
raw_copy(mon2abs(consolescreen),
vid_mem_base + boot_tty_info.consorigin,
sizeof(consolescreen));
clear_screen();
for(line = 0; line < LINES; line++) {
int ch;
for(ch = 0; ch < CHARS; ch++) {
u16_t newch = consolescreen[line][ch] & BYTE;
if(newch < ' ') newch = ' ';
putch(newch);
}
}
}
}
}
void exec_image(char *image)
/* Get a Minix image into core, patch it up and execute. */
{
int i;
struct image_header hdr;
char *buf;
u32_t vsec, addr, limit, aout, n, totalmem = 0;
struct process *procp; /* Process under construction. */
long a_text, a_data, a_bss, a_stack;
int banner= 0;
long processor= a2l(b_value("processor"));
u16_t kmagic, mode;
char *console;
char params[SECTOR_SIZE];
extern char *sbrk(int);
char *verb;
/* The stack is pretty deep here, so check if heap and stack collide. */
(void) sbrk(0);
if ((verb= b_value(VERBOSEBOOTVARNAME)) != nil)
verboseboot = a2l(verb);
printf("\nLoading ");
pretty_image(image);
printf(".\n");
vsec= 0; /* Load this sector from image next. */
addr= mem[0].base; /* Into this memory block. */
limit= mem[0].base + mem[0].size;
if (limit > caddr) limit= caddr;
/* Allocate and clear the area where the headers will be placed. */
aout = (limit -= PROCESS_MAX * A_MINHDR);
/* Clear the area where the headers will be placed. */
raw_clear(aout, PROCESS_MAX * A_MINHDR);
/* Read the many different processes: */
for (i= 0; vsec < image_size; i++) {
u32_t startaddr;
startaddr = addr;
if (i == PROCESS_MAX) {
printf("There are more then %d programs in %s\n",
PROCESS_MAX, image);
errno= 0;
return;
}
procp= &process[i];
/* Read header. */
DEBUGEXTRA(("Reading header... "));
for (;;) {
if ((buf= get_sector(vsec++)) == nil) return;
memcpy(&hdr, buf, sizeof(hdr));
if (BADMAG(hdr.process)) { errno= ENOEXEC; return; }
/* Check the optional label on the process. */
if (selected(hdr.name)) break;
/* Bad label, skip this process. */
vsec+= proc_size(&hdr);
}
DEBUGEXTRA(("done\n"));
/* Sanity check: an 8086 can't run a 386 kernel. */
if (hdr.process.a_cpu == A_I80386 && processor < 386) {
printf("You can't run a 386 kernel on this 80%ld\n",
processor);
errno= 0;
return;
}
/* Get the click shift from the kernel text segment. */
if (i == KERNEL_IDX) {
if (!get_clickshift(vsec, &hdr)) return;
addr= align(addr, click_size);
/* big kernels must be loaded into extended memory */
if (k_flags & K_KHIGH) {
addr= mem[1].base;
limit= mem[1].base + mem[1].size;
}
}
/* Save a copy of the header for the kernel, with a_syms
* misused as the address where the process is loaded at.
*/
DEBUGEXTRA(("raw_copy(0x%lx, 0x%lx, 0x%x)... ",
aout + i * A_MINHDR, mon2abs(&hdr.process), A_MINHDR));
hdr.process.a_syms= addr;
raw_copy(aout + i * A_MINHDR, mon2abs(&hdr.process), A_MINHDR);
DEBUGEXTRA(("done\n"));
if (!banner) {
DEBUGBASIC((" cs ds text data bss"));
if (k_flags & K_CHMEM) DEBUGBASIC((" stack"));
DEBUGBASIC(("\n"));
banner= 1;
}
/* Segment sizes. */
DEBUGEXTRA(("a_text=0x%lx; a_data=0x%lx; a_bss=0x%lx; a_flags=0x%x)\n",
hdr.process.a_text, hdr.process.a_data,
hdr.process.a_bss, hdr.process.a_flags));
a_text= hdr.process.a_text;
a_data= hdr.process.a_data;
a_bss= hdr.process.a_bss;
if (k_flags & K_CHMEM) {
a_stack= hdr.process.a_total - a_data - a_bss;
if (!(hdr.process.a_flags & A_SEP)) a_stack-= a_text;
} else {
a_stack= 0;
}
/* Collect info about the process to be. */
procp->cs= addr;
/* Process may be page aligned so that the text segment contains
* the header, or have an unmapped zero page against vaxisms.
*/
procp->entry= hdr.process.a_entry;
if (hdr.process.a_flags & A_PAL) a_text+= hdr.process.a_hdrlen;
if (hdr.process.a_flags & A_UZP) procp->cs-= click_size;
/* Separate I&D: two segments. Common I&D: only one. */
if (hdr.process.a_flags & A_SEP) {
/* Read the text segment. */
DEBUGEXTRA(("get_segment(0x%lx, 0x%lx, 0x%lx, 0x%lx)\n",
vsec, a_text, addr, limit));
if (!get_segment(&vsec, &a_text, &addr, limit)) return;
DEBUGEXTRA(("get_segment done vsec=0x%lx a_text=0x%lx "
"addr=0x%lx\n",
vsec, a_text, addr));
/* The data segment follows. */
procp->ds= addr;
if (hdr.process.a_flags & A_UZP) procp->ds-= click_size;
procp->data= addr;
} else {
/* Add text to data to form one segment. */
procp->data= addr + a_text;
procp->ds= procp->cs;
a_data+= a_text;
}
/* Read the data segment. */
DEBUGEXTRA(("get_segment(0x%lx, 0x%lx, 0x%lx, 0x%lx)\n",
vsec, a_data, addr, limit));
if (!get_segment(&vsec, &a_data, &addr, limit)) return;
DEBUGEXTRA(("get_segment done vsec=0x%lx a_data=0x%lx "
"addr=0x%lx\n",
vsec, a_data, addr));
/* Make space for bss and stack unless... */
if (i != KERNEL_IDX && (k_flags & K_CLAIM)) a_bss= a_stack= 0;
DEBUGBASIC(("%07lx %07lx %8ld %8ld %8ld",
procp->cs, procp->ds, hdr.process.a_text,
hdr.process.a_data, hdr.process.a_bss));
if (k_flags & K_CHMEM) DEBUGBASIC((" %8ld", a_stack));
/* Note that a_data may be negative now, but we can look at it
* as -a_data bss bytes.
*/
/* Compute the number of bss clicks left. */
a_bss+= a_data;
n= align(a_bss, click_size);
a_bss-= n;
/* Zero out bss. */
DEBUGEXTRA(("\nraw_clear(0x%lx, 0x%lx); limit=0x%lx... ", addr, n, limit));
if (addr + n > limit) { errno= ENOMEM; return; }
raw_clear(addr, n);
DEBUGEXTRA(("done\n"));
addr+= n;
/* And the number of stack clicks. */
a_stack+= a_bss;
n= align(a_stack, click_size);
a_stack-= n;
/* Add space for the stack. */
addr+= n;
/* Process endpoint. */
procp->end= addr;
if (verboseboot >= VERBOSEBOOT_BASIC)
printf(" %s\n", hdr.name);
else {
u32_t mem;
mem = addr-startaddr;
printf("%s ", hdr.name);
totalmem += mem;
}
if (i == 0 && (k_flags & (K_HIGH | K_KHIGH)) == K_HIGH) {
/* Load the rest in extended memory. */
addr= mem[1].base;
limit= mem[1].base + mem[1].size;
}
}
if (verboseboot < VERBOSEBOOT_BASIC)
printf("(%luk)\n", totalmem/1024);
if ((n_procs= i) == 0) {
printf("There are no programs in %s\n", image);
errno= 0;
return;
}
/* Check the kernel magic number. */
raw_copy(mon2abs(&kmagic),
process[KERNEL_IDX].data + MAGIC_OFF, sizeof(kmagic));
if (kmagic != KERNEL_D_MAGIC) {
printf("Kernel magic number is incorrect (0x%x@0x%lx)\n",
kmagic, process[KERNEL_IDX].data + MAGIC_OFF);
errno= 0;
return;
}
/* Patch sizes, etc. into kernel data. */
DEBUGEXTRA(("patch_sizes()... "));
patch_sizes();
DEBUGEXTRA(("done\n"));
#if !DOS
if (!(k_flags & K_MEML)) {
/* Copy the a.out headers to the old place. */
raw_copy(HEADERPOS, aout, PROCESS_MAX * A_MINHDR);
}
#endif
/* Run the trailer function just before starting Minix. */
DEBUGEXTRA(("run_trailer()... "));
if (!run_trailer()) { errno= 0; return; }
DEBUGEXTRA(("done\n"));
/* Translate the boot parameters to what Minix likes best. */
DEBUGEXTRA(("params2params(0x%x, 0x%x)... ", params, sizeof(params)));
if (!params2params(params, sizeof(params))) { errno= 0; return; }
DEBUGEXTRA(("done\n"));
/* Set the video to the required mode. */
if ((console= b_value("console")) == nil || (mode= a2x(console)) == 0) {
mode= strcmp(b_value("chrome"), "color") == 0 ? COLOR_MODE :
MONO_MODE;
}
DEBUGEXTRA(("set_mode(%d)... ", mode));
set_mode(mode);
DEBUGEXTRA(("done\n"));
/* Close the disk. */
DEBUGEXTRA(("dev_close()... "));
(void) dev_close();
DEBUGEXTRA(("done\n"));
/* Minix. */
DEBUGEXTRA(("minix(0x%lx, 0x%lx, 0x%lx, 0x%x, 0x%x, 0x%lx)\n",
process[KERNEL_IDX].entry, process[KERNEL_IDX].cs,
process[KERNEL_IDX].ds, params, sizeof(params), aout));
minix(process[KERNEL_IDX].entry, process[KERNEL_IDX].cs,
process[KERNEL_IDX].ds, params, sizeof(params), aout);
if (!(k_flags & K_BRET)) {
extern u32_t reboot_code;
raw_copy(mon2abs(params), reboot_code, sizeof(params));
}
parse_code(params);
/* Return from Minix. Things may have changed, so assume nothing. */
fsok= -1;
errno= 0;
/* Read leftover character, if any. */
scan_keyboard();
/* Restore screen contents. */
restore_screen();
}
ino_t latest_version(char *version, struct stat *stp)
/* Recursively read the current directory, selecting the newest image on
* the way up. (One can't use r_stat while reading a directory.)
*/
{
char name[NAME_MAX + 1];
ino_t ino, newest;
time_t mtime;
if ((ino= r_readdir(name)) == 0) { stp->st_mtime= 0; return 0; }
newest= latest_version(version, stp);
mtime= stp->st_mtime;
r_stat(ino, stp);
if (S_ISREG(stp->st_mode) && stp->st_mtime > mtime) {
newest= ino;
strcpy(version, name);
} else {
stp->st_mtime= mtime;
}
return newest;
}
char *select_image(char *image)
/* Look image up on the filesystem, if it is a file then we're done, but
* if its a directory then we want the newest file in that directory. If
* it doesn't exist at all, then see if it is 'number:number' and get the
* image from that absolute offset off the disk.
*/
{
ino_t image_ino;
struct stat st;
image= strcpy(malloc((strlen(image) + 1 + NAME_MAX + 1)
* sizeof(char)), image);
fsok= r_super(&block_size) != 0;
if (!fsok || (image_ino= r_lookup(ROOT_INO, image)) == 0) {
char *size;
if (numprefix(image, &size) && *size++ == ':'
&& numeric(size)) {
vir2sec= flat_vir2sec;
image_off= a2l(image);
image_size= a2l(size);
strcpy(image, "Minix");
return image;
}
if (!fsok)
printf("No image selected\n");
else
printf("Can't load %s: %s\n", image, unix_err(errno));
goto bail_out;
}
r_stat(image_ino, &st);
if (!S_ISREG(st.st_mode)) {
char *version= image + strlen(image);
char dots[NAME_MAX + 1];
if (!S_ISDIR(st.st_mode)) {
printf("%s: %s\n", image, unix_err(ENOTDIR));
goto bail_out;
}
(void) r_readdir(dots);
(void) r_readdir(dots); /* "." & ".." */
*version++= '/';
*version= 0;
if ((image_ino= latest_version(version, &st)) == 0) {
printf("There are no images in %s\n", image);
goto bail_out;
}
r_stat(image_ino, &st);
}
vir2sec= file_vir2sec;
image_size= (st.st_size + SECTOR_SIZE - 1) >> SECTOR_SHIFT;
return image;
bail_out:
free(image);
return nil;
}
void bootminix(void)
/* Load Minix and run it. (Given the size of this program it is surprising
* that it ever gets to that.)
*/
{
char *image;
if ((image= select_image(b_value("image"))) == nil) return;
if(serial_line >= 0) {
char linename[2];
linename[0] = serial_line + '0';
linename[1] = '\0';
b_setvar(E_VAR, SERVARNAME, linename);
}
exec_image(image);
switch (errno) {
case ENOEXEC:
printf("%s contains a bad program header\n", image);
break;
case ENOMEM:
printf("Not enough memory to load %s\n", image);
break;
case EIO:
printf("Unexpected EOF on %s\n", image);
case 0:
/* No error or error already reported. */;
}
free(image);
if(serial_line >= 0)
b_unset(SERVARNAME);
}
/*
* $PchId: bootimage.c,v 1.10 2002/02/27 19:39:09 philip Exp $
*/

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +0,0 @@
/* image.h - Info between installboot and boot. Author: Kees J. Bot
*/
#define IM_NAME_MAX 63
struct image_header {
char name[IM_NAME_MAX + 1]; /* Null terminated. */
struct exec process;
};
/*
* $PchId: image.h,v 1.4 1995/11/27 22:23:12 philip Exp $
*/

View File

@@ -1,832 +0,0 @@
/* installboot 3.0 - Make a device bootable Author: Kees J. Bot
* 21 Dec 1991
*
* Either make a device bootable or make an image from kernel, mm, fs, etc.
*/
#define _POSIX_SOURCE 1
#define _MINIX 1
#include <stdio.h>
#include <stddef.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <dirent.h>
#include <a.out.h>
#include <minix/config.h>
#include <minix/const.h>
#include <minix/partition.h>
#include <minix/u64.h>
#include "rawfs.h"
#include "image.h"
#define BOOTBLOCK 0 /* Of course */
#define SECTOR_SIZE 512 /* Disk sector size. */
#define RATIO(b) ((b)/SECTOR_SIZE)
#define SIGNATURE 0xAA55 /* Boot block signature. */
#define BOOT_MAX 64 /* Absolute maximum size of secondary boot */
#define SIGPOS 510 /* Where to put signature word. */
#define PARTPOS 446 /* Offset to the partition table in a master
* boot block.
*/
#define between(a, c, z) ((unsigned) ((c) - (a)) <= ((z) - (a)))
#define control(c) between('\0', (c), '\37')
#define BOOT_BLOCK_SIZE 1024
static void report(const char *label)
/* installboot: label: No such file or directory */
{
fprintf(stderr, "installboot: %s: %s\n", label, strerror(errno));
}
static void fatal(const char *label)
{
report(label);
exit(1);
}
char *basename(char *name)
/* Return the last component of name, stripping trailing slashes from name.
* Precondition: name != "/". If name is prefixed by a label, then the
* label is copied to the basename too.
*/
{
static char base[IM_NAME_MAX];
char *p, *bp= base;
if ((p= strchr(name, ':')) != NULL) {
while (name <= p && bp < base + IM_NAME_MAX - 1)
*bp++ = *name++;
}
for (;;) {
if ((p= strrchr(name, '/')) == NULL) { p= name; break; }
if (*++p != 0) break;
*--p= 0;
}
while (*p != 0 && bp < base + IM_NAME_MAX - 1) *bp++ = *p++;
*bp= 0;
return base;
}
static void bread(FILE *f, char *name, void *buf, size_t len)
/* Read len bytes. Don't dare return without them. */
{
if (len > 0 && fread(buf, len, 1, f) != 1) {
if (ferror(f)) fatal(name);
fprintf(stderr, "installboot: Unexpected EOF on %s\n", name);
exit(1);
}
}
static void bwrite(FILE *f, const char *name, const void *buf, size_t len)
{
if (len > 0 && fwrite(buf, len, 1, f) != 1) fatal(name);
}
long total_text= 0, total_data= 0, total_bss= 0;
int making_image= 0;
void read_header(int talk, char *proc, FILE *procf, struct image_header *ihdr)
/* Read the a.out header of a program and check it. If procf happens to be
* NULL then the header is already in *image_hdr and need only be checked.
*/
{
int n, big= 0;
static int banner= 0;
struct exec *phdr= &ihdr->process;
if (procf == NULL) {
/* Header already present. */
n= phdr->a_hdrlen;
} else {
memset(ihdr, 0, sizeof(*ihdr));
/* Put the basename of proc in the header. */
strncpy(ihdr->name, basename(proc), IM_NAME_MAX);
/* Read the header. */
n= fread(phdr, sizeof(char), A_MINHDR, procf);
if (ferror(procf)) fatal(proc);
}
if (n < A_MINHDR || BADMAG(*phdr)) {
fprintf(stderr, "installboot: %s is not an executable\n", proc);
exit(1);
}
/* Get the rest of the exec header. */
if (procf != NULL) {
bread(procf, proc, ((char *) phdr) + A_MINHDR,
phdr->a_hdrlen - A_MINHDR);
}
if (talk && !banner) {
printf(" text data bss size\n");
banner= 1;
}
if (talk) {
printf(" %8ld %8ld %8ld %9ld %s\n",
phdr->a_text, phdr->a_data, phdr->a_bss,
phdr->a_text + phdr->a_data + phdr->a_bss, proc);
}
total_text+= phdr->a_text;
total_data+= phdr->a_data;
total_bss+= phdr->a_bss;
if (phdr->a_cpu == A_I8086) {
long data= phdr->a_data + phdr->a_bss;
if (!(phdr->a_flags & A_SEP)) data+= phdr->a_text;
if (phdr->a_text >= 65536) big|= 1;
if (data >= 65536) big|= 2;
}
if (big) {
fprintf(stderr,
"%s will crash, %s%s%s segment%s larger then 64K\n",
proc,
big & 1 ? "text" : "",
big == 3 ? " and " : "",
big & 2 ? "data" : "",
big == 3 ? "s are" : " is");
}
}
void padimage(const char *image, FILE *imagef, int n)
/* Add n zeros to image to pad it to a sector boundary. */
{
while (n > 0) {
if (putc(0, imagef) == EOF) fatal(image);
n--;
}
}
#define align(n) (((n) + ((SECTOR_SIZE) - 1)) & ~((SECTOR_SIZE) - 1))
void copyexec(char *proc, FILE *procf, char *image, FILE *imagef, long n)
/* Copy n bytes from proc to image padded to fill a sector. */
{
int pad, c;
/* Compute number of padding bytes. */
pad= align(n) - n;
while (n > 0) {
if ((c= getc(procf)) == EOF) {
if (ferror(procf)) fatal(proc);
fprintf(stderr, "installboot: premature EOF on %s\n",
proc);
exit(1);
}
if (putc(c, imagef) == EOF) fatal(image);
n--;
}
padimage(image, imagef, pad);
}
void make_image(char *image, char **procv)
/* Collect a set of files in an image, each "segment" is nicely padded out
* to SECTOR_SIZE, so it may be read from disk into memory without trickery.
*/
{
FILE *imagef, *procf;
char *proc, *file;
int procn;
struct image_header ihdr;
struct exec phdr;
struct stat st;
making_image= 1;
if ((imagef= fopen(image, "w")) == NULL) fatal(image);
for (procn= 0; (proc= *procv++) != NULL; procn++) {
/* Remove the label from the file name. */
if ((file= strchr(proc, ':')) != NULL) file++; else file= proc;
/* Real files please, may need to seek. */
if (stat(file, &st) < 0
|| (errno= EISDIR, !S_ISREG(st.st_mode))
|| (procf= fopen(file, "r")) == NULL
) fatal(proc);
/* Read a.out header. */
read_header(1, proc, procf, &ihdr);
/* Scratch. */
phdr= ihdr.process;
/* The symbol table is always stripped off. */
ihdr.process.a_syms= 0;
ihdr.process.a_flags &= ~A_NSYM;
/* Write header padded to fill a sector */
bwrite(imagef, image, &ihdr, sizeof(ihdr));
padimage(image, imagef, SECTOR_SIZE - sizeof(ihdr));
/* A page aligned executable needs the header in text. */
if (phdr.a_flags & A_PAL) {
rewind(procf);
phdr.a_text+= phdr.a_hdrlen;
}
/* Copy text and data of proc to image. */
if (phdr.a_flags & A_SEP) {
/* Separate I&D: pad text & data separately. */
copyexec(proc, procf, image, imagef, phdr.a_text);
copyexec(proc, procf, image, imagef, phdr.a_data);
} else {
/* Common I&D: keep text and data together. */
copyexec(proc, procf, image, imagef,
phdr.a_text + phdr.a_data);
}
/* Done with proc. */
(void) fclose(procf);
}
/* Done with image. */
if (fclose(imagef) == EOF) fatal(image);
printf(" ------ ------ ------ -------\n");
printf(" %8ld %8ld %8ld %9ld total\n",
total_text, total_data, total_bss,
total_text + total_data + total_bss);
}
void extractexec(FILE *imagef, char *image, FILE *procf, char *proc,
long count, off_t *alen)
/* Copy a segment of an executable. It is padded to a sector in image. */
{
char buf[SECTOR_SIZE];
while (count > 0) {
bread(imagef, image, buf, sizeof(buf));
*alen-= sizeof(buf);
bwrite(procf, proc, buf,
count < sizeof(buf) ? (size_t) count : sizeof(buf));
count-= sizeof(buf);
}
}
void extract_image(char *image)
/* Extract the executables from an image. */
{
FILE *imagef, *procf;
off_t len;
struct stat st;
struct image_header ihdr;
struct exec phdr;
char buf[SECTOR_SIZE];
if (stat(image, &st) < 0) fatal(image);
/* Size of the image. */
len= S_ISREG(st.st_mode) ? st.st_size : -1;
if ((imagef= fopen(image, "r")) == NULL) fatal(image);
while (len != 0) {
/* Extract a program, first sector is an extended header. */
bread(imagef, image, buf, sizeof(buf));
len-= sizeof(buf);
memcpy(&ihdr, buf, sizeof(ihdr));
phdr= ihdr.process;
/* Check header. */
read_header(1, ihdr.name, NULL, &ihdr);
if ((procf= fopen(ihdr.name, "w")) == NULL) fatal(ihdr.name);
if (phdr.a_flags & A_PAL) {
/* A page aligned process contains a header in text. */
phdr.a_text+= phdr.a_hdrlen;
} else {
bwrite(procf, ihdr.name, &ihdr.process, phdr.a_hdrlen);
}
/* Extract text and data segments. */
if (phdr.a_flags & A_SEP) {
extractexec(imagef, image, procf, ihdr.name,
phdr.a_text, &len);
extractexec(imagef, image, procf, ihdr.name,
phdr.a_data, &len);
} else {
extractexec(imagef, image, procf, ihdr.name,
phdr.a_text + phdr.a_data, &len);
}
if (fclose(procf) == EOF) fatal(ihdr.name);
}
}
static int rawfd; /* File descriptor to open device. */
static const char *rawdev; /* Name of device. */
void readblock(off_t blk, char *buf, int block_size)
/* For rawfs, so that it can read blocks. */
{
int n;
if (lseek(rawfd, blk * block_size, SEEK_SET) < 0
|| (n= read(rawfd, buf, block_size)) < 0
) fatal(rawdev);
if (n < block_size) {
fprintf(stderr, "installboot: Unexpected EOF on %s\n", rawdev);
exit(1);
}
}
void writeblock(off_t blk, const char *buf, int block_size)
/* Add a function to write blocks for local use. */
{
if (lseek(rawfd, blk * block_size, SEEK_SET) < 0
|| write(rawfd, buf, block_size) < 0
) fatal(rawdev);
}
int raw_install(char *file, off_t *start, off_t *len, int block_size)
/* Copy bootcode or an image to the boot device at the given absolute disk
* block number. This "raw" installation is used to place bootcode and
* image on a disk without a filesystem to make a simple boot disk. Useful
* in automated scripts for J. Random User.
* Note: *len == 0 when an image is read. It is set right afterwards.
*/
{
static char buf[_MAX_BLOCK_SIZE]; /* Nonvolatile block buffer. */
FILE *f;
off_t sec;
unsigned long devsize;
static int banner= 0;
struct partition entry;
/* See if the device has a maximum size. */
devsize= -1;
if (ioctl(rawfd, DIOCGETP, &entry) == 0) devsize= cv64ul(entry.size);
if ((f= fopen(file, "r")) == NULL) fatal(file);
/* Copy sectors from file onto the boot device. */
sec= *start;
do {
int off= sec % RATIO(BOOT_BLOCK_SIZE);
if (fread(buf + off * SECTOR_SIZE, 1, SECTOR_SIZE, f) == 0)
break;
if (sec >= devsize) {
fprintf(stderr,
"installboot: %s can't be attached to %s\n",
file, rawdev);
return 0;
}
if (off == RATIO(BOOT_BLOCK_SIZE) - 1) writeblock(sec / RATIO(BOOT_BLOCK_SIZE), buf, BOOT_BLOCK_SIZE);
} while (++sec != *start + *len);
if (ferror(f)) fatal(file);
(void) fclose(f);
/* Write a partial block, this may be the last image. */
if (sec % RATIO(BOOT_BLOCK_SIZE) != 0) writeblock(sec / RATIO(BOOT_BLOCK_SIZE), buf, BOOT_BLOCK_SIZE);
if (!banner) {
printf(" sector length\n");
banner= 1;
}
*len= sec - *start;
printf("%8ld%8ld %s\n", *start, *len, file);
*start= sec;
return 1;
}
enum howto { FS, BOOT };
void make_bootable(enum howto how, char *device, char *bootblock,
char *bootcode, char **imagev)
/* Install bootblock on the bootsector of device with the disk addresses to
* bootcode patched into the data segment of bootblock. "How" tells if there
* should or shoudn't be a file system on the disk. The images in the imagev
* vector are added to the end of the device.
*/
{
char buf[_MAX_BLOCK_SIZE + 256], *adrp, *parmp;
struct fileaddr {
off_t address;
int count;
} bootaddr[BOOT_MAX + 1], *bap= bootaddr;
struct exec boothdr;
struct image_header dummy;
struct stat st;
ino_t ino;
off_t sector, max_sector;
FILE *bootf;
off_t addr, fssize, pos, len;
char *labels, *label, *image;
int nolabel;
int block_size = 0;
/* Open device and set variables for readblock. */
if ((rawfd= open(rawdev= device, O_RDWR)) < 0) fatal(device);
/* Read and check the superblock. */
fssize= r_super(&block_size);
switch (how) {
case FS:
if (fssize == 0) {
fprintf(stderr,
"installboot: %s is not a Minix file system\n",
device);
exit(1);
}
break;
case BOOT:
if (fssize != 0) {
int s;
printf("%s contains a file system!\n", device);
printf("Scribbling in 10 seconds");
for (s= 0; s < 10; s++) {
fputc('.', stdout);
fflush(stdout);
sleep(1);
}
fputc('\n', stdout);
}
fssize= 1; /* Just a boot block. */
}
if (how == FS) {
/* See if the boot code can be found on the file system. */
if ((ino= r_lookup(ROOT_INO, bootcode)) == 0) {
if (errno != ENOENT) fatal(bootcode);
}
} else {
/* Boot code must be attached at the end. */
ino= 0;
}
if (ino == 0) {
/* For a raw installation, we need to copy the boot code onto
* the device, so we need to look at the file to be copied.
*/
if (stat(bootcode, &st) < 0) fatal(bootcode);
if ((bootf= fopen(bootcode, "r")) == NULL) fatal(bootcode);
} else {
/* Boot code is present in the file system. */
r_stat(ino, &st);
/* Get the header from the first block. */
if ((addr= r_vir2abs((off_t) 0)) == 0) {
boothdr.a_magic[0]= !A_MAGIC0;
} else {
readblock(addr, buf, block_size);
memcpy(&boothdr, buf, sizeof(struct exec));
}
bootf= NULL;
dummy.process= boothdr;
}
/* See if it is an executable (read_header does the check). */
read_header(0, bootcode, bootf, &dummy);
boothdr= dummy.process;
if (bootf != NULL) fclose(bootf);
/* Get all the sector addresses of the secondary boot code. */
max_sector= (boothdr.a_hdrlen + boothdr.a_text
+ boothdr.a_data + SECTOR_SIZE - 1) / SECTOR_SIZE;
if (max_sector > BOOT_MAX * RATIO(block_size)) {
fprintf(stderr, "installboot: %s is way too big\n", bootcode);
exit(0);
}
/* Determine the addresses to the boot code to be patched into the
* boot block.
*/
bap->count= 0; /* Trick to get the address recording going. */
for (sector= 0; sector < max_sector; sector++) {
if (ino == 0) {
addr= fssize + (sector / RATIO(block_size));
} else
if ((addr= r_vir2abs(sector / RATIO(block_size))) == 0) {
fprintf(stderr, "installboot: %s has holes!\n",
bootcode);
exit(1);
}
addr= (addr * RATIO(block_size)) + (sector % RATIO(block_size));
/* First address of the addresses array? */
if (bap->count == 0) bap->address= addr;
/* Paste sectors together in a multisector read. */
if (bap->address + bap->count == addr)
bap->count++;
else {
/* New address. */
bap++;
bap->address= addr;
bap->count= 1;
}
}
(++bap)->count= 0; /* No more. */
/* Get the boot block and patch the pieces in. */
readblock(BOOTBLOCK, buf, BOOT_BLOCK_SIZE);
if ((bootf= fopen(bootblock, "r")) == NULL) fatal(bootblock);
read_header(0, bootblock, bootf, &dummy);
boothdr= dummy.process;
if (boothdr.a_text + boothdr.a_data +
4 * (bap - bootaddr) + 1 > PARTPOS) {
fprintf(stderr,
"installboot: %s + addresses to %s don't fit in the boot sector\n",
bootblock, bootcode);
fprintf(stderr,
"You can try copying/reinstalling %s to defragment it\n",
bootcode);
exit(1);
}
/* All checks out right. Read bootblock into the boot block! */
bread(bootf, bootblock, buf, boothdr.a_text + boothdr.a_data);
(void) fclose(bootf);
/* Patch the addresses in. */
adrp= buf + (int) (boothdr.a_text + boothdr.a_data);
for (bap= bootaddr; bap->count != 0; bap++) {
*adrp++= bap->count;
*adrp++= (bap->address >> 0) & 0xFF;
*adrp++= (bap->address >> 8) & 0xFF;
*adrp++= (bap->address >> 16) & 0xFF;
}
/* Zero count stops bootblock's reading loop. */
*adrp++= 0;
if (bap > bootaddr+1) {
printf("%s and %d addresses to %s patched into %s\n",
bootblock, (int)(bap - bootaddr), bootcode, device);
}
/* Boot block signature. */
buf[SIGPOS+0]= (SIGNATURE >> 0) & 0xFF;
buf[SIGPOS+1]= (SIGNATURE >> 8) & 0xFF;
/* Sector 2 of the boot block is used for boot parameters, initially
* filled with null commands (newlines). Initialize it only if
* necessary.
*/
for (parmp= buf + SECTOR_SIZE; parmp < buf + 2*SECTOR_SIZE; parmp++) {
if (*imagev != NULL || (control(*parmp) && *parmp != '\n')) {
/* Param sector must be initialized. */
memset(buf + SECTOR_SIZE, '\n', SECTOR_SIZE);
break;
}
}
/* Offset to the end of the file system to add boot code and images. */
pos= fssize * RATIO(block_size);
if (ino == 0) {
/* Place the boot code onto the boot device. */
len= max_sector;
if (!raw_install(bootcode, &pos, &len, block_size)) {
if (how == FS) {
fprintf(stderr,
"\t(Isn't there a copy of %s on %s that can be used?)\n",
bootcode, device);
}
exit(1);
}
}
parmp= buf + SECTOR_SIZE;
nolabel= 0;
if (how == BOOT) {
/* A boot only disk needs to have floppies swapped. */
strcpy(parmp,
"trailer()echo \\nInsert the root diskette then hit RETURN\\n\\w\\c\n");
parmp+= strlen(parmp);
}
while ((labels= *imagev++) != NULL) {
/* Place each kernel image on the boot device. */
if ((image= strchr(labels, ':')) != NULL)
*image++= 0;
else {
if (nolabel) {
fprintf(stderr,
"installboot: Only one image can be the default\n");
exit(1);
}
nolabel= 1;
image= labels;
labels= NULL;
}
len= 0;
if (!raw_install(image, &pos, &len, block_size)) exit(1);
if (labels == NULL) {
/* Let this image be the default. */
sprintf(parmp, "image=%ld:%ld\n", pos-len, len);
parmp+= strlen(parmp);
}
while (labels != NULL) {
/* Image is prefixed by a comma separated list of
* labels. Define functions to select label and image.
*/
label= labels;
if ((labels= strchr(labels, ',')) != NULL) *labels++ = 0;
sprintf(parmp,
"%s(%c){label=%s;image=%ld:%ld;echo %s kernel selected;menu}\n",
label,
between('A', label[0], 'Z')
? label[0]-'A'+'a' : label[0],
label, pos-len, len, label);
parmp+= strlen(parmp);
}
if (parmp > buf + block_size) {
fprintf(stderr,
"installboot: Out of parameter space, too many images\n");
exit(1);
}
}
/* Install boot block. */
writeblock((off_t) BOOTBLOCK, buf, 1024);
if (pos > fssize * RATIO(block_size)) {
/* Tell the total size of the data on the device. */
printf("%16ld (%ld kb) total\n", pos,
(pos + RATIO(block_size) - 1) / RATIO(block_size));
}
}
static void install_master(const char *device, char *masterboot, char **guide)
/* Booting a hard disk is a two stage process: The master bootstrap in sector
* 0 loads the bootstrap from sector 0 of the active partition which in turn
* starts the operating system. This code installs such a master bootstrap
* on a hard disk. If guide[0] is non-null then the master bootstrap is
* guided into booting a certain device.
*/
{
FILE *masf;
unsigned long size;
struct stat st;
static char buf[_MAX_BLOCK_SIZE];
/* Open device. */
if ((rawfd= open(rawdev= device, O_RDWR)) < 0) fatal(device);
/* Open the master boot code. */
if ((masf= fopen(masterboot, "r")) == NULL) fatal(masterboot);
/* See if the user is cloning a device. */
if (fstat(fileno(masf), &st) >=0 && S_ISBLK(st.st_mode))
size= PARTPOS;
else {
/* Read and check header otherwise. */
struct image_header ihdr;
read_header(1, masterboot, masf, &ihdr);
size= ihdr.process.a_text + ihdr.process.a_data;
}
if (size > PARTPOS) {
fprintf(stderr, "installboot: %s is too big\n", masterboot);
exit(1);
}
/* Read the master boot block, patch it, write. */
readblock(BOOTBLOCK, buf, BOOT_BLOCK_SIZE);
memset(buf, 0, PARTPOS);
(void) bread(masf, masterboot, buf, size);
if (guide[0] != NULL) {
/* Fixate partition to boot. */
const char *keys= guide[0];
const char *logical= guide[1];
size_t i;
int logfd;
u32_t offset;
struct partition geometry;
/* A string of digits to be seen as keystrokes. */
i= 0;
do {
if (!between('0', keys[i], '9')) {
fprintf(stderr,
"installboot: bad guide keys '%s'\n",
keys);
exit(1);
}
} while (keys[++i] != 0);
if (size + i + 1 > PARTPOS) {
fprintf(stderr,
"installboot: not enough space after '%s' for '%s'\n",
masterboot, keys);
exit(1);
}
memcpy(buf + size, keys, i);
size += i;
buf[size]= '\r';
if (logical != NULL) {
if ((logfd= open(logical, O_RDONLY)) < 0
|| ioctl(logfd, DIOCGETP, &geometry) < 0
) {
fatal(logical);
}
offset= div64u(geometry.base, SECTOR_SIZE);
if (size + 5 > PARTPOS) {
fprintf(stderr,
"installboot: not enough space "
"after '%s' for '%s' and an offset "
"to '%s'\n",
masterboot, keys, logical);
exit(1);
}
buf[size]= '#';
memcpy(buf+size+1, &offset, 4);
}
}
/* Install signature. */
buf[SIGPOS+0]= (SIGNATURE >> 0) & 0xFF;
buf[SIGPOS+1]= (SIGNATURE >> 8) & 0xFF;
writeblock(BOOTBLOCK, buf, BOOT_BLOCK_SIZE);
}
static void usage(void)
{
fprintf(stderr,
"Usage: installboot -i(mage) image kernel mm fs ... init\n"
" installboot -(e)x(tract) image\n"
" installboot -d(evice) device bootblock boot [image ...]\n"
" installboot -b(oot) device bootblock boot image ...\n"
" installboot -m(aster) device masterboot [keys [logical]]\n");
exit(1);
}
static int isoption(const char *option, const char *test)
/* Check if the option argument is equals "test". Also accept -i as short
* for -image, and the special case -x for -extract.
*/
{
if (strcmp(option, test) == 0) return 1;
if (option[0] != '-' && strlen(option) != 2) return 0;
if (option[1] == test[1]) return 1;
if (option[1] == 'x' && test[1] == 'e') return 1;
return 0;
}
int main(int argc, char **argv)
{
if (argc < 2) usage();
if (argc >= 4 && isoption(argv[1], "-image")) {
make_image(argv[2], argv + 3);
} else
if (argc == 3 && isoption(argv[1], "-extract")) {
extract_image(argv[2]);
} else
if (argc >= 5 && isoption(argv[1], "-device")) {
make_bootable(FS, argv[2], argv[3], argv[4], argv + 5);
} else
if (argc >= 6 && isoption(argv[1], "-boot")) {
make_bootable(BOOT, argv[2], argv[3], argv[4], argv + 5);
} else
if ((4 <= argc && argc <= 6) && isoption(argv[1], "-master")) {
install_master(argv[2], argv[3], argv + 4);
} else {
usage();
}
exit(0);
}
/*
* $PchId: installboot.c,v 1.10 2000/08/13 22:07:50 philip Exp $
*/

View File

@@ -1,261 +0,0 @@
! jumpboot 1.0 - Jump to another bootstrap Author: Kees J. Bot
! 14 Apr 1999
!
! This code may be placed into any free boot sector, like the first sector
! of an extended partition, a file system partition other than the root,
! or even the master bootstrap. It will load and run another bootstrap whose
! disk, partition, and slice number (not necessarily all three) are patched
! into this code by installboot. If the ALT key is held down when this code
! is booted then you can type the disk, partition, and slice numbers manually.
! The manual interface is default if no numbers are patched in by installboot.
!
o32 = 0x66 ! This assembler doesn't know 386 extensions
LOADOFF = 0x7C00 ! 0x0000:LOADOFF is where this code is loaded
BUFFER = 0x0600 ! First free memory
PART_TABLE = 446 ! Location of partition table within master
PENTRYSIZE = 16 ! Size of one partition table entry
MAGIC = 510 ! Location of the AA55 magic number
! <ibm/partition.h>:
MINIX_PART = 0x81
sysind = 4
lowsec = 8
.text
! Find and load another bootstrap and jump to it.
jumpboot:
xor ax, ax
mov ds, ax
mov es, ax
cli
mov ss, ax ! ds = es = ss = Vector segment
mov sp, #LOADOFF
sti
! Move this code to safety, then jump to it.
mov si, sp ! si = start of this code
mov di, #BUFFER ! di = Buffer area
mov cx, #512/2 ! One sector
cld
rep movs
jmpf BUFFER+migrate, 0 ! To safety
migrate:
mov bp, #BUFFER+guide ! Patched guiding characters
altkey:
movb ah, #0x02 ! Keyboard shift status
int 0x16
testb al, #0x08 ! Bit 3 = ALT key
jz noalt ! ALT key pressed?
again:
mov bp, #zero ! Ignore patched stuff
noalt:
! Follow guide characters to find the boot partition.
call print
.ascii "d?\b\0" ! Initial greeting
! Disk number?
disk:
movb dl, #0x80 - 0x30 ! Prepare to add an ASCII digit
call getch ! Get number to tell which disk
addb dl, al ! dl = 0x80 + (al - '0')
jns n0nboot ! Result should be >= 0x80
mov si, #BUFFER+zero-lowsec ! si = where lowsec(si) is zero
cmpb (bp), #0x23 ! Next guide character is '#'?
jne notlogical
lea si, 1-lowsec(bp) ! Logical sector offset follows '#'
notlogical:
call load ! Load chosen sector of chosen disk
cmpb (bp), #0x23
je boot ! Run bootstrap if a logical is chosen
call print ! Intro to partition number
.ascii "p?\b\0"
part:
call getch ! Get character to tell partition
call gettable ! Get partition table
call sort ! Sort partition table
call choose_load ! Compute chosen entry and load
cmpb sysind(si), #MINIX_PART ! Minix subpartition table possible?
jne waitboot
call print ! Intro to slice number
.ascii "s?\b\0"
slice:
call getch ! Get character to tell slice
call gettable ! Get partition table
call choose_load ! Compute chosen entry and load
waitboot:
call print ! Intro to nothing
.ascii " ?\b\0"
call getch ! Supposed to type RETURN now
n0nboot:jmp nonboot ! Sorry, can't go further
! Get a character, either the patched-in, or one from the keyboard.
getch:
movb al, (bp) ! Get patched-in character
testb al, al
jz getkey
inc bp
jmp gotkey
getkey: xorb ah, ah ! Wait for keypress
int 0x16
gotkey: testb dl, dl ! Ignore CR if disk number not yet set
jns putch
cmpb al, #0x0D ! Carriage return?
je boot
!jmp putch
! Print a character
putch: movb ah, #0x0E ! Print character in teletype mode
mov bx, #0x0001 ! Page 0, foreground color
int 0x10
ret
! Print a message.
print: mov cx, si ! Save si
pop si ! si = String following 'call print'
prnext: lodsb ! al = *si++ is char to be printed
testb al, al ! Null marks end
jz prdone
call putch
jmp prnext
prdone: xchg si, cx ! Restore si
jmp (cx) ! Continue after the string
! Return typed (or in patched data) means to run the bootstrap now in core!
boot:
call print ! Make line on screen look proper
.ascii "\b \r\n\0"
jmp LOADOFF-BUFFER ! Jump to LOADOFF
! Compute address of chosen partition entry from choice al into si, then
! continue to load the boot sector of that partition.
choose_load:
subb al, #0x30 ! al -= '0'
cmpb al, #4 ! Only four partitions
ja n0nboot
movb ah, #PENTRYSIZE
mulb ah ! al *= PENTRYSIZE
add ax, #BUFFER+PART_TABLE
mov si, ax ! si = &part_table[al - '0']
movb al, sysind(si) ! System indicator
testb al, al ! Unused partition?
jz n0nboot
!jmp load ! Continue to load boot sector
! Load boot sector of the current partition.
load:
push dx ! Save drive code
push es ! Next call sets es
movb ah, #0x08 ! Code for drive parameters
int 0x13
pop es
andb cl, #0x3F ! cl = max sector number (1-origin)
incb dh ! dh = 1 + max head number (0-origin)
movb al, cl ! al = cl = sectors per track
mulb dh ! dh = heads, ax = heads * sectors
mov bx, ax ! bx = sectors per cylinder = heads * sectors
mov ax, lowsec+0(si)
mov dx, lowsec+2(si) ! dx:ax = sector within drive
cmp dx, #[1024*255*63-255]>>16 ! Near 8G limit?
jae bigdisk
div bx ! ax = cylinder, dx = sector within cylinder
xchg ax, dx ! ax = sector within cylinder, dx = cylinder
movb ch, dl ! ch = low 8 bits of cylinder
divb cl ! al = head, ah = sector (0-origin)
xorb dl, dl ! About to shift bits 8-9 of cylinder into dl
shr dx, #1
shr dx, #1 ! dl[6..7] = high cylinder
orb dl, ah ! dl[0..5] = sector (0-origin)
movb cl, dl ! cl[0..5] = sector, cl[6..7] = high cyl
incb cl ! cl[0..5] = sector (1-origin)
pop dx ! Restore drive code in dl
movb dh, al ! dh = al = head
mov bx, #LOADOFF ! es:bx = where sector is loaded
mov ax, #0x0201 ! ah = Code for read / al = one sector
int 0x13
jmp rdeval ! Evaluate read result
bigdisk:
mov bx, dx ! bx:ax = dx:ax = sector to read
pop dx ! Restore drive code in dl
push si ! Save si
mov si, #BUFFER+ext_rw ! si = extended read/write parameter packet
mov 8(si), ax ! Starting block number = bx:ax
mov 10(si), bx
movb ah, #0x42 ! Extended read
int 0x13
pop si ! Restore si to point to partition entry
!jmp rdeval
rdeval:
jnc rdok
rderr:
call print
.ascii "\r\nRead error\r\n\0"
jmp again
rdok:
cmp LOADOFF+MAGIC, #0xAA55
je sigok ! Signature ok?
nonboot:
call print
.ascii "\r\nNot bootable\r\n\0"
jmp again
sigok:
ret
! Get the partition table into my space.
gettable:
mov si, #LOADOFF+PART_TABLE
mov di, #BUFFER+PART_TABLE
mov cx, #4*PENTRYSIZE/2
rep movs
ret
! Sort the partition table.
sort:
mov cx, #4 ! Four times is enough to sort
bubble: mov si, #BUFFER+PART_TABLE ! First table entry
bubble1:lea di, PENTRYSIZE(si) ! Next entry
cmpb sysind(si), ch ! Partition type, nonzero when in use
jz exchg ! Unused entries sort to the end
inuse: mov bx, lowsec+0(di)
sub bx, lowsec+0(si) ! Compute di->lowsec - si->lowsec
mov bx, lowsec+2(di)
sbb bx, lowsec+2(si)
jae order ! In order if si->lowsec <= di->lowsec
exchg: movb bl, (si)
xchgb bl, PENTRYSIZE(si) ! Exchange entries byte by byte
movb (si), bl
inc si
cmp si, di
jb exchg
order: mov si, di
cmp si, #BUFFER+PART_TABLE+3*PENTRYSIZE
jb bubble1
loop bubble
ret
.data
! Extended read/write commands require a parameter packet.
ext_rw:
.data1 0x10 ! Length of extended r/w packet
.data1 0 ! Reserved
.data2 1 ! Blocks to transfer (just one)
.data2 LOADOFF ! Buffer address offset
.data2 0 ! Buffer address segment
.data4 0 ! Starting block number low 32 bits (tbfi)
zero: .data4 0 ! Starting block number high 32 bits
.align 2
guide:
! Guide characters and possibly a logical partition number patched here by
! installboot, up to 6 bytes maximum.

View File

@@ -1,218 +0,0 @@
! masterboot 2.0 - Master boot block code Author: Kees J. Bot
!
! This code may be placed in the first sector (the boot sector) of a floppy,
! hard disk or hard disk primary partition. There it will perform the
! following actions at boot time:
!
! - If the booted device is a hard disk and one of the partitions is active
! then the active partition is booted.
!
! - Otherwise the next floppy or hard disk device is booted, trying them one
! by one.
!
! To make things a little clearer, the boot path might be:
! /dev/fd0 - Floppy disk containing data, tries fd1 then d0
! [/dev/fd1] - Drive empty
! /dev/c0d0 - Master boot block, selects active partition 2
! /dev/c0d0p2 - Submaster, selects active subpartition 0
! /dev/c0d0p2s0 - Minix bootblock, reads Boot Monitor /boot
! Minix - Started by /boot from a kernel image in /minix
LOADOFF = 0x7C00 ! 0x0000:LOADOFF is where this code is loaded
BUFFER = 0x0600 ! First free memory
PART_TABLE = 446 ! Location of partition table within this code
PENTRYSIZE = 16 ! Size of one partition table entry
MAGIC = 510 ! Location of the AA55 magic number
! <ibm/partition>.h:
bootind = 0
sysind = 4
lowsec = 8
.text
! Find active (sub)partition, load its first sector, run it.
master:
xor ax, ax
mov ds, ax
mov es, ax
cli
mov ss, ax ! ds = es = ss = Vector segment
mov sp, #LOADOFF
sti
! Copy this code to safety, then jump to it.
mov si, sp ! si = start of this code
push si ! Also where we'll return to eventually
mov di, #BUFFER ! Buffer area
mov cx, #512/2 ! One sector
cld
rep movs
jmpf BUFFER+migrate, 0 ! To safety
migrate:
! Find the active partition
findactive:
testb dl, dl
jns nextdisk ! No bootable partitions on floppies
mov si, #BUFFER+PART_TABLE
find: cmpb sysind(si), #0 ! Partition type, nonzero when in use
jz nextpart
testb bootind(si), #0x80 ! Active partition flag in bit 7
jz nextpart ! It's not active
loadpart:
call load ! Load partition bootstrap
jc error1 ! Not supposed to fail
bootstrap:
ret ! Jump to the master bootstrap
nextpart:
add si, #PENTRYSIZE
cmp si, #BUFFER+PART_TABLE+4*PENTRYSIZE
jb find
! No active partition, tell 'em
call print
.ascii "No active partition\0"
jmp reboot
! There are no active partitions on this drive, try the next drive.
nextdisk:
incb dl ! Increment dl for the next drive
testb dl, dl
js nexthd ! Hard disk if negative
int 0x11 ! Get equipment configuration
shl ax, #1 ! Highest floppy drive # in bits 6-7
shl ax, #1 ! Now in bits 0-1 of ah
andb ah, #0x03 ! Extract bits
cmpb dl, ah ! Must be dl <= ah for drive to exist
ja nextdisk ! Otherwise try disk 0 eventually
call load0 ! Read the next floppy bootstrap
jc nextdisk ! It failed, next disk please
ret ! Jump to the next master bootstrap
nexthd: call load0 ! Read the hard disk bootstrap
error1: jc error ! No disk?
ret
! Load sector 0 from the current device. It's either a floppy bootstrap or
! a hard disk master bootstrap.
load0:
mov si, #BUFFER+zero-lowsec ! si = where lowsec(si) is zero
!jmp load
! Load sector lowsec(si) from the current device. The obvious head, sector,
! and cylinder numbers are ignored in favour of the more trustworthy absolute
! start of partition.
load:
mov di, #3 ! Three retries for floppy spinup
retry: push dx ! Save drive code
push es
push di ! Next call destroys es and di
movb ah, #0x08 ! Code for drive parameters
int 0x13
pop di
pop es
andb cl, #0x3F ! cl = max sector number (1-origin)
incb dh ! dh = 1 + max head number (0-origin)
movb al, cl ! al = cl = sectors per track
mulb dh ! dh = heads, ax = heads * sectors
mov bx, ax ! bx = sectors per cylinder = heads * sectors
mov ax, lowsec+0(si)
mov dx, lowsec+2(si)! dx:ax = sector within drive
cmp dx, #[1024*255*63-255]>>16 ! Near 8G limit?
jae bigdisk
div bx ! ax = cylinder, dx = sector within cylinder
xchg ax, dx ! ax = sector within cylinder, dx = cylinder
movb ch, dl ! ch = low 8 bits of cylinder
divb cl ! al = head, ah = sector (0-origin)
xorb dl, dl ! About to shift bits 8-9 of cylinder into dl
shr dx, #1
shr dx, #1 ! dl[6..7] = high cylinder
orb dl, ah ! dl[0..5] = sector (0-origin)
movb cl, dl ! cl[0..5] = sector, cl[6..7] = high cyl
incb cl ! cl[0..5] = sector (1-origin)
pop dx ! Restore drive code in dl
movb dh, al ! dh = al = head
mov bx, #LOADOFF ! es:bx = where sector is loaded
mov ax, #0x0201 ! Code for read, just one sector
int 0x13 ! Call the BIOS for a read
jmp rdeval ! Evaluate read result
bigdisk:
mov bx, dx ! bx:ax = dx:ax = sector to read
pop dx ! Restore drive code in dl
push si ! Save si
mov si, #BUFFER+ext_rw ! si = extended read/write parameter packet
mov 8(si), ax ! Starting block number = bx:ax
mov 10(si), bx
movb ah, #0x42 ! Extended read
int 0x13
pop si ! Restore si to point to partition entry
!jmp rdeval
rdeval:
jnc rdok ! Read succeeded
cmpb ah, #0x80 ! Disk timed out? (Floppy drive empty)
je rdbad
dec di
jl rdbad ! Retry count expired
xorb ah, ah
int 0x13 ! Reset
jnc retry ! Try again
rdbad: stc ! Set carry flag
ret
rdok: cmp LOADOFF+MAGIC, #0xAA55
jne nosig ! Error if signature wrong
ret ! Return with carry still clear
nosig: call print
.ascii "Not bootable\0"
jmp reboot
! A read error occurred, complain and hang
error:
mov si, #LOADOFF+errno+1
prnum: movb al, ah ! Error number in ah
andb al, #0x0F ! Low 4 bits
cmpb al, #10 ! A-F?
jb digit ! 0-9!
addb al, #7 ! 'A' - ':'
digit: addb (si), al ! Modify '0' in string
dec si
movb cl, #4 ! Next 4 bits
shrb ah, cl
jnz prnum ! Again if digit > 0
call print
.ascii "Read error "
errno: .ascii "00\0"
!jmp reboot
reboot:
call print
.ascii ". Hit any key to reboot.\0"
xorb ah, ah ! Wait for keypress
int 0x16
call print
.ascii "\r\n\0"
int 0x19
! Print a message.
print: pop si ! si = String following 'call print'
prnext: lodsb ! al = *si++ is char to be printed
testb al, al ! Null marks end
jz prdone
movb ah, #0x0E ! Print character in teletype mode
mov bx, #0x0001 ! Page 0, foreground color
int 0x10
jmp prnext
prdone: jmp (si) ! Continue after the string
.data
! Extended read/write commands require a parameter packet.
ext_rw:
.data1 0x10 ! Length of extended r/w packet
.data1 0 ! Reserved
.data2 1 ! Blocks to transfer (just one)
.data2 LOADOFF ! Buffer address offset
.data2 0 ! Buffer address segment
.data4 0 ! Starting block number low 32 bits (tbfi)
zero: .data4 0 ! Starting block number high 32 bits

View File

@@ -1,137 +0,0 @@
! Mkfhead.s - DOS & BIOS support for mkfile.c Author: Kees J. Bot
! 9 May 1998
!
! This file contains the startup and low level support for the MKFILE.COM
! utility. See doshead.ack.s for more comments on .COM files.
!
.sect .text; .sect .rom; .sect .data; .sect .bss
.sect .text
.define _PSP
_PSP:
.space 256 ! Program Segment Prefix
mkfile:
cld ! C compiler wants UP
xor ax, ax ! Zero
mov di, _edata ! Start of bss is at end of data
mov cx, _end ! End of bss (begin of heap)
sub cx, di ! Number of bss bytes
shr cx, 1 ! Number of words
rep stos ! Clear bss
xor cx, cx ! cx = argc
xor bx, bx
push bx ! argv[argc] = NULL
movb bl, (_PSP+0x80) ! Argument byte count
0: movb _PSP+0x81(bx), ch ! Null terminate
dec bx
js 9f
cmpb _PSP+0x81(bx), 0x20 ! Whitespace?
jbe 0b
1: dec bx ! One argument character
js 2f
cmpb _PSP+0x81(bx), 0x20 ! More argument characters?
ja 1b
2: lea ax, _PSP+0x81+1(bx) ! Address of argument
push ax ! argv[n]
inc cx ! argc++;
test bx, bx
jns 0b ! More arguments?
9: movb _PSP+0x81(bx), ch ! Make a null string
lea ax, _PSP+0x81(bx)
push ax ! to use as argv[0]
inc cx ! Final value of argc
mov ax, sp
push ax ! argv
push cx ! argc
call _main ! main(argc, argv)
push ax
call _exit ! exit(main(argc, argv))
! int creat(const char *path, mode_t mode)
! Create a file with the old creat() call.
.define _creat
_creat:
mov bx, sp
mov dx, 2(bx) ! Filename
xor cx, cx ! Ignore mode, always read-write
movb ah, 0x3C ! "CREAT"
dos: int 0x21 ! ax = creat(path, 0666);
jc seterrno
ret
seterrno:
mov (_errno), ax ! Set errno to the DOS error code
mov ax, -1
cwd ! return -1L;
ret
! int open(const char *path, int oflag)
! Open a file with the oldfashioned two-argument open() call.
.define _open
_open:
mov bx, sp
mov dx, 2(bx) ! Filename
movb al, 4(bx) ! O_RDONLY, O_WRONLY, O_RDWR
movb ah, 0x3D ! "OPEN"
jmp dos
! int close(int fd)
! Close an open file.
.define _close
_close:
mov bx, sp
mov bx, 2(bx) ! bx = file handle
movb ah, 0x3E ! "CLOSE"
jmp dos
! void exit(int status)
! void _exit(int status)
! Return to DOS.
.define _exit, __exit, ___exit
_exit:
__exit:
___exit:
pop ax
pop ax ! al = status
movb ah, 0x4C ! "EXIT"
int 0x21
hlt
! ssize_t read(int fd, void *buf, size_t n)
! Read bytes from an open file.
.define _read
_read:
mov bx, sp
mov cx, 6(bx)
mov dx, 4(bx)
mov bx, 2(bx)
movb ah, 0x3F ! "READ"
jmp dos
! ssize_t write(int fd, const void *buf, size_t n)
! Write bytes to an open file.
.define _write
_write:
mov bx, sp
mov cx, 6(bx)
mov dx, 4(bx)
mov bx, 2(bx)
movb ah, 0x40 ! "WRITE"
jmp dos
! off_t lseek(int fd, off_t offset, int whence)
! Set file position for read or write.
.define _lseek
_lseek:
mov bx, sp
movb al, 8(bx) ! SEEK_SET, SEEK_CUR, SEEK_END
mov dx, 4(bx)
mov cx, 6(bx) ! cx:dx = offset
mov bx, 2(bx)
movb ah, 0x42 ! "LSEEK"
jmp dos
!
! $PchId: mkfhead.ack.s,v 1.3 1999/01/14 21:17:06 philip Exp $

View File

@@ -1,179 +0,0 @@
/* mkfile 1.0 - create a file under DOS for use as a Minix "disk".
* Author: Kees J. Bot
* 9 May 1998
*/
#define nil 0
#include <sys/types.h>
#include <string.h>
#include <limits.h>
/* Stuff normally found in <unistd.h>, <errno.h>, etc. */
extern int errno;
int creat(const char *file, int mode);
int open(const char *file, int oflag);
off_t lseek(int fd, off_t offset, int whence);
ssize_t write(int fd, const char *buf, size_t len);
void exit(int status);
int printf(const char *fmt, ...);
#define O_WRONLY 1
#define SEEK_SET 0
#define SEEK_END 2
/* Kernel printf requires a putk() function. */
void putk(int c)
{
char ch = c;
if (c == 0) return;
if (c == '\n') putk('\r');
(void) write(2, &ch, 1);
}
static void usage(void)
{
printf("Usage: mkfile <size>[gmk] <file>\n"
"(Example sizes, all 50 meg: 52428800, 51200k, 50m)\n");
exit(1);
}
char *strerror(int err)
/* Translate some DOS error numbers to text. */
{
static struct errlist {
int err;
char *what;
} errlist[] = {
{ 0, "No error" },
{ 1, "Function number invalid" },
{ 2, "File not found" },
{ 3, "Path not found" },
{ 4, "Too many open files" },
{ 5, "Access denied" },
{ 6, "Invalid handle" },
{ 12, "Access code invalid" },
{ 39, "Insufficient disk space" },
};
struct errlist *ep;
static char unknown[]= "Error 65535";
unsigned e;
char *p;
for (ep= errlist; ep < errlist + sizeof(errlist)/sizeof(errlist[0]);
ep++) {
if (ep->err == err) return ep->what;
}
p= unknown + sizeof(unknown) - 1;
e= err;
do *--p= '0' + (e % 10); while ((e /= 10) > 0);
strcpy(unknown + 6, p);
return unknown;
}
int main(int argc, char **argv)
{
static char buf[512];
unsigned long size, mul;
off_t offset;
char *cp;
int fd;
char *file;
if (argc != 3) usage();
cp= argv[1];
size= 0;
while ((unsigned) (*cp - '0') < 10) {
unsigned d= *cp++ - '0';
if (size <= (ULONG_MAX-9) / 10) {
size= size * 10 + d;
} else {
size= ULONG_MAX;
}
}
if (cp == argv[1]) usage();
while (*cp != 0) {
mul = 1;
switch (*cp++) {
case 'G':
case 'g': mul *= 1024;
case 'M':
case 'm': mul *= 1024;
case 'K':
case 'k': mul *= 1024;
case 'B':
case 'b': break;
default: usage();
}
if (size <= ULONG_MAX / mul) {
size *= mul;
} else {
size= ULONG_MAX;
}
}
if (size > 1024L*1024*1024) {
printf("mkfile: A file size over 1G is a bit too much\n");
exit(1);
}
/* Open existing file, or create a new file. */
file= argv[2];
if ((fd= open(file, O_WRONLY)) < 0) {
if (errno == 2) {
fd= creat(file, 0666);
}
}
if (fd < 0) {
printf("mkfile: Can't open %s: %s\n", file, strerror(errno));
exit(1);
}
/* How big is the file now? */
if ((offset= lseek(fd, 0, SEEK_END)) == -1) {
printf("mkfile: Can't seek in %s: %s\n", file, strerror(errno));
exit(1);
}
if (offset == 0 && size == 0) exit(0); /* Huh? */
/* Write the first bit if the file is zero length. This is necessary
* to circumvent a DOS bug by extending a new file by lseek. We also
* want to make sure there are zeros in the first sector.
*/
if (offset == 0) {
if (write(fd, buf, sizeof(buf)) == -1) {
printf("mkfile: Can't write to %s: %s\n",
file, strerror(errno));
exit(1);
}
}
/* Seek to the required size and write 0 bytes to extend/truncate the
* file to that size.
*/
if (lseek(fd, size, SEEK_SET) == -1) {
printf("mkfile: Can't seek in %s: %s\n", file, strerror(errno));
exit(1);
}
if (write(fd, buf, 0) == -1) {
printf("mkfile: Can't write to %s: %s\n",
file, strerror(errno));
exit(1);
}
/* Did the file become the required size? */
if ((offset= lseek(fd, 0, SEEK_END)) == -1) {
printf("mkfile: Can't seek in %s: %s\n", file, strerror(errno));
exit(1);
}
if (offset != size) {
printf("mkfile: Failed to extend %s. Disk full?\n", file);
exit(1);
}
return 0;
}
/*
* $PchId: mkfile.c,v 1.4 2000/08/13 22:06:40 philip Exp $
*/

View File

@@ -1,330 +0,0 @@
/* rawfs.c - Raw Minix file system support. Author: Kees J. Bot
* 23 Dec 1991
* Based on readfs by Paul Polderman
*/
#define _POSIX_SOURCE 1
#define _MINIX 1
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <errno.h>
#include <minix/config.h>
#include <minix/const.h>
#include <minix/type.h>
#include <servers/mfs/const.h>
#include <servers/mfs/type.h>
#include <servers/mfs/buf.h>
#include <servers/mfs/super.h>
#include <servers/mfs/inode.h>
#include "rawfs.h"
void readblock(off_t blockno, char *buf, int);
/* The following code handles two file system types: Version 1 with small
* inodes and 16-bit disk addresses and Version 2 with big inodes and 32-bit
* disk addresses.
#ifdef FLEX
* To make matters worse, Minix-vmd knows about the normal Unix Version 7
* directories and directories with flexible entries.
#endif
*/
/* File system parameters. */
static unsigned nr_dzones; /* Fill these in after reading superblock. */
static unsigned nr_indirects;
static unsigned inodes_per_block;
static int block_size;
#ifdef FLEX
#include <dirent.h>
#define direct _v7_direct
#else
#include <sys/dir.h>
#endif
#if __minix_vmd
static struct v12_super_block super; /* Superblock of file system */
#define s_log_zone_size s_dummy /* Zones are obsolete. */
#else
static struct super_block super; /* Superblock of file system */
#define SUPER_V1 SUPER_MAGIC /* V1 magic has a weird name. */
#endif
static struct inode curfil; /* Inode of file under examination */
static char indir[_MAX_BLOCK_SIZE]; /* Single indirect block. */
static char dindir[_MAX_BLOCK_SIZE]; /* Double indirect block. */
static char dirbuf[_MAX_BLOCK_SIZE]; /* Scratch/Directory block. */
#define scratch dirbuf
static block_t a_indir, a_dindir; /* Addresses of the indirects. */
static off_t dirpos; /* Reading pos in a dir. */
#define fsbuf(b) (* (union fsdata_u *) (b))
#define zone_shift (super.s_log_zone_size) /* zone to block ratio */
off_t r_super(int *bs)
/* Initialize variables, return size of file system in blocks,
* (zero on error).
*/
{
/* Read superblock. (The superblock is always at 1kB offset,
* that's why we lie to readblock and say the block size is 1024
* and we want block number 1 (the 'second block', at offset 1kB).)
*/
readblock(1, scratch, 1024);
memcpy(&super, scratch, sizeof(super));
/* Is it really a MINIX file system ? */
if (super.s_magic == SUPER_V2 || super.s_magic == SUPER_V3) {
if(super.s_magic == SUPER_V2)
super.s_block_size = 1024;
*bs = block_size = super.s_block_size;
if(block_size < _MIN_BLOCK_SIZE ||
block_size > _MAX_BLOCK_SIZE) {
return 0;
}
nr_dzones= V2_NR_DZONES;
nr_indirects= V2_INDIRECTS(block_size);
inodes_per_block= V2_INODES_PER_BLOCK(block_size);
return (off_t) super.s_zones << zone_shift;
} else
if (super.s_magic == SUPER_V1) {
*bs = block_size = 1024;
nr_dzones= V1_NR_DZONES;
nr_indirects= V1_INDIRECTS;
inodes_per_block= V1_INODES_PER_BLOCK;
return (off_t) super.s_nzones << zone_shift;
} else {
/* Filesystem not recognized as Minix. */
return 0;
}
}
void r_stat(Ino_t inum, struct stat *stp)
/* Return information about a file like stat(2) and remember it. */
{
block_t block;
block_t ino_block;
ino_t ino_offset;
union fsdata_u *blockbuf;
/* Calculate start of i-list */
block = START_BLOCK + super.s_imap_blocks + super.s_zmap_blocks;
/* Calculate block with inode inum */
ino_block = ((inum - 1) / inodes_per_block);
ino_offset = ((inum - 1) % inodes_per_block);
block += ino_block;
/* Fetch the block */
blockbuf = (union fsdata_u *) scratch;
readblock(block, (char *) blockbuf, block_size);
if (super.s_magic == SUPER_V2 || super.s_magic == SUPER_V3) {
d2_inode *dip;
int i;
dip= &blockbuf->b__v2_ino[(unsigned int) ino_offset];
curfil.i_mode= dip->d2_mode;
curfil.i_nlinks= dip->d2_nlinks;
curfil.i_uid= dip->d2_uid;
curfil.i_gid= dip->d2_gid;
curfil.i_size= dip->d2_size;
curfil.i_atime= dip->d2_atime;
curfil.i_mtime= dip->d2_mtime;
curfil.i_ctime= dip->d2_ctime;
for (i= 0; i < V2_NR_TZONES; i++)
curfil.i_zone[i]= dip->d2_zone[i];
} else {
d1_inode *dip;
int i;
dip= &blockbuf->b__v1_ino[(unsigned int) ino_offset];
curfil.i_mode= dip->d1_mode;
curfil.i_nlinks= dip->d1_nlinks;
curfil.i_uid= dip->d1_uid;
curfil.i_gid= dip->d1_gid;
curfil.i_size= dip->d1_size;
curfil.i_atime= dip->d1_mtime;
curfil.i_mtime= dip->d1_mtime;
curfil.i_ctime= dip->d1_mtime;
for (i= 0; i < V1_NR_TZONES; i++)
curfil.i_zone[i]= dip->d1_zone[i];
}
curfil.i_dev= -1; /* Can't fill this in alas. */
curfil.i_num= inum;
stp->st_dev= curfil.i_dev;
stp->st_ino= curfil.i_num;
stp->st_mode= curfil.i_mode;
stp->st_nlink= curfil.i_nlinks;
stp->st_uid= curfil.i_uid;
stp->st_gid= curfil.i_gid;
stp->st_rdev= (dev_t) curfil.i_zone[0];
stp->st_size= curfil.i_size;
stp->st_atime= curfil.i_atime;
stp->st_mtime= curfil.i_mtime;
stp->st_ctime= curfil.i_ctime;
a_indir= a_dindir= 0;
dirpos= 0;
}
ino_t r_readdir(char *name)
/* Read next directory entry at "dirpos" from file "curfil". */
{
ino_t inum= 0;
int blkpos;
struct direct *dp;
if (!S_ISDIR(curfil.i_mode)) { errno= ENOTDIR; return -1; }
if(!block_size) { errno = 0; return -1; }
while (inum == 0 && dirpos < curfil.i_size) {
if ((blkpos= (int) (dirpos % block_size)) == 0) {
/* Need to fetch a new directory block. */
readblock(r_vir2abs(dirpos / block_size), dirbuf, block_size);
}
#ifdef FLEX
if (super.s_flags & S_FLEX) {
struct _fl_direct *dp;
dp= (struct _fl_direct *) (dirbuf + blkpos);
if ((inum= dp->d_ino) != 0) strcpy(name, dp->d_name);
dirpos+= (1 + dp->d_extent) * FL_DIR_ENTRY_SIZE;
continue;
}
#endif
/* Let dp point to the next entry. */
dp= (struct direct *) (dirbuf + blkpos);
if ((inum= dp->d_ino) != 0) {
/* This entry is occupied, return name. */
strncpy(name, dp->d_name, sizeof(dp->d_name));
name[sizeof(dp->d_name)]= 0;
}
dirpos+= DIR_ENTRY_SIZE;
}
return inum;
}
off_t r_vir2abs(off_t virblk)
/* Translate a block number in a file to an absolute disk block number.
* Returns 0 for a hole and -1 if block is past end of file.
*/
{
block_t b= virblk;
zone_t zone, ind_zone;
block_t z, zone_index;
int i;
if(!block_size) return -1;
/* Check if virblk within file. */
if (virblk * block_size >= curfil.i_size) return -1;
/* Calculate zone in which the datablock number is contained */
zone = (zone_t) (b >> zone_shift);
/* Calculate index of the block number in the zone */
zone_index = b - ((block_t) zone << zone_shift);
/* Go get the zone */
if (zone < (zone_t) nr_dzones) { /* direct block */
zone = curfil.i_zone[(int) zone];
z = ((block_t) zone << zone_shift) + zone_index;
return z;
}
/* The zone is not a direct one */
zone -= (zone_t) nr_dzones;
/* Is it single indirect ? */
if (zone < (zone_t) nr_indirects) { /* single indirect block */
ind_zone = curfil.i_zone[nr_dzones];
} else { /* double indirect block */
/* Fetch the double indirect block */
if ((ind_zone = curfil.i_zone[nr_dzones + 1]) == 0) return 0;
z = (block_t) ind_zone << zone_shift;
if (a_dindir != z) {
readblock(z, dindir, block_size);
a_dindir= z;
}
/* Extract the indirect zone number from it */
zone -= (zone_t) nr_indirects;
i = zone / (zone_t) nr_indirects;
ind_zone = (super.s_magic == SUPER_V2 || super.s_magic == SUPER_V3)
? fsbuf(dindir).b__v2_ind[i]
: fsbuf(dindir).b__v1_ind[i];
zone %= (zone_t) nr_indirects;
}
if (ind_zone == 0) return 0;
/* Extract the datablock number from the indirect zone */
z = (block_t) ind_zone << zone_shift;
if (a_indir != z) {
readblock(z, indir, block_size);
a_indir= z;
}
zone = (super.s_magic == SUPER_V2 || super.s_magic == SUPER_V3)
? fsbuf(indir).b__v2_ind[(int) zone]
: fsbuf(indir).b__v1_ind[(int) zone];
/* Calculate absolute datablock number */
z = ((block_t) zone << zone_shift) + zone_index;
return z;
}
ino_t r_lookup(Ino_t cwd, const char *path)
/* Translates a pathname to an inode number. This is just a nice utility
* function, it only needs r_stat and r_readdir.
*/
{
char name[NAME_MAX+1], r_name[NAME_MAX+1];
char *n;
struct stat st;
ino_t ino;
ino= path[0] == '/' ? ROOT_INO : cwd;
for (;;) {
if (ino == 0) {
errno= ENOENT;
return 0;
}
while (*path == '/') path++;
if (*path == 0) return ino;
r_stat(ino, &st);
if (!S_ISDIR(st.st_mode)) {
errno= ENOTDIR;
return 0;
}
n= name;
while (*path != 0 && *path != '/')
if (n < name + NAME_MAX) *n++ = *path++;
*n= 0;
while ((ino= r_readdir(r_name)) != 0
&& strcmp(name, r_name) != 0) {
}
}
}
/*
* $PchId: rawfs.c,v 1.8 1999/11/05 23:14:15 philip Exp $
*/

View File

@@ -1,48 +0,0 @@
/* rawfs.h - Raw Minix file system support. Author: Kees J. Bot
*
* off_t r_super(int *block_size);
* Initialize variables, returns the size of a valid Minix
* file system blocks, but zero on error.
*
* void r_stat(ino_t file, struct stat *stp);
* Return information about a file like stat(2) and
* remembers file for the next two calls.
*
* off_t r_vir2abs(off_t virblockno);
* Translate virtual block number in file to absolute
* disk block number. Returns 0 if the file contains
* a hole, or -1 if the block lies past the end of file.
*
* ino_t r_readdir(char *name);
* Return next directory entry or 0 if there are no more.
* Returns -1 and sets errno on error.
*
* ino_t r_lookup(ino_t cwd, const char *path);
* A utility function that translates a pathname to an
* inode number. It starts from directory "cwd" unless
* path starts with a '/', then from ROOT_INO.
* Returns 0 and sets errno on error.
*
* One function needs to be provided by the outside world:
*
* void readblock(off_t blockno, char *buf, int block_size);
* Read a block into the buffer. Outside world handles
* errors.
*/
#ifndef INC_RAWFS_H
#define INC_RAWFS_H
#define ROOT_INO ((ino_t) 1) /* Inode nr of root dir. */
extern off_t r_super(int *);
extern void r_stat(Ino_t file, struct stat *stp);
extern off_t r_vir2abs(off_t virblockno);
extern ino_t r_readdir(char *name);
extern ino_t r_lookup(Ino_t cwd, const char *path);
/*
* $PchId: rawfs.h,v 1.4 1996/04/19 08:16:36 philip Exp $
*/
#endif

View File

@@ -1,27 +0,0 @@
#!/bin/sh
set -e
BOOT=/boot/boot
ROOT=`printroot -r`
if [ ! -b "$ROOT" ]
then echo root device $ROOT not found
exit 1
fi
echo -n "Install boot as $BOOT on current root and patch into $ROOT? (y/N) "
read ans
if [ ! "$ans" = y ]
then echo Aborting.
exit 1
fi
make install || true
echo Installing boot monitor into $BOOT.
cp boot $BOOT
echo Patching position of $BOOT into $ROOT.
installboot -d "$ROOT" /usr/mdec/bootblock $BOOT
sync

View File

@@ -182,7 +182,7 @@ do
des="audio" dev=audio
;;
14,0)
des="audio mixer" dev=mixer
des="faulty block device driver" dev=fbd
;;
15,0)
des="kernel log" dev=klog

View File

@@ -1,28 +0,0 @@
#!/bin/sh
#
# M, U - mount or unmount standard devices.
case $#:$2 in
1:|2:-r) ;;
*) echo "Usage: $0 <abbreviation> [-r]" >&2; exit 1
esac
. /etc/fstab
dev=$1 dir=$1
case $1 in
0) dev=/dev/fd0 dir=fd0 ;;
1) dev=/dev/fd1 dir=fd1 ;;
PS0|at0|fd0|pat0|pc0|ps0) dev=/dev/$dev dir=fd0 ;;
PS1|at1|fd1|pat1|pc1|ps1) dev=/dev/$dev dir=fd1 ;;
root) dev=$root ;;
tmp) dev=$tmp ;;
usr) dev=$usr ;;
*) dev=/dev/$dev dir=mnt
esac
case $0 in
*M) mount $dev /$dir $2 ;;
*U) umount $dev
esac

View File

@@ -1,7 +0,0 @@
SCRIPTS= M.sh
BINDIR= /bin
MAN=
LINKS+= ${BINDIR}/M ${BINDIR}/U
.include <bsd.prog.mk>

View File

@@ -23,7 +23,7 @@ case $#:$1 in
ttypa ttypb ttypc ttypd ttype ttypf \
ttyq0 ttyq1 ttyq2 ttyq3 ttyq4 ttyq5 ttyq6 ttyq7 ttyq8 ttyq9 \
ttyqa ttyqb ttyqc ttyqd ttyqe ttyqf \
eth klog random uds filter hello
eth klog random uds filter fbd hello
;;
0:|1:-\?)
cat >&2 <<EOF
@@ -49,6 +49,7 @@ Where key is one of the following:
kbd # Make /dev/kbd
kbdaux # Make /dev/kbdaux
filter # Make /dev/filter
fbd # Make /dev/fbd
hello # Make /dev/hello
video # Make /dev/video
std # All standard devices
@@ -267,6 +268,11 @@ do
$e mknod filter b 11 0
$e chmod 644 filter
;;
fbd)
# faulty block device driver
$e mknod fbd b 14 0
$e chmod 600 fbd
;;
hello)
# hello driver
$e mknod hello c 17 0

View File

@@ -2,43 +2,43 @@
.include <bsd.own.mk>
SUBDIR= aal add_route adduser advent arp ash at autil awk \
backup badblocks banner basename bigmake binpackage \
binpackages binsizes bzip2 bzip2recover cal calendar \
cat cawf cd cdprobe checkhier chmem \
SUBDIR= add_route arp ash at awk \
backup badblocks banner basename \
btrace cal calendar \
cat cawf cd cdprobe checkhier cpp \
chmod chown chroot ci cksum cleantmp clear cmp co \
comm compress cp crc cron crontab cut date \
dd de decomp16 DESCRIBE dev2name devsize df dhcpd \
dhrystone diff dirname dis88 diskctl du dumpcore \
ed eject elle elvis env expand factor file \
comm compress cp crc cron crontab cut \
dd decomp16 DESCRIBE dev2name devsize df dhcpd \
dhrystone diff dirname diskctl du dumpcore \
ed eject elvis env expand factor fbdctl file \
find finger fingerd fix fold format fortune fsck.mfs \
fsck1 ftp101 ftpd200 gcov-pull getty grep gomoku head hexdump host \
hostaddr id ifconfig ifdef indent install \
ftp101 gcore gcov-pull getty grep head hexdump host \
hostaddr id ifconfig ifdef install \
intr ipcrm ipcs irdpd isoread join kill last leave \
less lex life loadkeys loadramdisk logger login look lp \
lpd ls lspci M m4 mail make MAKEDEV man \
mdb mdocml mesg mined mkdep mkdir mkdist mkfifo mkfs.mfs mknod \
less lex loadkeys loadramdisk logger login look lp \
lpd ls lspci mail make MAKEDEV \
mdb mesg mined mkfifo mkfs.mfs mknod \
mkproto modem mount mt netconf newroot nice acknm nohup \
nonamed od packman passwd paste patch pax \
nonamed od paste patch pax \
ping postinstall poweroff pr prep printf printroot \
profile progressbar proto pr_routes ps pwd pwdauth \
ramdisk rarpd rawspeed rcp rdate readall readclock \
readfs reboot remsync rev rget rlogin rlogind rmdir \
rotate rsh rshd sed service setup shar size \
sleep slip sort spell split srccrc stat strings ackstrip \
stty su sum svclog swapfs swifi sync synctree sysenv \
syslogd tail talk talkd tar tcpd tcpdp tcpstat tee telnet \
telnetd term termcap tget time tinyhalt top touch tr \
truncate tsort ttt tty udpstat umount uname unexpand \
uniq unstack update urlget uud uue version vol wc \
reboot remsync rev rget rlogin rlogind \
rotate rsh rshd sed service setup shar acksize \
sleep slip sort spell split srccrc \
stty su sum svclog swifi sync synctree sysenv \
syslogd tail tar tcpd tcpdp tcpstat tee telnet \
telnetd term termcap tget time touch tr \
truncate tsort tty udpstat umount uname unexpand \
unstack update uud uue version vol wc \
whereis which who write writeisofs fetch \
xargs yacc yes zdump zic zmodem pkg_install pkgin_cd
xargs yacc yes zdump zmodem pkgin_cd \
mktemp worldstone updateboot
.if ${ARCH} == "i386"
SUBDIR+= atnormalize dosread fdisk loadfont \
mixer autopart part partition playwave postmort \
recwave repartition screendump padtext
SUBDIR+= acd asmconv gas2ack
autopart part partition playwave \
recwave repartition screendump
.endif
.include <bsd.subdir.mk>

View File

@@ -1,2 +1,3 @@
CPPFLAGS+= -D_MINIX -D_POSIX_SOURCE
CPPFLAGS+= -D_MINIX -D_NETBSD_SOURCE -D_MINIX_COMPAT
LDADD+= -lminlib -lcompat_minix -lasyn -lterminfo
BINDIR?=/usr/bin

View File

@@ -1,11 +0,0 @@
# Makefile for aal
PROG= aal
SRCS= archiver.c print.c rd.c rd_arhdr.c rd_unsig2.c sprint.c \
wr_arhdr.c wr_bytes.c wr_int2.c wr_long.c wr_ranlib.c \
format.c rd_bytes.c system.c write.c long2str.c
CPPFLAGS+= -I${.CURDIR} -DAAL -DSTB -DNDEBUG -DDISTRIBUTION
MAN=
.include <bsd.prog.mk>

View File

@@ -1,28 +0,0 @@
/* $Header$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef __ARCH_H_INCLUDED
#define __ARCH_H_INCLUDED
#define ARMAG 0177545
#define AALMAG 0177454
struct ar_hdr {
char ar_name[14];
long ar_date;
char ar_uid;
char ar_gid;
short ar_mode;
long ar_size;
};
#define AR_TOTAL 26
#define AR_SIZE 22
extern int rd_arhdr(int fd, register struct ar_hdr arhdr[]);
extern void wr_arhdr(int fd, struct ar_hdr arhdr[]);
#endif /* __ARCH_H_INCLUDED */

View File

@@ -1,813 +0,0 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* ar - archiver Author: Michiel Huisjes */
/* Made into arch/aal by Ceriel Jacobs
*/
#include <sys/types.h>
#include <fcntl.h>
#include "rd.h"
#include "wr_bytes.h"
#include "wr_long.h"
#include "wr_int2.h"
#include "arch.h"
#include "archiver.h"
#include "print.h"
static char RcsId[] = "$Header$";
/*
* Usage: [arch|aal] [adprtvx] archive [file] ...
* v: verbose
* x: extract
* a: append
* r: replace (append when not in archive)
* d: delete
* t: print contents of archive
* p: print named files
* l: temporaries in current directory instead of /usr/tmp
* c: don't give "create" message
* u: replace only if dated later than member in archive
#ifdef DISTRIBUTION
* D: make distribution: use distr_time, uid=2, gid=2, mode=0644
#endif
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifndef S_IREAD
#define S_IREAD S_IRUSR
#endif
#ifndef S_IWRITE
#define S_IWRITE S_IWUSR
#endif
#ifndef S_IEXEC
#define S_IEXEC S_IXUSR
#endif
#include <signal.h>
#include <arch.h>
#ifdef AAL
#include <ranlib.h>
#include <out.h>
#define MAGIC_NUMBER AALMAG
long offset;
struct ranlib *tab;
unsigned int tnum = 0;
char *tstrtab;
unsigned int tssiz = 0;
long time();
unsigned int tabsz, strtabsz;
#else
#define MAGIC_NUMBER ARMAG
#endif
long lseek();
#define odd(nr) (nr & 01)
#define even(nr) (odd(nr) ? nr + 1 : nr)
typedef char BOOL;
#define FALSE 0
#define TRUE 1
#define READ 0
#define APPEND 2
#define CREATE 1
#define MEMBER struct ar_hdr
#define IO_SIZE (10 * 1024)
#define equal(str1, str2) (!strncmp((str1), (str2), 14))
#ifndef S_ISDIR
#define S_ISDIR(m) (m & S_IFDIR) /* is a directory */
#endif
BOOL verbose;
BOOL app_fl;
BOOL ex_fl;
BOOL show_fl;
BOOL pr_fl;
BOOL rep_fl;
BOOL del_fl;
BOOL nocr_fl;
BOOL local_fl;
BOOL update_fl;
#ifdef DISTRIBUTION
BOOL distr_fl;
long distr_time;
#endif
int ar_fd;
char io_buffer[IO_SIZE];
char *progname;
char temp_buf[32];
char *temp_arch = &temp_buf[0];
extern char *mktemp();
extern char *ctime();
/* Forward declarations. */
static void enter_name(struct outname *namep);
static void do_names(struct outhead *headp);
static void do_object(int f, long size);
static void show(char *s, char *name);
static void write_symdef(void);
static void mwrite(int fd, char *address, int bytes);
static void extract(register MEMBER *member);
static void copy_member(MEMBER *member, int from, int to, int extracting);
static void add(char *name, int fd, char *mess);
static void get(int argc, char *argv[]);
/*VARARGS2*/
void error1(BOOL quit, char *str1)
{
fputs(str1,stderr);
if (quit) {
unlink(temp_arch);
_exit(1);
}
}
void error2(BOOL quit, char *str1, char *str2)
{
fprintf(stderr,str1,str2);
if (quit) {
unlink(temp_arch);
_exit(1);
}
}
void error3(BOOL quit, char *str1, char *str2, char *str3)
{
fprintf(stderr,str1,str2,str3);
if (quit) {
unlink(temp_arch);
_exit(1);
}
}
void usage()
{
error3(TRUE, "usage: %s %s archive [file] ...\n",
progname,
#ifdef AAL
"[acdrtxvlu]"
#else
"[acdprtxvlu]"
#endif
);
}
char *basename(char *path)
{
register char *ptr = path;
register char *last = NULL;
while (*ptr != '\0') {
if (*ptr == '/')
last = ptr;
ptr++;
}
if (last == NULL)
return path;
if (*(last + 1) == '\0') {
*last = '\0';
return basename(path);
}
return last + 1;
}
extern unsigned int rd_unsigned2();
int open_archive(char *name, int mode)
{
unsigned short magic = 0;
int fd;
if (mode == CREATE) {
if ((fd = creat(name, 0666)) < 0)
error2(TRUE, "cannot creat %s\n", name);
magic = MAGIC_NUMBER;
wr_int2(fd, magic);
return fd;
}
if ((fd = open(name, mode)) < 0) {
if (mode == APPEND) {
close(open_archive(name, CREATE));
if (!nocr_fl) error3(FALSE, "%s: creating %s\n", progname, name);
return open_archive(name, APPEND);
}
error2(TRUE, "cannot open %s\n", name);
}
lseek(fd, 0L, 0);
magic = rd_unsigned2(fd);
if (magic != AALMAG && magic != ARMAG)
error2(TRUE, "%s is not in ar format\n", name);
return fd;
}
#if __STDC__
void catch(int sig)
#else
catch()
#endif
{
unlink(temp_arch);
_exit (2);
}
int main(int argc, char *argv[])
{
register char *ptr;
int needs_arg = 0;
progname = argv[0];
if (argc < 3)
usage();
for (ptr = argv[1]; *ptr; ptr++) {
switch (*ptr) {
case 't' :
show_fl = TRUE;
break;
case 'v' :
verbose = TRUE;
break;
case 'x' :
ex_fl = TRUE;
break;
case 'a' :
needs_arg = 1;
app_fl = TRUE;
break;
case 'c' :
nocr_fl = TRUE;
break;
#ifndef AAL
case 'p' :
needs_arg = 1;
pr_fl = TRUE;
break;
#endif
case 'd' :
needs_arg = 1;
del_fl = TRUE;
break;
case 'r' :
needs_arg = 1;
rep_fl = TRUE;
break;
case 'l' :
local_fl = TRUE;
break;
case 'u' :
update_fl = TRUE;
break;
#ifdef DISTRIBUTION
case 'D' :
distr_fl = TRUE;
break;
#endif
default :
usage();
}
}
if (needs_arg && argc <= 3)
usage();
#ifdef DISTRIBUTION
if (distr_fl) {
struct stat statbuf;
stat(progname, &statbuf);
distr_time = statbuf.st_mtime;
}
#endif
if (local_fl) strcpy(temp_arch, "ar.XXXXXX");
else strcpy(temp_arch, "/usr/tmp/ar.XXXXXX");
if (app_fl + ex_fl + del_fl + rep_fl + show_fl + pr_fl != 1)
usage();
if (update_fl && !rep_fl)
usage();
if (rep_fl || del_fl
#ifdef AAL
|| app_fl
#endif
) {
mktemp(temp_arch);
}
#ifdef AAL
tab = (struct ranlib *) malloc(512 * sizeof(struct ranlib));
tstrtab = malloc(4096);
if (!tab || !tstrtab) error1(TRUE,"Out of core\n");
tabsz = 512;
strtabsz = 4096;
#endif
signal(SIGINT, catch);
get(argc, argv);
return 0;
}
MEMBER *
get_member()
{
static MEMBER member;
again:
if (rd_arhdr(ar_fd, &member) == 0)
return NULL;
if (member.ar_size < 0) {
error1(TRUE, "archive has member with negative size\n");
}
#ifdef AAL
if (equal(SYMDEF, member.ar_name)) {
lseek(ar_fd, member.ar_size, 1);
goto again;
}
#endif
return &member;
}
char *get_mode();
static void get(int argc, char *argv[])
{
register MEMBER *member;
int i = 0;
int temp_fd, read_chars;
ar_fd = open_archive(argv[2], (show_fl || pr_fl || ex_fl) ? READ : APPEND);
if (rep_fl || del_fl
#ifdef AAL
|| app_fl
#endif
)
temp_fd = open_archive(temp_arch, CREATE);
while ((member = get_member()) != NULL) {
if (argc > 3) {
for (i = 3; i < argc; i++) {
if (equal(basename(argv[i]), member->ar_name))
break;
}
if (i == argc || app_fl) {
if (rep_fl || del_fl
#ifdef AAL
|| app_fl
#endif
) {
#ifdef AAL
if (i != argc) {
print("%s: already in archive\n", argv[i]);
argv[i] = "";
}
#endif
wr_arhdr(temp_fd, member);
copy_member(member, ar_fd, temp_fd, 0);
}
else {
#ifndef AAL
if (app_fl && i != argc) {
print("%s: already in archive\n", argv[i]);
argv[i] = "";
}
#endif
lseek(ar_fd, even(member->ar_size),1);
}
continue;
}
}
if (ex_fl || pr_fl)
extract(member);
else {
if (rep_fl) {
int isold = 0;
if(update_fl) {
struct stat status;
if (stat(argv[i], &status) >= 0) {
if(status.st_mtime <= member->ar_date)
isold = 1;
}
}
if(!isold)
add(argv[i], temp_fd, "r - %s\n");
else {
wr_arhdr(temp_fd, member);
copy_member(member, ar_fd, temp_fd, 0);
if(verbose)
show("r - %s (old)\n", member->ar_name);
}
}
else if (show_fl) {
char buf[sizeof(member->ar_name) + 2];
register char *p = buf, *q = member->ar_name;
while (q <= &member->ar_name[sizeof(member->ar_name)-1] && *q) {
*p++ = *q++;
}
*p++ = '\n';
*p = '\0';
if (verbose) {
char *mode = get_mode(member->ar_mode);
char *date = ctime(&(member->ar_date));
*(date + 16) = '\0';
*(date + 24) = '\0';
print("%s%3u/%u%7ld %s %s %s",
mode,
(unsigned) (member->ar_uid & 0377),
(unsigned) (member->ar_gid & 0377),
member->ar_size,
date+4,
date+20,
buf);
}
else print(buf);
}
else if (del_fl)
show("d - %s\n", member->ar_name);
lseek(ar_fd, even(member->ar_size), 1);
}
argv[i] = "";
}
if (argc > 3) {
for (i = 3; i < argc; i++)
if (argv[i][0] != '\0') {
#ifndef AAL
if (app_fl)
add(argv[i], ar_fd, "a - %s\n");
else
#endif
if (rep_fl
#ifdef AAL
|| app_fl
#endif
)
add(argv[i], temp_fd, "a - %s\n");
else {
print("%s: not found\n", argv[i]);
}
}
}
if (rep_fl || del_fl
#ifdef AAL
|| app_fl
#endif
) {
signal(SIGINT, SIG_IGN);
close(ar_fd);
close(temp_fd);
ar_fd = open_archive(argv[2], CREATE);
temp_fd = open_archive(temp_arch, APPEND);
#ifdef AAL
write_symdef();
#endif
while ((read_chars = read(temp_fd, io_buffer, IO_SIZE)) > 0)
mwrite(ar_fd, io_buffer, read_chars);
close(temp_fd);
unlink(temp_arch);
}
close(ar_fd);
}
static void add(char *name, int fd, char *mess)
{
static MEMBER member;
register int read_chars;
struct stat status;
int src_fd;
if (stat(name, &status) < 0) {
error2(FALSE, "cannot find %s\n", name);
return;
}
else if (S_ISDIR(status.st_mode)) {
error2(FALSE, "%s is a directory (ignored)\n", name);
return;
}
else if ((src_fd = open(name, 0)) < 0) {
error2(FALSE, "cannot open %s\n", name);
return;
}
strncpy (member.ar_name, basename (name), sizeof(member.ar_name));
member.ar_uid = status.st_uid;
member.ar_gid = status.st_gid;
member.ar_mode = status.st_mode;
member.ar_date = status.st_mtime;
member.ar_size = status.st_size;
#ifdef DISTRIBUTION
if (distr_fl) {
member.ar_uid = 2;
member.ar_gid = 2;
member.ar_mode = 0644;
member.ar_date = distr_time;
}
#endif
wr_arhdr(fd, &member);
#ifdef AAL
do_object(src_fd, member.ar_size);
lseek(src_fd, 0L, 0);
offset += AR_TOTAL + even(member.ar_size);
#endif
while (status.st_size > 0) {
int x = IO_SIZE;
read_chars = x;
if (status.st_size < x) {
x = status.st_size;
read_chars = x;
status.st_size = 0;
x = even(x);
}
else status.st_size -= x;
if (read(src_fd, io_buffer, read_chars) != read_chars) {
error2(FALSE,"%s seems to shrink\n", name);
break;
}
mwrite(fd, io_buffer, x);
}
if (verbose)
show(mess, member.ar_name);
close(src_fd);
}
static void extract(register MEMBER *member)
{
int fd = 1;
char buf[sizeof(member->ar_name) + 1];
strncpy(buf, member->ar_name, sizeof(member->ar_name));
buf[sizeof(member->ar_name)] = 0;
if (pr_fl == FALSE && (fd = creat(buf, 0666)) < 0) {
error2(FALSE, "cannot create %s\n", buf);
fd = -1;
}
if (verbose) {
if (pr_fl == FALSE) show("x - %s\n", buf);
else show("\n<%s>\n\n", buf);
}
copy_member(member, ar_fd, fd, 1);
if (fd >= 0 && fd != 1)
close(fd);
if (pr_fl == FALSE) chmod(buf, member->ar_mode);
}
static void copy_member(MEMBER *member, int from, int to, int extracting)
{
register int rest;
long mem_size = member->ar_size;
BOOL is_odd = odd(mem_size) ? TRUE : FALSE;
#ifdef AAL
if (! extracting) {
long pos = lseek(from, 0L, 1);
do_object(from, mem_size);
offset += AR_TOTAL + even(mem_size);
lseek(from, pos, 0);
}
#endif
do {
rest = mem_size > (long) IO_SIZE ? IO_SIZE : (int) mem_size;
if (read(from, io_buffer, rest) != rest) {
char buf[sizeof(member->ar_name) + 1];
strncpy(buf, member->ar_name, sizeof(member->ar_name));
buf[sizeof(member->ar_name)] = 0;
error2(TRUE, "read error on %s\n", buf);
}
if (to >= 0) mwrite(to, io_buffer, rest);
mem_size -= (long) rest;
} while (mem_size > 0L);
if (is_odd) {
lseek(from, 1L, 1);
if (to >= 0 && ! extracting)
lseek(to, 1L, 1);
}
}
char *
get_mode(mode)
register int mode;
{
static char mode_buf[11];
register int tmp = mode;
int i;
mode_buf[9] = ' ';
for (i = 0; i < 3; i++) {
mode_buf[i * 3] = (tmp & S_IREAD) ? 'r' : '-';
mode_buf[i * 3 + 1] = (tmp & S_IWRITE) ? 'w' : '-';
mode_buf[i * 3 + 2] = (tmp & S_IEXEC) ? 'x' : '-';
tmp <<= 3;
}
if (mode & S_ISUID)
mode_buf[2] = 's';
if (mode & S_ISGID)
mode_buf[5] = 's';
return mode_buf;
}
void wr_fatal()
{
error1(TRUE, "write error\n");
}
void rd_fatal()
{
error1(TRUE, "read error\n");
}
static void mwrite(int fd, char *address, int bytes)
{
if (write(fd, address, bytes) != bytes)
error1(TRUE, "write error\n");
}
static void show(char *s, char *name)
{
MEMBER x;
char buf[sizeof(x.ar_name)+1];
register char *p = buf, *q = name;
while (q <= &name[sizeof(x.ar_name)-1] && *q) *p++ = *q++;
*p++ = '\0';
print(s, buf);
}
#ifdef AAL
/*
* Write out the ranlib table: first 4 bytes telling how many ranlib structs
* there are, followed by the ranlib structs,
* then 4 bytes giving the size of the string table, followed by the string
* table itself.
*/
static void write_symdef(void)
{
register struct ranlib *ran;
register int i;
register long delta;
MEMBER arbuf;
if (odd(tssiz))
tstrtab[tssiz++] = '\0';
for (i = 0; i < sizeof(arbuf.ar_name); i++)
arbuf.ar_name[i] = '\0';
strcpy(arbuf.ar_name, SYMDEF);
arbuf.ar_size = 4 + 2 * 4 * (long)tnum + 4 + (long)tssiz;
time(&arbuf.ar_date);
arbuf.ar_uid = getuid();
arbuf.ar_gid = getgid();
arbuf.ar_mode = 0444;
#ifdef DISTRIBUTION
if (distr_fl) {
arbuf.ar_uid = 2;
arbuf.ar_gid = 2;
arbuf.ar_date = distr_time;
}
#endif
wr_arhdr(ar_fd,&arbuf);
wr_long(ar_fd, (long) tnum);
/*
* Account for the space occupied by the magic number
* and the ranlib table.
*/
delta = 2 + AR_TOTAL + arbuf.ar_size;
for (ran = tab; ran < &tab[tnum]; ran++) {
ran->ran_pos += delta;
}
wr_ranlib(ar_fd, tab, (long) tnum);
wr_long(ar_fd, (long) tssiz);
wr_bytes(ar_fd, tstrtab, (long) tssiz);
}
/*
* Return whether the bytes in `buf' form a good object header.
* The header is put in `headp'.
*/
int
is_outhead(register struct outhead *headp)
{
return !BADMAGIC(*headp) && headp->oh_nname != 0;
}
static void do_object(int f, long size)
{
struct outhead headbuf;
if (size < SZ_HEAD) {
/* It can't be an object file. */
return;
}
/*
* Read a header to see if it is an object file.
*/
if (! rd_fdopen(f)) {
rd_fatal();
}
rd_ohead(&headbuf);
if (!is_outhead(&headbuf)) {
return;
}
do_names(&headbuf);
}
/*
* First skip the names and read in the string table, then seek back to the
* name table and read and write the names one by one. Update the ranlib table
* accordingly.
*/
static void do_names(struct outhead *headp)
{
register char *strings;
register int nnames = headp->oh_nname;
#define NNAMES 100
struct outname namebuf[NNAMES];
long xxx = OFF_CHAR(*headp);
if ( headp->oh_nchar != (unsigned int)headp->oh_nchar ||
(strings = malloc((unsigned int)headp->oh_nchar)) == (char *)0
) {
error1(TRUE, "string table too big\n");
}
rd_string(strings, headp->oh_nchar);
while (nnames) {
int i = nnames >= NNAMES ? NNAMES : nnames;
register struct outname *p = namebuf;
nnames -= i;
rd_name(namebuf, i);
while (i--) {
long off = p->on_foff - xxx;
if (p->on_foff == (long)0) {
p++;
continue; /* An unrecognizable name. */
}
p->on_mptr = strings + off;
/*
* Only enter names that are exported and are really
* defined. Also enter common names. Note, that
* this might cause problems when the name is really
* defined in a later file, with a value != 0.
* However, this problem also exists on the Unix
* ranlib archives.
*/
if ( (p->on_type & S_EXT) &&
(p->on_type & S_TYP) != S_UND
)
enter_name(p);
p++;
}
}
free(strings);
}
static void enter_name(struct outname *namep)
{
register char *cp;
if (tnum >= tabsz) {
tab = (struct ranlib *)
realloc((char *) tab, (tabsz += 512) * sizeof(struct ranlib));
if (! tab) error1(TRUE, "Out of core\n");
}
tab[tnum].ran_off = tssiz;
tab[tnum].ran_pos = offset;
for (cp = namep->on_mptr;; cp++) {
if (tssiz >= strtabsz) {
tstrtab = realloc(tstrtab, (strtabsz += 4096));
if (! tstrtab) error1(TRUE, "string table overflow\n");
}
tstrtab[tssiz++] = *cp;
if (!*cp) break;
}
tnum++;
}
#endif /* AAL */

View File

@@ -1,3 +0,0 @@
extern void rd_fatal();
extern void wr_fatal();

View File

@@ -1,9 +0,0 @@
#if defined(mc68020) || defined(mc68000) || defined(sparc)
#define BYTES_REVERSED 1
#define WORDS_REVERSED 1
#define CHAR_UNSIGNED 0
#else
#define BYTES_REVERSED 0
#define WORDS_REVERSED 0
#define CHAR_UNSIGNED 0
#endif

View File

@@ -1,112 +0,0 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Header$ */
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include <string.h>
extern char *long2str();
static int
integral(int c)
{
switch (c) {
case 'b':
return -2;
case 'd':
return 10;
case 'o':
return -8;
case 'u':
return -10;
case 'x':
return -16;
}
return 0;
}
/*VARARGS2*/
/*FORMAT1 $
%s = char *
%l = long
%c = int
%[uxbo] = unsigned int
%d = int
$ */
int
_format(char *buf, char *fmt, va_list argp)
{
register char *pf = fmt;
register char *pb = buf;
while (*pf) {
if (*pf == '%') {
register int width, base, pad, npad;
char *arg;
char cbuf[2];
char *badformat = "<bad format>";
/* get padder */
if (*++pf == '0') {
pad = '0';
++pf;
}
else
pad = ' ';
/* get width */
width = 0;
while (*pf >= '0' && *pf <= '9')
width = 10 * width + *pf++ - '0';
if (*pf == 's') {
arg = va_arg(argp, char *);
}
else
if (*pf == 'c') {
cbuf[0] = va_arg(argp, int);
cbuf[1] = '\0';
arg = &cbuf[0];
}
else
if (*pf == 'l') {
/* alignment ??? */
base = integral(*++pf);
if (base) {
arg = long2str(va_arg(argp,long), base);
}
else {
pf--;
arg = badformat;
}
}
else
if ((base = integral(*pf))) {
arg = long2str((long)va_arg(argp,int), base);
}
else
if (*pf == '%')
arg = "%";
else
arg = badformat;
npad = width - strlen(arg);
while (npad-- > 0)
*pb++ = pad;
while (*pb++ = *arg++);
pb--;
pf++;
}
else
*pb++ = *pf++;
}
return pb - buf;
}

View File

@@ -1,2 +0,0 @@
extern int _format(char *buf, char *fmt, va_list argp);

View File

@@ -1,19 +0,0 @@
/* $Header$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* collection of options, selected by including or excluding 'defines' */
/* Version number of the EM object code */
# define VERSION 3 /* 16 bits number */
/* The default machine used by ack, acc, apc */
# define ACKM "minix"
/* size of local machine, either 0 (for 16 bit address space), or 1 */
# undef BIGMACHINE
/* operating system, SYS_5, V7, BSD4_1 or BSD4_2; Do NOT delete the comment
in the next line! */
# define V7 1 /* SYSTEM */

View File

@@ -1,67 +0,0 @@
/* $Header$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* Integer to String translator
-> base is a value from [-16,-2] V [2,16]
-> base < 0: see 'val' as unsigned value
-> no checks for buffer overflow and illegal parameters
(1985, EHB)
*/
#define MAXWIDTH 32
char *
long2str(val, base)
register long val;
register int base;
{
static char numbuf[MAXWIDTH];
static char vec[] = "0123456789ABCDEF";
register char *p = &numbuf[MAXWIDTH];
int sign = (base > 0);
*--p = '\0'; /* null-terminate string */
if (val) {
if (base > 0) {
if (val < 0L) {
long v1 = -val;
if (v1 == val)
goto overflow;
val = v1;
}
else
sign = 0;
}
else
if (base < 0) { /* unsigned */
base = -base;
if (val < 0L) { /* taken from Amoeba src */
register int mod, i;
overflow:
mod = 0;
for (i = 0; i < 8 * sizeof val; i++) {
mod <<= 1;
if (val < 0)
mod++;
val <<= 1;
if (mod >= base) {
mod -= base;
val++;
}
}
*--p = vec[mod];
}
}
do {
*--p = vec[(int) (val % base)];
val /= base;
} while (val != 0L);
if (sign)
*--p = '-'; /* don't forget it !! */
}
else
*--p = '0'; /* just a simple 0 */
return p;
}

View File

@@ -1,76 +0,0 @@
/* $Header$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#include "byte_order.h"
#include <local.h>
#include <stdio.h>
#if CHAR_UNSIGNED
#define Xchar(ch) (ch)
#else
#define Xchar(ch) ((ch) & 0377)
#endif
#if ! defined(BYTES_REVERSED)
#define BYTES_REVERSED 1
#endif
#if ! defined(WORDS_REVERSED)
#define WORDS_REVERSED 1
#endif
#if BYTES_REVERSED
#define uget2(c) (Xchar((c)[0]) | ((unsigned) Xchar((c)[1]) << 8))
#define Xput2(i, c) (((c)[0] = (i)), ((c)[1] = (i) >> 8))
#define put2(i, c) { register int j = (i); Xput2(j, c); }
#else
#define uget2(c) (* ((unsigned short *) (c)))
#define Xput2(i, c) (* ((short *) (c)) = (i))
#define put2(i, c) Xput2(i, c)
#endif
#define get2(c) ((short) uget2(c))
#if WORDS_REVERSED || BYTES_REVERSED
#define get4(c) (uget2(c) | ((long) uget2((c)+2) << 16))
#define put4(l, c) { register long x=(l); \
Xput2((int)x,c); \
Xput2((int)(x>>16),(c)+2); \
}
#else
#define get4(c) (* ((long *) (c)))
#define put4(l, c) (* ((long *) (c)) = (l))
#endif
#define SECTCNT 3 /* number of sections with own output buffer */
#if BIGMACHINE
#define WBUFSIZ (8*BUFSIZ)
#else
#define WBUFSIZ BUFSIZ
#endif
struct fil {
int cnt;
char *pnow;
char *pbegin;
long currpos;
int fd;
char pbuf[WBUFSIZ];
};
extern struct fil __parts[];
#define PARTEMIT 0
#define PARTRELO (PARTEMIT+SECTCNT)
#define PARTNAME (PARTRELO+1)
#define PARTCHAR (PARTNAME+1)
#ifdef SYMDBUG
#define PARTDBUG (PARTCHAR+1)
#else
#define PARTDBUG (PARTCHAR+0)
#endif
#define NPARTS (PARTDBUG + 1)
#define getsect(s) (PARTEMIT+((s)>=(SECTCNT-1)?(SECTCNT-1):(s)))

View File

@@ -1,126 +0,0 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Header$ */
#ifndef __OUT_H_INCLUDED
#define __OUT_H_INCLUDED
/*
* output format for ACK assemblers
*/
#ifndef ushort
#define ushort unsigned short
#endif /* ushort */
struct outhead {
ushort oh_magic; /* magic number */
ushort oh_stamp; /* version stamp */
ushort oh_flags; /* several format flags */
ushort oh_nsect; /* number of outsect structures */
ushort oh_nrelo; /* number of outrelo structures */
ushort oh_nname; /* number of outname structures */
long oh_nemit; /* sum of all os_flen */
long oh_nchar; /* size of string area */
};
#define O_MAGIC 0x0201 /* magic number of output file */
#define O_STAMP 0 /* version stamp */
#define MAXSECT 64 /* Maximum number of sections */
#define HF_LINK 0x0004 /* unresolved references left */
#define HF_8086 0x0008 /* os_base specially encoded */
struct outsect {
long os_base; /* startaddress in machine */
long os_size; /* section size in machine */
long os_foff; /* startaddress in file */
long os_flen; /* section size in file */
long os_lign; /* section alignment */
};
struct outrelo {
char or_type; /* type of reference */
char or_sect; /* referencing section */
ushort or_nami; /* referenced symbol index */
long or_addr; /* referencing address */
};
struct outname {
union {
char *on_ptr; /* symbol name (in core) */
long on_off; /* symbol name (in file) */
} on_u;
#define on_mptr on_u.on_ptr
#define on_foff on_u.on_off
ushort on_type; /* symbol type */
ushort on_desc; /* debug info */
long on_valu; /* symbol value */
};
/*
* relocation type bits
*/
#define RELSZ 0x07 /* relocation length */
#define RELO1 1 /* 1 byte */
#define RELO2 2 /* 2 bytes */
#define RELO4 4 /* 4 bytes */
#define RELPC 0x08 /* pc relative */
#define RELBR 0x10 /* High order byte lowest address. */
#define RELWR 0x20 /* High order word lowest address. */
/*
* section type bits and fields
*/
#define S_TYP 0x007F /* undefined, absolute or relative */
#define S_EXT 0x0080 /* external flag */
#define S_ETC 0x7F00 /* for symbolic debug, bypassing 'as' */
/*
* S_TYP field values
*/
#define S_UND 0x0000 /* undefined item */
#define S_ABS 0x0001 /* absolute item */
#define S_MIN 0x0002 /* first user section */
#define S_MAX (S_TYP-1) /* last user section */
#define S_CRS S_TYP /* on_valu is symbol index which contains value */
/*
* S_ETC field values
*/
#define S_SCT 0x0100 /* section names */
#define S_LIN 0x0200 /* hll source line item */
#define S_FIL 0x0300 /* hll source file item */
#define S_MOD 0x0400 /* ass source file item */
#define S_COM 0x1000 /* Common name. */
#define S_STB 0xe000 /* entries with any of these bits set are
reserved for debuggers
*/
/*
* structure format strings
*/
#define SF_HEAD "22222244"
#define SF_SECT "44444"
#define SF_RELO "1124"
#define SF_NAME "4224"
/*
* structure sizes (bytes in file; add digits in SF_*)
*/
#define SZ_HEAD 20
#define SZ_SECT 20
#define SZ_RELO 8
#define SZ_NAME 12
/*
* file access macros
*/
#define BADMAGIC(x) ((x).oh_magic!=O_MAGIC)
#define OFF_SECT(x) SZ_HEAD
#define OFF_EMIT(x) (OFF_SECT(x) + ((long)(x).oh_nsect * SZ_SECT))
#define OFF_RELO(x) (OFF_EMIT(x) + (x).oh_nemit)
#define OFF_NAME(x) (OFF_RELO(x) + ((long)(x).oh_nrelo * SZ_RELO))
#define OFF_CHAR(x) (OFF_NAME(x) + ((long)(x).oh_nname * SZ_NAME))
#endif /* __OUT_H_INCLUDED */

View File

@@ -1,7 +0,0 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Header$ */
#define SSIZE 1024

View File

@@ -1,44 +0,0 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Header$ */
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include <system.h>
#include "param.h"
#include "format.h"
#include "write.h"
/*VARARGS*/
/*FORMAT0v $
%s = char *
%l = long
%c = int
%[uxbo] = unsigned int
%d = int
$ */
void
#if __STDC__
print(char *fmt, ...)
#else
print(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
va_list args;
char buf[SSIZE];
#if __STDC__
va_start(args, fmt);
#else
va_start(args);
#endif
sys_write(STDOUT, buf, _format(buf, fmt, args));
va_end(args);
}

View File

@@ -1,2 +0,0 @@
extern void print(char *fmt, ...);

View File

@@ -1,36 +0,0 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Header$ */
#ifndef __RANLIB_H_INCLUDED
#define __RANLIB_H_INCLUDED
#ifndef SYMDEF
# define SYMDEF "__.SYMDEF"
#endif /* SYMDEF */
/*
* Structure of the SYMDEF table of contents for an archive.
* SYMDEF begins with a long giving the number of ranlib
* structures that immediately follow, and then continues with a string
* table consisting of a long giving the number of bytes of
* strings that follow and then the strings themselves.
*/
struct ranlib {
union {
char *ran__ptr; /* symbol name (in core) */
long ran__off; /* symbol name (in file) */
} ran_u;
#define ran_ptr ran_u.ran__ptr
#define ran_off ran_u.ran__off
long ran_pos; /* library member is at this position */
};
#define SZ_RAN 8
#define SF_RAN "44"
extern void wr_ranlib(int fd, struct ranlib ran[], long cnt);
#endif /* __RANLIB_H_INCLUDED */

View File

@@ -1,247 +0,0 @@
/* $Header$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include "out.h"
#include "object.h"
#include "rd.h"
#include "rd_bytes.h"
extern long lseek();
/*
* Parts of the output file.
*/
#undef PARTEMIT
#undef PARTRELO
#undef PARTNAME
#undef PARTCHAR
#undef PARTDBUG
#undef NPARTS
#define PARTEMIT 0
#define PARTRELO 1
#define PARTNAME 2
#define PARTCHAR 3
#ifdef SYMDBUG
#define PARTDBUG 4
#else
#define PARTDBUG 3
#endif
#define NPARTS (PARTDBUG + 1)
static long offset[MAXSECT];
static int outfile;
static long outseek[NPARTS];
static long currpos;
static long rd_base;
#define OUTSECT(i) \
(outseek[PARTEMIT] = offset[i])
#define BEGINSEEK(p, o) \
(outseek[(p)] = (o))
static int sectionnr;
static
void OUTREAD(int p, char *b, long n)
{
register long l = outseek[p];
if (currpos != l) {
lseek(outfile, l, 0);
}
rd_bytes(outfile, b, n);
l += n;
currpos = l;
outseek[p] = l;
}
/*
* Open the output file according to the chosen strategy.
*/
int
rd_open(char *f)
{
int outfile = open(f, 0);
if (outfile < 0)
return 0;
return rd_fdopen(outfile);
}
static int offcnt;
int rd_fdopen(int fd)
{
register int i;
for (i = 0; i < NPARTS; i++) outseek[i] = 0;
offcnt = 0;
rd_base = lseek(fd, 0L, 1);
if (rd_base < 0) {
return 0;
}
currpos = rd_base;
outseek[PARTEMIT] = currpos;
outfile = fd;
sectionnr = 0;
return 1;
}
void rd_close()
{
close(outfile);
outfile = -1;
}
int rd_fd()
{
return outfile;
}
void rd_ohead(register struct outhead *head)
{
register long off;
OUTREAD(PARTEMIT, (char *) head, (long) SZ_HEAD);
#if ! (BYTES_REVERSED || WORDS_REVERSED)
if (sizeof(struct outhead) != SZ_HEAD)
#endif
{
register char *c = (char *) head + (SZ_HEAD-4);
head->oh_nchar = get4(c);
c -= 4; head->oh_nemit = get4(c);
c -= 2; head->oh_nname = uget2(c);
c -= 2; head->oh_nrelo = uget2(c);
c -= 2; head->oh_nsect = uget2(c);
c -= 2; head->oh_flags = uget2(c);
c -= 2; head->oh_stamp = uget2(c);
c -= 2; head->oh_magic = uget2(c);
}
off = OFF_RELO(*head) + rd_base;
BEGINSEEK(PARTRELO, off);
off += (long) head->oh_nrelo * SZ_RELO;
BEGINSEEK(PARTNAME, off);
off += (long) head->oh_nname * SZ_NAME;
BEGINSEEK(PARTCHAR, off);
#ifdef SYMDBUG
off += head->oh_nchar;
BEGINSEEK(PARTDBUG, off);
#endif
}
void rd_rew_relos(head)
register struct outhead *head;
{
register long off = OFF_RELO(*head) + rd_base;
BEGINSEEK(PARTRELO, off);
}
void rd_sect(sect, cnt)
register struct outsect *sect;
register unsigned int cnt;
{
register char *c = (char *) sect + cnt * SZ_SECT;
OUTREAD(PARTEMIT, (char *) sect, (long)cnt * SZ_SECT);
sect += cnt;
offcnt += cnt;
while (cnt--) {
sect--;
#if ! (BYTES_REVERSED || WORDS_REVERSED)
if (sizeof(struct outsect) != SZ_SECT)
#endif
{
c -= 4; sect->os_lign = get4(c);
c -= 4; sect->os_flen = get4(c);
c -= 4; sect->os_foff = get4(c);
}
offset[--offcnt] = sect->os_foff + rd_base;
#if ! (BYTES_REVERSED || WORDS_REVERSED)
if (sizeof(struct outsect) != SZ_SECT)
#endif
{
c -= 4; sect->os_size = get4(c);
c -= 4; sect->os_base = get4(c);
}
}
}
void rd_outsect(int s)
{
OUTSECT(s);
sectionnr = s;
}
/*
* We don't have to worry about byte order here.
*/
void rd_emit(emit, cnt)
char *emit;
long cnt;
{
OUTREAD(PARTEMIT, emit, cnt);
offset[sectionnr] += cnt;
}
void rd_relo(relo, cnt)
register struct outrelo *relo;
register unsigned int cnt;
{
OUTREAD(PARTRELO, (char *) relo, (long) cnt * SZ_RELO);
#if ! (BYTES_REVERSED || WORDS_REVERSED)
if (sizeof(struct outrelo) != SZ_RELO)
#endif
{
register char *c = (char *) relo + (long) cnt * SZ_RELO;
relo += cnt;
while (cnt--) {
relo--;
c -= 4; relo->or_addr = get4(c);
c -= 2; relo->or_nami = uget2(c);
relo->or_sect = *--c;
relo->or_type = *--c;
}
}
}
void rd_name(struct outname *name, unsigned int cnt)
{
OUTREAD(PARTNAME, (char *) name, (long) cnt * SZ_NAME);
#if ! (BYTES_REVERSED || WORDS_REVERSED)
if (sizeof(struct outname) != SZ_NAME)
#endif
{
register char *c = (char *) name + (long) cnt * SZ_NAME;
name += cnt;
while (cnt--) {
name--;
c -= 4; name->on_valu = get4(c);
c -= 2; name->on_desc = uget2(c);
c -= 2; name->on_type = uget2(c);
c -= 4; name->on_foff = get4(c);
}
}
}
void rd_string(char *addr, long len)
{
OUTREAD(PARTCHAR, addr, len);
}
#ifdef SYMDBUG
void rd_dbug(char *buf, long size)
{
OUTREAD(PARTDBUG, buf, size);
}
#endif

View File

@@ -1,10 +0,0 @@
/*
* Headers for rd.c
*/
#include "out.h"
extern void rd_string(char *addr, long len);
extern void rd_name(struct outname name[], unsigned int cnt);
extern int rd_fdopen(int fd);
extern void rd_ohead(register struct outhead head[]);

View File

@@ -1,39 +0,0 @@
/* $Header$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#include <sys/types.h>
#include <unistd.h>
#include <arch.h>
#include "object.h"
#include "arch.h"
#include "archiver.h"
int
rd_arhdr(int fd, register struct ar_hdr *arhdr)
{
char buf[AR_TOTAL];
register char *c = buf;
register char *p = arhdr->ar_name;
register int i;
i = read(fd, c, AR_TOTAL);
if (i == 0) return 0;
if (i != AR_TOTAL) {
rd_fatal();
}
i = 14;
while (i--) {
*p++ = *c++;
}
arhdr->ar_date = ((long) get2(c)) << 16; c += 2;
arhdr->ar_date |= ((long) get2(c)) & 0xffff; c += 2;
arhdr->ar_uid = *c++;
arhdr->ar_gid = *c++;
arhdr->ar_mode = get2(c); c += 2;
arhdr->ar_size = (long) get2(c) << 16; c += 2;
arhdr->ar_size |= (long) get2(c) & 0xffff;
return 1;
}

View File

@@ -1,35 +0,0 @@
/* $Header$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#define MININT (1 << (sizeof(int) * 8 - 1))
#define MAXCHUNK (~MININT) /* Highest count we read(2). */
/* Unfortunately, MAXCHUNK is too large with some compilers. Put it in
an int!
*/
#include <sys/types.h>
#include <unistd.h>
#include "archiver.h"
#include "rd_bytes.h"
static int maxchunk = MAXCHUNK;
/*
* We don't have to worry about byte order here.
* Just read "cnt" bytes from file-descriptor "fd".
*/
void rd_bytes(int fd, char *string, long cnt)
{
while (cnt) {
register int n = cnt >= maxchunk ? maxchunk : cnt;
if (read(fd, string, n) != n)
rd_fatal();
string += n;
cnt -= n;
}
}

View File

@@ -1,2 +0,0 @@
extern void rd_bytes(int fd, char *string, long cnt);

View File

@@ -1,16 +0,0 @@
/* $Header$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#include "object.h"
#include "rd_bytes.h"
unsigned int
rd_unsigned2(int fd)
{
char buf[2];
rd_bytes(fd, buf, 2L);
return uget2(buf);
}

View File

@@ -1,43 +0,0 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Header$ */
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include <system.h>
#include "param.h"
#include "format.h"
/*VARARGS*/
/*FORMAT1v $
%s = char *
%l = long
%c = int
%[uxbo] = unsigned int
%d = int
$ */
char *
#if __STDC__
sprint(char *buf, char *fmt, ...)
#else
sprint(buf, fmt, va_alist)
char *buf, *fmt;
va_dcl
#endif
{
va_list args;
#if __STDC__
va_start(args, fmt);
#else
va_start(args);
#endif
buf[_format(buf, fmt, args)] = '\0';
va_end(args);
return buf;
}

View File

@@ -1,24 +0,0 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* RCS: $Header$ */
#include <system.h>
File _sys_ftab[SYS_NOPEN] = {
{ 0, OP_READ},
{ 1, OP_APPEND},
{ 2, OP_APPEND}
};
File *
_get_entry()
{
register File *fp;
for (fp = &_sys_ftab[0]; fp < &_sys_ftab[SYS_NOPEN]; fp++)
if (fp->o_flags == 0)
return fp;
return (File *)0;
}

View File

@@ -1,49 +0,0 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* RCS: $Header$ */
#ifndef __SYSTEM_INCLUDED__
#define __SYSTEM_INCLUDED__
struct _sys_fildes {
int o_fd; /* UNIX filedescriptor */
int o_flags; /* flags for open; 0 if not used */
};
typedef struct _sys_fildes File;
extern File _sys_ftab[];
/* flags for sys_open() */
#define OP_READ 01
#define OP_WRITE 02
#define OP_APPEND 04
/* flags for sys_access() */
#define AC_EXIST 00
#define AC_READ 04
#define AC_WRITE 02
#define AC_EXEC 01
/* flags for sys_stop() */
#define S_END 0
#define S_EXIT 1
#define S_ABORT 2
/* standard file decsriptors */
#define STDIN &_sys_ftab[0]
#define STDOUT &_sys_ftab[1]
#define STDERR &_sys_ftab[2]
/* maximum number of open files */
#define SYS_NOPEN 20
/* return value for sys_break */
#define ILL_BREAK ((char *)0)
/* system's idea of block */
#ifndef BUFSIZ
#define BUFSIZ 1024
#endif
#endif /* __SYSTEM_INCLUDED__ */

View File

@@ -1,16 +0,0 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Header$ */
#ifndef _VARARGS_H
#define _VARARGS_H
typedef char *va_list;
# define __va_sz(mode) (((sizeof(mode) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
# define va_dcl int va_alist;
# define va_start(list) (list = (char *) &va_alist)
# define va_end(list)
# define va_arg(list,mode) (*((mode *)((list += __va_sz(mode)) - __va_sz(mode))))
#endif /* _VARARGS_H */

View File

@@ -1,30 +0,0 @@
/* $Header$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#include <arch.h>
#include "object.h"
#include "arch.h"
#include "write.h"
#include "wr_bytes.h"
void wr_arhdr(int fd, struct ar_hdr *arhdr)
{
char buf[AR_TOTAL];
register char *c = buf;
register char *p = arhdr->ar_name;
register int i = 14;
while (i--) {
*c++ = *p++;
}
put2((int)(arhdr->ar_date>>16),c); c += 2;
put2((int)(arhdr->ar_date),c); c += 2;
*c++ = arhdr->ar_uid;
*c++ = arhdr->ar_gid;
put2(arhdr->ar_mode,c); c += 2;
put2((int)(arhdr->ar_size>>16),c); c += 2;
put2((int)(arhdr->ar_size),c);
wr_bytes(fd, buf, (long) AR_TOTAL);
}

View File

@@ -1,33 +0,0 @@
/* $Header$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#define MININT (1 << (sizeof(int) * 8 - 1))
#define MAXCHUNK (~MININT) /* Highest count we write(2). */
/* Notice that MAXCHUNK itself might be too large with some compilers.
You have to put it in an int!
*/
#include <sys/types.h>
#include <unistd.h>
#include "wr_bytes.h"
#include "archiver.h"
static int maxchunk = MAXCHUNK;
/*
* Just write "cnt" bytes to file-descriptor "fd".
*/
void wr_bytes(int fd, register char *string, long cnt)
{
while (cnt) {
register int n = cnt >= maxchunk ? maxchunk : cnt;
if (write(fd, string, n) != n)
wr_fatal();
string += n;
cnt -= n;
}
}

View File

@@ -1,4 +0,0 @@
/*
* Exported symbols of wr_bytes.c
*/
extern void wr_bytes(int fd, register char *string, long cnt);

View File

@@ -1,16 +0,0 @@
/* $Header$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#include "object.h"
#include "wr_int2.h"
#include "wr_bytes.h"
void wr_int2(int fd, int i)
{
char buf[2];
put2(i, buf);
wr_bytes(fd, buf, 2L);
}

View File

@@ -1,2 +0,0 @@
extern void wr_int2(int fd, int i);

View File

@@ -1,16 +0,0 @@
/* $Header$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#include "object.h"
#include "wr_bytes.h"
#include "wr_long.h"
void wr_long(int fd, long l)
{
char buf[4];
put4(l, buf);
wr_bytes(fd, buf, 4L);
}

View File

@@ -1,2 +0,0 @@
extern void wr_long(int fd, long l);

View File

@@ -1,36 +0,0 @@
/* $Header$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#include <ranlib.h>
#include "object.h"
#include "wr_bytes.h"
#include "ranlib.h"
void wr_ranlib(int fd, struct ranlib *ran, long cnt)
{
#if ! (BYTES_REVERSED || WORDS_REVERSED)
if (sizeof (struct ranlib) != SZ_RAN)
#endif
{
char buf[100 * SZ_RAN];
while (cnt) {
register int i = (cnt > 100) ? 100 : cnt;
register char *c = buf;
long j = i * SZ_RAN;
cnt -= i;
while (i--) {
put4(ran->ran_off,c); c += 4;
put4(ran->ran_pos,c); c += 4;
ran++;
}
wr_bytes(fd, buf, j);
}
}
#if ! (BYTES_REVERSED || WORDS_REVERSED)
else wr_bytes(fd, (char *) ran, cnt * SZ_RAN);
#endif
}

View File

@@ -1,17 +0,0 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Header$ */
#include <sys/types.h>
#include <unistd.h>
#include <system.h>
#include "write.h"
int
sys_write(File *fp, char *bufptr, int nbytes)
{
if (! fp) return 0;
return write(fp->o_fd, bufptr, nbytes) == nbytes;
}

View File

@@ -1,3 +0,0 @@
#include "system.h"
extern int sys_write(File *fp, char *bufptr, int nbytes);

View File

@@ -1,13 +0,0 @@
# Makefile for acd
.include <bsd.own.mk>
PROG= acd
CPPFLAGS+= -DARCH=\"`arch`\" -DDESCR=\"/usr/lib/descr\"
LINKS+= ${BINDIR}/acd ${BINDIR}/cc
FILESDIR= /usr/lib
FILES= acd.descr
FILESNAME= descr
MAN=
.include <bsd.prog.mk>

File diff suppressed because it is too large Load Diff

View File

@@ -1,438 +0,0 @@
# ACD pass description for the ACK compilers.
#
# Pre-set variables.
# PROGRAM - Name the compiler driver is called with.
# ARCH - Default target architecture.
# Library directories search path.
L = /lib /usr/lib
# ACK Compilers support search path.
A = $L $L/ack
# ARCH must be defined.
ifndef ARCH
error "\$ARCH is not predefined"
# Get ARCH from the environment if set.
import ARCH
# Compiler passes.
ACK_CPP = $A/cpp.ansi $CPP_F $PREDEF $NOLINENO
ACK_CEM = $A/em_cemcom.ansi -L $CPP_F $PREDEF \
-Vw${W}.${W}i${W}.${W}p${P}.${W}f4.${W}s2.2l4.${W}d8.${W}
ACK_M2 = $A/em_m2 -I$MOD_INCL -WR \
-Vw${W}.${W}i${W}.${W}p${P}.${W}l4.${W}f4.${W}d8.${W}
ACK_PC = $A/em_pc \
-Vw${W}.${W}i${W}.${W}l4.${W}p${P}.${W}f8.${W}S${W}.${W}
MOD_INCL = $A/m2 +
ACK_DECODE = $A/em_decode
ACK_ENCODE = $A/em_encode
ACK_OPT = $A/em_opt
ACK_EGO = $A/em_ego -P $A/ego -M$EGO_DESCR
EGO_DESCR = $A/ego/${ARCH}descr +
ACK_OPT2 = $A/em_opt2
ACK_CG = $A/$ARCH/cg
ACK_AS = $A/$ARCH/as \-
ACK_LED = $A/em_led -a0:$W -a1:$W -a2:$W -a3:$W
ACK_CV = $A/cv
ASMCONV = /usr/bin/asmconv
AAL = /usr/bin/aal
# Minix predefined symbols.
CPP_F = -D__minix -D__minix3 -D__$ARCH
# Library path.
LIBPATH = $USERLIBPATH $A/$ARCH
# Default output "model".
MODEL = -sep
# Floating point is done in software.
LIBS = -fsoft
# Default optimization level.
OPT_LEVEL = 1
# Call names.
if $PROGRAM = acc
PROGRAM = cc
if $PROGRAM = apc
PROGRAM = pc
if $PROGRAM = am2
PROGRAM = m2
if $PROGRAM = kcc
PROGRAM = cc
# Default transformation target.
stop .out
# Select the runtime environment by option or program name.
arg -.c
if $PROGRAM = cc
ifndef RTSO
RTSO = -.c
LIBS = $LIBS + -.c
# Omit the runtime startoff, but keep the libraries.
arg -.o
RTSO =
arg -.$any
error ".$any: unknown language"
# Select the target architecture.
arg -m$arch
ARCH = $arch
# Preprocessor directives.
arg -D$name
arg -D $name
CPP_F = $CPP_F -D$name
arg -U$name
arg -U $name
CPP_F = $CPP_F -U$name
arg -I$dir
arg -I $dir
CPP_F = $CPP_F -I$dir
ACK_M2 = $ACK_M2 -I$dir
# Debugging.
arg -g # Add debugging info.
ACK_CEM = $ACK_CEM -g
ACK_CG = $ACK_CG -gdb
arg -n # Suppress line numbers.
ACK_M2 = $ACK_M2 -L
ACK_PC = $ACK_PC -L
arg -a # Enable assertions.
arg -A # Enable array bound checks.
ACK_M2 = $ACK_M2 $*
ACK_PC = $ACK_PC $*
# Language checking.
arg -w # No warnings.
ACK_CEM = $ACK_CEM $*
ACK_M2 = $ACK_M2 $*
ACK_PC = $ACK_PC $*
arg -ws # No strict warnings.
ACK_CEM = $ACK_CEM -s
ACK_M2 = $ACK_M2 -wR
arg -wa # No warnings and no strict warnings.
ACK_CEM = $ACK_CEM -a
ACK_M2 = $ACK_M2 -wR
arg -wo # No warnings about old style C.
ACK_CPP = $ACK_CPP -o
ACK_CEM = $ACK_CEM -o
ACK_M2 = $ACK_M2 -wO
arg -3 # Only accept 3rd generation Modula-2.
ACK_M2 = $ACK_M2 $*
arg -_ # Allow underscores in identifiers.
ACK_M2 = $ACK_M2 -U
ACK_PC = $ACK_PC -U
arg -w$any
arg -F
arg -m
# Ignore strange -w flags, and past and present i86 compiler flags.
# Stop suffix.
arg -c
stop .o
arg -c.$stop
stop .$stop
arg -E
stop .E
arg -P
CPP_F = $CPP_F -P
stop .i
arg -S
stop .s
# Optimization.
arg -O
OPT_LEVEL = 1
arg -OS # Optimize for size.
ACK_EGO = $ACK_EGO -S
arg -OT # Optimize for time.
ACK_EGO = $ACK_EGO -T
arg -O$n
numeric $n
OPT_LEVEL = $n
# Library search path.
arg -L$dir
arg -L $dir
USERLIBPATH = $USERLIBPATH $dir/$ARCH $dir
# -llib must be searched in $LIBPATH later.
arg -l$lib
arg -l $lib
$> = $LIBPATH/lib$lib.a
# Software floating point, hardware floating point, or no floating point.
arg -f
arg -fp
arg -fsoft
LIBS = $LIBS + -fsoft
arg -fhard
LIBS = $LIBS - -fsoft
arg -fnone
LIBS = $LIBS + -fnone
# Output model.
arg -com
MODEL = # Common I&D.
arg -sep
arg -i # Separate I&D.
MODEL = -sep
arg -r # Relocatable object (combined .o)
MODEL = -r
# Strip executable.
arg -s
ACK_LED = $ACK_LED -s
# Size of heap+stack.
arg -stack $size
ACK_CV = $ACK_CV -S $size
# Change output file.
arg -o$out
arg -o $out
OUT = $out
# Complain about just -D, -U, -I, ...
arg -D; arg -U; arg -I; arg -L; arg -l; arg -o; arg -stack
error "argument expected after '$*'"
arg -R$pass-$flag # The ACK way of passing options to passes.
arg -Wack-R$pass-$flag # The ACD way.
if $pass = cpp
ACK_CPP = $ACK_CPP -$flag
if $pass = cem
ACK_CEM = $ACK_CEM -$flag
if $pass = m2
ACK_M2 = $ACK_M2 -$flag
if $pass = pc
ACK_PC = $ACK_PC -$flag
if $pass = opt
ACK_OPT = $ACK_OPT -$flag
if $pass = ego
ACK_EGO = $ACK_EGO -$flag
if $pass = opt2
ACK_OPT2 = $ACK_OPT2 -$flag
if $pass = cg
ACK_CG = $ACK_CG -$flag
if $pass = as
ACK_AS = $ACK_AS -$flag
if $pass = led
ACK_LED = $ACK_LED -$flag
arg -Was-$dialect # Default assembly dialect.
ASDIALECT = $dialect
arg -W$any
# Ignore any other -W options.
# Complain about unknown options, don't give them to the loader.
arg -$any
error "$*: unknown option"
# Do the scanning phase early, we need to know the architecture.
scan
# The word and pointer sizes of the target.
if $ARCH = i86
W = 2; P = 2
if $ARCH = i386
W = 4; P = 4
ifndef W
error "$ARCH: unsupported architecture"
# Optimize -O2 or higher?
if (0 1 - $OPT_LEVEL) = (0 1)
ACK_EGO = $ACK_EGO -O$OPT_LEVEL
ACK_OPT = $ACK_OPT -m0 # Leave multiplication optimization to opt2.
prefer .m .gk
# Tell cem to reverse bitfields on the i386 to be compatible with gcc.
if $ARCH = i386
ACK_CEM = $ACK_CEM -Vr
# Predefined preprocessor flags.
PREDEF = -D_EM_WSIZE=$W -D_EM_PSIZE=$P -D_EM_SSIZE=2 -D_EM_LSIZE=4 \
-D_EM_FSIZE=4 -D_EM_DSIZE=8 -D__ACK__ -D_ACK
# Preprocess C source.
transform .c .i
$ACK_CPP $* > $>
# Preprocess any type of file and send it to standard output or $OUT.
transform "" .E
if $* = "-"
file = # Standard input.
else
file = $*
ifndef OUT
$ACK_CPP $file
else
$ACK_CPP $file > $OUT
# Compile C source to EM-code.
transform .c .k
transform .i .k
$ACK_CEM $* $>
ifndef RTSO
RTSO = -.c
LIBS = $LIBS + -.c
# Compact EM to readable EM.
transform .k .e
transform .m .e
transform .gk .e
transform .g .e
$ACK_DECODE $* > $>
# Readable EM to compact EM.
transform .e .k
ifhash $*
NOLINENO = -P # Encode chokes on cpp line directives.
apply .c .i
unset NOLINENO
$ACK_ENCODE $* > $>
# Peephole optimization.
transform .k .m
$ACK_OPT $* > $>
# Global optimization.
transform .m .gk
$ACK_EGO $* > $>
# Second peephole optimization after global optimization.
transform .gk .g
$ACK_OPT2 $* > $>
# EM-code to target machine assembly.
transform .m .ack.s
transform .g .ack.s
transform .m .s
transform .g .s
if $ARCH = i386
$ACK_CG -F__fp_hook $* > $>
else
$ACK_CG $* > $>
# How to treat plain .s?
ifndef ASDIALECT
transform .s .ack.s
$> = $*
# Assembly to object file.
transform .ack.s .o
ifhash $*
apply .c .i
if $> = $<.o
ifdef OUT
$> = $OUT
$ACK_AS -o $> $*
# Combine object files and libraries to an executable.
combine (.o .a) .out
if $MODEL = ()
model = -b0:0
if $MODEL = (-sep)
model = -b0:0 -b1:0
rtso =
if $RTSO = -.c
rtso = $A/$ARCH/crtso.o
libd = ; libc = ; libfp =
if (-.c - $LIBS) = ()
libd = $A/$ARCH/libd.a
libc = $A/$ARCH/libc.a
if (-fsoft - $LIBS) = ()
libfp = $A/$ARCH/libfp.a
libs = $libd $libc $libfp $A/$ARCH/libe.a
ifndef OUT
OUT = a.out
if (-r - $MODEL) = ()
# Combine to an object file.
$ACK_LED -r -o $OUT $*
else
# Combine to an executable.
mktemp EXE
$ACK_LED $model -o $EXE $rtso $* $libs $A/$ARCH/libend.a
$ACK_CV -x -m$ARCH $EXE $OUT
# Add object files to a library.
combine (.o) .a
if $> = $<.a
ifdef OUT
$> = $OUT
$AAL cr $> $*
# Assembly conversions.
# ACK assembly to ACK Xenix assembly.
transform .ack.s .ncc.s
ifhash $*
apply .c .i
$ASMCONV -m$ARCH ack ncc $* $>
# ACK assembly to GNU assembly.
transform .ack.s .gnu.s
ifhash $*
apply .c .i
$ASMCONV -m$ARCH ack gnu $* $>
# ACK Xenix assembly to ACK assembly.
transform .ncc.s .ack.s
ifhash $*
apply .c .i
$ASMCONV -m$ARCH ncc ack $* $>
# ACK Xenix assembly to GNU assembly.
transform .ncc.s .gnu.s
ifhash $*
apply .c .i
$ASMCONV -m$ARCH ncc gnu $* $>
# BCC assembly to ACK assembly.
transform .bas.s .ack.s
ifhash $*
apply .c .i
$ASMCONV -m$ARCH bas ack $* $>
# BCC assembly to ACK Xenix assembly.
transform .bas.s .ncc.s
ifhash $*
apply .c .i
$ASMCONV -m$ARCH bas ncc $* $>
# BCC assembly to GNU assembly.
transform .bas.s .gnu.s
ifhash $*
apply .c .i
$ASMCONV -m$ARCH bas gnu $* $>
#ifdef ASDIALECT
# Treat plain .s as being in the given dialect.
transform .s .$ASDIALECT.s
$> = $*

View File

@@ -0,0 +1,4 @@
PROG= acksize
MAN=
.include <bsd.prog.mk>

View File

@@ -1,4 +0,0 @@
PROG= ackstrip
MAN=
.include <bsd.prog.mk>

View File

@@ -1,169 +0,0 @@
/* strip - remove symbols. Author: Dick van Veen */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <a.out.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
/* Strip [file] ...
*
* - when no file is present, a.out is assumed.
*
*/
#define A_OUT "a.out"
#define NAME_LENGTH 128 /* max file path name */
char buffer[BUFSIZ]; /* used to copy executable */
char new_file[NAME_LENGTH]; /* contains name of temporary */
struct exec header;
_PROTOTYPE(int main, (int argc, char **argv));
_PROTOTYPE(void strip, (char *file));
_PROTOTYPE(int read_header, (int fd));
_PROTOTYPE(int write_header, (int fd));
_PROTOTYPE(int make_tmp, (char *new_name, char *name));
_PROTOTYPE(int copy_file, (int fd1, int fd2, long size));
int main(argc, argv)
int argc;
char **argv;
{
argv++;
if (*argv == NULL)
strip(A_OUT);
else
while (*argv != NULL) {
strip(*argv);
argv++;
}
return(0);
}
void strip(file)
char *file;
{
int fd, new_fd;
struct stat buf;
long symb_size, relo_size;
fd = open(file, O_RDONLY);
if (fd == -1) {
fprintf(stderr, "can't open %s\n", file);
close(fd);
return;
}
if (read_header(fd)) {
fprintf(stderr, "%s: not an executable file\n", file);
close(fd);
return;
}
if (header.a_syms == 0L) {
close(fd); /* no symbol table present */
return;
}
symb_size = header.a_syms;
header.a_syms = 0L; /* remove table size */
fstat(fd, &buf);
relo_size = buf.st_size - (A_MINHDR + header.a_text + header.a_data + symb_size);
new_fd = make_tmp(new_file, file);
if (new_fd == -1) {
fprintf(stderr, "can't create temporary file\n");
close(fd);
return;
}
if (write_header(new_fd)) {
fprintf(stderr, "can't write temporary file\n");
unlink(new_file);
close(fd);
close(new_fd);
return;
}
if (copy_file(fd, new_fd, header.a_text + header.a_data)) {
fprintf(stderr, "can't copy %s\n", file);
unlink(new_file);
close(fd);
close(new_fd);
return;
}
if (relo_size != 0) {
lseek(fd, symb_size, 1);
if (copy_file(fd, new_fd, relo_size)) {
fprintf(stderr, "can't copy %s\n", file);
unlink(new_file);
close(fd);
close(new_fd);
return;
}
}
close(fd);
close(new_fd);
if (unlink(file) == -1) {
fprintf(stderr, "can't unlink %s\n", file);
unlink(new_file);
return;
}
link(new_file, file);
unlink(new_file);
chmod(file, buf.st_mode);
}
int read_header(fd)
int fd;
{
if (read(fd, (char *) &header, A_MINHDR) != A_MINHDR) return(1);
if (BADMAG(header)) return (1);
if (header.a_hdrlen > sizeof(struct exec)) return (1);
lseek(fd, 0L, SEEK_SET); /* variable size header */
if (read(fd, (char *)&header, (int)header.a_hdrlen) != (int) header.a_hdrlen)
return(1);
return(0);
}
int write_header(fd)
int fd;
{
lseek(fd, 0L, SEEK_SET);
if (write(fd, (char *)&header, (int)header.a_hdrlen) != (int)header.a_hdrlen)
return(1);
return(0);
}
int make_tmp(new_name, name)
char *new_name, *name;
{
int len;
char *nameptr;
len = strlen(name);
if (len + 1 > NAME_LENGTH) return(-1);
strcpy(new_name, name);
nameptr = strrchr(new_name, '/');
if (nameptr == NULL) nameptr = new_name - 1;
if (nameptr - new_name + 6 + 1 > NAME_LENGTH) return (-1);
strcpy(nameptr + 1, "XXXXXX");
mktemp(new_name);
return(creat(new_name, 0777));
}
int copy_file(fd1, fd2, size)
int fd1, fd2;
long size;
{
int length;
while (size > 0) {
if (size < sizeof(buffer))
length = size;
else
length = sizeof(buffer);
if (read(fd1, buffer, length) != length) return(1);
if (write(fd2, buffer, length) != length) return (1);
size -= length;
}
return(0);
}

View File

@@ -181,26 +181,49 @@ int main(int argc, char *argv[])
if (!(high_byte & 0x80)) /* class A or 0 */
{
if (destination)
#ifdef __NBSD_LIBC
defaultmask= htonl(0xff000000);
#else
defaultmask= HTONL(0xff000000);
#endif
}
else if (!(high_byte & 0x40)) /* class B */
{
#ifdef __NBSD_LIBC
defaultmask= htonl(0xffff0000);
#else
defaultmask= HTONL(0xffff0000);
#endif
}
else if (!(high_byte & 0x20)) /* class C */
{
#ifdef __NBSD_LIBC
defaultmask= htonl(0xffffff00);
#else
defaultmask= HTONL(0xffffff00);
#endif
}
else /* class D is multicast ... */
{
fprintf(stderr, "%s: Warning: Martian address '%s'\n",
prog_name, inet_ntoa(destination));
#ifdef __NBSD_LIBC
defaultmask= htonl(0xffffffff);
#else
defaultmask= HTONL(0xffffffff);
#endif
}
if (destination & ~defaultmask)
{
/* host route */
#ifdef __NBSD_LIBC
defaultmask= htonl(0xffffffff);
#else
defaultmask= HTONL(0xffffffff);
#endif
}
if (!cidr)
netmask= defaultmask;

View File

@@ -1,4 +0,0 @@
SCRIPTS= adduser.sh
MAN=
.include <bsd.prog.mk>

View File

@@ -1,121 +0,0 @@
#!/bin/sh
#
# adduser 1.0 - add a new user to the system Author: Kees J. Bot
# 16 Jan 1996
# Check arguments.
case "$#" in
3) user="$1"; group="$2"; home="$3"
;;
*) echo "Usage: adduser user group home-dir" >&2; exit 1
esac
# We need to be root.
case "`id`" in
'uid=0('*)
;;
*) echo "adduser: you must be root to add users" >&2; exit 1
esac
# User and group names must be alphanumeric and no longer than 8 characters.
len=`expr "$user" : '[a-z][a-z0-9]*$'`
if [ "$len" -eq 0 -o "$len" -gt 8 ]
then
echo >&2 \
"adduser: the user name must be alphanumeric and no longer than 8 characters"
exit 1
fi
len=`expr "$group" : '[a-z][a-z0-9]*$'`
if [ "$len" -eq 0 -o "$len" -gt 8 ]
then
echo >&2 \
"adduser: the group name must be alphanumeric and no longer than 8 characters"
exit 1
fi
# The new user name must not exist, but the group must exist.
if grep "^$user:" /etc/passwd >/dev/null
then
echo "adduser: user $user already exists" >&2
exit 1
fi
gid=`sed -e "/^$group:/!d" -e 's/^[^:]*:[^:]*:\\([^:]*\\):.*/\\1/' /etc/group`
if [ `expr "$gid" : '[0-9]*$'` -eq 0 ]
then
echo "adduser: group $group does not exist" >&2
exit 1
fi
# Find the first free user-id of 10 or higher.
uid=10
while grep "^[^:]*:[^:]*:$uid:.*" /etc/passwd >/dev/null
do
uid=`expr $uid + 1`
done
# No interruptions.
trap '' 1 2 3 15
# Lock the password file.
ln /etc/passwd /etc/ptmp || {
echo "adduser: password file busy, try again later"
exit 1
}
# Make the new home directory, it should not exist already.
mkdir "$home" || {
rm -rf /etc/ptmp
exit 1
}
# Make the new home directory by copying the honorary home directory of our
# fearless leader.
echo cpdir /usr/ast "$home"
cpdir /usr/ast "$home" || {
rm -rf /etc/ptmp "$home"
exit 1
}
# Change the ownership to the new user.
echo chown -R $uid:$gid "$home"
chown -R $uid:$group "$home" || {
rm -rf /etc/ptmp "$home"
exit 1
}
# Is there a shadow password file? If so add an entry.
if [ -f /etc/shadow ]
then
echo "echo $user::0:0::: >>/etc/shadow"
echo "$user::0:0:::" >>/etc/shadow || {
rm -rf /etc/ptmp "$home"
exit 1
}
pwd="##$user"
else
pwd=
fi
# Finish up by adding a password file entry.
echo "echo $user:$pwd:$uid:$gid:$user:$home: >>/etc/passwd"
echo "$user:$pwd:$uid:$gid:$user:$home:" >>/etc/passwd || {
rm -rf /etc/ptmp "$home"
exit 1
}
# Remove the lock.
rm /etc/ptmp || exit
echo "
The new user $user has been added to the system. Note that the password,
full name, and shell may be changed with the commands passwd(1), chfn(1),
and chsh(1). The password is now empty, so only console logins are possible."
if [ $gid = 0 ]
then
echo "\
Also note that a new operator needs an executable search path (\$PATH) that
does not contain the current directory (an empty field or "." in \$PATH)."
fi
exit 0

View File

@@ -1,34 +0,0 @@
# Makefile for advent
PROG= advent
SRCS= advent.c database.c english.c initial.c itverb.c score.c \
travel.c turn.c utility.c verb.c vocab.c
# Where to put the adventure text files
# Need the trailing "/" on TEXTDIR
TEXTDIR= /usr/lib/advent/
FILESDIR= ${TEXTDIR}
DATFILES= advent1.dat advent2.dat advent3.dat advent4.dat
FILES= ${DATFILES}
MAN=
database.o: advtext.h
setup: setup.c advent.h
${CC} ${CPPFLAGS} ${LDFLAGS} -o $@ ${.CURDIR}/setup.c
advtext.h advent1.dat advent2.dat advent3.dat advent4.dat: \
setup advent1.txt advent2.txt advent3.txt advent4.txt
./setup ${.CURDIR}
database.d: touch-genfiles
touch-genfiles:
[ -e advtext.h ] || touch -t 197001010000.00 advtext.h
CPPFLAGS.advent.c= -DTEXTDIR='"${TEXTDIR}"'
CLEANFILES+= ${DATFILES} advtext.h setup
.include <bsd.prog.mk>

File diff suppressed because it is too large Load Diff

View File

@@ -1,71 +0,0 @@
/* header ADVDEC.H *
* WARNING: GLOBAL (EXTERNAL) declarations for adventure */
#ifndef EXTERN /* #define as '' to define the variables */
#define EXTERN extern
#endif
EXTERN boolean gaveup; /* TRUE if he quits early */
EXTERN FILE *fd1, *fd2, *fd3, *fd4;
/*
English variables
*/
EXTERN char *vtxt[MAXWORDS], *iotxt[MAXITEMS], *otxt[MAXITEMS];
EXTERN int verbs[MAXWORDS], objs[MAXITEMS], iobjs[MAXITEMS];
EXTERN int vrbx, objx, iobx;
EXTERN int verb, object, motion, iobj, prep;
EXTERN boolean newtravel, is_wiz;
/*
Play variables
*/
extern int plac[MAXOBJ]; /* initial location */
extern int fixd[MAXOBJ];
struct playinfo {
int turns;
int loc, oldloc, oldloc2, newloc; /* location variables */
long loc_attrib[MAXLOC+1]; /* location status */
int place[MAXOBJ]; /* object location */
int fixed[MAXOBJ]; /* second object loc */
int weight[MAXOBJ];
int atloc[MAXLOC+1];
int link[MAXOBJ * 2];
int holder[MAXOBJ];
int hlink[MAXOBJ];
int visited[MAXLOC+1]; /* >0 if has been here */
int prop[MAXOBJ]; /* status of object */
long obj_state[MAXOBJ];
long points[MAXOBJ];
int hinted[HNTMAX+1];
int hints[HNTMAX+1][5];
int hintlc[HNTMAX+1];
int tally, tally2; /* item counts */
int limit; /* time limit */
int lmwarn; /* lamp warning flag */
int wzdark, closing, closed; /* game state flags */
int holding; /* count of held items */
int detail; /* LOOK count */
int knfloc; /* knife location */
int clock, clock2, panic; /* timing variables */
int dloc[DWARFMAX+1]; /* dwarf locations */
int dflag; /* dwarf flag */
int dseen[DWARFMAX+1]; /* dwarf seen flag */
int odloc[DWARFMAX+1]; /* dwarf old locations */
int daltloc; /* alternate appearance */
int dkill; /* dwarves killed */
int chloc, chloc2; /* chest locations */
int bonus; /* to pass to end */
int numdie; /* number of deaths */
int foobar; /* fee fie foe foo... */
int combo; /* combination for safe */
boolean terse;
int abbnum;
int health;
int chase;
boolean flg239;
int lastglob; /* to get space req. */
};
extern struct playinfo g;

View File

@@ -1,136 +0,0 @@
/** Adventure translated from Fortran to "C"
and ported to Minix by:
Robert R. Hall
San Diego, Calif 92115
hall@crash.cts.com
*/
/** program ADVENT.C *
* "advent.c" allocates GLOBAL storage space by *
* #defining EXTERN before #including "advdec.h". */
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <errno.h>
#include "advent.h" /* #define preprocessor equates */
#include "advdec.h"
#ifndef TEXTDIR
#define TEXTDIR ""
#endif
char textdir[] = TEXTDIR; /* directory where text files
live. */
_PROTOTYPE(int main, (int, char **));
_PROTOTYPE(static void opentxt, (void));
_PROTOTYPE(static void file_error, (char *));
int main(argc, argv)
int argc;
char **argv;
{
opentxt();
initialize();
rspeak(325);
if (argc == 2)
restore(argv[1]);
else {
g.hinted[3] = yes(65, 1, 0);
g.limit = (g.hinted[3] ? 800 : 550);
}
gaveup = FALSE;
srand((unsigned) time(NULL)); /* seed random */
while (!gaveup)
turn();
fclose(fd1);
fclose(fd2);
fclose(fd3);
fclose(fd4);
return (EXIT_SUCCESS); /* exit = ok */
} /* main */
/*
Open advent?.txt files
*/
static void opentxt()
{
static char filename[sizeof(textdir) + 16];
static FILE **fp[] = {0, &fd1, &fd2, &fd3, &fd4};
int i;
for (i = 1; i <= 4; i++) {
sprintf(filename, "%sadvent%d.dat", textdir, i);
*fp[i] = fopen(filename, "r");
if (!*fp[i])
file_error(filename);
}
}
/*
save adventure game
*/
void saveadv(username)
char *username;
{
int cnt;
FILE *savefd;
savefd = fopen(username, "wb");
if (savefd == NULL) {
perror(username);
return;
}
cnt = fwrite((void *) &g, 1, sizeof(struct playinfo), savefd);
if (cnt != sizeof(struct playinfo)) {
fprintf(stderr, "wrote %d of %u bytes\n",
cnt, (unsigned) sizeof(struct playinfo));
if (ferror(savefd)) {
fprintf(stderr, "errno is: 0x%.4x\n", errno);
perror(username);
}
}
if (fclose(savefd) == -1) {
perror(username);
}
printf("Saved in %s.\n", username);
return;
}
/*
restore saved game handler
*/
void restore(username)
char *username;
{
int cnt;
FILE *restfd;
restfd = fopen(username, "rb");
if (restfd == NULL)
file_error(username);
cnt = fread((void *) &g, 1, sizeof(struct playinfo), restfd);
if (cnt != sizeof(struct playinfo)) {
fprintf(stderr, "read %d bytes, expected %u\n",
cnt, (unsigned) sizeof(struct playinfo));
if (ferror(restfd)) {
fprintf(stderr, "errno is: 0x%.4x\n", errno);
perror(username);
}
}
if (fclose(restfd) == -1) {
perror(username);
}
printf("Restored from %s.\n", username);
return;
}
static void file_error(filename)
char *filename;
{
perror(filename);
exit(EXIT_FAILURE);
}

View File

@@ -1,405 +0,0 @@
/* header ADVENT.H *
* WARNING: HEADER file for all adventure modules */
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#define EXIT_SUCCESS (!(EXIT_FAILURE))
#endif
#define INPUTBUFLEN 80 /* Max input line length */
typedef int boolean;
#define FALSE (0)
#define TRUE (!FALSE)
#define MAXOBJ 123 /* max # of objects in cave */
#define MAXLOC 248 /* max # of cave locations */
#define WORDSIZE 20 /* max # of chars in commands */
#define MAXMSG 408 /* max # of long location descr */
#define HNTMAX 18 /* max # of hints */
#define HNTMIN 7 /* hints starting count */
#define MAXWORDS 25
#define MAXITEMS 45
#define CLASS(word) ((word)<0 ? -((-(word)) / 1000) : (word) / 1000)
#define VAL(word) ((word)<0 ? -((-(word)) % 1000) : (word) % 1000)
#define MAXTRAV (23+1) /* max # of travel directions from loc */
/* +1 for terminator travel[x].tdest=-1 */
#define DWARFMAX 6 /* max # of nasty dwarves */
#define MAXDIE 3 /* max # of deaths before close */
#define MAXTRS 79 /* max # of */
#define Y2 33
/*
Object definitions
*/
#define ANVIL 91
#define AXE 28
#define BATTERIES 39
#define BEAR 35
#define BEES 87
#define BILLBD 116
#define BIRD 101
#define BOAT 48
#define BOOK 110
#define BOOK2 BOOK + 1
#define BOOTH 93
#define BOTTLE 20
#define BRUSH 114
#define CAGE 4
#define CAKES 107
#define CARVNG 115
#define CASK 71
#define CHAIN 64
#define CHASM 21
#define CHASM2 CHASM + 1
#define CHEST 55
#define CLAM 14
#define CLOAK 47
#define COINS 54
#define CROWN 66
#define DOG 98
#define DOOR 41 /* giant door */
#define DRAGON 31
#define DWARF 17
#define EGGS 56
#define EMERALD 59
#define FISSURE 12
#define FLOWER 46
#define FLY 69
#define FOOD 19
#define GNOME 105
#define GRAIL 70
#define GRATE 3
#define HIVE 97
#define HONEY 96
#define HORN 52
#define JEWELS 53
#define KEYS 102
#define KNIFE 18
#define LAMP 2
#define LYRE 68
#define MAGAZINE 16
#define MESSAGE 36
#define MIRROR 23
#define MUSHRM 106
#define NUGGET 50
#define OIL 83
#define OIL2 OIL + 1
#define OYSTER 15
#define PLAGUE 125
#define PEARL 61
#define PHONE 94
#define PILLOW 10
#define PLANT 24
#define PLANT2 PLANT + 1
#define POLE 9
#define POSTER 113
#define PYRAMID 60
#define RADIUM 119
#define RING 72
#define ROCKS 92
#define ROD 5
#define ROD2 ROD + 1
#define RUG 62
#define SAFE 112
#define SAPPHIRE 69
#define SHIELD 118
#define SHOES 67
#define SKEY 90
#define SLUGS 95
#define SNAKE 11
#define SPHERE 120
#define SPICES 63
#define SPIDER 121
#define STEPS 7
#define STICKS 49
#define SWORD 65
#define TABLET 13
#define TDOOR 42 /* tiny door */
#define TDOOR2 TDOOR + 1 /* wrought-iron door */
#define PDOOR TDOOR2 + 1 /* door to phone booth */
#define TRIDENT 57
#define TROLL 33
#define TROLL2 TROLL + 1
#define VASE 58
#define VEND 38
#define WALL 88
#define WALL2 WALL + 1
#define WATER 81 /* in bottle */
#define WATER2 WATER + 1 /* in cask */
#define WINE 85 /* in bottle */
#define WINE2 WINE + 1 /* in cask */
#define WUMPUS 99
/*
Verb definitions
*/
#define BACK 8
#define CAVE 67
#define DEPRESSION 63
#define ENTRANCE 64
#define EXIT 11
#define NULLX 21
/*
Action verb definitions
*/
#define TAKE 1
#define DROP 2
#define SAY 3
#define OPEN 4
#define NOTHING 5
#define CLOSE 6
#define ON 7
#define OFF 8
#define WAVE 9
#define CALM 10
#define WALK 11
#define KILL 12
#define POUR 13
#define EAT 14
#define DRINK 15
#define RUB 16
#define THROW 17
#define QUIT 18
#define FIND 19
#define INVENTORY 20
#define FEED 21
#define FILL 22
#define BLAST 23
#define SCORE 24
#define FOO 25
#define BRIEF 26
#define READ 27
#define BREAK 28
#define WAKE 29
#define SUSPEND 30
#define RESTORE 31
#define YANK 32
#define WEAR 33
#define HIT 34
#define ANSWER 35
#define BLOW 36
#define LEAVE 37
#define YELL 38
#define DIAL 39
#define PLAY 40
#define PICK 41
#define PUT 42
#define TURN 43
#define GET 44
#define INSRT 45
#define REMOVE 46
#define BURN 47
#define GRIPE 48
#define LOCK 49
#define UNLOCK 50
#define HEALTH 51
#define LOOK 52
#define COMBO 53
#define SWEEP 54
#define TERSE 55
#define WIZ 56
#define MAP 57
#define GATE 58
#define PIRLOC 59
#define GO 11
#define SHUT 6
#define LOG 33
#define MOTION 0 /* CLASSD */
#define NOUN 1 /* CLASSN */
#define ACTION 2 /* CLASSA */
#define MISC 3 /* CLASSM */
#define PREPOSITION 4 /* CLASSP */
#define ADJACTIVE 5 /* CLASSJ */
#define CONJUNCTION 6 /* CLASSC */
/*
and a few preposition. prefix PREP to distinguish them from
verbs or nouns
*/
#define PREPAT 9
#define PREPDN 8
#define PREPIN 1
#define PREPFR 5
#define PREPOF 6
#define PREPOFF 6
#define PREPON 2
/*
BIT mapping of "cond" array which indicates location status
*/
#define LIGHT 1
#define WATOIL 2
#define LIQUID 4
#define NOPIRAT 16
/* Object condition bit functions */
#define OPENBT 2
#define LOCKBT 4
#define BURNBT 6
#define DEADBT 10
#define WEARBT 12
/*
Structure definitions
*/
struct wac {
char *aword;
int acode;
};
struct trav {
int tdest;
int tverb;
int tcond;
};
/* Function prototypes.
"#if (__STDC__)" should have been be enough,
but some compilers are stupid, so allow Makefile to say -DHAS_STDC=whatever.
*/
#if defined(HAS_STDC) ? (HAS_STDC) : (__STDC__)
#undef HAS_STDC
#define HAS_STDC 1
#define _PROTOTYPE(function, params) function params
#define _CONST const
#else
#define _PROTOTYPE(function, params) function ()
#define _CONST
#endif
/* Advent.c */
_PROTOTYPE(void saveadv, (char *username));
_PROTOTYPE(void restore, (char *username));
/* Initialize.c */
_PROTOTYPE(void initialize, (void));
/* Database.c */
_PROTOTYPE(int yes, (int msg1, int msg2, int msg3));
_PROTOTYPE(void rspeak, (int msg));
_PROTOTYPE(void pspeak, (int item, int state));
_PROTOTYPE(void desclg, (int loc));
_PROTOTYPE(void descsh, (int loc));
/* English.c */
_PROTOTYPE(int english, (void));
_PROTOTYPE(int analyze, (char *word, int *type, int *value));
/* Itverb.c */
_PROTOTYPE(void itverb, (void));
_PROTOTYPE(void ivblast, (void));
_PROTOTYPE(void ivlook, (void));
/* Turn.c */
_PROTOTYPE(void turn, (void));
_PROTOTYPE(void describe, (void));
_PROTOTYPE(void descitem, (void));
_PROTOTYPE(void dwarfend, (void));
_PROTOTYPE(void normend, (void));
_PROTOTYPE(void score, (int));
_PROTOTYPE(void death, (void));
_PROTOTYPE(char *probj, (void));
_PROTOTYPE(void trobj, (void));
_PROTOTYPE(void dwarves, (void));
_PROTOTYPE(void dopirate, (void));
_PROTOTYPE(int stimer, (void));
/* Verb.c */
_PROTOTYPE(void trverb, (void));
_PROTOTYPE(void vtake, (void));
_PROTOTYPE(void vdrop, (void));
_PROTOTYPE(void vopen, (void));
_PROTOTYPE(void vsay, (void));
_PROTOTYPE(void von, (void));
_PROTOTYPE(void voff, (void));
_PROTOTYPE(void vwave, (void));
_PROTOTYPE(void vkill, (void));
_PROTOTYPE(void vpour, (void));
_PROTOTYPE(void veat, (void));
_PROTOTYPE(void vdrink, (void));
_PROTOTYPE(void vthrow, (void));
_PROTOTYPE(void vfind, (void));
_PROTOTYPE(void vfill, (void));
_PROTOTYPE(void vfeed, (void));
_PROTOTYPE(void vread, (void));
_PROTOTYPE(void vbreak, (void));
_PROTOTYPE(void vwake, (void));
_PROTOTYPE(void actspk, (int verb));
_PROTOTYPE(void vyank, (void));
_PROTOTYPE(void vwear, (void));
_PROTOTYPE(void vlock, (void));
_PROTOTYPE(void vunlock, (void));
_PROTOTYPE(void vclose, (void));
/* Utility.c */
_PROTOTYPE(boolean ajar, (int));
_PROTOTYPE(boolean at, (int item));
_PROTOTYPE(boolean athand, (int));
_PROTOTYPE(void bitoff, (int, int));
_PROTOTYPE(void biton, (int, int));
_PROTOTYPE(boolean bitset, (long, int));
_PROTOTYPE(boolean blind, (void));
_PROTOTYPE(int burden, (int));
_PROTOTYPE(void carry, (int obj, int where));
_PROTOTYPE(int confuz, (void));
_PROTOTYPE(boolean dark, (void));
_PROTOTYPE(boolean dcheck, (void));
_PROTOTYPE(boolean dead, (int));
_PROTOTYPE(void drop, (int obj, int where));
_PROTOTYPE(void destroy, (int obj));
_PROTOTYPE(boolean edible, (int));
_PROTOTYPE(boolean enclosed, (int));
_PROTOTYPE(void extract, (int));
_PROTOTYPE(boolean forced, (int atloc));
_PROTOTYPE(boolean here, (int item));
_PROTOTYPE(boolean hinged, (int));
_PROTOTYPE(boolean holding, (int));
_PROTOTYPE(void insert, (int, int));
_PROTOTYPE(boolean inside, (int));
_PROTOTYPE(void juggle, (int loc));
_PROTOTYPE(int liq, (int));
_PROTOTYPE(int liqloc, (int loc));
_PROTOTYPE(int liq2, (int pbottle));
_PROTOTYPE(boolean living, (int));
_PROTOTYPE(boolean locked, (int));
_PROTOTYPE(boolean locks, (int));
_PROTOTYPE(void lookin, (int));
_PROTOTYPE(void move, (int obj, int where));
_PROTOTYPE(int noway, (void));
_PROTOTYPE(boolean opaque, (int));
_PROTOTYPE(boolean outside, (int));
_PROTOTYPE(boolean pct, (int x));
_PROTOTYPE(boolean plural, (int));
_PROTOTYPE(boolean portal, (int));
_PROTOTYPE(boolean printed, (int));
_PROTOTYPE(int put, (int obj, int where, int pval));
_PROTOTYPE(int ranz, (int));
_PROTOTYPE(boolean small, (int));
_PROTOTYPE(boolean toting, (int item));
_PROTOTYPE(boolean treasr, (int));
_PROTOTYPE(boolean vessel, (int));
_PROTOTYPE(boolean wearng, (int));
_PROTOTYPE(boolean worn, (int));
_PROTOTYPE(void bug, (unsigned int n));
_PROTOTYPE(char *ask, (char *prompt, char *buf, int buflen));
_PROTOTYPE(void panic, (char *msg, boolean save));
/* travel.c */
_PROTOTYPE(void domove, (void));
_PROTOTYPE(void gettrav, (int loc, struct trav *travel));
/* vocab.c */
_PROTOTYPE(int vocab, (char *word, int val));

View File

@@ -1,827 +0,0 @@
#1
You are standing at the end of a road before a small brick building.
Around you is a forest. A small stream flows out of the building and
down a gully.
#2
You have walked up a hill, still in the forest. The road slopes back
down the other side of the hill. There is a building in the distance.
#3
You are inside a building, a well house for a large spring. Off
to one side is a small pantry.
#4
You are in a valley in the forest beside a stream tumbling along a
rocky bed.
#5
You are in open forest, with a deep valley to one side. Not far
is a large billboard.
#6
You are in open forest near both a valley and a road.
#7
At your feet all the water of the stream splashes into a 2-inch slit
in the rock. Downstream the stream bed is bare rock.
#8
You are in a 20-foot depression floored with bare dirt. Set into the
dirt is a strong steel grate mounted in concrete. A dry stream bed
leads into the depression.
#9
You are in a small chamber beneath a 3x3 steel grate to the surface.
A low crawl over cobbles leads inward to the west.
#10
You are crawling over cobbles in a low passage. There is a dim light
at the east end of the passage.
#11
You are in a debris room filled with stuff washed in from the surface.
A low wide passage with cobbles becomes plugged with mud and debris
here, but an awkward canyon leads upward and west. A note on the wall
says "Magic Word XYZZY".
#12
You are in an awkward sloping east/west canyon.
#13
You are in a splendid chamber thirty feet high. The walls are frozen
rivers of orange stone. An awkward canyon and a good passage exit
from east and west sides of the chamber.
#14
At your feet is a small pit breathing traces of white mist. An east
passage ends here except for a small crack leading on.
#15
You are at one end of a vast hall stretching forward out of sight to
the west. There are openings to either side. Nearby, a wide stone
staircase leads downward. The hall is filled with wisps of white mist
swaying to and fro almost as if alive. A cold wind blows up the
staircase. There is a passage at the top of a dome behind you.
#16
The crack is far too small for you to follow.
#17
You are on the east bank of a fissure slicing clear across the hall.
The mist is quite thick here, and the fissure is too wide to jump.
#18
This is a low room with a crude note on the wall. The note says,
"You won't get it up the steps".
#19
You are in the Hall of the Mountain King, with passages off in all
directions.
#20
You are at the bottom of the pit with a broken neck.
#21
You didn't make it.
#22
The dome is unclimbable.
#23
You are at the west end of the Twopit Room. There is a large hole in
the wall above the pit at this end of the room.
#24
You are at the bottom of the eastern pit in the Twopit Room. There is
a small pool of oil in one corner of the pit.
#25
You are at the bottom of the western pit in the Twopit Room. There is
a large hole in the wall about 25 feet above you.
#26
You clamber up the plant and scurry through the hole at the top.
#27
You are on the west side of the fissure in the Hall of Mists.
#28
You are in a low N/S passage at a hole in the floor. The hole goes
down to an E/W passage.
#29
You are in the South Side Chamber.
#30
You are in the West Side Chamber of the Hall of the Mountain King.
A passage continues west and up here.
#31
<$$<
#32
You can't get by the snake.
#33
You are in a large room, with a passage to the south, a passage to the
west, and a wall of broken rock to the east. There is a large "Y2" on
a rock in the room's center.
#34
You are in a jumble of rock, with cracks everywhere.
#35
You're at a low window overlooking a huge pit, which extends up out of
sight. A floor is indistinctly visible over 50 feet below. Traces of
white mist cover the floor of the pit, becoming thicker to the right.
Marks in the dust around the window would seem to indicate that
someone has been here recently. Directly across the pit from you and
25 feet away there is a similar window looking into a lighted room. A
shadowy figure can be seen there peering back at you.
#36
You are in a dirty broken passage. To the east is a crawl. To the
west is a large passage. Above you is a hole to another passage.
#37
You are on the brink of a small clean climbable pit. A crawl leads
west.
#38
You are in the bottom of a small pit with a little stream, which
enters and exits through tiny slits.
#39
You are in a large room full of dusty rocks. There is a big hole in
the floor. There are cracks everywhere, and a passage leading east.
#40
You have crawled through a very low wide passage parallel to and north
of the Hall of Mists.
#41
You are at the west end of Hall of Mists. A low wide crawl continues
west and another goes north. To the south is a little passage 6 feet
off the floor.
#42
You are in a maze of twisty little passages, all alike.
#43
You are in a maze of twisty little passages, all alike.
#44
You are in a maze of twisty little passages, all alike.
#45
You are in a maze of twisty little passages, all alike.
#46
Dead end.
#47
Dead end.
#48
Dead end.
#49
You are in a maze of twisty little passages, all alike.
#50
You are in a maze of twisty little passages, all alike.
#51
You are in a maze of twisty little passages, all alike.
#52
You are in a maze of twisty little passages, all alike.
#53
You are in a maze of twisty little passages, all alike.
#54
Dead end.
#55
You are in a maze of twisty little passages, all alike.
#56
Dead end.
#57
You are on the brink of a thirty foot pit with a massive orange column
down one wall. You could climb down here but you could not get back
up. The maze continues at this level.
#58
Dead end.
#59
You have crawled through a very low wide passage parallel to and north
of the Hall of Mists.
#60
You are at the east end of a very long hall apparently without side
chambers. In the south wall are several wide cracks and a high
hole, but the hole is far above your head. To the east a wide
crawl slants up. To the north a round two foot hole slants down.
#61
You are at the west end of a very long featureless hall. The hall
joins up with a narrow north/south passage.
#62
You are at a crossover of a high N/S passage and a low E/W one.
#63
Dead end.
#64
You are at a complex junction. A low hands and knees passage from the
north joins a higher crawl from the east to make a walking passage
going west. There is also a large room above. The air is damp here.
#65
You are in Bedquilt, a long east/west passage with holes everywhere.
To explore at random select north, south, up, or down.
#66
You are in a room whose walls resemble swiss cheese. Obvious passages
go west, east, NE, and NW. Part of the room is occupied by a large
bedrock block.
#67
You are at the east end of the Twopit Room. The floor here is
littered with thin rock slabs, which make it easy to descend the pits.
There is a path here bypassing the pits to connect passages from east
and west. There are holes all over, but the only big one is on the
wall directly over the west pit where you can't get to it.
#68
You are in a large low circular chamber whose floor is an immense slab
fallen from the ceiling (Slab Room). East and west there once were
large passages, but they are now filled with boulders. Low small
passages go north and south, and the south one quickly bends west
around the boulders.
#69
You are in a secret N/S canyon above a large room.
#70
You are in a secret N/S canyon above a sizable passage.
#71
You are in a secret canyon at a junction of three canyons, bearing
north, south, and SE. The north one is as tall as the other two
combined.
#72
You are in a large low room. Crawls lead north, NE, and SW.
#73
Dead end crawl.
#74
You are in a secret canyon which here runs E/W. It crosses over a
very tight canyon 15 feet below. If you go down you may not be able
to get back up.
#75
You are at a wide place in a very tight N/S canyon.
#76
The canyon here becomes too tight to go further south.
#77
You are in a tall E/W canyon. A low tight crawl goes 3 feet north and
seems to open up.
#78
The canyon runs into a mass of boulders -- dead end.
#79
The stream flows out through a pair of 1 foot diameter sewer pipes.
It would be advisable to use the exit.
#80
You are in a maze of twisty little passages, all alike.
#81
Dead end.
#82
Dead end.
#83
You are in a maze of twisty little passages, all alike.
#84
You are in a maze of twisty little passages, all alike.
#85
Dead end.
#86
Dead end.
#87
You are in a maze of twisty little passages, all alike.
#88
You are in a long, narrow corridor stretching out of sight to the
west. At the eastern end is a hole through which you can see a
profusion of leaves.
#89
There is nothing here to climb. Use "up" or "out" to leave the pit.
#90
You have climbed up the plant and out of the pit.
#91
You are at the top of a steep incline above a large room. You could
climb down here, but you would not be able to climb up. There is a
passage leading back to the north.
#92
You are in the Giant Room. The ceiling here is too high up for your
lamp to show it. Cavernous passages lead east, north, and south. On
the west wall is scrawled the inscription, "FEE FIE FOE FOO" [sic].
#93
The passage here is blocked by a recent cave-in.
#94
You are at one end of an immense north/south passage.
#95
You are in a magnificent cavern with a rushing stream, which cascades
over a sparkling waterfall into a roaring whirlpool which disappears
through a hole in the floor. Passages exit to the south and west.
#96
You are in the Soft Room. The walls are covered with heavy curtains,
the floor with a thick pile carpet. Moss covers the ceiling.
#97
This is the Oriental Room. Ancient oriental cave drawings cover the
walls. A gently sloping passage leads upward to the north, another
passage leads SE, and a hands and knees crawl leads east.
#98
You are following a wide path around the outer edge of a large cavern.
Far below, through a heavy white mist, strange splashing noises can be
heard. The mist rises up through a fissure in the ceiling. The path
hugs the cavern's rim to the NE and south, while another branch forks
west. A round chute with extremely smooth walls angles sharply up
to the southwest.
#99
You are in an alcove. A small NW path seems to widen after a short
distance. An extremely tight tunnel leads east. It looks like a very
tight squeeze. An eerie light can be seen at the other end.
#100
You're in a small chamber lit by an eerie green light. An extremely
narrow tunnel exits to the west, and a dark corridor leads NE.
#101
You're in the Dark-Room. A corridor leading south is the only exit.
#102
You are in an arched hall. A coral passage once continued up and east
from here, but is now blocked by debris. The air smells of sea water.
#103
You're in a large room carved out of sedimentary rock. The floor and
walls are littered with bits of shells imbedded in the stone. A
shallow passage proceeds downward, and a somewhat steeper one leads
up. A low hands and knees passage enters from the south.
#104
You are in a long sloping corridor with ragged sharp walls.
#105
You are in a cul-de-sac about eight feet across.
#106
You are in an anteroom leading to a large passage to the east. Small
passages go west and up. The remnants of recent digging are evident.
A sign in midair here says "Cave under construction beyond this point.
Proceed at own risk. [Witt Construction Company]".
#107
You are in a maze of twisty little passages, all different.
#108
You are at Witt's End. Passages lead off in *ALL* directions.
#109
You are in a north/south canyon about 25 feet across. The floor is
covered by white mist seeping in from the north. The walls extend
upward for well over 100 feet. Suspended from some unseen point far
above you, an enormous two-sided mirror is hanging parallel to and
midway between the canyon walls. (The mirror is obviously provided
for the use of the dwarves, who as you know, are extremely vain.) A
small window can be seen in either wall, some fifty feet up.
#110
You're at a low window overlooking a huge pit, which extends up out of
sight. A floor is indistinctly visible over 50 feet below. Traces of
white mist cover the floor of the pit, becoming thicker to the left.
Marks in the dust around the window would seem to indicate that
someone has been here recently. Directly across the pit from you and
25 feet away there is a similar window looking into a lighted room. A
shadowy figure can be seen there peering back at you.
#111
A large stalactite extends from the roof and almost reaches the floor
below. You could climb down it, and jump from it to the floor, but
having done so you would be unable to reach it to climb back up.
#112
You are in a little maze of twisting passages, all different.
#113
You are at the edge of a large underground reservoir. An opaque cloud
of white mist fills the room and rises rapidly upward. The lake is
fed by a stream, which tumbles out of a hole in the wall about 10 feet
overhead and splashes noisily into the water somewhere within the
mist. The indistinct shape of the opposite shore can be dimly seen
through the mist. The only passage goes back toward the south.
#114
Dead end.
#115
You are at the northeast end of an immense room, even larger than the
Giant Room. It appears to be a repository for the "ADVENTURE"
program. Massive torches far overhead bathe the room with smoky
yellow light. Scattered about you can be seen a pile of bottles (all
of them empty), a nursery of young beanstalks murmuring quietly, a bed
of oysters, a bundle of black rods with rusty stars on their ends, and
a collection of brass lanterns. Off to one side a great many dwarves
are sleeping on the floor, snoring loudly. A sign nearby reads: "Do
not disturb the dwarves!" An immense mirror is hanging against one
wall, and stretches to the other end of the room, where various other
sundry objects can be glimpsed dimly in the distance. An unoccupied
telephone booth stands against the north wall.
#116
You are at the southwest end of the repository. To one side is a pit
full of fierce green snakes. On the other side is a row of small
wicker cages, each of which contains a little sulking bird. In one
corner is a bundle of black rods with rusty marks on their ends. A
large number of velvet pillows are scattered about on the floor.
Beside one of the pillows is a large, dusty, leather-bound volume
with the title "History of Adventure" embossed in pure gold.
A vast mirror stretches off to the northeast, almost reaching the
phone booth. At your feet is a large steel grate, next to which is
a sign which reads, "Treasure Vault. Keys in Main Office."
#117
You are on one side of a large, deep chasm. A heavy white mist rising
up from below obscures all view of the far side. A SW path leads away
from the chasm into a winding corridor.
#118
You are in a long winding corridor sloping out of sight in both
directions.
#119
You are in a secret canyon which exits to the north and east.
#120
You are in a secret canyon which exits to the north and east.
#121
You are in a secret canyon which exits to the north and east.
#122
You are on the northeast side of a deep chasm. A NE path leads away
from the chasm on this side.
#123
You're in a long east/west corridor. A faint rumbling noise can be
heard in the distance.
#124
The path forks here. The left fork leads northeast. A dull rumbling
seems to get louder in that direction. The right fork leads southeast
down a gentle slope. The main corridor enters from the west.
#125
The walls are quite warm here. From the north can be heard a steady
roar, so loud that the entire cave seems to be trembling. Another
passage leads south, and a low crawl goes east.
#126
You are on the edge of a breathtaking view. Far below you is an
active volcano, from which great gouts of molten lava come surging
out, cascading back down into the depths. The glowing rock fills the
farthest reaches of the cavern with a blood-red glare, giving every-
thing an eerie, macabre appearance. The air is filled with flickering
sparks of ash and a heavy smell of brimstone. The walls are hot to
the touch, and the thundering of the volcano drowns out all other
sounds. Embedded in the jagged roof far overhead are myriad twisted
formations composed of pure white alabaster, which scatter the murky
light into sinister apparitions upon the walls. To one side is a deep
gorge, filled with a bizarre chaos of tortured rock which seems to
have been crafted by the devil himself. An immense river of fire
crashes out from the depths of the volcano, burns its way through the
gorge, and plummets into a bottomless pit far off to your left. To
the right, an immense geyser of blistering steam erupts continuously
from a barren island in the center of a sulfurous lake, which bubbles
ominously. The far right wall is aflame with an incandescence of its
own, which lends an additional infernal splendor to the already
hellish scene. A dark, foreboding passage exits to the south.
#127
You are in a small chamber filled with large boulders. The walls are
very warm, causing the air in the room to be almost stifling from the
heat. The only exit is a crawl heading west, through which is coming
a low rumbling.
#128
You are walking along a gently sloping north/south passage lined with
oddly shaped limestone formations.
#129
You are standing at the entrance to a large, barren room. A sign
posted above the entrance reads: "Caution! Bear in room!"
#130
You are inside a barren room. The center of the room is completely
empty except for some dust. Marks in the dust lead away toward the
far end of the room. The only exit is the way you came in.
#131
You are in a maze of twisting little passages, all different.
#132
You are in a little maze of twisty passages, all different.
#133
You are in a twisting maze of little passages, all different.
#134
You are in a twisting little maze of passages, all different.
#135
You are in a twisty little maze of passages, all different.
#136
You are in a twisty maze of little passages, all different.
#137
You are in a little twisty maze of passages, all different.
#138
You are in a maze of little twisting passages, all different.
#139
You are in a maze of little twisty passages, all different.
#140
Dead end.
#141
You are on a narrow promontory at the foot of a waterfall, which
spurts from an overhead hole in the rock wall and splashes into a
large reservoir, sending up clouds of mist and spray.
Through the thick white mist looms a polished marble slab, to
which is affixed an enormous rusty iron anvil. In golden letters
are written the words: "Whoso Pulleth Out This Sword of This
Stone and Anvil, is Right wise King-Born of All This Mountain."
There is a narrow chimney on the east side of the promontory.
#142
You are on a narrow shelf above and east of the top of a very steep
chimney. A long smooth granite slide curves down out of sight
to the east. If you go down the slide, you may not be able to
climb back up.
#143
You are in the private chamber of the Mountain King. Hewn into the
solid rock of the east wall of the chamber is an intricately-wrought
throne of elvish design. There is an exit to the west.
#144
You are on the east side of the throne room. On the arm of the throne
has been hung a sign which reads "Gone for the day: visiting
sick snake. --M.K."
#145
You are dragged down, down, into the depths of the whirlpool.
Just as you can no longer hold your breath, you are shot out over
a waterfall into the shallow end of a large reservoir. Gasping
and sputtering, you crawl weakly towards the shore....
#146
You are in dense forest, with a hill to one side. The trees appear
to thin out towards the north and east.
#147
You are at the high point of a wide grassy knoll, partially surrounded
by dense forest. The land rises to the south and east, and drops off
sharply to the north and west. The air smells of sea water.
#148
You are at the edge of a trackless salt marsh. Tall reeds obscure
the view.
#149
You're in salt marsh.
#150
You're in salty marsh.
#151
You are in salt marsh.
#152
Dead end.
#153
You're on a sandy beach at the edge of the open sea. The beach
ends a short distance south and the land rises to a point. To
the north, the beach ends cliffs and broken rocks.
#154
You are at a jumble of large broken rocks. A gentle path leads up
to the top of the nearby cliffs. A narrow treacherous path
disappears among the rocks at the foot of the cliff.
#155
You are on a high cliff overlooking the sea. Far below the
rolling breakers smash into a jumble of large broken rocks.
The thunder of the surf is deafening.
#156
You're at the bottom of the cliff, smashed to smithereens by the
pounding surf.
#157
You are at Thunder Hole, a funnel shaped cavern opening onto the sea.
The noise of the surf pounding against the outer rocks of the cave is
amplified by the peculiar shape of the cave, causing a thunder-like
booming sound to reverberate throughout the cave. Outside, a narrow
path leads south towards some large rocks.
#158
You are at the top of some arched steps. On one side is a blank wall
with a tiny door at the base and a shelf overhead. On the other side
a westward passage leads to the sea.
#159
You are in a low cramped chamber at the back of a small cave.
There is a shelf in the rock wall at about the height of your
shoulder.
#160
You are on a wide ledge, bounded on one side by a rock wall,
and on the other by a sheer cliff. The only way past is through
a large wrought-iron door.
#161
You feel dizzy...Everything around you is spinning, expanding,
growing larger.... Dear me! Is the cave bigger or are you smaller?
#162
You are again overcome by a sickening vertigo, but this time
everything around you is shrinking...Shrinking...
#163
You are again overcome by a sickening vertigo, but this time
everything is shrinking... I mean, you are growing. This is
terribly confusing!
#164
You feel dizzy...Everything around you is spinning, expanding,
growing larger....
#165
You're at the bottom of the cliff with a broken neck.
#166
You are at the western tip of the Blue Grotto. A large lake almost
covers the cavern floor, except for where you are standing. Small
holes high in the rock wall to the east admit a dim light. The
reflection of the light from the water suffuses the cavern with
a hazy bluish glow.
#167
You are on the shore of an underground sea. A high wooden
structure of vast proportions extends out into the water to the
east. The way west is through a wrought-iron door.
#168
You are on the eastern shore of the Blue Grotto. An ascending
tunnel disappears into the darkness to the SE.
#169
You are at a high rock on the NE side of a watery chamber at the mouth
of a small brook. An unknown gas bubbles up through the water from
the chamber floor. A bluish light can be seen to the southwest.
#170
You are in a windy tunnel between two large rooms.
#171
You are in the Bat Cave. The walls and ceiling are covered with
sleeping bats. The floor is buried by a mass of dry, foul-smelling
guano. The stench is overpowering. Exits to the NW and east.
#172
You are in a very tight N/S crack. The passage seems to widen to
the south.
#173
You are in a very tight N/S crack. The passage south is blocked
by a recent cave-in.
#174
You're in the Cloakroom. This is where the dreaded Wumpus repairs
to sleep off heavy meals. (Adventurers are his favorite dinner!)
Two very narrow passages exit NW and NE.
#175
You're in a room containing several small climbable pits. Passages
exit to the east and north.
#176
You are at the bottom of a small featureless pit.
#177
You are at a high hole in a rock wall.
#178
The NE passage is blocked by a recent cave-in.
#179
You are in a sloping muddy defile, next to a tumbling brook.
#180
You are in a level E/W passage partially blocked by an overhanging
tongue of rock. A steep scramble would take you up over the tongue,
whence continues an upward crawl.
#181
The dog won't let you pass.
#182
You're in the Upper Passage, a long level E/W tunnel.
#183
You are in a star-shaped chamber. Passages exit north, east, south,
and west.
#184
You are at an elbow in a winding E/W passage.
#185
Dead end.
#186
You're at the intersection of two long tunnels. One goes NW,
the other NE.
#187
You're in a long narrow east-west passage which curves out of sight
at both ends.
#188
You're in the Rotunda. Corridors radiate in all directions.
There is a telephone booth standing against the north wall.
#189
You are standing in a telephone booth at the side of a large chamber.
Hung on the wall is a banged-up pay telephone of ancient design.
#190
You're at the Devil's Chair, a large crystallization shaped like a
seat, at the edge of a black abyss. You can't see the bottom.
An upward path leads away from the abyss.
#191
You're in a dead-end crack.
#192
You're on a small gravel beach at the south wall of the Blue Grotto.
A gravelly path leads east.
#193
You are in the Flower Room. The walls are covered with colorful,
intricate, flowerlike patterns of crystallized gypsum. A hole leads
to the west.
#194
You are at the end of a short E/W corridor.
#195
You are looking west from the end of a short E/W corridor. At your
feet is a pile of loose rubble. On your left is a hole into another
chamber.
#196
You are in an arched hall. The remnants of a now-plugged coral
passage lie to the east. The north wall has partially crumbled,
exposing a large connecting hole to another room.
#197
You're in the Vestibule, a short east-west passage between two rooms.
#198
You are in the Fairy Grotto. All around you innumerable stalactites,
arranged in immense colonnades, form elegant arches. On every side
you hear the dripping of water, like the footsteps of a thousand
fairies. A small stream runs from the SW corner. A bright glow
emanates from the south side of the grotto, and a steep passage
descends to the east.
#199
You have approached the lower end of a steep passage, but it is
just too cold here to hang around, and you aren't properly equipped
to continue. With teeth chattering, you climb back up....
#200
You are in the Crystal Palace. An overhead vein of phosphorescent
quartz casts a luminous glow which is reflected by countless chips of
mica embedded in both walls, which consist of some sort of highly
reflective glass, apparently of volcanic origin. A winding path
of yellow sandstone leads west and rises steeply to the east.
#201
You are following a yellow sandstone path. There is a glow
to the west.
#202
You are in a very tall chamber whose walls are comprised of many
different rock strata. Layers of red and yellow sandstone
intertwine with bright bands of calcareous limestone in a rainbow-
like profusion of color. The rainbow effect is so real, you
are almost tempted to look for a pot of gold! Poised far over
your head, a gigantic slab, wedged tightly between the north and
south walls, forms a natural bridge across the roof of the chamber.
A trail leads east and west.
#203
You're in a steeply sloping passage. It is very cold here.
#204
You are in the Hall of Ice, in the deepest part of the caverns.
During winter, frigid outside air settles here, making this room
extremely cold all year round. The walls and ceilings are covered
with a thick coating of ice. An upward passage exits to the west.
#205
You are standing on a natural bridge far above the floor of a circular
chamber whose walls are a rainbow of multicolored rock. The bridge
was formed eons ago by a huge slab which fell from the ceiling and
is now jammed between the north and south walls of the chamber.
#206
You are in a low, wide room below another chamber. A small green
pond fills the center of the room. The lake is apparently spring
fed. A small stream exits through a narrow passage to the north.
A larger passage continues west.
#207
You are in a tight north/south crawl through a stratum of red
colored rock. The air is damp with mist.
#208
You are in a tall canyon on the south side of a swift, wide river.
Written in the mud in crude letters are the words: "You Have Found
Lost River." A wide path leads east and west along the bank. A tight
crawl way would take you south out of the canyon.
#209
You are standing on a large flat rock table at the western end of
Lost River Canyon. Beneath your feet, the river disappears amidst
foam and spray into a large sinkhole. A gentle path leads east
along the river's south shore. Another leads sharply upward along
the river's north side.
#210
You are at a niche in the canyon wall, far above a raging river.
The air is filled with mist and spray, making it difficult to see
ahead. A downward sloping ledge narrows to the east. The path
to the west is easier.
#211
The ledge is growing very narrow and treacherous, and falls off almost
vertically. You could go down, but you won't be able to climb back.
#212
You are standing in a telephone booth at the side of the Repository.
#213
You're at the east end of a level passage at a hole in the floor.
#214
You're at the north edge of a dark cove.
#215
You are in a dry granite basin, worn smooth eons ago by water
swirling down from a now-dry spillway.
#216
You're in a dry spillway east of and above a smooth rock basin.
#217
You are in the Winery, a cool dark room which extends some
distance off to the east.
#218
You are to the east of the Winery, where the room ends in a thicket
of high, sharp, pointed, climbable limestone pinnacles. There is a
narrow ledge just above the top of the spires. If you go up, it
might be difficult to get back down.
#219
You are in a high-vaulted cavern whose roof rises over fifty
meters to culminate in a series of pointed arches directly over
your head. There are also two low arches to either side, forming
side portals. The whole effect is that of a gothic cathedral.
You can proceed north, south, east, or west.
#220
You're at the east portal of the Gothic Cathedral. The path leads
east and west.
#221
You're at the west portal of the Gothic Cathedral.
#222
You are at the foot of the Altar, an immense, broad stalagmite.
An opening leads south.
#223
You're on top of an enormous, broad stalagmite. There is a hole
in the ceiling overhead.
#224
You are in a room the size and shape of a small crypt. A narrow
cut exits east. There is a hole in the floor.
#225
You are in the Gothic Chapel, a small chamber adjoining the Gothic
Cathedral. A path leads west.
#226
You are on the floor of the Rainbow Room. In fact, you are spread
*ALL OVER* the floor of the Rainbow Room.
#227
You are in a dimly lit passage behind Thunder Hole. Etched into
the rock wall are the ominous words:
* "You are approaching the River Styx. *
* Laciate Ogni Speranza Voi Ch'Entrate." *
#228
You are at the River Styx, a narrow little stream cutting directly
across the passageway. The edge of the stream is littered with sticks
and other debris washed in by a recent rainfall. On the far side
of the river, the passage continues east.
#229
You're on the east side of the river's sticks.
#230
You are on a ledge at the northern end of a long N/S crawl. The
ledge is above a large number of sharp vertical limestone spires.
An attempt to climb down could be dangerous, if you get my *point*!
#231
You are very neatly skewered on the point of a sharp rock.
#232
You have poled your boat across the calm water.
#233
You have poled your boat across the dark water.
#234
You have poled your boat across the Blue Grotto.
#235
You're at Dante's Rest, on the north side of a yawning dark chasm.
A passage continues west along the chasm's edge.
#236
You are at the east end of a river bank path in Lost River Canyon.
#237
The staircase is now unclimbable.
#238
You're in the caretaker's pantry.
#239
You are on a small rise overlooking a beautiful bay. In the center
of the bay is the castle of the elves.
#240
You are on the highest pinnacle of the castle in the bay.
Steps lead down into the garden.
#241
You are in the outer courtyard of the garden of the elves.
Steps lead up to the tower, and to the west, separating you
from the inner courtyard, is a maze of hedges, living things,
but almost crystalline in their multicolored splendor.
#242
From the inside the maze looks like a kaleidoscope, with
swatches of color dancing as you move. In this part the colors
are produced by shining red berries on the branches.
#243
You are surrounded by a tall hedge with sharp iridescent leaves
and metallic orange flowers.
#244
You are in the center of the living maze. The plants here are
dormant this season, but still carry brilliant yellow leaves.
#245
Unlike the other areas of the hedge system, this area seems to
have no metallic gleam; nevertheless it is still breathtaking.
The trees and bushes are all variegated shades of green, the
evergreens being a rich dark shade while the seasonal bushes
are a lighter yellowish green, making a startling contrast.
#246
You are near the edge of the maze. You sample the blueberries
on the bushes. They are delicious.
#247
You are at the western end of the living maze. Beside the
shrubs forming the walls are tastefully planted beds of
violets and brilliant purple pansies.
To the west is the inner garden.
#248
You are in the inner garden of the elves. In the center is
a living tree, with shimmering silvery bark, glistening metallic
green leaves, and flowers ripe with nectar. As the nectar falls
to the ground it forms droplets of silver. Around the tree is
a hedge of briars which cannot be crossed. Unfortunately for
adventurers such as you, most of the nectar falls inside the hedge.
The exit is to the east.

View File

@@ -1,514 +0,0 @@
#1
You're at end of road again.
#2
You're at hill in road.
#3
You're inside building.
#4
You're in valley.
#5
You're in forest.
#6
You're in forest.
#7
You're at slit in streambed.
#8
You're outside grate.
#9
You're below the grate.
#10
You're in cobble crawl.
#11
You're in Debris Room.
#12
You are in an awkward sloping east/west canyon.
#13
You're in Bird Chamber.
#14
You're at top of small pit.
#15
You're in Hall of Mists.
#16
The crack is far too small for you to follow.
#17
You're on east bank of fissure.
#18
You're in Nugget of Gold Room.
#19
You're in Hall of Mt King.
#20
You are at the bottom of the pit with a broken neck.
#21
You didn't make it.
#22
The dome is unclimbable.
#23
You're at west end of Twopit Room.
#24
You're in east pit.
#25
You're in west pit.
#26
You clamber up the plant and scurry through the hole at the top.
#27
You are on the west side of the fissure in the Hall of Mists.
#28
You are in a low N/S passage at a hole in the floor. The hole goes
down to an E/W passage.
#29
You are in the South Side Chamber.
#30
You are in the West Side Chamber of the Hall of the Mountain King.
#31
<$$<
#32
You can't get by the snake.
#33
You're at "Y2".
#34
You are in a jumble of rock, with cracks everywhere.
#35
You're at window on pit.
#36
You're in dirty passage.
#37
You are on the brink of a small clean climbable pit.
#38
You are in the bottom of a small pit with a little stream.
#39
You're in dusty rock room.
#40
You have crawled through a very low wide passage parallel.
#41
You're at west end of Hall of Mists.
#42
You are in a maze of twisty little passages, all alike.
#43
You are in a maze of twisty little passages, all alike.
#44
You are in a maze of twisty little passages, all alike.
#45
You are in a maze of twisty little passages, all alike.
#46
Dead end.
#47
Dead end.
#48
Dead end.
#49
You are in a maze of twisty little passages, all alike.
#50
You are in a maze of twisty little passages, all alike.
#51
You are in a maze of twisty little passages, all alike.
#52
You are in a maze of twisty little passages, all alike.
#53
You are in a maze of twisty little passages, all alike.
#54
Dead end.
#55
You are in a maze of twisty little passages, all alike.
#56
Dead end.
#57
You're at brink of pit.
#58
Dead end.
#59
You have crawled through a very low wide passage.
#60
You're at east end of Long Hall.
#61
You're at west end of Long Hall.
#62
You are at a crossover of a high N/S passage and a low E/W one.
#63
Dead end.
#64
You're at Complex Junction.
#65
You are in Bedquilt.
#66
You're in Swiss Cheese Room.
#67
You're at east end of Twopit Room.
#68
You're in Slab Room.
#69
You are in a secret N/S canyon above a large room.
#70
You are in a secret N/S canyon above a sizable passage.
#71
You're at junction of three secret canyons.
#72
You are in a large low room. Crawls lead north, NE, and SW.
#73
Dead end crawl.
#74
You're in secret E/W canyon above tight canyon.
#75
You are at a wide place in a very tight N/S canyon.
#76
The canyon here becomes too tight to go further south.
#77
You are in a tall E/W canyon.
#78
The canyon runs into a mass of boulders -- dead end.
#79
The stream flows out through a pair of 1 foot diameter sewer pipes.
#80
You are in a maze of twisty little passages, all alike.
#81
Dead end.
#82
Dead end.
#83
You are in a maze of twisty little passages, all alike.
#84
You are in a maze of twisty little passages, all alike.
#85
Dead end.
#86
Dead end.
#87
You are in a maze of twisty little passages, all alike.
#88
You're in narrow corridor.
#89
There is nothing here to climb. Use "up" or "out" to leave the pit.
#90
You have climbed up the plant and out of the pit.
#91
You're at steep incline above large room.
#92
You're in Giant Room.
#93
The passage here is blocked by a recent cave-in.
#94
You are at one end of an immense north/south passage.
#95
You're in cavern with waterfall.
#96
You're in Soft Room.
#97
You're in Oriental Room.
#98
You're in Misty Cavern.
#99
You're in Alcove.
#100
You're in Plover Room.
#101
You're in Dark-Room.
#102
You're in Arched Hall.
#103
You're in Shell Room.
#104
You are in a long sloping corridor with ragged sharp walls.
#105
You are in a cul-de-sac about eight feet across.
#106
You're in Anteroom.
#107
You are in a maze of twisty little passages, all different.
#108
You're at Witt's End.
#109
You're in Mirror Canyon.
#110
You're at window on pit.
#111
You're at top of stalactite.
#112
You are in a little maze of twisting passages, all different.
#113
You're at Reservoir.
#114
Dead end.
#115
You're at NE end.
#116
You're at SW end.
#117
You're on SW side of chasm.
#118
You're in sloping corridor.
#119
You are in a secret canyon which exits to the north and east.
#120
You are in a secret canyon which exits to the north and east.
#121
You are in a secret canyon which exits to the north and east.
#122
You're on NE side of chasm.
#123
You're in corridor.
#124
You're at fork in path.
#125
You're at junction with warm walls.
#126
You're at breath-taking view.
#127
You're in Chamber of Boulders.
#128
You're in Limestone Passage.
#129
You're in front of Barren Room.
#130
You're in Barren Room.
#131
You are in a maze of twisting little passages, all different.
#132
You are in a little maze of twisty passages, all different.
#133
You are in a twisting maze of little passages, all different.
#134
You are in a twisting little maze of passages, all different.
#135
You are in a twisty little maze of passages, all different.
#136
You are in a twisty maze of little passages, all different.
#137
You are in a little twisty maze of passages, all different.
#138
You are in a maze of little twisting passages, all different.
#139
You are in a maze of little twisty passages, all different.
#140
Dead end.
#141
You're at Sword Point.
#142
You're at top of slide.
#143
You're at entrance to Throne Room.
#144
You're on east side of Throne Room.
#145
<$$<
#146
You're in forest.
#147
You're on grassy knoll.
#148
You are at the edge of a trackless salt marsh. Tall reeds obscure
the view.
#149
You're in salt marsh.
#150
You're in salty marsh.
#151
You are in salt marsh.
#152
Dead end.
#153
You're on sandy beach.
#154
You're at broken rocks.
#155
You're at Ocean Vista.
#156
You're at the bottom of the cliff.
#157
You're at Thunder Hole.
#158
You're at top of steps in back of Thunder Hole.
#159
You're in cramped chamber.
#160
You're at ledge by wrought-iron door.
#161
You feel dizzy...Everything around you is spinning, expanding,
growing larger.... Dear me! Is the cave bigger or are you smaller?
#162
You are again overcome by a sickening vertigo, but this time
everything around you is shrinking...Shrinking...
#163
You are again overcome by a sickening vertigo, but this time
everything is shrinking... I mean, you are growing. This is
terribly confusing!
#164
You feel dizzy...Everything around you is spinning, expanding,
growing larger....
#165
You're at the bottom of the cliff with a broken neck.
#166
You're at west wall of Blue Grotto.
#167
You're at underground sea.
#168
You're on east side of the Blue Grotto.
#169
You're in Bubble Chamber.
#170
You are in a windy tunnel between two large rooms.
#171
You're in Bat Cave.
#172
You are in a very tight N/S crack.
#173
You are in a very tight N/S crack.
#174
You're in the Cloakroom.
#175
You're in a room containing several small climbable pits.
#176
You are at the bottom of a small featureless pit.
#177
You are at a high hole in a rock wall.
#178
The NE passage is blocked by a recent cave-in.
#179
You are in a sloping muddy defile, next to a tumbling brook.
#180
You're at Tongue of Rock.
#181
The dog won't let you pass.
#182
You're in the Upper Passage, a long level E/W tunnel.
#183
You're in Star Chamber.
#184
You are at an elbow in a winding E/W passage.
#185
Dead end.
#186
You're at the intersection of two long tunnels.
#187
You're in a long narrow east-west passage.
#188
You're in Rotunda.
#189
You're in phone booth.
#190
You're at Devil's Chair.
#191
You're in a dead-end crack.
#192
You're on gravel beach.
#193
You're in Flower Room.
#194
You are at east end of short E/W corridor.
#195
You are at east end of short E/W corridor.
#196
You're in Arched Hall.
#197
You're in the Vestibule, a short east-west passage between two rooms.
#198
You're in the Fairy Grotto.
#199
You have approached the lower end of a steep passage.
#200
You're in the Crystal Palace.
#201
You are following a yellow sandstone path.
#202
You're in the Rainbow Room.
#203
You're in a steeply sloping passage. It is very cold here.
#204
You're in the Hall of Ice.
#205
You are over the Rainbow (Room).
#206
You're in Green Lake Room.
#207
You're in red rock crawl.
#208
You're on south side of Lost River Canyon.
#209
You're at end of Lost River Canyon.
#210
You're at niche in ledge above Lost River.
#211
A very narrow and treacherous ledge.
#212
You're in phone booth.
#213
You're at the east end of a level passage at a hole in the floor.
#214
You're in dark cove.
#215
You're in dry basin.
#216
You're in old spillway.
#217
You're in the Winery.
#218
You're at limestone pinnacles.
#219
You're in Gothic Cathedral.
#220
You're at the east portal of the Gothic Cathedral.
#221
You're at the west portal of the Gothic Cathedral.
#222
You are at the foot of the Altar, an immense, broad stalagmite.
#223
You're on top of stalagmite.
#224
You're in the Crypt.
#225
You're in Gothic Chapel.
#226
You are on the floor of the Rainbow Room.
#227
You are at approach to River Styx.
#228
You're at the River Styx.
#229
You're on the east side of the river's sticks.
#230
You're on ledge above limestone pinnacles.
#231
You are very neatly skewered on the point of a sharp rock.
#232
You have poled your boat across the calm water.
#233
You have poled your boat across the dark water.
#234
You have poled your boat across the Blue Grotto.
#235
You're at Dante's Rest.
#236
You're at east end of Lost River Canyon.
#237
The staircase is now unclimbable.
#238
You're in the caretaker's pantry.
#239
You're on a small rise over the bay.
#240
You are on the highest pinnacle of the castle in the bay.
Steps lead down into the garden.
#241
You are in the outer courtyard of the elves.
#242
You are in the living maze. There are red berries here.
#243
You are surrounded by a tall hedge with sharp iridescent leaves
and metallic orange flowers.
#244
You are in the center of the living maze. The plants here are
dormant this season, but still carry brilliant yellow leaves.
#245
Unlike the other areas of the hedge system, this area seems to
have no metallic gleam; nevertheless it is still breathtaking.
The trees and bushes are all variegated shades of green, the
evergreens being a rich dark shade while the seasonal bushes
are a lighter yellowish green, making a startling contrast.
#246
You are near the edge of the maze. You sample the blueberries
on the bushes. They are delicious.
#247
You are at the western end of the living maze. Beside the
shrubs forming the walls are tastefully planted beds of
violets and brilliant purple pansies.
To the west is the inner garden.
#248
You're in the inner courtyard of the elves.

View File

@@ -1,539 +0,0 @@
#1
#2
/Brass lantern
/There is a shiny brass lamp nearby.
/There is a lamp shining nearby.
/
#3
/*Grate
/The grate is locked.
/The grate is open.
/
#4
/Wicker cage
/There is a small wicker cage discarded nearby.
/
#5
/Black rod
/A three foot black rod with a rusty star on an end lies nearby.
/
#6
/Black rod
/A three foot black rod with a rusty mark on an end lies nearby.
/
#7
/*Steps
/Rough stone steps lead down the pit.
/Rough stone steps lead up the dome.
/
#8
#9
/Wooden pole
/A wooden pole is lying nearby.
/A wooden pole has been stuck in the mud here.
/
#10
/Velvet pillow
/A small velvet pillow lies on the floor.
/
#11
/*Snake
/A huge green fierce snake bars the way!
/<$$< (Chased away)
/
#12
/*Fissure
/<$$<
/A crystal bridge now spans the fissure.
/The crystal bridge has vanished!
/
#13
/*Stone tablet
/A massive stone tablet imbedded in the wall reads:
"Congratulations on bringing light into the Dark-Room!"
/
#14
/Giant clam >grunt!<
/There is an enormous clam here with its shell tightly closed.
/
#15
/Giant oyster >groan!<
/There is an enormous oyster here with its shell tightly closed.
/Interesting. There seems to be something written on the underside of
the oyster.
/
#16
/"Spelunker Today"
/There are a few recent issues of "Spelunker Today" magazine here.
/
#17
#18
#19
/Tasty food
/There is food here.
/
#20
/Small bottle
/There is a small bottle here.
/There is an empty bottle here.
/There is a small bottle here.
/There is a broken bottle here.
/There is a small bottle here.
/
#21
/*Chasm - troll bridge
/A rickety wooden bridge extends across the chasm, vanishing into the
mist. A sign posted on the bridge reads, "Stop! Pay troll!"
/The wreckage of a bridge (and a dead bear) can be seen at the bottom
of the chasm.
/
#22
/*Chasm2 & decrepit natural bridge
/A decrepit natural bridge spans the chasm. A message scrawled into
the rock wall reads: "Bridge out of repair. Maximum load: 35 Foonts."
/The remnants of a natural bridge partially overhang the chasm.
/
#23
/*Mirror
/<$$<
/
#24
/*plant
/There is a tiny little plant in the pit, murmuring "Water, water, ..."
/The plant spurts into furious growth for a few seconds.
/There is a 12-foot-tall beanstalk stretching up out of the pit,
bellowing "Water!! Water!!"
/The plant grows explosively, almost filling the bottom of the pit.
/There is a gigantic beanstalk stretching all the way up to the hole.
/You've over-watered the plant! It's shriveling up! It's, it's...
/
#25
/*Phony plant (seen in twopit room only when tall enough)
/<$$<
/The top of a 12-foot-tall beanstalk is poking out of the west pit.
/There is a huge beanstalk growing out of the west pit up to the hole.
/
#26
/*Stalactite
/<$$<
/
#27
/*shadowy figure
/The shadowy figure seems to be trying to attract your attention.
/
#28
/Dwarf's axe
/There is a little axe here.
/There is a little axe lying beside the bear.
/There is a little axe lying beside the Wumpus.
/There is a little axe lying beside the dog.
/
#29
/*Cave drawings
/<$$<
/
#30
/*pirate
/<$$<
/
#31
/*dragon
/A huge green fierce dragon bars the way!
/Congratulations! You have just vanquished a dragon with your bare
hands! (Unbelievable, isn't it?)
/The body of a huge green dead dragon is lying off to one side.
/
#32
#33
/*Troll
/A burly troll stands by the bridge and insists you throw him a
treasure before you may cross.
/The troll steps out from beneath the bridge and blocks your way.
/<$$< (Chased away)
/
#34
/*phony troll
/The troll is nowhere to be seen.
/
#35
/<$$< (Bear uses rtext 141)
/There is a ferocious cave bear eying you from the far end of the room!
/There is a gentle cave bear sitting placidly in one corner.
/There is a contented-looking bear wandering about nearby.
/<$$< (Dead)
/
#36
/*Message in second maze
/There is a message scrawled in the dust in a flowery script, reading:
"This is not the maze where the pirate leaves his treasure chest."
/
#37
/*Volcano and/or geyser
/<$$<
/
#38
/*Vending machine
/There is a massive vending machine here. The instructions on it
read: "Insert coins to receive fresh batteries."
/There is a massive vending machine here.
/
#39
/Batteries
/There are fresh batteries here.
/Some worn-out batteries have been discarded nearby.
/Some worn-out batteries have been discarded nearby.
/
#40
/*Carpet and/or moss
/<$$<
/
#41
/*Rusty door
/The way north is barred by a massive, rusty, iron door.
/The way north leads through a massive, rusty, iron door.
/
#42
/*Tiny door
/The only way past the wall is through a tiny locked door.
/The only way past the wall is through a tiny open door.
/
#43
/*Tiny door-2
/The door is locked.
/The door is open.
/
#44
/*Phone booth door
/<$$<
/
#45
#46
/Beautiful flowers
/There are some beautiful flowers here!
/On the other side of the room a swarm of bees eagerly buzzes over
a bunch of fresh flowers.
/
#47
/Silken cloak
/There is a silken cloak here!
/<$$< (wearing cloak)
/A lovely silken cloak lies partially buried under a pile of
loose rocks.
/
#48
/Wooden boat
/There is a small wooden boat here.
/You are in a wooden boat.
/
#49
/*Sticks at Styx
/<$$<
/
#50
/Large gold nugget
/There is a large sparkling nugget of gold here!
/
#51
/Several diamonds
/There are diamonds here!
/
#52
/Silver horn
/There is a silver horn here!
/
#53
/Precious jewelry
/There is precious jewelry here!
/<$$< (wearing jewelry)
/
#54
/Rare coins
/There are many coins here!
/
#55
/Treasure chest
/The pirate's treasure chest is here!
/
#56
/Golden eggs
/There is a large nest here, full of golden eggs!
/The nest of golden eggs has vanished!
/Done!
/
#57
/Jeweled trident
/There is a jewel-encrusted trident here!
/
#58
/Ming vase
/There is a delicate, precious, ming vase here!
/The vase is now resting, delicately, on a velvet pillow.
/The floor is littered with worthless shards of pottery.
/The ming vase drops with a delicate crash.
/
#59
/Egg-sized emerald
/There is an emerald here the size of a plover's egg!
/
#60
/Platinum pyramid
/There is a platinum pyramid here, 8 inches on a side!
/
#61
/Glistening pearl
/Off to one side lies a glistening pearl!
/
#62
/Persian rug
/There is a persian rug spread out on the floor!
/The dragon is sprawled out on a persian rug!!
/
#63
/Rare spices
/There are rare spices here!
/
#64
/Golden chain
/There is a golden chain lying in a heap on the floor!
/The bear is locked to the wall with a golden chain!
/There is a golden chain locked to the wall!
/
#65
/Gleaming sword
/There is a gleaming sword here!
/A gleaming sword is stuck into the anvil!
/You grasp the sword's handle and give a mighty heave, but with a
loud clang the sword blade shatters into several fragments.
/Rusty shards of a elven sword lie scattered about.
/A very clean sword is stuck into the anvil!
/An oily sword is stuck into the anvil.
/
#66
/Elfin crown
/An ancient crown of elfin kings lies here!
/<$$< (wearing crown)
/
#67
/Ruby slippers
/There is a pair of ruby slippers here.
/<$$< (wearing slippers)
/There is a pair of ruby slippers here.
/
#68
/Delicate lyre
/There is a delicate lyre here!
/
#69
/Star sapphire
/There is a star sapphire here!
/
#70
/Holy Grail
/There is an ornate silver chalice here!
/
#71
/Oaken cask
/There is an oaken cask here.
/There is an empty oaken cask here.
/There is an oaken cask here.
/<$$< (Unused)
/There is an oaken cask here.
/
#72
/Golden ring
/There is a small gold ring here.
/<$$< (wearing ring)
/On the Wumpus' finger is a small gold ring.
/
#73
/Four-leafed clover
/There is a four-leafed clover here!
/<$$< (wearing clover)
/
#74
/Gold tree
/There is a gold statue of a tree here.
/
#75
/Silver droplet
/There is a single droplet of silver on the ground here.
/
#76
#77
#78
#79
#80
#81
/Clear water
/
#82
/Cool water
/
#83
/Thick, black oil
/
#84
/Thick, black oil
/
#85
/Vintage wine
/
#86
/Vintage wine
/
#87
/*Bumblebees
/<$$<
/Some bumblebees are swarming around a bunch of fresh flowers.
/
#88
/*Hollow wall
/Your footsteps echo hollowly throughout the chamber.
/<$$<
/
#89
/*Wall with safe
/A steel safe is embedded in the wall.
/
#90
/Tiny brass key
/There is a tiny brass key here.
/There is a tiny brass key on the shelf.
/
#91
/*Anvil
/<$$<
/
#92
/*rocks on cloak
/<$$< (ON CLOAK)
/<$$< (AFTER ROCK SLIDE)
/
#93
/*telephone booth
/The telephone booth is empty.
The phone is ringing.
/The phone booth is occupied by a gnome. He is talking excitedly
to someone at the other end.
/The telephone booth is empty.
/<$$<
/
#94
/*Telephone
/The phone is ringing.
/The telephone is out of order.
/The telephone is out of order. It is badly dented.
/<$$<
/
#95
/Lead slugs
/There are some lead slugs here!
/
#96
/Sweet honeycomb
/There is a sweet honeycomb here!
/
#97
/*Beehive
/There is an active beehive nearby. The bees hum protectively
around the hive.
/There is an empty beehive nearby.
/
#98
/*Black dog
/A hideous black dog bares his teeth and growls at your approach.
/Nearby, a large black dog is in a deep slumber.
/
#99
/*Dreaded Wumpus
/In the corner, a Wumpus is sleeping peacefully.
/A sleepy Wumpus is ambling towards you. He wants to invite you to
dinner. He wants you to *be* the dinner!
/The Wumpus is still on your trail! And he's getting closer!!
/The Wumpus is only a few steps behind you! All this exercise is
making him veerrrrry hungry!
/The Wumpus almost has you in his grasp! You can feel his hot breath
on your neck!
/"Chomp, chomp." Crunch! Chew! Slurp! Smack! Yum!!!
/Nearby is the smashed body of a defunct Wumpus.
/
#100
#101
/Little bird in cage
/A cheerful little bird is sitting here singing.
/There is a little bird in the cage.
/
#102
/Set of keys
/There are some keys on the ground here.
/
#103
/*Fountain
/There is a fountain of sparkling vintage wine here!
/
#104
/*Bats & guano in bat-cave
/<$$<
/
#105
/*gnome in phone booth
/<$$<
/
#106
/Colored mushrooms
/There are some oddly-colored mushrooms here.
/
#107
/Tiny cakes
/There are some tiny cakes on the shelf.
/
#108
/Leather Sack
/There is a leather sack here.
/
#109
#110
/Rare book
/There is a dusty, leather-bound volume here.
/
#111
/Rare book
/There is a dusty, leather-bound volume here.
/
#112
/Steel wall-safe
/The safe door is locked.
/The safe door is open.
/
#113
/Faded poster
/Taped to the wall is a faded poster.
/There is a faded poster here.
/
#114
/Whiskbroom
/There is a small whiskbroom here.
/
#115
/*Carving on dusty rocks
/<$$<
/<$$<
/
#116
/*Billboard
/
/
#117
#118
/Small metal canister
/There is a heavy, grey, metal canister here.
/
#119
/Glowing stone
/Nearby, a strange, greenish stone is glowing brightly.
/
#120
/Quartz sphere
/There is a polished sphere of pure quartz here!
/

File diff suppressed because it is too large Load Diff

View File

@@ -1,141 +0,0 @@
/* program DATABASE.C */
#include <string.h>
#include <stdio.h>
#include "advent.h"
#include "advdec.h"
#include "advtext.h"
static char oline[256];
_PROTOTYPE(void rdupto, (FILE *, int, int, char *));
_PROTOTYPE(void rdskip, (FILE *, int, int));
/*
Function to scan a file up to a specified
point and either print or return a string.
*/
void rdupto(fdi, uptoc, print, string)
FILE *fdi;
int uptoc, print;
char *string;
{
int c, i;
static _CONST unsigned char key[4] = {'c' | 0x80, 'L' | 0x80,
'y' | 0x80, 'D' | 0x80};
i = 1;
while ((c = getc(fdi)) != uptoc && c != EOF) {
if (c == '\n')
i = 1;
if (c >= 0x80)
c ^= key[i++ & 3];
if (c == '\r')
continue;
if (print)
putchar(c);
else
*string++ = (char) c;
}
if (!print)
*string = '\0';
return;
}
/*
Function to read a file skipping
a given character a specified number
of times, with or without repositioning
the file.
*/
void rdskip(fdi, skipc, n)
FILE *fdi;
int skipc, n;
{
int c;
while (n--)
while ((c = getc(fdi)) != skipc)
if (c == EOF)
bug(32);
return;
}
/*
Routine to request a yes or no answer to a question.
*/
boolean yes(msg1, msg2, msg3)
int msg1, msg2, msg3;
{
char answer[INPUTBUFLEN];
if (msg1)
rspeak(msg1);
do {
switch (*ask("\n> ", answer, sizeof(answer))) {
case 'n':
case 'N':
if (msg3)
rspeak(msg3);
return (FALSE);
case 'y':
case 'Y':
if (msg2)
rspeak(msg2);
return (TRUE);
default:
fputs("Please answer Y (yes) or N (no).", stdout);
}
} while (TRUE);
}
/*
Print a location description from "advent4.txt"
*/
void rspeak(msg)
int msg;
{
if (msg == 54)
printf("ok.\n");
else {
fseek(fd4, idx4[msg - 1], 0);
rdupto(fd4, '#', 1, 0);
}
return;
}
/*
Print an item message for a given state from "advent3.txt"
*/
void pspeak(item, state)
int item, state;
{
fseek(fd3, idx3[item - 1], 0);
rdskip(fd3, '/', state + 2);
rdupto(fd3, '/', FALSE, oline);
if (strncmp(oline, "<$$<", 4) != 0)
printf("%s", oline);
return;
}
/*
Print a long location description from "advent1.txt"
*/
void desclg(loc)
int loc;
{
fseek(fd1, idx1[loc - 1], 0);
rdupto(fd1, '#', 1, 0);
return;
}
/*
Print a short location description from "advent2.txt"
*/
void descsh(loc)
int loc;
{
fseek(fd2, idx2[loc - 1], 0);
rdupto(fd2, '#', 1, 0);
return;
}

View File

@@ -1,676 +0,0 @@
/* program ENGLISH.C */
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include "advent.h"
#include "advdec.h"
#define ALL 109
#define ENTER 3
#define CRAWL 17
#define JUMP 39
#define CLIMB 56
#define XYZZY 62
#define PLUGH 65
#define PLOVER 71
#define PHUCE 82
_PROTOTYPE(static void getwords, (void));
_PROTOTYPE(static void clrlin, (void));
_PROTOTYPE(static void doobj, (int *));
_PROTOTYPE(static boolean doiobj, (void));
_PROTOTYPE(static boolean do_scoop_up, (void));
_PROTOTYPE(static boolean check_next, (void));
static char buffer[INPUTBUFLEN] = {'\0', '\0', '\0', '\0'};
static char *txt[MAXWORDS] = {buffer, buffer, buffer, buffer};
static char *cindex = buffer;
static boolean pflag;
static int vrbkey, words[MAXWORDS] = {0, 0, 0, 0}, word, wdx = 0;
static int takdir[20] = {2, 6, 9, 10, 11, 13, 14, 17, 23, 25,
33, 34, 36, 37, 39, 78, 79, 80, 89, -1};
static int vkey[60] = {
0, 199, 9, 0, 130, 0, 197, 0, 0, 243,
0, 0, 89, 140, 0, 5, 0, 227, 0, 0,
0, 31, 42, 0, 0, 0, 0, 172, 1, 0,
0, 0, 254, 0, 69, 0, 0, 92, 0, 0,
138, 137, 149, 239, 45, 74, 183, 0, 0, 112,
241, 0, 114, 0, 30, 0, 0, 0, 0, 0
};
static int ptab[260] = {
0, 3028, 3065, 3009, -3005, 5071, 5070, 5058, -5020, 19055,
19108, 19038, 19020, 19071, 19070, 19058, 19004, 19048, 19091, 19094,
19112, 19002, 19118, 2062, 2066, 2047, 2067, 2053, 2065, -2010,
-3114, 4034, 4011, 4101, 4035, 4099, 4098, 4017, 4104, 4014,
4015, -4087, 3083, 3085, -3081, 5055, 5108, 5020, 5071, 5070,
5058, 5004, 5048, 5091, 5112, 5099, 5118, 19055, 19108, 19020,
19071, 19070, 19058, 19004, 19048, 19091, 19112, 19099,-19118, 3028,
3065, 3009, 3005, -3018, 19055, 19108, 19038, 19020, 19071, 19070,
19058, 19004, 19004, 19048, 19091, 19094, 19112, 19002,-19118, 3028,
3065, -3018, 19055, 19108, 19038, 19020, 19071, 19070, 19058, 19004,
19048, 19091, 19094, 19112, 19118, 2062, 2066, 2047, 2067, 2053,
2065, -2010, 3102, -3090, 19055, 19108, 19020, 19071, 19070, 19058,
19004, 19048, 19091, 19014, 19015, 19112, 19118, 19120, 19120, -9999,
3090, 3102, 3028, 3057, 3065, 3009, -3005,-29999, 2052, -2068,
2024, 2065, 2091, 2042, 2073, 5071, 5070, 5058, -5020, 30999,
2062, 2066, 2047, 2067, 2053, 2065, 2010, 2073, 19055, 19108,
19038, 19020, 19071, 19070, 19058, 19004, 19048, 19091, 19094, 19112,
19002,-19118, 2014, 2015, 2013, 2999, 5014, 5015, 5013, 5999,
5110, 5113, -5999, 5055, 5108, 5020, 5071, 5070, 5058, 5004,
5048, 5091, 5014, 5015, 5112, 5099, -5118, 3102, -3090, 6066,
6047, 6067, 6053, 6072, 6073, 5055, 5108, 5020, 5071, 5070,
5004, 5004, 5048, 5091, 5112, 5099, 5118, 19055, 19108, 19020,
19071, 19070, 19058, 19004, 19048, 19091,-19118, 4034, 4011, 4101,
4035, 4099, 4098, 4017, 4104, 4027, 4087, 9999,-30999, 2002,
-6002, 3102, -3090, 9999, 4034, 4011, 4101, 4035, 4099, 4087,
4098, 4017, 4104, -4027, -5999, 0, 0, 0, 0, 0,
};
static int adjkey[40] = {
0, 15, 38, 64, 4, 63, 1, 61, 62, 67,
9, 27, 53, 46, 47, 60, 31, 39, 40, 6,
43, 26, 32, 28, 34, 50, 49, 45, 44, 10,
20, 25, 21, 36, 37, 30, 33, 0, 0, 0
};
static int adjtab[70] = {
0, 5, 98, -83, 2, -90, 66, 41, -90, -39,
41, 14, 15, 50, -11, 50, 64, 56, 72, -74,
-19, 119, 59, 73, -118, -119, -70, -41, 95, -118,
-118, -58, -71, -120, 110, -108, -120, -73, -62, -60,
110, 54, -63, -67, -41, -27, -47, 52, -75, -69,
65, 112, -3, 41, 72, 90, 20, 101, 107, -118,
-55, -10, -38, -4, 48, 9, -71, -39, 0, 0
};
/*
Analyze a two word sentence
*/
int english()
{
char *ch_ptr, *word1, *word2;
int type, val, type2, val2, adj, k, kk;
static int iwest = 0;
if (!(words[++wdx])) {
getwords();
wdx = 0;
}
pflag = FALSE;
word = words[wdx];
if (word < 0) { /* check first word */
printf("I didn't understand the word \"%s\"\n", txt[wdx]);
words[wdx+1] = 0;
return (FALSE); /* didn't know it */
}
type2 = val2 = -1;
type = CLASS(word);
clrlin();
val = VAL(word);
if (words[wdx + 1] && CLASS(words[wdx + 1]) != CONJUNCTION) {
/* 'SAY' or 'CALL'. If no next word, pass on to higher powers. */
if (type == ACTION && (val == SAY || val == YELL)) {
word = words[++wdx];
if (!(word == XYZZY || word == PLUGH
|| word == PLOVER || word == PHUCE)) {
if (val == SAY)
printf("Okay, \"%s\".\n", txt[wdx]);
else {
for (ch_ptr = txt[wdx]; *ch_ptr; ch_ptr++)
if (islower(*ch_ptr))
*ch_ptr = toupper(*ch_ptr);
printf("Okay, \"%s\"!!!!!\n", txt[wdx]);
}
return (FALSE);
}
} else {
word1 = txt[wdx];
word2 = txt[wdx + 1];
/* Special stuff for 'ENTER'. Can't go into water. 'ENTER
BOAT' means 'TAKE BOAT' */
if (word == ENTER) {
if (CLASS(words[wdx + 1]) == NOUN && VAL(words[wdx + 1]) == BOAT)
word = TAKE + 2000;
else if ((strcmp(word2, "stream") == 0)
|| (strcmp(word2, "water") == 0)
|| (strcmp(word2, "reservoir") == 0)
|| (strcmp(word2, "ocean") == 0)
|| (strcmp(word2, "sea") == 0)
|| (strcmp(word2, "pool") == 0)) {
rspeak(liqloc(g.loc) == WATER ? 70 : 43);
wdx++;
return (FALSE);
}
} else {
type2 = CLASS(words[wdx + 1]);
val2 = VAL(words[wdx + 1]);
/* 'LEAVE' is motion verb, unsless leaving an object.
E.G., 'LEAVE BOAT' or 'LEAVE BOTTLE'. BUt make sure
to leave ('DROP') only totable objects. */
if (strcmp(word1, "leave") == 0 && type2 == NOUN) {
if (!hinged(val2) || g.fixed[val2])
word = LEAVE + 2000;
/* IF 'LIGHT LAMP', Light must be taken as an
action verb, not a noun. */
} else if (strcmp(word1, "light") == 0
&& VAL(words[wdx + 1]) == LAMP) {
word = ON + 2000;
/* 'WATER PLANT' becomes 'POUR WATER', If we are at
plant. 'OIL DOOR' becomes 'POUR OIL', etc., etc. */
} else if ((strcmp(word1, "water") == 0 || strcmp(word1, "oil") == 0)
&& (strcmp(word2, "plant") == 0 || strcmp(word2, "door") == 0
|| strcmp(word2, "sword") == 0 || strcmp(word2, "anvil") == 0)
&& at(val2)) {
words[wdx + 1] = word;
txt[wdx + 1] = txt[wdx];
word = POUR + 2000;
}
}
}
}
/* This is the 'inner' loop. Dispatching of all word in a clause
after the first comes through here. */
do {
switch (CLASS(word)) {
case MOTION:
{
boolean do_part2;
int i;
do_part2 = FALSE;
type = CLASS(verbs[vrbx]);
val = VAL(verbs[vrbx]);
if (!vrbx)
do_part2 = TRUE;
else {
if (type > ACTION) {
rspeak(confuz());
return (FALSE);
}
}
if (type == ACTION) {
if (val == GO)
do_part2 = TRUE;
else {
if (val == TAKE) {
for (i = 0; i < 20; i++)
if (takdir[i] == val)
do_part2 = TRUE;
}
if (!do_part2) {
word = vocab(txt[wdx], 1);
if (word)
words[wdx--] = word;
}
}
} else if (type != CRAWL && type != JUMP
&& type != CLIMB)
do_part2 = TRUE;
if (do_part2) {
verbs[1] = word;
vrbx = 1;
if (strcmp(txt[wdx], "west") == 0) {
iwest++;
if (iwest == 10)
rspeak(17);
}
}
break;
}
case NOUN:
if (pflag) {
if (!doiobj())
return (FALSE);
} else {
word = VAL(word);
if (word == ALL) {
if (!do_scoop_up())
return (FALSE);
} else {
doobj(&word);
if (word > 0) {
objs[++objx] = word;
otxt[objx] = txt[wdx];
} else {
clrlin();
pflag = FALSE;
wdx++;
while (words[wdx]) {
if (CLASS(words[wdx]) == CONJUNCTION)
break;
wdx++;
}
if (words[wdx] == 0)
return (FALSE);
}
}
}
break;
case ACTION:
if (vrbx == 0)
vrbx++;
else {
if (VAL(verbs[vrbx]) == TAKE) {
val = VAL(word);
if (val == DRINK || val == INVENTORY
|| val == SCORE || val == NOTHING
|| val == LOOK);
else if (val == GO && (
strcmp(txt[wdx], "walk") == 0
|| strcmp(txt[wdx], "run") == 0
|| strcmp(txt[wdx], "hike") == 0));
else {
rspeak(confuz());
return (FALSE);
}
} else if (objx || CLASS(words[wdx - 1]) == CONJUNCTION) {
rspeak(confuz());
return (FALSE);
}
}
verbs[vrbx] = word;
vtxt[vrbx] = txt[wdx];
break;
case MISC:
if (vrbx) {
rspeak(confuz());
return (FALSE);
}
verbs[1] = word;
vrbx = 1;
break;
case PREPOSITION:
if (CLASS(verbs[vrbx]) != ACTION || iobx) {
rspeak(confuz());
return (FALSE);
}
vrbkey = vkey[VAL(verbs[vrbx])];
if (!vrbkey) {
rspeak(confuz());
return (FALSE);
}
prep = VAL(word);
pflag = TRUE;
break;
case ADJACTIVE:
/* Adjective handler. Scarf the next word, make sure it is
a valid object for this object. Then call getobj to see
if it is really there, Then link into object code. */
adj = VAL(word);
if (!check_next())
return (FALSE);
else if (CLASS(word) == CONJUNCTION) {
printf("%s what?\n", txt[wdx - 1]);
return (FALSE);
} else {
if (CLASS(word) != NOUN)
word = vocab(txt[wdx], NOUN);
if (word == -1 || CLASS(word) != NOUN || VAL(word) == ALL) {
rspeak(confuz());
return (FALSE);
}
words[wdx] = word;
kk = VAL(word);
for (k = adjkey[adj]; adjtab[k] >= 0; k++) {
if (kk == abs(adjtab[k]))
break;
}
if (adjtab[k] < 0) {
rspeak(confuz());
return (FALSE);
}
}
break;
case CONJUNCTION:
if (!check_next())
return (FALSE);
switch (CLASS(word)) {
case MOTION:
case ACTION:
case MISC:
words[wdx--] = 0;
break;
case NOUN:
case ADJACTIVE:
break;
case PREPOSITION:
case CONJUNCTION:
rspeak(confuz());
return (FALSE);
default:
bug(33);
}
break;
default:
bug(33);
}
word = words[++wdx];
if (word < 0) {
if (pct(50))
printf("I don't understand the word %s?\n", txt[wdx]);
else
printf("Mumble ? %s\n", txt[wdx]);
words[wdx+1] = 0;
return (FALSE);
}
type = CLASS(word);
if (type == NOUN) {
/* It's not the first: Make sure he included a comma or
'and'. Differenctiate between direct & indirect objects.
Check for special case of multiple ofjects: 'feed bear
honey' or 'throw troll nugget'. */
if ((pflag ? iobx : objx)
&& CLASS(words[wdx - 1]) != CONJUNCTION) {
val = VAL(verbs[vrbx]);
if (!living(objs[objx]) || (val != THROW && val != FEED)) {
rspeak(confuz());
return (FALSE);
}
iobx++;
iobjs[iobx] = objs[objx];
objs[objx] = 0;
objx++;
}
}
} while (word);
if (verbs[1] == 0) {
if (objs[1] == 0) {
rspeak(confuz());
clrlin();
} else if (objs[2])
printf("What do you want to do with them?\n");
else
printf("What do you want to do with %s?\n", otxt[1]);
return (FALSE);
} else if (objx > 1 && iobx > 1) {
rspeak(confuz());
return (FALSE);
}
return (TRUE);
}
/*
retrieve input line (max INPUTBUFLEN chars), convert to lower case
& rescan for first two words (max. WORDSIZE-1 chars).
*/
static void getwords()
{
static int wdx = 0;
int i, term_loc;
char terminator;
if (*cindex == '\0') {
while (!*ask("\n> ", buffer, sizeof(buffer))) ;
for (cindex = buffer; *cindex; cindex++)
if (isupper(*cindex))
*cindex = tolower(*cindex);
cindex = buffer;
}
wdx = 0;
buffer[sizeof(buffer)-1] = '\0';
for (i = 0; i < MAXWORDS; i++) {
txt[i] = &buffer[sizeof(buffer)-1];
words[i] = 0;
}
do {
while (*cindex == ' ')
cindex++;
txt[wdx] = cindex;
term_loc = strcspn(cindex, " ,.;\n");
cindex += term_loc;
terminator = *cindex;
*cindex++ = '\0';
if ((strcmp(txt[wdx], "a") != 0)
&& (strcmp(txt[wdx], "the") != 0)
&& (strcmp(txt[wdx], "an") != 0)) {
words[wdx] = vocab(txt[wdx], 0);
wdx++;
}
if (terminator == ',') {
txt[wdx] = "and";
words[wdx] = vocab(txt[wdx], 0);
wdx++;
}
}
while ((terminator != ';') && (terminator != '.')
&& (terminator != '\0') && (terminator != '\n'));
if (terminator == '\0')
cindex--;
return;
}
/* CLRIN, clears out all surrent syntax args in preparation for
* new input line
*/
static void clrlin()
{
int i;
for (i = 0; i < MAXWORDS; i++) {
verbs[i] = 0;
vtxt[i] = &buffer[sizeof(buffer)-1];
}
for (i = 0; i < MAXITEMS; i++) {
objs[i] = 0;
otxt[i] = &buffer[sizeof(buffer)-1];
iobjs[i] = 0;
iotxt[i] = &buffer[sizeof(buffer)-1];
}
vrbx = 0;
objx = 0;
iobx = 0;
prep = 0;
}
/*
Routine to process an object.
*/
static void doobj(object)
int *object;
{
int msg;
if (holding(*object))
return;
if (blind()) {
printf("I see no %s here.\n", txt[wdx]);
*object = 0;
return;
}
/* Is object here? if so, transitive */
if (g.fixed[*object] == g.loc || athand(*object))
return;
else if (here(*object)) {
msg = plural(*object) ? 373 : 335;
*object = 0;
rspeak(msg);
}
/* Did he give grate as destination? */
else if (*object == GRATE) {
if (g.loc == 1 || g.loc == 4 || g.loc == 7) {
verbs[1] = DEPRESSION;
vrbx = 1;
return;
} else if (g.loc > 9 && g.loc < 15) {
verbs[1] = ENTRANCE;
vrbx = 1;
return;
}
}
/* Is it a dwarf he is after? */
else if (dcheck() && g.dflag >= 2) {
*object = DWARF;
}
/* Is he trying to get/use a liquid? */
else if (liqloc(g.loc) == *object
|| (liq(BOTTLE) == *object && athand(BOTTLE))
|| (liq(CASK) == *object && athand(CASK)));
else if (*object == PLANT && at(PLANT2) &&
g.prop[PLANT2] == 0) {
*object = PLANT2;
} else if (*object == ROCKS && at(CARVNG)) {
*object = CARVNG;
}
/* Is he trying to grab a knife? */
else if (*object == KNIFE && g.knfloc == g.loc) {
rspeak(116);
g.knfloc = -1;
}
/* Is he trying to get at dynamite? */
else if (*object == ROD && athand(ROD2)) {
*object = ROD2;
} else if (*object == DOOR && (at(SAFE) || at(TDOOR)
|| at(TDOOR2) || at(PDOOR))) {
if (at(TDOOR2))
*object = TDOOR2;
else if (at(PDOOR))
*object = PDOOR;
else if (at(SAFE))
*object = SAFE;
else
*object = TDOOR;
} else if (*object == BOOK && athand(BOOK2)) {
*object = BOOK2;
} else if (!(verbs[vrbx] == FIND || verbs[vrbx] == INVENTORY)) {
*object = 0;
printf("I see no %s here.\n", txt[wdx]);
}
return;
}
static boolean doiobj()
{
char dk[INPUTBUFLEN], dkk[INPUTBUFLEN];
int kk;
boolean ok;
/* checks object is valid for this preposition */
ok = TRUE;
word = VAL(word);
if (word != ALL) {
doobj(&word);
if (word > 0) {
iobjs[++iobx] = word;
iotxt[iobx] = txt[wdx];
} else
ok = FALSE;
}
kk = abs(ptab[vrbkey]) / 1000;
if (kk == prep) {
/* preprosition is valid with this verb now check object of
preprosition */
if (word == 0 || CLASS(word) == CONJUNCTION) {
/* no object following prepresition: check special cases */
pflag = FALSE;
strcpy(dk, txt[--wdx]);
strcpy(dkk, vtxt[vrbx]);
ok = FALSE;
if ((strcmp(dk, "on") == 0
|| strcmp(dk, "off") == 0)
&& (strcmp(dkk, "turn") == 0
|| objs[objx] == LAMP))
ok = TRUE;
if (strcmp(dkk, "take") == 0
|| strcmp(dkk, "put") == 0)
ok = TRUE;
if (strcmp(dk, "up") == 0
&& strcmp(dkk, "pick") == 0)
ok = TRUE;
if (strcmp(dk, "down") == 0
&& (strcmp(dkk, "put") == 0 || verbs[vrbx] == THROW) )
ok = TRUE;
} else {
/* object follows preposition See if it's plausible. */
kk = abs(ptab[vrbkey]) % 1000;
if (kk == word && kk == ALL) {
if (!do_scoop_up())
return (FALSE);
} else if (!(kk == word || kk == 999)) {
vrbkey++;
ok = ptab[vrbkey - 1] < 0 ? FALSE : TRUE;
}
}
}
return (ok);
}
static boolean do_scoop_up()
{
int i, val;
val = VAL(verbs[vrbx]);
if (val == DROP || val == PUT || val == LEAVE) {
for (i = 1; i < MAXOBJ; i++) {
if (!athand(i) || g.fixed[i])
continue;
if (i > WATER && i <= WINE + 1)
continue;
if (toting(i)) {
objs[++objx] = i;
otxt[objx] = "BUG???";
if (objx >= 44)
break;
}
}
}
if (val == TAKE || val == PICK || val == GET) {
if (blind()) {
rspeak(357);
return (FALSE);
} else {
for (i = 1; i < MAXOBJ; i++) {
if (!athand(i) || g.fixed[i])
continue;
if (i > WATER && i <= WINE + 1)
continue;
if (!toting(i)) {
objs[++objx] = i;
otxt[objx] = "BUG???";
if (objx >= 44)
break;
}
}
}
}
return (TRUE);
}
static boolean check_next()
{
word = words[wdx + 1];
if (word > 0)
return (TRUE);
else if (word == 0)
rspeak(confuz());
else {
if (pct(50))
printf("I don't understand the word %s?\n", txt[wdx]);
else
printf("Mumble ? %s\n", txt[wdx]);
words[wdx+1] = 0;
}
return (FALSE);
}

Some files were not shown because too many files have changed in this diff Show More