1932 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
Arun Thomas
207e88d3c4 Update release script for pkgsrc 2010-09-10 17:00:30 +00:00
David van Moolenbroek
d29833c5aa remove hardcoding of system.conf path in various service calls 2010-09-10 09:22:22 +00:00
David van Moolenbroek
6b902492ae memory driver: propagate data copy error to caller 2010-09-09 16:13:02 +00:00
David van Moolenbroek
2bda06bbb5 shutdown(8): buffer accessed beyond end during option parsing 2010-09-09 08:48:47 +00:00
David van Moolenbroek
2e209097b6 IS: delete obsolete is.h 2010-09-09 08:47:39 +00:00
Tomas Hruby
e6ebac015d APIC mode uses IO APICs
- kernel turns on IO APICs if no_apic is _not_ set or is equal 0

- pci driver must use the acpi driver to setup IRQ routing otherwise
  the system cannot work correctly except systems like KVM that use
  only legacy (E)ISA IRQs 0-15
2010-09-07 07:18:11 +00:00
Erik van der Kouwe
5cc29a6c7e Make realpath deal with double slashes 2010-09-06 07:45:32 +00:00
Tomas Hruby
ad5ecf906b asm.h not installed 2010-09-03 17:01:18 +00:00
Erik van der Kouwe
18ad0b52d3 Make hexdump ACK-compilable and add it to the base system 2010-09-03 07:37:31 +00:00
Arun Thomas
9e4e26e0c8 No more packman, easypack, packit
-Create a dummy packman script that tells users about pkgin
2010-09-03 07:27:39 +00:00
Tomas Hruby
99d9144556 PCI driver uses ACPI if APIC is used.
-  PCI must query ACPI, if (IO)APIC is in use, for the routing
   information and change the ILR (interrupt line register) of each
   device accordingly so drivers use the right IRQ.
2010-09-02 15:44:38 +00:00
Tomas Hruby
7ae6f8740d ACPI driver loaded at boot time
- the acpi driver is part of the ramdisk and if present the rc script
  starts it before pci is started as pci needs if APIC mode is turned
  on.
2010-09-02 15:44:36 +00:00
Tomas Hruby
9560b6dea8 ACPI driver
- 99% of the code is Intel's ACPICA. The license is compliant with BSD
  and GNU and virtually all systems that use ACPI use this code, For
  instance it is part of the Linux kernel.

- The only minix specific files are

  acpi.c
  osminixxf.c
  platform/acminix.h

  and

  include/minix/acpi.h

- At the moment the driver does not register interrupt hooks which I
  believe is mainly for handling PnP, events like "battery level is
  low" and power management. Should not be difficult to add it if need
  be.

- The interface to the outside world is virtually non-existent except
  a trivial message based service for PCI driver to query which device
  is connected to what IRQ line. This will evolve as more components
  start using this driver. VM, Scheduler and IOMMU are the possible
  users right now.

- because of dependency on a native 64bit (long long, part of c99) it
  is compiled only with a gnu-like compilers which in case of Minix
  includes gcc llvm-gcc and clang
2010-09-02 15:44:04 +00:00
Tomas Hruby
43a4725423 pci_*.h headers moved from drivers/pci to include/machine 2010-09-02 15:43:59 +00:00
Tomas Hruby
2440ffae49 Kernel exports DSDP and apic_enabled in machine structure
- kernel exports DSDP (the root pointer where ACPI parsing starts) and
  apic_enabled in the machine structure.

- ACPI driver uses DSDP to locate ACPI in memory. acpi_enabled tell
  PCI driver to query ACPI for IRQ routing information.
2010-09-02 15:43:56 +00:00
Tomas Hruby
344e9221ec Kernel supports up to 64 IRQs
- enough for 2 io apics (usually with 24 pins)
2010-09-02 15:43:54 +00:00
Tomas Hruby
45badf4c05 ACPI in kernel
- the ability for kernel to use ACPI tables to detect IO APICs. It is
  the bare minimum the kernel needs to know about ACPI tables.

- it will be used to find out about processors as the MPS tables are
  deprecated by ACPI and not all vendorsprovide them.
2010-09-02 15:43:51 +00:00
Thomas Veerman
e7252adc1e Clean up the created temp file after running the test. 2010-09-02 09:33:37 +00:00
Ben Gras
eca25a6cab removed redundant includes dependency from gnu-libraries. 2010-09-01 18:48:47 +00:00
Ben Gras
c6cfdbffe4 also make gcc includes before compiling gcc libraries. 2010-09-01 18:28:55 +00:00
Thomas Veerman
0b00cf70b6 - Return ENOENT when trying to add files to removed (but open) directories.
- Add test58 to test this behavior.
2010-09-01 09:07:18 +00:00
Tomas Hruby
bf6f0216d5 tools/Makefile uses padtext only when building with ack 2010-09-01 07:46:51 +00:00
Ben Gras
b3c3a1cb1e gcc compiles - add -fno-builtin so that gcc optimisations don't break things.
- kernel compile was broken with gcc as putchar() was added by gcc in
    stacktrace.c
  - add -fno-builtin everywhere to avoid such problems in the future
  - -fno-builtin in kernel now redundant
2010-08-31 16:42:44 +00:00
Ben Gras
b1847ae244 make service look in /etc/system.conf.d/<progname> first for config file.
This makes it easier to
  - have non-base system drivers (get clobbered by global system.conf)
  - have drivers as packages (can't touch global system.conf)
  - make configs part of the drivers/servers instead of in global file
    (makes system parts more self-contained)
2010-08-31 14:33:31 +00:00
Erik van der Kouwe
1f2054c89c Shutdown changes for multiboot: CTRL-ALT-DEL resets, panic halts 2010-08-30 19:01:58 +00:00
David van Moolenbroek
4448836263 ramdisk: more inodes 2010-08-30 17:08:19 +00:00
Arun Thomas
36fb30dfef cdefs.h: Allow __CONCAT() macro to be nested 2010-08-30 14:34:58 +00:00
Thomas Veerman
a4c30acd9d Improve UDS testing. Fix a few bugs. Add testing of passing file descriptors.
Contributed by Thomas Cort.
2010-08-30 13:49:49 +00:00
Thomas Veerman
e8ddc0f46e - Add support for file descriptor passing to PFS.
- For security reasons move some libc code to PFS.
- Fix a few bugs in PFS.
Contributed by Thomas Cort.
2010-08-30 13:46:44 +00:00
Thomas Veerman
13ef7f1f38 Prepare VFS to support back calls from PFS. For security reasons and to support
file descriptor passing, PFS does some back calls to VFS. For example, to
verify the validity of a path provided by a process and to tell VFS it must
copy file descriptors from one process to another.
2010-08-30 13:44:07 +00:00
Thomas Veerman
2297e26660 Prepare headers to support file descriptor passing over UNIX Domain Sockets.
Contributed by Thomas Cort.
2010-08-30 13:41:22 +00:00
Erik van der Kouwe
a0bb199f69 Release script improvements, moving towards having the ramdisk working again 2010-08-29 19:22:42 +00:00
Erik van der Kouwe
a37514163b Touch generated files to avoid dependency generation warnings and missing dependencies 2010-08-29 17:50:51 +00:00
Erik van der Kouwe
a5741a465f update /etc on make world 2010-08-27 10:09:06 +00:00
David van Moolenbroek
3e3d627b25 mdb: disassembly fix for short 8-bit values 2010-08-27 09:31:26 +00:00
Arun Thomas
a78608ec86 Fix dependency problems in the build 2010-08-26 19:54:49 +00:00
Ben Gras
c81f201c8c added missing sef_gcov.c 2010-08-25 13:23:32 +00:00
Ben Gras
5d6c2aae0a gcov support, based on work contributed by Anton Kuijsten. 2010-08-25 13:06:43 +00:00
Ben Gras
d8466ce31f libaudiodriver <minix/audio_fw.h> fixes 2010-08-25 11:18:38 +00:00
Ben Gras
1c359afad4 connect libaudiodriver. 2010-08-25 11:07:36 +00:00
Ben Gras
0f4eda33eb new base libaudiodriver out of -lcommon in drivers/audio.
- this lets the drivers that used that library be compiled easily with
   different compilers.
2010-08-25 11:03:53 +00:00
Ben Gras
cb86231930 sb16: flatten mixer, common, dsp hierarchy into 2-PROGS dir 2010-08-25 09:57:10 +00:00
Ben Gras
36fa521a0e further ramdisk size increase for gcc+gcov binaries. 2010-08-25 07:26:00 +00:00
Ben Gras
1d0e0e217d <stddef.h> - alternative definition of offsetof for gcc using builtin 2010-08-25 07:25:32 +00:00
Erik van der Kouwe
50ca7f7f8f Zero out to three stack dwords to fix boot errors 2010-08-24 12:51:11 +00:00
Ben Gras
6fb1789ba4 at_wini: fix warning, bogus PRIVATE in struct type declaration 2010-08-24 12:45:37 +00:00
David van Moolenbroek
959026c29a RS: use PM's API instead of its internals 2010-08-24 07:20:41 +00:00
Erik van der Kouwe
3211be5d14 Avoid duplicate type definitions, especially wchar_t which was inconsstent and caused trouble in libarchive 2010-08-23 17:00:04 +00:00
Erik van der Kouwe
a2647a4181 Fix buffer overflow in libarchive if a UTF-8 encoded string has codepoints that require two UTF-16 words 2010-08-23 16:32:05 +00:00
Erik van der Kouwe
d743c5c6f3 Solve buffer overflow on tab completion in ash 2010-08-23 16:30:58 +00:00
Arun Thomas
c9d500e9fd Import hexdump(1) from NetBSD 2010-08-21 13:24:09 +00:00
Arun Thomas
de231a713e Move MIN() and MAX() macros to sys/params.h 2010-08-21 13:10:41 +00:00
Arun Thomas
60a71efca8 easprintf() and evasprintf() 2010-08-21 13:07:25 +00:00
Erik van der Kouwe
292f98dc29 Minor malloc-debug fixes 2010-08-20 19:50:36 +00:00
Erik van der Kouwe
2a736d0c2e Add MALLOC_DEBUG env var to debug applications using malloc 2010-08-20 19:16:31 +00:00
Erik van der Kouwe
b337d3f8e5 move rrrrrrread_tsc from libsys to libc so anyone can use it 2010-08-20 18:43:56 +00:00
Ben Gras
205855b8ee boot ramdisk slightly bigger for gcc-compiled binaries. 2010-08-20 12:59:55 +00:00
Erik van der Kouwe
b9f5e50421 Provide boot image process main functions with a full parameter list, so that bad things don't heppen when using getenv 2010-08-20 11:07:16 +00:00
Ben Gras
02440068fc update MANPATH for gcc, X 2010-08-19 16:35:01 +00:00
Ben Gras
4b9420d7d7 mk: use ar instead of gar for gcc/clang ar. 2010-08-18 16:08:10 +00:00
Ben Gras
3e7c270f6c rc: add /sbin to $PATH for fsck.mfs 2010-08-18 16:07:54 +00:00
Arun Thomas
9a21d1a2fd Macros for symbols used in both ASM and C
-The macros take care of prepending the leading underscore when
 necessary.
2010-08-17 16:44:07 +00:00
Thomas Veerman
c8cfcab5db - Make sure there's space left in the vmnt table for another mount point.
- Increase mount point limit.
2010-08-17 10:02:50 +00:00
Erik van der Kouwe
551374c228 Add ftello function 2010-08-16 17:07:40 +00:00
Erik van der Kouwe
a3e4dcafe0 Add fseeko function 2010-08-16 17:06:08 +00:00
Ben Gras
66b8f17a29 AR=ar still needed for pkgsrc. 2010-08-14 20:28:32 +00:00
Ben Gras
b1eb16e5ff pkgsrc: no more g* prefix for binutils. 2010-08-13 13:33:51 +00:00
David van Moolenbroek
5a377144b0 diskctl(8) into commands makefile 2010-08-12 14:21:55 +00:00
David van Moolenbroek
78fc74633a diskctl(8) tool 2010-08-12 14:11:28 +00:00
David van Moolenbroek
484b2f43d6 at_wini/ahci: write cache ioctls 2010-08-12 14:09:34 +00:00
David van Moolenbroek
5998a4b2af AHCI driver: miscellaneous changes
- check the DF status flag after each command
- increase I/O timeout from 15 to 30 seconds
- share some code between ATA and ATAPI after all
- produce more accurate errors on DIOCEJECT
- rename AHCI_ID_SIZE to the more appropriate ATA_ID_SIZE
- rearrange ahci.h in a now more sensible way
2010-08-12 14:08:23 +00:00
Erik van der Kouwe
f8c56494c9 Boot monitor shouldn't report memory after 4GB; the addresses are wrong and VM can't deal with it anyways 2010-08-12 13:44:47 +00:00
David van Moolenbroek
a7ed430587 ramdisk: actually add ahci to the image, too 2010-08-11 11:30:08 +00:00
David van Moolenbroek
3f6f7672c2 ramdisk: add preliminary support for ahci 2010-08-11 11:16:44 +00:00
David van Moolenbroek
5824aab560 small fix in hgfs.8 manpage 2010-08-11 10:01:34 +00:00
David van Moolenbroek
9acaece9cc fix ptrace.2 man page 2010-08-11 08:57:48 +00:00
David van Moolenbroek
bee1f38e01 VTreeFS library 2010-08-10 20:05:51 +00:00
Erik van der Kouwe
4e95b347a7 Make it possible again to compile the tests without installing GCC first 2010-08-09 05:51:01 +00:00
David van Moolenbroek
46624d640e hgfs comment fix: inode status, not statistics 2010-08-07 11:50:15 +00:00
Tomas Hruby
f7ef192c02 Fixed warning noreturn function returns in arch_system.c 2010-08-06 12:48:26 +00:00
Tomas Hruby
58654acf08 both ack and gcc can compile klib16.S 2010-08-06 12:46:44 +00:00
Tomas Hruby
905e94f058 gas2ack filters out .code16
- .code16 tells gnu as to generate 16bit assembly ack requires -mi86 switch
2010-08-06 12:46:01 +00:00
Erik van der Kouwe
c8f70b8154 Fix tests when run as root; use bin account but current directory 2010-08-06 12:33:32 +00:00
Tomas Hruby
ac9a7f47bd Missing prototype in pre_init.c
- gcc does not like it
2010-08-06 12:26:26 +00:00
Tomas Hruby
d5482f6e75 Reverted __packed for ACK
- ack does not produce packed structures
2010-08-06 10:28:40 +00:00
Tomas Hruby
6e614336d6 __packed defined for ACK 2010-08-06 09:53:53 +00:00
Erik van der Kouwe
c3c97e66b1 Fix ar error in testsh1.sh (ar was previously renamed to aal) 2010-08-06 09:28:26 +00:00
Erik van der Kouwe
5d4ef90b2c Fix cdiff error in testsh1.sh 2010-08-06 09:27:49 +00:00
David van Moolenbroek
16f2eb25f4 AHCI driver 2010-08-05 16:37:58 +00:00
Thomas Veerman
ce41c63f41 fsck and mkfs have been moved to /sbin 2010-08-05 15:11:10 +00:00
Ben Gras
e1f30da613 pkg_install: DESTDIR support. 2010-08-05 14:51:46 +00:00
Ben Gras
56770462c2 merge datasizes and unstack 2010-08-05 14:09:06 +00:00
Ben Gras
8da0925650 release.sh - let some packages come pre-installed (right now just pkgin) 2010-08-05 13:56:51 +00:00
Erik van der Kouwe
a9d31d3169 Remove spurious space 2010-08-05 13:35:41 +00:00
Thomas Veerman
5bf3967f26 Rename mkfs to mkfs.mfs and fsck to fsck.mfs. Add /sbin to root's PATH. 2010-08-05 12:35:00 +00:00
Erik van der Kouwe
0fc71a1154 Increase NR_INODES in the FS servers to match NR_VNODES in VFS 2010-08-05 11:37:37 +00:00
Erik van der Kouwe
912b4e0cb7 Return ENOSPC when out of inodes 2010-08-05 11:37:06 +00:00
Erik van der Kouwe
42a2c1a03a Increase max number of open files to 255 (more should be possible but does not seem necessary for now) 2010-08-04 13:35:19 +00:00
Thomas Veerman
e8846c3930 Also run test56, please 2010-08-04 10:03:50 +00:00
Ben Gras
83fc90c8c3 test57: test that state isn't corrupted after a signal handler being executed. 2010-08-04 09:00:58 +00:00
Erik van der Kouwe
b43f3b6bfc This patch copies the ext2 server onto the initial ramdisk, the final
patch to allow MINIX to boot from ext2.

To create a setup with MINIX on ext2, follow these steps:

- Assumptions:
  - there exists a primary partition c0dApB with a MINIX installation
    with GRUB support (/boot/image_latest exists on /dev/c0dApB)
  - there exists a free primary partition c0dCpD

- Create an ext2 filesystem on c0dApB (from Linux, until Tthom
  has ported mke2fs)

- Follow these steps (from a MINIX CD with ext2 support, another MINIX
  installation (not c0dApB) or Linux >= 2.6.35):

  mkdir /mnt/mfs /mnt/ext2
  mount /dev/c0dApBs0 /mnt/mfs
  mount /dev/c0dApBs1 /mnt/mfs/home
  mount /dev/c0dApBs2 /mnt/mfs/usr
  mount /dev/c0dCpD /mnt/ext2
  synctree  -f /mnt/mfs /mnt/ext2
  echo root=/dev/c0dCpD > /mnt/ext2/etc/fstab

  (note: no subpartitions used because that would confuse an unmodified
  bootloader)

- Add the new MINIX installation to GRUB according to steps 7&8 in
  http://wiki.minix3.org/en/SummerOfCode2010/MultiBoot/HowTo
2010-08-04 05:18:03 +00:00
Erik van der Kouwe
4eb7340395 Silence newroot 2010-08-03 13:58:36 +00:00
Erik van der Kouwe
4989de6acc Don't write to /etc/mtab in newroot, may be an issue on read-only filesystems 2010-08-03 13:57:58 +00:00
David van Moolenbroek
256c37f7fa mount: don't always autodetect 2010-08-03 13:46:00 +00:00
Ben Gras
42bbd56673 lib: when building clang/gcc libraries: add /usr/pkg/bin to $PATH 2010-08-03 11:21:25 +00:00
Ben Gras
e1dc59bd16 test Makefile: use any gcc in path 2010-08-03 11:20:31 +00:00
Ben Gras
9ce3961b8e mtree: drop /usr/local, add some pkgsrc dirs; /usr/etc/rc: pkgsrc rc.d 2010-08-03 11:18:18 +00:00
Dirk Vogt
4523163411 Some PCI config space registers have to be accessed in with there actual
width. Without this patch DDELinux is not able to read the PCI BARs
correctly.
2010-08-03 10:03:40 +00:00
Erik van der Kouwe
a719ab7780 Auto-detect ext2 partitions in mount 2010-08-03 06:28:58 +00:00
Ben Gras
453be3b530 rename nm and strip to acknm and ackstrip
this is to force invocations of these utils for ack to be
explicitly named such, so in the future binutils can be installed
in /usr/pkg without the g- prefix.
2010-08-02 16:09:19 +00:00
Erik van der Kouwe
0f92964a2f Oops 2010-08-02 14:49:35 +00:00
Erik van der Kouwe
25397ef756 Deal all shutdown cases with multiboot as either reset or poweroff depending on their type (contributed by Feiran 'Fam' Zheng) 2010-08-02 14:41:45 +00:00
Erik van der Kouwe
ebec792700 Display fallback message in case poweroff fails (contributed by Feiran 'Fam' Zheng) 2010-08-02 14:40:26 +00:00
Erik van der Kouwe
c7859a538c Replace newroot with a call to mount, will make type autodetect easier 2010-08-02 14:15:48 +00:00
Ben Gras
3b386ad39f minor pkgsrc tweaks; allow pkgsrc to install rc scripts in /usr/pkg/etc/rc.d 2010-08-02 12:28:24 +00:00
Thomas Veerman
dff0434eaf Add support for the ext2 file system. Contributed by Evgeniy Ivanov. 2010-08-02 11:44:45 +00:00
Thomas Veerman
253b4b3fe5 - Add support for ST_NOTRUNC to struct statvfs.
- Let tests that test for long file names check for that flag, so that they can
  verify the results properly.
2010-08-02 11:16:32 +00:00
David van Moolenbroek
20eced94e7 libdriver: allow driver to break out of message loop 2010-08-01 22:07:46 +00:00
David van Moolenbroek
da597227ac put env_arg[cv] declaration in minix/sysutil.h 2010-07-29 21:16:23 +00:00
Tomas Hruby
170b420d07 driver.h - missing guardian 2010-07-29 10:53:50 +00:00
Ben Gras
4510dddae4 add the sshd group 2010-07-29 09:54:34 +00:00
Ben Gras
49fe8e24b2 rename nameserv.h 2010-07-29 08:41:22 +00:00
Ben Gras
fb96391106 rename nemserv 2010-07-29 08:39:49 +00:00
Tomas Hruby
c80138ac71 BIOS function 0xE820 for memory map detection
- this function returns a ritcher description of available memory

- is ACPI compliant, ACPI data structures are excluded from free
  memory list

- available memory exported to Minix in a backwards compatible manner

- fallback to the old method if this function not available (old
  hardware)
2010-07-29 07:21:11 +00:00
Ben Gras
a022f412b5 extra includes to make porting cleaner 2010-07-28 16:32:45 +00:00
Ben Gras
05bbf81f93 new EPFNOSUPPORT errno 2010-07-28 16:32:21 +00:00
Ben Gras
b9cea27497 kernel: deadlock test with endpoints instead of slot numbers, slightly cleaner 2010-07-28 14:14:06 +00:00
Ben Gras
5d47cafa5b pkg_install: move db dir 2010-07-28 09:59:00 +00:00
Ben Gras
e9651ae962 pkgsrc: minor changes to paths, options. 2010-07-28 09:41:15 +00:00
Erik van der Kouwe
6dec907191 Shorter reporting of contiguous identical blocks for the IS VM dump (F8) to avoid MFS frrom filling many screens 2010-07-27 18:46:08 +00:00
Arun Thomas
dafc8f1062 Add poll.h
Open Group requires this. Reported by Thomas Cort.
2010-07-27 09:21:56 +00:00
Arun Thomas
ee1cabf06c Import poll() from NetBSD's libnbcompat 2010-07-26 20:46:04 +00:00
Ben Gras
541b5c5c38 inet_pton(), patched by Thomas Cort. 2010-07-26 14:47:10 +00:00
Ben Gras
008cc7c1a7 stdio.h - define P_tmpdir 2010-07-26 14:46:35 +00:00
Ben Gras
eb057107c5 pkg_install - bpm - changes to work with minix ftp client by Gautam Tirumala. 2010-07-26 14:02:05 +00:00
Ben Gras
cf975bbc22 gcc headers: look at pkgsrc-installed gcc too 2010-07-26 12:48:48 +00:00
Ben Gras
c297701987 libarchive: sanitize out-of-range uids/gids 2010-07-26 12:44:48 +00:00
Ben Gras
149153f8ca <sys/resource.h> - define RLIM_NLIMITS 2010-07-26 10:04:45 +00:00
Ben Gras
9f0364df60 lib - sanity check for group_from_gid etc. 2010-07-24 10:40:55 +00:00
Erik van der Kouwe
df0ba02a38 Multiboot support (contributed by Feiran "Fam" Zheng);
keep in mind that GRUB needs to be patched to read MFS for now;
use /boot/image_latest to boot the last compiled image in GRUB
2010-07-23 14:24:34 +00:00
Erik van der Kouwe
9212eab21f Add padtext utility (needed for Multiboot) 2010-07-23 14:22:49 +00:00
Erik van der Kouwe
d7c70a41e5 Allow vm to split blocks in memory map (needed for multiboot, contributed by Feiran "Fam" Zheng 2010-07-23 14:22:13 +00:00
Ben Gras
1c4065cd10 pkg_install: forget about OS_RELEASE, just a properly formatted OS_VERSION. 2010-07-23 14:10:23 +00:00
Ben Gras
34a58c8d82 inet_ntop, contributed by Thomas Cort. 2010-07-23 09:54:47 +00:00
Erik van der Kouwe
3a5d923bf1 IO port is always 16 bit, even for inl 2010-07-23 07:25:21 +00:00
Erik van der Kouwe
7b9bddad1b {in,out}s[bwl] deleted in previous commit, also delete their headers 2010-07-23 07:24:34 +00:00
Erik van der Kouwe
f389ad2655 Move sensitive instructions from libc into kernel 2010-07-23 07:12:47 +00:00
Erik van der Kouwe
a06e5c383d Throw out ins[bwl] and out[bwl] from libc as they are not used 2010-07-23 07:10:47 +00:00
Ben Gras
c4bb6abc2b vsprintf: fix special yet useful case for vsprintf where n < 1.
reported by jaldhar.
2010-07-22 22:35:44 +00:00
Ben Gras
6c2c2f3c34 libfp: use ${CC} instead of cc, reported by Antoine Leca. 2010-07-22 22:24:08 +00:00
Ben Gras
fe343bb002 Make kernel ipc log scripts work for separate ${.OBJDIR}.
contributed by Antoine Leca.
2010-07-22 22:04:37 +00:00
Ben Gras
3badab8b70 vfs - split fp_fd field into fd + callnr fields 2010-07-22 14:55:28 +00:00
Ben Gras
1c2dd749eb make.conf: make pkgsrc.conf separate. 2010-07-22 14:42:20 +00:00
Arun Thomas
dbde088d98 Replace NULL macro defs with null.h include 2010-07-22 10:03:31 +00:00
Tomas Hruby
62d44dc9ef service utility fix
- of course 0 is a valid cpu
2010-07-22 09:57:14 +00:00
Ben Gras
81f6039a7f pkg_install: some uname normalisation. 2010-07-22 08:28:12 +00:00
Ben Gras
e8e2f6f6b9 profile: don't set $MANPATH explicitly as it's already in man.conf. 2010-07-22 08:26:49 +00:00
Arun Thomas
88e7725c13 string.h: Include null.h 2010-07-21 15:37:42 +00:00
Erik van der Kouwe
5bf75abb30 Parse LODS correctly in gas2ack 2010-07-21 14:47:01 +00:00
Ben Gras
122a32b928 mkboot fix, missing " 2010-07-21 14:23:52 +00:00
David van Moolenbroek
220eafe705 inet: a little more resilience against misbehaving drivers 2010-07-21 13:47:50 +00:00
Tomas Hruby
f6f20e1269 Overly restrictive assert
- not true if APIC is enabled
2010-07-21 13:46:29 +00:00
Cristiano Giuffrida
7978f9d2f3 Unbreak gcc compilation for pfs. 2010-07-21 13:39:46 +00:00
Ben Gras
63deb069bb uname: make uname -r and -v both print out full version info.
the world seems to expect this, and do this.
2010-07-21 12:47:48 +00:00
Ben Gras
f6655c171b /usr/sbin in $PATH too. 2010-07-21 10:12:03 +00:00
Ben Gras
5e5d5ab1f6 make.conf: pkgsrc fix/workaround 2010-07-21 10:00:34 +00:00
Cristiano Giuffrida
0824146978 Disable debug info on trunk. 2010-07-21 08:22:24 +00:00
Cristiano Giuffrida
03bb1e5750 Don't panic so easily on unexpected pagefault. 2010-07-20 23:51:34 +00:00
Cristiano Giuffrida
91a83fe265 Crash recovery and live update support for VM. 2010-07-20 23:03:52 +00:00
Ben Gras
0b364d00bc install new Makefile in /usr instead. 2010-07-20 22:20:43 +00:00
Cristiano Giuffrida
0d984b36ef Get rid of static spare pages after VM startup. 2010-07-20 21:59:27 +00:00
Cristiano Giuffrida
40b4e71db2 COW for physically contiguous blocks in VM 2010-07-20 18:57:25 +00:00
Ben Gras
7f343ed574 kernel: clear MF_CONTEXT_SET on kernel exit. 2010-07-20 17:13:44 +00:00
Ben Gras
eb1627049f pkg_install: record OS version for created packages. 2010-07-20 17:10:21 +00:00
Ben Gras
c0074d3aa9 kernel: fix case of EAX getting clobbered after sigreturn. 2010-07-20 17:10:09 +00:00
Arun Thomas
13be76efe5 Makefile for pkgsrc repo update/checkout
-From DragonflyBSD with minor tweaks
2010-07-20 17:09:44 +00:00
Erik van der Kouwe
8fc07701bc UPDATING update 2010-07-20 07:52:55 +00:00
Erik van der Kouwe
fb24016c30 UPDATING update 2010-07-20 07:52:46 +00:00
Tomas Hruby
f248bffc9e service utility can par cpu option in system.conf
- does not have any effect, solely for debugging SMP

- backward compatible with older RS instance
2010-07-20 07:27:45 +00:00
Cristiano Giuffrida
1b7d95df29 Generalize interface of some VM functions 2010-07-20 02:08:28 +00:00
Cristiano Giuffrida
af424b4e43 Don't always assume NOPINGREPLY as a failure in RS 2010-07-20 01:50:33 +00:00
Ben Gras
16d0609fad vm: restore sanity checks in NONCONTIGUOUS case. 2010-07-19 18:20:14 +00:00
Ben Gras
068944de36 vm: add MEMPROTECT feature in vm.h. 2010-07-19 18:19:59 +00:00
Ben Gras
77267ca28b vm: add missing USE() macros in utility.c. 2010-07-19 18:19:38 +00:00
Ben Gras
5e2c84b119 vm: allow readonly pages when sanity checking when they're supposed to be rw. 2010-07-19 18:19:16 +00:00
Ben Gras
e0701109ca kernel: make loading kernel in 2nd chunk of memory (at 1MB) the default.
(indicated by flags hardcoded in kernel that the boot monitor
interprets.)
2010-07-19 16:33:49 +00:00
Thomas Veerman
103dc9e80a Teach DESCRIBE and fsck about UNIX Domain Sockets. Contributed by Thomas Cort 2010-07-19 13:57:47 +00:00
Ben Gras
6ed6e31e80 un-duplicate sha2hl.c 2010-07-19 13:08:48 +00:00
Ben Gras
e37a6ef219 pkg_install: use /usr/sbin 2010-07-19 11:58:39 +00:00
Ben Gras
53b6f99fb0 includes: remove some prototypes of functions that aren't defined. 2010-07-19 11:39:57 +00:00
Ben Gras
4234aa2c4a pkg_install path fixes. 2010-07-19 11:30:39 +00:00
Ben Gras
069f6ed574 pkg_install: correct PKG_LOG_DIR 2010-07-19 11:28:51 +00:00
Ben Gras
373df14150 pkg_install: these manpages were moved to man. 2010-07-19 10:47:11 +00:00
Ben Gras
f08922e848 include - string functions. 2010-07-19 10:46:49 +00:00
Ben Gras
ffe7e9166e lib - extra file for libutil; strnstr and strcasestr from freebsd for libc. 2010-07-19 10:46:26 +00:00
Ben Gras
6ce51040a2 patch: fixes to use plan a (too) by Gautam Tirumala. 2010-07-19 10:40:48 +00:00
Ben Gras
34dd221af7 man - no more whoami, mdb (get installed from commands) 2010-07-18 22:19:34 +00:00
Ben Gras
dc2194efa7 man: add some pkgsrc pages; no more minix diff manpage 2010-07-18 22:15:10 +00:00
Ben Gras
ac66d329c7 mtree: add libexec; don't make any oss dirs. 2010-07-18 22:06:40 +00:00
Ben Gras
09c18bc918 lib: bugfix for mbstowcs, debugged by Gautam Tirumala. 2010-07-18 20:57:55 +00:00
Ben Gras
89df7fc91d MAKEDEV: make /dev/uds 2010-07-18 19:20:36 +00:00
Ben Gras
a46b8b84d4 aal - don't install yourself as ar; must invoke aal explicitly for ack archives.
To make switching to 'ar' for gcc/clang archives smoother in the future.
2010-07-16 15:40:04 +00:00
Ben Gras
b05c989298 kernel - prettier output for ipc errors, call names instead of trap numbers 2010-07-16 15:36:29 +00:00
Erik van der Kouwe
98725c443e Fix RS warning at start-up by inheriting scdeduling properties from init for unprivileged children of system processes 2010-07-16 14:56:05 +00:00
Tomas Hruby
7f47f4174d Fixed comments in sched
- not only PM can send sched requests. RS too.
2010-07-16 09:40:12 +00:00
Ben Gras
6955228f39 rc - also add /usr/pkg/sbin to $PATH 2010-07-16 00:44:57 +00:00
Ben Gras
693bd970e7 sha1 manpage - fix #include 2010-07-16 00:19:19 +00:00
Ben Gras
7e8ed05df4 pkgsrc pkg_install tools, ported by Gautam Tirumala. 2010-07-16 00:15:25 +00:00
Ben Gras
0f7365e6af link in new manpages 2010-07-16 00:15:03 +00:00
Ben Gras
09f03783ea man - longer default manpath for packages and llvm 2010-07-16 00:13:50 +00:00
Ben Gras
84e730cbd8 new dirs for pkgsrc; new $PATH for pkg root and llvm 2010-07-16 00:13:27 +00:00
Ben Gras
4aca722796 lib - link in new u64 functions. 2010-07-16 00:12:51 +00:00
Ben Gras
28b533cf87 includes - link in new ones 2010-07-16 00:12:32 +00:00
Ben Gras
2a556de6d2 further sha2 conversion by Gautam Tirumala 2010-07-16 00:12:16 +00:00
Ben Gras
feaa082ea8 libutil - sha1 functions. 2010-07-16 00:11:16 +00:00
Ben Gras
117bac1e2d libutil: md5 functions. 2010-07-16 00:06:00 +00:00
Ben Gras
6c66933f90 64-bit bitwise manipulation functions, by Gautam Tirumala. 2010-07-15 23:48:56 +00:00
Thomas Veerman
ee1b608bcf Add/adjust man pages for UDS. Contributed by Thomas Cort 2010-07-15 14:56:49 +00:00
Thomas Veerman
d26290a017 Add test56 to test our UDS implementation. Contributed by Thomas Cort 2010-07-15 14:52:29 +00:00
Erik van der Kouwe
739f2d7536 Fix comment 2010-07-15 14:47:08 +00:00
Ben Gras
16d01fba85 mtree: dirs for pkgsrc 2010-07-15 14:29:07 +00:00
Thomas Veerman
f531dba2d2 Add support for UNIX Domain Sockets to the C lib. Contributed by Thomas Cort 2010-07-15 14:05:23 +00:00
Thomas Veerman
5aff633a0b Make RS and VFS aware of new UDS major. Contributed by Thomas Cort 2010-07-15 13:51:38 +00:00
Thomas Veerman
ea19830de1 Add UNIX Domain Sockets internals to PFS. Contributed by Thomas Cort 2010-07-15 13:39:57 +00:00
Thomas Veerman
ecc8a52f82 Add getnucred system call. Contributed by Thomas Cort 2010-07-15 13:24:57 +00:00
Thomas Veerman
17a0731f28 Update header files to support UNIX Domain Sockets. Contributed by Thomas Cort 2010-07-15 12:48:15 +00:00
Thomas Veerman
ca0bed1400 Add EOVERFLOW error condition 2010-07-15 12:36:41 +00:00
Thomas Veerman
3404e8e4e5 Convert a few man pages to mandoc 2010-07-15 08:48:24 +00:00
Ben Gras
8a0c10fcb9 lib: mkdtemp(), contributed by by Gautam Tirumala 2010-07-14 22:45:28 +00:00
Ben Gras
2639ae9b17 libc: add db code from netbsd 2010-07-14 17:46:18 +00:00
Ben Gras
8d24932c80 lib: don't give back the same temporary filenames even if removed.
workaround for what seems to be a clang/llvm bug/assumption.
2010-07-14 15:18:50 +00:00
Ben Gras
4fcd34137c includes: header files for netbsd db code. 2010-07-14 14:52:02 +00:00
Cristiano Giuffrida
20101b3bab Remove patch leftovers. 2010-07-13 22:40:14 +00:00
Arun Thomas
e41c0b1a2d Replace paxtar with bsdtar 2010-07-13 21:35:58 +00:00
Cristiano Giuffrida
f8a8ea0a79 Dynamic configuration in system.conf for boot system services. 2010-07-13 21:11:44 +00:00
Ben Gras
f6e558f5d4 errno EFTYPE 2010-07-13 20:05:47 +00:00
Ben Gras
9bb7552df5 remove old man.1 2010-07-13 19:49:12 +00:00
Ben Gras
ba759ef03e new command: bsdtar. 2010-07-13 19:28:09 +00:00
Ben Gras
470ab03b86 libarchive port by Gautam Tirumala. 2010-07-13 19:17:02 +00:00
Ben Gras
9a14560daf netconf: recognize another rtl8169-compatible model 2010-07-13 18:44:51 +00:00
Ben Gras
8b0dbff312 test44: suid root to call getsysinfo 2010-07-13 18:27:42 +00:00
Cristiano Giuffrida
8cedace2f5 Scheduling parameters out of the kernel. 2010-07-13 15:30:17 +00:00
Ben Gras
d4e41fd1f6 top-level Makefile: include info on clang-libraries target. 2010-07-13 14:13:27 +00:00
Ben Gras
0574bb5a63 lib: clang-libraries top-level target. 2010-07-13 14:11:31 +00:00
Ben Gras
835232d504 tests: fixes to accomodate growing OPEN_MAX and a logic error 2010-07-13 12:38:58 +00:00
Cristiano Giuffrida
60549b67be Man pages for new system configuration. 2010-07-13 11:45:41 +00:00
David van Moolenbroek
1ecdac623a libsys: add standard condition spinning primitives 2010-07-12 23:14:40 +00:00
David van Moolenbroek
78a0260993 datasizes(1): gcc/clang support 2010-07-12 23:12:21 +00:00
Ben Gras
dd19f8cd07 elle: minor changes to compile with non-ack. 2010-07-12 20:09:03 +00:00
Arun Thomas
bcaf746508 Import strsep() from NetBSD's libnbcompat
Ported by Gautam Tirumala
2010-07-12 17:41:31 +00:00
Arun Thomas
652618e458 shquote() from NetBSD's libnbcompat
Ported by Gautam Tirumala
2010-07-12 17:32:57 +00:00
Ben Gras
4ff8fdba57 unstack: filter for llvm internal symbols. 2010-07-12 17:03:29 +00:00
Ben Gras
78ce6f86f7 tests: turn of optimisation when compiling the tests, less unexpected optimisations. 2010-07-12 16:22:05 +00:00
Arun Thomas
590ff06418 Fix bsd.own.mk owners/objformat for pkgsrc
Contributed by Gautam Tirumala
2010-07-12 13:48:14 +00:00
Arun Thomas
4b30979086 Install(1): Allow -c option with -d
Contributed by Gautam Tirumala
2010-07-12 13:38:13 +00:00
Ben Gras
12e9303297 kernel: compile with -mi386 under gcc/clang to not generate SSE code in-kernel. 2010-07-12 10:11:50 +00:00
Arun Thomas
1cee6fe95e Import asprintf() and vasprintf()
Ported from libnbcompat by Gautam Tirumala
2010-07-11 13:46:58 +00:00
Ben Gras
ae9fa7fdf6 rtl8169 driver: let it recognize an extra card that works too 2010-07-10 17:04:17 +00:00
Ben Gras
b4345d7598 test44: add bogus getsysinfo() to test invalid memory range request to vm
test case contributed by Roman Ignatov.
2010-07-10 00:24:43 +00:00
Kees van Reeuwijk
a5dfadeb70 Let string.h include stdint.h, since some programs, in particular llvm/clang,
assume that this happens.
2010-07-09 23:58:37 +00:00
Cristiano Giuffrida
8427d774b6 RS live update support. 2010-07-09 18:29:04 +00:00
David van Moolenbroek
895850b8cf move timers code to libsys 2010-07-09 12:58:18 +00:00
Ben Gras
8c925134f9 vm: NONCONTIGUOUS - try to make physical memory as maximally noncontiguous 2010-07-09 12:22:33 +00:00
Arun Thomas
f3ce085913 Pull in NetBSD's queue.h (for pkgsrc) 2010-07-07 14:17:25 +00:00
David van Moolenbroek
8182a9d972 libdriver: don't panic so easily 2010-07-07 11:04:33 +00:00
Cristiano Giuffrida
1f8dbed029 RS crash recovery support. 2010-07-06 22:05:21 +00:00
Ben Gras
e920c1e1df kernel: fix main prototype 2010-07-06 12:14:59 +00:00
Ben Gras
5859ad686b boot: fix clang warnings. 2010-07-06 12:11:25 +00:00
Ben Gras
e698d818c6 commands: fixes for clang errors. 2010-07-06 12:10:23 +00:00
Ben Gras
68db8ed0b9 lib: fixes for warnings that clang has for libraries. 2010-07-06 12:08:22 +00:00
Ben Gras
f6f814cb02 include, kernel: minor fixes to make compiling and linking work with clang.
(fixing warnings)
2010-07-06 11:59:19 +00:00
Ben Gras
dc47875fc7 sys.mk: remove trailing whitespace. 2010-07-06 11:48:11 +00:00
Kees van Reeuwijk
0cfdb11450 Repair errors and warnings flagged by llvm. 2010-07-06 11:29:23 +00:00
Arun Thomas
368f77ceea Fix building of image target 2010-07-06 09:19:04 +00:00
Cristiano Giuffrida
397575951e Cleanup dep file. 2010-07-05 21:04:31 +00:00
Cristiano Giuffrida
3de6a807ce Configure settings for system services dynamically with the new service edit command. 2010-07-05 19:37:08 +00:00
Ben Gras
42399159da kernel: these asserts from r7657 are not reasonable
will fire if copy needs more than one try, which is legit.
2010-07-05 17:45:16 +00:00
Ben Gras
fc8f0b9ee2 vm: better fix for clang 'unused expression' warning 2010-07-05 17:34:26 +00:00
Ben Gras
7011e7c680 mk: add recognizing CC=clang, patch by Arun 2010-07-05 17:33:34 +00:00
Ben Gras
86139e8bf2 vm: last commit should not have included wiping out these calls
(this was done temporarily to make vm work with clang; vm crashes when
the 64-bit arithmetic functions are used when compiled with clang.)
2010-07-05 14:01:34 +00:00
Ben Gras
b4bea1bfcb vm: fixes for clang warnings 2010-07-05 13:58:57 +00:00
Ben Gras
545054c608 kernel: use MF_KCALL_RESUME instead of RTS_VMREQUEST for memcopy retry.
solves tracker item 499, submitted by Roman Ignatov.
2010-07-04 23:09:24 +00:00
Kees van Reeuwijk
9fd2d72ce8 Llvm-inspired code cleanup. 2010-07-04 23:01:32 +00:00
Ben Gras
01fcee7d71 ash: make test/expr support 'file1 -ot file2' 2010-07-03 22:18:11 +00:00
David van Moolenbroek
4d3c887d6b at_wini: rename 'ata_instance' to 'instance' 2010-07-03 17:51:12 +00:00
David van Moolenbroek
4392e004f8 bring back mdb (Bug#501, reported by Roman Ignatov) 2010-07-03 10:25:19 +00:00
Erik van der Kouwe
37325bd7c5 Make service ABI backwards compatible again 2010-07-03 05:02:59 +00:00
Thomas Veerman
34a2864e27 Fix a few compile time warnings 2010-07-02 12:41:19 +00:00
David van Moolenbroek
9a37f63263 netconf: psip0 is not a driver (Bug#500, reported by Roman Ignatov) 2010-07-02 11:22:42 +00:00
Kees van Reeuwijk
630f566d3f Convert a few main() functions to a form that the clang compiler likes. 2010-07-01 22:23:25 +00:00
Cristiano Giuffrida
03f64ac97a Self update support in RS. 2010-07-01 18:48:25 +00:00
David van Moolenbroek
71dbe2d023 ramdisk rc: start disk drivers synchronously.
This eliminates a race condition between the disk driver calling
sys_statectl(SYS_STATE_CLEAR_IPC_REFS) as part of driver_announce(),
and the root MFS calling sendrec(DEV_OPEN) on the disk driver.
2010-07-01 14:35:47 +00:00
Tomas Hruby
97eb470bee Fix 2010-07-01 12:31:53 +00:00
Tomas Hruby
7920d48156 FPU cleanup
- last reference to MF_USED_FPU removed

- proc_used_fpu() used to test for MF_FPU_INITIALIZED
2010-07-01 12:23:25 +00:00
Erik van der Kouwe
b5ae3961bb Fix unintended changes in r7614 2010-07-01 11:56:02 +00:00
David van Moolenbroek
06a0260c3c PCI: add AHCI T3 and subclass values 2010-07-01 09:20:36 +00:00
David van Moolenbroek
2488cc6442 PCI: expose BAR sizes 2010-07-01 09:10:16 +00:00
Cristiano Giuffrida
9e4312453d Improve memory pinning. 2010-07-01 08:54:25 +00:00
Erik van der Kouwe
4690e8b015 Opps, forgot to svn add these files 2010-07-01 08:38:15 +00:00
Erik van der Kouwe
23284ee7bd User-space scheduling for system processes 2010-07-01 08:32:33 +00:00
Tomas Hruby
b17e3adb60 drivers/ builds in parallel (make -j N) 2010-07-01 07:39:36 +00:00
Erik van der Kouwe
5c591816cb Remove warning in inet; this situation is harmless and can be caused by a race 2010-07-01 06:14:38 +00:00
Erik van der Kouwe
5e602d3dab Put rs.single on initial ramdisk to prevent potential race when readclock terminates early 2010-07-01 06:14:06 +00:00
Ben Gras
0ad4e16985 packman: use fetch instead of urlget 2010-07-01 00:10:07 +00:00
Ben Gras
47b58b2ebb fetch command 2010-07-01 00:06:41 +00:00
Ben Gras
65be30daed libfetch - move fetch.3 to man and fetch.h to include 2010-07-01 00:05:48 +00:00
Ben Gras
429639f938 lib: added libfetch 2010-06-30 23:55:55 +00:00
Ben Gras
098412be83 small fixes for pkgsrc by Buccapatnam Tirumala, Gautam. 2010-06-30 12:18:34 +00:00
David van Moolenbroek
9313bc9a6f fix dec21140A driver (reported by zvolkov) 2010-06-29 11:45:32 +00:00
Cristiano Giuffrida
180358ffb4 Give RS a page table. 2010-06-28 22:07:49 +00:00
Cristiano Giuffrida
06700d05d1 Give RS a page table. 2010-06-28 21:53:37 +00:00
Cristiano Giuffrida
869a223d43 service clone command to clone system services on demand. 2010-06-28 21:38:29 +00:00
Ben Gras
635a8f772c memory driver: use mmap to pre-allocate ramdisks to avoid overcommit. 2010-06-28 18:12:32 +00:00
Ben Gras
f044bd10ef make ps and top use sanity checking kernel proc table retrieval 2010-06-28 11:05:34 +00:00
Ben Gras
8379b08845 library function to retrieve kernel proc table and sanity check it 2010-06-28 11:05:15 +00:00
Tomas Hruby
67fa273d00 MF_REPLY_PEND should be removed when sendrec finishes 2010-06-28 08:32:49 +00:00
Ben Gras
b9f53528ee sep ${.OBJDIR} fixes by Antoine Leica. 2010-06-27 23:47:59 +00:00
Ben Gras
6e47e2996f sep ${.OBJDIR} fixes by Antoine Leica. 2010-06-27 23:47:23 +00:00
Ben Gras
a3db59df6f sep ${.OBJDIR} fixes by Antoine Leica. 2010-06-27 23:46:23 +00:00
Ben Gras
dbfb70134c sep. ${.OBJDIR} fixes, contributed by Antoine Leica. 2010-06-27 23:45:30 +00:00
Ben Gras
831edb6614 no makewhatis. 2010-06-27 23:38:17 +00:00
David van Moolenbroek
53866b1ebb oops. 2010-06-27 17:20:17 +00:00
David van Moolenbroek
71435d15cf HGFS: statvfs support 2010-06-27 17:19:50 +00:00
Ben Gras
d24348c636 man - statvfs(5) manpage 2010-06-27 15:52:50 +00:00
Ben Gras
6ef440c03b statvfs manpage. 2010-06-27 15:40:06 +00:00
Ben Gras
f1faf0d327 no more minix whoami 2010-06-27 14:07:43 +00:00
Arun Thomas
1f20814fe8 Fix grep test 4 in testsh1 2010-06-27 10:59:14 +00:00
Cristiano Giuffrida
377f4e7e31 Fix and comment a race in SEF Init 2010-06-27 09:01:15 +00:00
Ben Gras
f200f53a0b teach packman about new id (tracker item 489) 2010-06-26 23:10:24 +00:00
Kees van Reeuwijk
5eb6f6e922 Fixed a type declaration inconsistency. 2010-06-26 21:13:36 +00:00
Arun Thomas
e2d45ae24c Update docs/UPDATING 2010-06-26 20:33:57 +00:00
Ben Gras
d2dbe5b2ae install man.conf from commands/man 2010-06-26 11:20:47 +00:00
Arun Thomas
2fc2748c5a Add missing share/mk/Makefile 2010-06-26 08:01:30 +00:00
Ben Gras
2793cb097b bigger default manpath 2010-06-26 02:47:45 +00:00
Ben Gras
b24f63f996 man.conf 2010-06-26 02:43:31 +00:00
Ben Gras
a1a12bbc34 man: throw out *whatis 2010-06-26 02:37:41 +00:00
Ben Gras
01b5238d50 getsubopt: use regular assert()s 2010-06-26 02:37:17 +00:00
Ben Gras
a187743e75 netbsd man 2010-06-26 02:35:08 +00:00
Ben Gras
24cb4e60fc no more minix man 2010-06-26 02:33:49 +00:00
Ben Gras
3f22092d45 import mdocml. 2010-06-26 02:20:06 +00:00
Ben Gras
2f3c9c04cc chrootmake: don't call makewhatis any more 2010-06-26 01:56:28 +00:00
Ben Gras
74c06cfc43 commands: less is more. 2010-06-26 01:41:19 +00:00
Ben Gras
8003edc357 don't call makewhatis 2010-06-26 01:10:04 +00:00
Ben Gras
6ebe0cdf82 no more minix more, *whatis 2010-06-26 01:08:31 +00:00
Ben Gras
aa6ff4c8be lib: setprogname() + getsubopt() 2010-06-26 00:44:24 +00:00
Arun Thomas
8e0253ac3d Make: Updates from NetBSD
Needed for pkgsrc
2010-06-25 23:25:48 +00:00
Arun Thomas
e10916476a Move mkfiles from /etc/mk to /usr/share/mk
Simplifies pkgsrc porting.
2010-06-25 19:33:56 +00:00
Arun Thomas
c0c8d25799 Rename mkfiles from minix.*.mk to bsd.*.mk
Makes things easier for pkgsrc
2010-06-25 18:29:09 +00:00
Ben Gras
9dc7c1f081 man: remove id, touch 2010-06-25 17:18:45 +00:00
Ben Gras
373aecf3cd commands: id from netbsd; touch from bsd-utils port 2010-06-25 17:14:56 +00:00
Ben Gras
bfeecdbf62 no more minix touch, id 2010-06-25 17:13:57 +00:00
Erik van der Kouwe
c0dfa2f3f1 Get rid of asynsend backup copy in VFS 2010-06-25 14:57:54 +00:00
Cristiano Giuffrida
5c7d64b981 No malloc() in VM. 2010-06-25 12:48:56 +00:00
Erik van der Kouwe
6011237232 Extra sync to reduce damage of failing shutdowns 2010-06-24 14:56:03 +00:00
Kees van Reeuwijk
25dc0fc376 Some standard Unix functions were feature-dependent on _MINIX. 2010-06-24 14:17:25 +00:00
Erik van der Kouwe
fe07e7c984 Optional IPC logging 2010-06-24 13:31:40 +00:00
Erik van der Kouwe
3985311b2e Beng's boot fix 2010-06-24 12:29:13 +00:00
Erik van der Kouwe
26ebfa1ce1 Revert bad prior reversion 2010-06-24 12:27:58 +00:00
Ben Gras
b3a0a2d86f kernel: don't initialize catch_pagefaults at the extern declaration. 2010-06-24 12:23:23 +00:00
Erik van der Kouwe
e8d30bba65 Beng's boot fix 2010-06-24 12:20:01 +00:00
Ben Gras
33c9d427fd mfs - added put_block() to statvfs loop. 2010-06-24 10:56:45 +00:00
Erik van der Kouwe
498d7d8a4c Don't use kernel responses in servers 2010-06-24 07:37:26 +00:00
Ben Gras
491efeead9 mfs - revert part of previous commit; should not have been commited 2010-06-24 00:32:17 +00:00
Ben Gras
762665cec1 some prettification for test55. 2010-06-24 00:27:26 +00:00
Ben Gras
e3354a8556 test 55 for statvfs. fix formatting bug in test54. 2010-06-24 00:06:40 +00:00
Ben Gras
6cd2d1218e mfs - statvfs call, by Buccapatnam Tirumala, Gautam. 2010-06-23 23:58:16 +00:00
Ben Gras
4b496e29bd iso9660fs - statvfs call, by Buccapatnam Tirumala, Gautam. 2010-06-23 23:57:26 +00:00
Ben Gras
13b5dd4a82 statvfs/fstatvfs entries. 2010-06-23 23:56:36 +00:00
Ben Gras
fc01683584 include, vfs: statvfs, fstatvfs calls, contributed by Buccapatnam Tirumala, Gautam. 2010-06-23 23:53:50 +00:00
Ben Gras
45e4cce8c2 libc stubs for statvfs, contributed by Buccapatnam Tirumala, Gautam. 2010-06-23 23:51:29 +00:00
Ben Gras
79d62892ad includes: statvfs support, contributed by Buccapatnam Tirumala, Gautam 2010-06-23 23:46:10 +00:00
Ben Gras
ac310cbe09 boot: restore setting stack size, and remove wrong experimental
#ifndef DOS that shouldn't have been committed.
2010-06-23 16:24:40 +00:00
Erik van der Kouwe
50539c12f5 Remove obsolete mstats call 2010-06-23 10:43:08 +00:00
Tomas Hruby
76708e9bf4 mini_receive() clean up
- for better readability xpp is substitued by sender

- makes sure that the dequeued sender has p_q_link == NULL and that
  this condition holds when enqueuing the sender again. This is a
  sanity check to make sure that the new sender is not enqueued
  already

- Before this change the dequeued sender's p_q_link may not be NULL
  and it was only set to NULL when enqueued again
2010-06-23 10:36:19 +00:00
Erik van der Kouwe
921bacd244 Fix packman for new grep, which doesn't support \+ in BREs 2010-06-23 08:12:40 +00:00
Ben Gras
f2c3cbab00 test for pwrite() (Contributed by Buccapatnam Tirumala, Gautam) 2010-06-22 22:07:23 +00:00
Ben Gras
24a5f48921 lib - a pwrite() implementation (Contributed by Buccapatnam Tirumala, Gautam) 2010-06-22 22:04:43 +00:00
Ben Gras
d78ae27865 advent: support ${.OBJDIR} != ${.CURDIR}, tracker item 486 2010-06-22 21:56:38 +00:00
Ben Gras
ddc3f62290 strptime() for minix. 2010-06-22 21:42:49 +00:00
Ben Gras
08f731bae0 original strptime. 2010-06-22 21:41:56 +00:00
Ben Gras
08e4312998 forget netbsd strptime. 2010-06-22 21:41:20 +00:00
Ben Gras
c7050eea55 original netbsd strptime 2010-06-22 21:37:54 +00:00
Ben Gras
81399e75ad no WARNS 2010-06-22 21:24:50 +00:00
Ben Gras
6189062d12 cut fixes 2010-06-22 21:24:14 +00:00
Ben Gras
988b95f150 minix cut, printf from netbsd 2010-06-22 21:22:53 +00:00
Ben Gras
ff26d9a4ff original netbsd printf, cut 2010-06-22 21:20:54 +00:00
Ben Gras
2ac57865cb no more minix cut, printf 2010-06-22 21:19:42 +00:00
Ben Gras
86e323da6b correct to S_IFSOCK 2010-06-22 16:35:48 +00:00
Ben Gras
81056ac999 stdio: j modifier for %d. (Contributed by Buccapatnam Tirumala, Gautam) 2010-06-22 16:22:17 +00:00
Ben Gras
575d055f90 rename __ss_family to ss_family. (Contributed by Buccapatnam Tirumala, Gautam) 2010-06-22 16:21:21 +00:00
Ben Gras
d6af53bec0 boot: fix dosboot build and link to build. 2010-06-22 15:45:53 +00:00
Ben Gras
d1c117ec80 easypack: don't invoke binsizes 2010-06-22 15:44:47 +00:00
Ben Gras
32c757b12c chrootmake: don't invoke binsizes. 2010-06-22 15:44:29 +00:00
Ben Gras
ee1134da9d fortune: install fortune.dat in /usr/lib 2010-06-22 15:29:35 +00:00
Ben Gras
ac6e455f16 . make sed understand \t
. install it in /bin, where minix rc expects it
2010-06-22 15:28:07 +00:00
Cristiano Giuffrida
ad1f2f2d78 Fix misplaced comment. 2010-06-22 15:10:06 +00:00
Ben Gras
0c03a6a50f binpackage: don't call binsizes. 2010-06-22 14:21:34 +00:00
Ben Gras
c8372f31f8 make: don't link with -g as nm can't read the symbol table any more. 2010-06-22 14:00:42 +00:00
Ben Gras
5946b9d41d includes: S_ISSOCK and S_ISOCK 2010-06-22 13:37:33 +00:00
Tomas Hruby
21725c107d cd subdir && $(MAKE) targets -> $(MAKE) -C subdir targets
- first step towards parallel building
2010-06-22 12:03:09 +00:00
Kees van Reeuwijk
3eed5d3bdb Sort out problems with POSIX constants. 2010-06-22 10:50:03 +00:00
Ben Gras
15210b3e06 forget about multiple zeros on non-ack compiler, tracker item 457 2010-06-22 09:40:04 +00:00
Ben Gras
556faf0d3a minix netbsd diff 2010-06-22 09:38:20 +00:00
Ben Gras
82dee9dbc3 add LC_MESSAGES 2010-06-22 09:31:16 +00:00
Ben Gras
3cb1096425 new stdbool.h 2010-06-22 09:30:52 +00:00
Ben Gras
4383596e9d includes: small fixes and additions to help compiling programs. 2010-06-22 09:30:26 +00:00
Ben Gras
e68d8eb1ff original openbsd diff 2010-06-22 00:47:52 +00:00
Ben Gras
4c0a9db684 no more minix diff 2010-06-22 00:46:55 +00:00
Ben Gras
6dd606eabf no more minix sed, patch man pages 2010-06-22 00:44:20 +00:00
Ben Gras
4269db3991 minix patch port 2010-06-22 00:41:23 +00:00
Ben Gras
f50f1bf7d6 original netbsd patch 2010-06-22 00:41:00 +00:00
Ben Gras
6657c0e58e no more minix patch 2010-06-22 00:39:57 +00:00
Ben Gras
582c0ed74d netbsd sed for minix 2010-06-22 00:36:21 +00:00
Ben Gras
707fbb966d original netbsd sed 2010-06-22 00:33:14 +00:00
Ben Gras
1b2189c205 no more minix sed. 2010-06-22 00:32:21 +00:00
Ben Gras
a89bcc465b mfs: minor cleanup of readahead: they can be private to read.c. 2010-06-21 18:25:04 +00:00
Erik van der Kouwe
e2730c3e2f Recognize Intel 82558B, contributed by Sergei Antonov 2010-06-21 17:08:37 +00:00
Ben Gras
029d91baa9 no more minix grep man pages. 2010-06-21 14:42:53 +00:00
Ben Gras
cedc0404e1 force gcc to look in ../../../include before /usr/local/include 2010-06-20 12:32:41 +00:00
Ben Gras
137495002d grep: unsigned chars to fix gcc warnings. 2010-06-20 12:31:55 +00:00
Ben Gras
28663f45d6 fixes for minix grep 2010-06-20 11:55:19 +00:00
Ben Gras
bb830fc0d3 original openbsd grep (freegrep) 2010-06-20 11:54:40 +00:00
Ben Gras
f19304bf22 oops, that was the minx grep port; undo previous commit. 2010-06-20 11:54:03 +00:00
Ben Gras
1d14529942 original openbsd freegrep 2010-06-20 11:49:38 +00:00
Ben Gras
5b40436aaf remove minix greps. 2010-06-20 11:48:00 +00:00
Ben Gras
d78494cd6e fgetln() prototype 2010-06-20 11:46:50 +00:00
Erik van der Kouwe
330374be9e Fix unlikely race (or crawl?) condition in case going from alarm to ioctl takes more than 1 second 2010-06-20 07:30:53 +00:00
Erik van der Kouwe
90285c46a2 Packman also recognizes package names with no or partial version number 2010-06-20 06:39:23 +00:00
Ben Gras
6c0fcd575e lib: getproname: only return last path component 2010-06-20 00:24:35 +00:00
Ben Gras
3cc5e1add4 lib: no visibility features; fixes gcc warnings 2010-06-20 00:24:11 +00:00
Ben Gras
2144b289de getprogname(), setprogname() prototypes 2010-06-18 14:03:13 +00:00
Ben Gras
f60593cc35 libraries: fgetln() from pkgsrc branch. 2010-06-18 14:02:00 +00:00
Tomas Hruby
6bc21b6992 Cycle counters zeroed after fork for the child 2010-06-18 14:01:34 +00:00
Erik van der Kouwe
11193f5fa4 Don't allow PM to sys_kill itself, this causes a race with RS calling waitpid during shutdown 2010-06-18 13:49:07 +00:00
Tomas Hruby
8214e5e284 Removed racy COW optimization
- enabling writing in COW once phys block is reference only once is racy if VM
  is preemptible. original memory location may get overwritten before COW copies
  the memory

- problem when DEBUG_RACE is on and a big problem for SMP
2010-06-18 12:46:18 +00:00
Cristiano Giuffrida
ad5771aa28 Don't forget about pending signals coming from the kernel. 2010-06-18 12:04:20 +00:00
Arun Thomas
042b5bf606 We have sys/cdefs.h now, so remove hacks. 2010-06-17 15:14:57 +00:00
Ben Gras
7b7091e905 zlib includes in lib/libz, install them too in /usr/include from toplevel makefile. 2010-06-17 15:05:20 +00:00
Ben Gras
ae947059e6 libraries, includes: libz: original libz source files with minix makefile. 2010-06-17 13:29:20 +00:00
Erik van der Kouwe
d59c49aecb Work around vfs/inet/eth race by avoiding non-blocking ioctl in dhcpd 2010-06-17 12:14:33 +00:00
Erik van der Kouwe
6312d7238b bzip2 is now the default for releases 2010-06-17 12:00:55 +00:00
David van Moolenbroek
0964b221e7 ash: expr -e support 2010-06-16 09:33:11 +00:00
Ben Gras
482afb8a6f <sys/mman.h>: include <minix/type.h> instead of <minix/types.h> for endpoint_t 2010-06-14 20:33:14 +00:00
Ben Gras
423db7d35a binpackage: let's use the find -prune option to skip hierarchies. 2010-06-14 20:31:52 +00:00
David van Moolenbroek
eeab8e0680 libdriver: make partition code use a contiguous buffer 2010-06-13 10:40:22 +00:00
Arun Thomas
1b2c01db1b Makefile updates:
Turn on optimization
Remove some redundancy in FLAGS
2010-06-11 16:05:36 +00:00
Ben Gras
19b790eb53 vfs: don't use a mountpoint if it's in use for anything else.
(this avoids data structure confusion if a mountpoint is reused as
a mountpoint until that's properly fixed.)
2010-06-11 11:41:56 +00:00
Thomas Veerman
4d7c317700 Fix wrong field for stack address and a typo. 2010-06-11 11:17:31 +00:00
Thomas Veerman
f838e3c204 Also install getcontext and makecontext man pages 2010-06-11 11:03:47 +00:00
Tomas Hruby
360de619c0 No linear addresses in message delivery
- removes p_delivermsg_lin item from the process structure and code
  related to it

- as the send part, the receive does not need to use the
  PHYS_COPY_CATCH() and umap_local() couple.  

- The address space of the target process is installed before
  delivermsg() is called.

- unlike the linear address, the virtual address does not change when
  paging is turned on nor after fork().
2010-06-11 08:16:10 +00:00
Arun Thomas
1bf6d23f34 Make exec() use entry point in a.out header 2010-06-10 14:59:10 +00:00
Arun Thomas
f0a158d8c1 More cleanup to remove MM and FS references 2010-06-10 14:04:46 +00:00
David van Moolenbroek
2758519ed2 Change default hostname resolution order
Hostnames that contain at least one period, are now first attempted
to be resolved as FQDNs, before adding local domains is tried.
2010-06-10 11:14:36 +00:00
Erik van der Kouwe
65764218f7 Remove dependency of release.sh on bc, du option to give overhead totals 2010-06-10 11:14:04 +00:00
Erik van der Kouwe
a8cf207549 release.sh: avoid egrep -x which the base system doesn't support 2010-06-09 14:32:19 +00:00
Arun Thomas
eec65ac664 Rename tell_fs to tell_vfs 2010-06-09 14:31:30 +00:00
Ben Gras
4fe558f44f issue.install: 3.1.8 2010-06-09 14:02:35 +00:00
Ben Gras
1ce7983ee3 lib: declarations that needed ANSIfication since prototypes are declared 2010-06-09 13:01:11 +00:00
Ben Gras
c1b4cc24e4 ash: getmode in global includes now 2010-06-09 12:58:03 +00:00
Ben Gras
61db813ff6 find: fix warnings + error 2010-06-09 12:53:51 +00:00
Ben Gras
ac34bfd42b inlcude: new prototypes 2010-06-09 12:53:09 +00:00
Ben Gras
8fea317779 man: no more minix find manpage 2010-06-09 12:30:25 +00:00
Ben Gras
6704520919 commands: import of netbsd find 2010-06-09 12:27:36 +00:00
Ben Gras
fcd2a802a8 commands/find: original netbsd find 2010-06-09 12:19:38 +00:00
Ben Gras
13d50be356 commands, man: remove minix find 2010-06-09 12:17:42 +00:00
Ben Gras
6faa2a636c ash: remove setmode() declaration from shell.h, now in library 2010-06-09 12:11:56 +00:00
Ben Gras
e216edf294 unistd.h: add setmode() prototype. 2010-06-09 12:11:33 +00:00
Ben Gras
769302d3d6 err.h: include prototypes for new err* and warn* functions. 2010-06-09 12:11:13 +00:00
Ben Gras
c046958745 crtso.S: save *argv[] and argc globally, to be used by getprogname(). 2010-06-09 12:10:31 +00:00
Ben Gras
ba9990cc00 libc: minor minix changes for new netbsd files 2010-06-09 12:09:39 +00:00
Ben Gras
60d52d68da libc: add original netbsd files 2010-06-09 12:08:32 +00:00
Ben Gras
a0147a8c32 libutil: minix efun.c 2010-06-09 12:05:53 +00:00
Ben Gras
7b87ff5b11 libutil: original netbsd efun.c 2010-06-09 12:05:04 +00:00
Ben Gras
d7490d374d includes: minix <util.h> 2010-06-09 12:03:19 +00:00
Ben Gras
b697b67d53 includes: original netbsd <util.h> 2010-06-09 12:02:20 +00:00
Thomas Veerman
be6490f4b3 Turn off debug message. 2010-06-09 11:05:16 +00:00
Ben Gras
a6e357da22 kernel: fix assert condition after a caught in-kernel pagefault 2010-06-09 10:59:57 +00:00
Thomas Veerman
a0eaaa5c9f Fix a bug in put_inode that causes corruption to the file system and another
bug that causes problems when files grow bigger than a certain threshold. Also
fix a few type and code inconsistencies.
2010-06-09 09:56:43 +00:00
Tomas Hruby
1207fcc6f0 int to endpoint_t conversions in mmap 2010-06-09 09:14:53 +00:00
Ben Gras
cccfe8e0ce lib: move tzfile.h from lib/libc/stdtime/ to include/ for general usage. 2010-06-08 19:11:42 +00:00
Kees van Reeuwijk
826b9590f2 More endpoint_t correctness.
More const correctness.
Other code cleanup.
2010-06-08 14:09:18 +00:00
Arun Thomas
4c10a31440 Remove legacy MM, FS, and FS_PROC_NR macros 2010-06-08 13:58:01 +00:00
Erik van der Kouwe
7bd7946346 Remove redundant macro cproc_addr 2010-06-08 13:38:44 +00:00
Erik van der Kouwe
78186ee5f5 Add endpoint checks in scheduling kernel calls 2010-06-08 12:04:21 +00:00
Ben Gras
49165ef796 support for ukranian (charse koi8-u) contributed by Roman Ignatov. 2010-06-08 01:04:52 +00:00
Ben Gras
31adc0a3c4 vm: junkfree feature that fills freed pages with a recognizable pattern. 2010-06-08 00:59:48 +00:00
Ben Gras
a09a8d4f3e kernel: fix for vm_init that triggered assert(ptproc == newptproc)
- zero cr3 in vm_init() to avoid switch_address_space() not doing anything.

 - add vm_stop() to disable paging on shutdown.
2010-06-07 22:21:45 +00:00
Ben Gras
277ff6f2ce e1000: map in 0x1000 of flash if 0x10000 fails. 2010-06-07 16:30:10 +00:00
Ben Gras
f448dfe063 version: trunk will become 3.1.8. 2010-06-07 15:57:14 +00:00
Thomas Veerman
4b6b1bc47a Fix typo 2010-06-07 13:46:05 +00:00
Ben Gras
a98b9ca8dc tools: fix installing includes. 2010-06-07 10:10:27 +00:00
Tomas Hruby
cbc9586c13 Lazy FPU
- FPU context is stored only if conflict between 2 FPU users or while
  exporting context of a process to userspace while it is the active
  user of FPU

- FPU has its owner (fpu_owner) which points to the process whose
  state is currently loaded in FPU

- the FPU exception is only turned on when scheduling a process which
  is not the owner of FPU

- FPU state is restored for the process that generated the FPU
  exception. This process runs immediately without letting scheduler
  to pick a new process to resolve the FPU conflict asap, to minimize
  the FPU thrashing and FPU exception hadler execution

- faster all non-FPU-exception kernel entries as FPU state is not
  checked nor saved

- removed MF_USED_FPU flag, only MF_FPU_INITIALIZED remains to signal
  that a process has used FPU in the past
2010-06-07 07:43:17 +00:00
Arun Thomas
b641afc78a VM: Remove legacy non-paging code paths 2010-06-05 14:39:40 +00:00
Erik van der Kouwe
e7e6508854 Enter package names in packman 2010-06-05 13:25:41 +00:00
Cristiano Giuffrida
354d88f883 Put initialization code where it belongs. 2010-06-04 18:08:15 +00:00
Cristiano Giuffrida
a53514d4a9 Fix range checking in safecopy. 2010-06-04 18:05:38 +00:00
Arun Thomas
8c69c6cd7f Remove gcc-4.1.1 from packages list 2010-06-04 12:36:40 +00:00
Tomas Hruby
f28acecb78 Removed a buggy assert unintentionally commted in r7044 2010-06-04 10:54:43 +00:00
Erik van der Kouwe
8afc228c48 This patch changes the release script in the following ways:
- A staging directory is always used to avoid oversized images;
- As a consequence, the zero-filling is removed so no more "out of 
  space" errors should be printed to the console;
- The root and usr partition sizes are computed so less space should be 
  wasted (the root partition gets extra 1MB zones and 64 inodes for 
  run-time though and hardlinks/holes make the used space slightly less
  than expected); USRMB (and the new ROOTMB) are now used to enforce 
  a minimum size rather than set the size;
- TMPDISK1-3 are renamed to more meaningful names (and TMPDISK2 is 
  dropped because a separate tmp directory is no longer needed);
- The ramdisks are truncated at the end to save memory (not sure 
  whether it is actually released though).
2010-06-04 05:09:44 +00:00
Erik van der Kouwe
1bb7c4d78a Create link for lstat 2010-06-04 04:44:09 +00:00
Ben Gras
2f892aca91 kernel fpu context switching: fix race condition
There seems to have been a broken assumption in the fpu context
restoring code.  It restores the context of the running process, without
guarantee that the current process is the one that will be scheduled.
This caused fpu saving for a different process to be triggered without
fpu hardware being enabled, causing an fpu exception in the kernel. This
practically only shows up with DEBUG_RACE on. Fix my thruby+me.

The fix
 . is to only set the fpu-in-use-by-this-process flag in the
   exception handler, and then take care of fpu restoring when
   actually returning to userspace

And the patch
 . translates fpu saving and restoring to c in arch_system.c,
   getting rid of a juicy chunk of assembly
 . makes osfxsr_feature private to arch_system.c
 . removes most of the arch dependent code from do_sigsend
2010-06-03 11:32:22 +00:00
Cristiano Giuffrida
332842295a Always skip signals for PM itself when broadcasting. 2010-06-03 11:18:43 +00:00
Ben Gras
035c5a369c move drivers/random SHA implementation to libutil and header to <minix/sha2.h> 2010-06-02 22:58:29 +00:00
Kees van Reeuwijk
36e12d5bd8 Use endpoint_t for the destination of mini_send and _syscall, and the
source of mini_receive.

Also some small cleanup.
2010-06-02 21:51:32 +00:00
Gianluca Guida
0a42d36ac6 Fix ftp client's passive mode.
Before the ioctl the code zeroed the wrong variable.
2010-06-02 21:12:54 +00:00
Kees van Reeuwijk
ed0b81c25c Removed some unused variables and functions. 2010-06-02 19:41:38 +00:00
Erik van der Kouwe
fc29251444 setup: default root partition size is 64MB, reinstall keeps old root size 2010-06-02 17:07:10 +00:00
Tomas Hruby
463be393c2 Gracefull crash if FPU exception in kernel 2010-06-02 13:59:55 +00:00
Ben Gras
495970a17c boot monitor: introduce a 'reset' command that causes the cpu to
reset (triple fault).
2010-06-02 13:23:15 +00:00
Tomas Hruby
7bfa47476c Fixed stack trace if panic in stop_context() 2010-06-02 08:53:49 +00:00
Arun Thomas
ec27911a7f Ramdisk makefile update 2010-06-01 15:11:43 +00:00
Arun Thomas
2fd1f18803 Release script: Remove .d/.depend files from CD 2010-06-01 14:44:36 +00:00
Thomas Veerman
6bbcab3ec4 Clean up MFS a bit:
- Remove unused includes.
 - Add include guards to headers.
 - Use unsigned variables in case they're never going to hold a negative
   value. This causes GCC's complaints to disappear and should make flexelint
   a lot happier, too.
 - Make functions private when they're used only within a module.
 - Remove unused variables.
 - Add casts where appropriate.
2010-06-01 12:35:33 +00:00
Ben Gras
cc6fed4c51 packages: don't put oss on cd. 2010-06-01 11:11:35 +00:00
Arun Thomas
8579c59b3f Minor makefile changes for GCC 2010-06-01 09:41:31 +00:00
Tomas Hruby
40f440b8cd KCall methods do not depend on m_source and m_type fields
- substituted the use of the m_source message field by
  caller->p_endpoint in kernel calls. It is the same information, just
  passed more intuitively.
  
- the last dependency on m_type field is removed.
  
- do_unused() is substituted by a check for NULL.

- this pretty much removes the depency of kernel calls on the general
  message format. In the future this may be used to pass the kcall
  arguments in a different structure or registers (x86-64, ARM?) The
  kcall number may be passed in a register already.
2010-06-01 08:54:31 +00:00
Tomas Hruby
ebbd319ac0 do_safecopy split
- removes dependency of do_safecopy() on the m_type field of the kcall
  messages.

- instead of do_safecopy() figuring out what action is requested, the
  correct safecopy method is called right away.
2010-06-01 08:51:37 +00:00
Erik van der Kouwe
8bca982581 Remove those annoying $Id and $Revision tags 2010-05-31 20:00:08 +00:00
Thomas Veerman
5d78cefaf2 Clean up PFS 2010-05-28 09:39:18 +00:00
Erik van der Kouwe
8d06457241 Remove obsolete _fpu_present variable from crtso.S 2010-05-27 09:46:42 +00:00
Erik van der Kouwe
a31e9b0400 Oops, committed too much 2010-05-27 09:20:50 +00:00
Erik van der Kouwe
fc7438181b Avoid use of C++ reserved word class in headers (reported by Aki Goto, tracker item 375) 2010-05-27 09:18:49 +00:00
Erik van der Kouwe
43b589c1cc Avoid use of C++ reserved word class in headers (reported by Aki Goto, tracker item 375) 2010-05-27 08:48:53 +00:00
Arun Thomas
b48b037fbe Reorganize some directories
servers/hgfs/hgfs_server => servers/hgfs
servers/hgfs/libhgfs => lib/libhgfs
servers/rs/service => commands/service
drivers/memory/memory_driver => drivers/memory
drivers/memory/ramdisk => drivers/ramdisk
2010-05-26 22:49:57 +00:00
Arun Thomas
007104d60e GCC build fixes/updates
-Set stack sizes for boot image processes
-Increase RS stack size
-Reduce ramdisk size
-HARDWARE task should use kernel stack
-Minor asm tweaks for leading underscores
2010-05-26 18:45:55 +00:00
David van Moolenbroek
b16fc7e7bf different rtl8169 shutdown code 2010-05-26 11:22:06 +00:00
David van Moolenbroek
7f98ba962a make IS report masked IRQs properly 2010-05-26 08:44:50 +00:00
Tomas Hruby
24764ff47a Fixed ms-based scheduling for legacy timer 2010-05-26 08:20:29 +00:00
Tomas Hruby
a8111c5027 Various small scheduling related fixes 2010-05-26 07:16:39 +00:00
David van Moolenbroek
51ff10d7c0 reset alarm timer on PRIVCTL 2010-05-26 07:10:28 +00:00
Tomas Hruby
451a6890d6 scheduling - time quantum in miliseconds
- Currently the cpu time quantum is timer-ticks based. Thus the
  remaining quantum is decreased only if the processes is interrupted
  by a timer tick. As processes block a lot this typically does not
  happen for normal user processes. Also the quantum depends on the
  frequency of the timer.

- This change makes the quantum miliseconds based. Internally the
  miliseconds are translated into cpu cycles. Everytime userspace
  execution is interrupted by kernel the cycles just consumed by the
  current process are deducted from the remaining quantum.

- It makes the quantum system timer frequency independent.

- The boot processes quantum is loosely derived from the tick-based
  quantas and 60Hz timer and subject to future change

- the 64bit arithmetics is a little ugly, will be changes once we have
  compiler support for 64bit integers (soon)
2010-05-25 08:06:14 +00:00
Kees van Reeuwijk
ac14a989b3 Fixed some inconsistent strict typing declarations.
Better strict typing.
2010-05-25 07:23:24 +00:00
David van Moolenbroek
2a8961cdac fix int64.3 man page formatting 2010-05-24 21:10:37 +00:00
Erik van der Kouwe
1f11a57141 Oops, last commit included more than was intended 2010-05-20 08:07:47 +00:00
Erik van der Kouwe
5f15ec05b2 More system processes, this was not enough for the release script to run on some configurations 2010-05-20 08:05:07 +00:00
Erik van der Kouwe
456a125e00 Minor patch: increase size of root partition for minimal release, eve very small additions with -c made it fail 2010-05-19 20:11:22 +00:00
Arun Thomas
b0159ad168 Buildsystem changes for GCC
-Makefile updates
-Update mkdep
-Build fixes/warning cleanups for some programs
-Restore leading underscores on global syms in kernel asm files
-Increase ramdisk size
2010-05-19 13:24:15 +00:00
Ben Gras
bcdaf033b5 pm - fix sched interaction
For coredumping processes, PM forgets to inform SCHED that the
process has vanished, causing future fork()s to fail.
2010-05-19 13:22:29 +00:00
Erik van der Kouwe
77d5243f4a More sensible description for EPERM from http://www.opengroup.org/onlinepubs/000095399/basedefs/errno.h.html 2010-05-19 11:51:49 +00:00
Ben Gras
38ece51b25 charset cp1251 contributed by Roman Ignatov. 2010-05-19 11:34:47 +00:00
Ben Gras
987d3e6d85 packages: gcc-libs renamed, include gcc-4.4.3 2010-05-19 10:22:57 +00:00
Ben Gras
6d0e53c2ca use oxpcie only if enabled to avoid baud bottleneck of uart. 2010-05-19 10:18:46 +00:00
Ben Gras
9ba760e603 kernel: oxpcie serial card support.
ask to map in oxpcie i/o memory and support serial i/o for it in the
kernel. set oxpcie=<address> in boot monitor (retrieve address using
pci_debug=1 output). (no sanity checking is done on the address
currently.) disabled by default.

The change also contains some other minor cleanup (a new serial.h to set
register info common to UART and the OXPCIe card, in-kernel memory
mapping a little more structured and env_get() to get sysenv variables
without knowing about the params_buffer).
2010-05-19 10:00:02 +00:00
Tomas Hruby
dcc81d73e8 boot image - no need for entry point
- removes the initial_pc from struct boot_image. It is always set
  to 0 and RS uses a.out headers.
2010-05-18 13:51:46 +00:00
Tomas Hruby
b09bcf6779 Scheduling server (by Bjorn Swift)
In this second phase, scheduling is moved from PM to its own
scheduler (see r6557 for phase one). In the next phase we hope to a)
include useful information in the "out of quantum" message and b)
create some simple scheduling policy that makes use of that
information.

When the system starts up, PM will iterate over its process table and
ask SCHED to take over scheduling unprivileged processes. This is
done by sending a SCHEDULING_START message to SCHED. This message
includes the processes endpoint, the parent's endpoint and its nice
level. The scheduler adds this process to its schedproc table, issues
a schedctl, and returns its own endpoint to PM - as the endpoint of
the effective scheduler. When a process terminates, a SCHEDULING_STOP
message is sent to the scheduler.

The reason for this effective endpoint is for future compatibility.
Some day, we may have a scheduler that, instead of scheduling the
process itself, forwards the SCHEDULING_START message on to another
scheduler.

PM has information on who schedules whom. As such, scheduling
messages from user-land are sent through PM. An example is when
processes change their priority, using nice(). In that case, a
getsetpriority message is sent to PM, which then sends a
SCHEDULING_SET_NICE to the process's effective scheduler.

When a process is forked through PM, it inherits its parent's
scheduler, but is spawned with an empty quantum. As before, a request
to fork a process flows through VM before returning to PM, which then
wakes up the child process. This flow has been modified slightly so
that PM notifies the scheduler of the new process, before waking up
the child process. If the scheduler fails to take over scheduling,
the child process is torn down and the fork fails with an erroneous
value.

Process priority is entirely decided upon using nice levels. PM
stores a copy of each process's nice level and when a child is
forked, its parent's nice level is sent in the SCHEDULING_START
message. How this level is mapped to a priority queue is up to the
scheduler. It should be noted that the nice level is used to
determine the max_priority and the parent could have been in a lower
priority when it was spawned. To prevent a CPU intensive process from
hawking the CPU by continuously forking children that get scheduled
in the max_priority, the scheduler should determine in which queue
the parent is currently scheduled, and schedule the child in that
same queue.

Other fixes: The USER_Q in kernel/proc.h was incorrectly defined as
NR_SCHED_QUEUES/2. That results in a "off by one" error when
converting priority->nice->priority for nice=0. This also had the
side effect that if someone were to set the MAX_USER_Q to something
else than 0, then USER_Q would be off.
2010-05-18 13:39:04 +00:00
Tomas Hruby
b90c2d7026 rename of mode/context switching functions
- this patch only renames schedcheck() to switch_to_user(),
  cycles_accounting_stop() to context_stop() and restart() to
  +restore_user_context()

- the motivation is that since the introduction of schedcheck() it has
  been abused for many things. It deserves a better name.  It should
  express the fact that from the moment we call the function we are in
  the process of switching to user.

- cycles_accounting_stop() was originally a single purpose function.
  As this function is called at were convenient places it is used in
  for other things too, e.g. (un)locking the kernel. Thus it deserves
  a better name too.

- using the old name, restart() does not call schedcheck(), however
  calls to restart are replaced by calls to schedcheck()
  [switch_to_user] and it calls restart() [restore_user_context]
2010-05-18 13:00:39 +00:00
David van Moolenbroek
9ba65d2ea8 This patch switches the MINIX3 ethernet driver stack from a port-based
model to an instance-based model. Each ethernet driver instance is now
responsible for exactly one network interface card. The port field in
/etc/inet.conf now acts as an instance field instead.

This patch also updates the data link protocol. This update:
- eliminates the concept of ports entirely;
- eliminates DL_GETNAME entirely;
- standardizes on using m_source for IPC and DL_ENDPT for safecopies;
- removes error codes from TASK/STAT replies, as they were unused;
- removes a number of other old or unused fields;
- names and renames a few other fields.

All ethernet drivers have been changed to:
- conform to the new protocol, and exactly that;
- take on an instance number based on a given "instance" argument;
- skip that number of PCI devices in probe iterations;
- use config tables and environment variables based on that number;
- no longer be limited to a predefined maximum of cards in any way;
- get rid of any leftover non-safecopy support and other ancient junk;
- have a correct banner protocol figure, or none at all.

Other changes:
* Inet.conf is now taken to be line-based, and supports #-comments.
  No existing installations are expected to be affected by this.
* A new, select-based asynchio library replaces the old one.
  Kindly contributed by Kees J. Bot.
* Inet now supports use of select() on IP devices.
  Combined, the last two changes together speed up dhcpd
  considerably in the presence of multiple interfaces.
* A small bug has been fixed in nonamed.
2010-05-17 22:22:53 +00:00
Erik van der Kouwe
f5bce90216 Add -M release.sh option to write out a symbol map, either to /usr/src on the image (without -m) or to the tools directory (with -m) 2010-05-17 16:52:48 +00:00
Erik van der Kouwe
7570df267f Full 64-bit multitplication and division added to u64 library 2010-05-17 16:44:26 +00:00
Arun Thomas
5fa734b708 Awk build tweaks
-Make yacc invocation "less chatty to stderr" (again)
-Generate proctab.c (again)
2010-05-13 19:29:42 +00:00
Arun Thomas
869a181025 Buildsystem tweaks
Set build output verbosity level down to 1.
Make the 'install' target depend on the 'all' and 'depend' targets.
2010-05-13 13:26:27 +00:00
Arun Thomas
8630337c80 Fix permissions for halt, reboot, and shutdown 2010-05-13 12:05:53 +00:00
Erik van der Kouwe
6244867b11 xargs does not support the -f flag 2010-05-12 19:17:17 +00:00
Arun Thomas
5706670029 Convert boot/ and commands/ over to bsdmake 2010-05-12 16:28:54 +00:00
David van Moolenbroek
ce386974bc DS: base number of data entries on NR_SYS_PROCS 2010-05-12 13:21:15 +00:00
Ben Gras
bfc9c5c3a8 kernel: small ammendment to pagefault-in-kernel panic 2010-05-12 08:56:11 +00:00
Ben Gras
c5c25e7abc kernel/vm: change pde table info from single buffer to explicit per-process.
makes code in kernel more readable, and allows better sanity checking on
using the pde info.
2010-05-12 08:31:05 +00:00
Cristiano Giuffrida
23204787d5 - Fixed a bug when running out of priv structures.
- Tell VM about VM calls for every new service instance.
2010-05-11 20:49:42 +00:00
Ben Gras
7c5e1d1b29 kernel - don't print info about scheduled process if pagefault happened in kernel. 2010-05-11 15:14:10 +00:00
David van Moolenbroek
713454aca7 fix multiport support in ethernet drivers 2010-05-10 20:19:55 +00:00
Erik van der Kouwe
b7bf2733d6 Intermediate boot verbosity level EXTRA (2), MAX moved to 3 2010-05-10 18:07:59 +00:00
Erik van der Kouwe
d4188dcd5c New options for release script: -m to make tiny image, ZIP to set compressor 2010-05-10 18:02:15 +00:00
Tomas Hruby
d3e991a7b6 PM signal handling check too strict
- this panic may be unnecessarily triggered if PM gets the delayed
  stop signal from kernel before it gets reply from VFS to the UNPAUSE
  call.

- after this change PM does not proceed to delivering the signal until
  the reply from VFS is received. Perhaps PM could deliver the signal
  straight away as it knows that the process does not run. Possibly
 i dangerous.

- the signal is deliverd immediately after the UNPAUSE reply as the
  pending signals are always checked at the moment.
2010-05-10 14:27:22 +00:00
Tomas Hruby
5c63cac05a Removed defines not used since r6844. 2010-05-10 13:29:04 +00:00
Tomas Hruby
6e25ad8b0a Use of all NIL_* defines converted to NULL 2010-05-10 13:26:00 +00:00
Ben Gras
a1636b85b7 kernel: new DEBUG_RACE option. try to provoke race conditions between processes.
it does this by 
  - making all processes interruptible by running out of quantum
  - giving all processes a single tick of quantum
  - picking a random runnable process instead of in order, and
    from a single pool of runnable processes (no priorities)

This together with very high HZ values currently provokes some race conditions
seen earlier only when running with SMP.
2010-05-08 18:00:03 +00:00
Ben Gras
d5a0af826a vm: use arch_map2str to print pagefault info, to properly display code addrs 2010-05-08 17:25:54 +00:00
Ben Gras
72335b7642 kernel: print spurious interrupt message with increasing interval. 2010-05-08 17:21:37 +00:00
Tomas Hruby
7c334e2670 RS - fixed timeouts
- rs does not assume hz==60

- rs adjusts its timeout ticks by the system clock frequency

- drivers have time to reply if hz is set too high (e.g. 1000+) for
  instance when debugging
2010-05-07 18:12:16 +00:00
Tomas Hruby
ae9222a72b pci synchronous start up
- fixes a race between rs and pci
2010-05-07 16:23:07 +00:00
Tomas Hruby
4f962b4798 A small mini_receive() cleanup
- this patch substitutes *xpp for sender to increase readability of
  mini_receive().

- makes sure that the dequeued sender has p_q_link == NULL and that
  this condition holds when enqueuing the sender again. 

- it is a sanity check to make sure that the new sender is not
  enqueued already. Before this change the dequeued sender's p_q_link
  may not be NULL and it was only set to NULL when enqueued again.
2010-05-07 11:22:49 +00:00
Ben Gras
b8eddf00d8 kernel: don't try to lookup ANY in debug output. 2010-05-06 22:39:11 +00:00
Ben Gras
0194fe55dc kernel: increase some per-process privilege limits. 2010-05-06 22:21:08 +00:00
Cristiano Giuffrida
5a98cd3e92 Fix Inet initialization race. 2010-05-06 22:18:21 +00:00
Thomas Veerman
0aceb25535 Small cleanup of dead and/or redundant code. 2010-05-06 09:32:40 +00:00
Ben Gras
b6bb75963b vm: remove leftover diag print 2010-05-05 15:26:48 +00:00
Ben Gras
86e1b9d770 fsctl.h doesn't exist. 2010-05-05 11:49:41 +00:00
Ben Gras
f78d8e74fd secondary cache feature in vm.
A new call to vm lets processes yield a part of their memory to vm,
together with an id, getting newly allocated memory in return. vm is
allowed to forget about it if it runs out of memory. processes can ask
for it back using the same id. (These two operations are normally
combined in a single call.)

It can be used as a as-big-as-memory-will-allow block cache for
filesystems, which is how mfs now uses it.
2010-05-05 11:35:04 +00:00
Kees van Reeuwijk
51d46f8e46 Let memory allocation be aligned on 8-byte boundaries. 2010-05-04 21:02:44 +00:00
Ben Gras
09958abda8 tty: don't use custom kputc; this fixes tty printf()s. 2010-05-04 09:26:01 +00:00
Ben Gras
75b2153b9a awk Makefile: make yacc less chatty to stderr. 2010-05-04 09:23:31 +00:00
Ben Gras
ca86603cd6 libc: malloc: don't enable SLOWDEBUG by default 2010-05-03 22:54:51 +00:00
Ben Gras
029e809780 driver.h: increase max no. of open minors. 2010-05-03 19:43:54 +00:00
Erik van der Kouwe
1137ba9b32 Extra assertions on free if SLOWDEBUG is enabled: check whether the block exists and has not been freed before 2010-05-03 19:42:08 +00:00
Erik van der Kouwe
4b34ff6903 Add syslib function to obtain CPU frequency 2010-05-03 19:41:04 +00:00
Tomas Hruby
ec56479675 deadlock() - more info
- deadlock() is more verbose in case of a detected deadlock. First, it
  lists all processses in the deadlock group. Then it prints the proc
  extra info, not only  stack trace and register dump
2010-05-03 17:38:54 +00:00
Tomas Hruby
57a88ce708 debugging - printing processes on serial
- this patch moves the former printslot() from arch_system.c to
  debug.c and reimplements it slightly. The output is not changed,
  however, the process information is printed in a separate function
  print_proc() in debug.c as such a function is also handy in other
  situations and should be publicly available when debugging.
2010-05-03 17:37:18 +00:00
Thomas Veerman
4ae9c03147 - Add test52 to test FPU context switching
- Make test/run count how many tests it's going to perform instead of having to
  manually update it ourselves.
2010-05-03 15:12:39 +00:00
Kees van Reeuwijk
cfd28b671a Put the munmap and munmap_text trampolines in a separate .S file, so that they can be overridden independenly of mmap. 2010-04-29 20:12:56 +00:00
Kees van Reeuwijk
a2a0562a9c Make mdb compile in other places than just /usr/src. 2010-04-29 20:05:01 +00:00
Ben Gras
99a13341bd cpufeature() - rename _SSEx and correct logic in cpufeature() in lib 2010-04-29 19:08:49 +00:00
Erik van der Kouwe
3bf54e9b2b Allow loading images > 16M 2010-04-29 15:14:07 +00:00
Ben Gras
4e837dcfb3 kernel: more diagnostics for privctl ENOMEM conditions. 2010-04-29 08:50:52 +00:00
Ben Gras
4ac5eb7832 rs: stacktrace if system process exits early. 2010-04-29 08:50:17 +00:00
Cristiano Giuffrida
83ef7119f6 Don't panic when out of priv structures. 2010-04-28 20:41:23 +00:00
Erik van der Kouwe
93f3bf5bda Fix wrong word 2010-04-28 20:37:08 +00:00
Ben Gras
603ed23ebd at_wini: remove unnecessary quirks debug message 2010-04-28 14:19:40 +00:00
Ben Gras
50335291ae kernel: fpu_init: only enable OSXMMEXCPT in CR4 on at least SSE1 machines.
Found and debugged by totalinux at yandex.ru and Evgeniy Ivanov, thanks!
2010-04-28 13:51:02 +00:00
Ben Gras
c37401f23f kernel: fpu init to separate function; also move fpu init down
moving the fpu code causes exceptions raised by it to be trapped
neatly instead of causing a triple fault, before the IDT is initialized.
2010-04-28 13:25:29 +00:00
Thomas Veerman
f9317dc039 Scan all processes for that might be blocked on a lock 2010-04-28 11:54:22 +00:00
Ben Gras
b65ebdffac at_wini: more general system to allow devices that behave like ata controllers.
(let silicon image sata controller that is pci class 1, subclass 0x80,
but works as a sata controller, work as such.)
2010-04-28 11:52:28 +00:00
Ben Gras
72e866db48 pci: don't do sanity check for missing pci bus, the check can misfire. 2010-04-28 11:51:13 +00:00
Ben Gras
5d870f020d tty: try more often to get the config byte. 2010-04-28 11:50:54 +00:00
Erik van der Kouwe
d17590fcf4 Avoid sbrk (in favour of malloc) in RS where possible 2010-04-28 08:35:54 +00:00
Erik van der Kouwe
84d404aba3 Fix types in debug register functions 2010-04-28 08:35:05 +00:00
Erik van der Kouwe
8e918c407a Enable malloc assertions 2010-04-28 08:34:19 +00:00
Erik van der Kouwe
1b7de33a68 Add timeout for test 7 to indicate which test (if any) hangs 2010-04-28 08:33:23 +00:00
Tomas Hruby
b528d52ea8 pagefault() is private 2010-04-27 20:30:33 +00:00
Ben Gras
d11b88cfc5 mtree: no more /lib and /lib/i386. 2010-04-27 13:44:48 +00:00
Erik van der Kouwe
a033e6fcae Add missing newline at end of file 2010-04-27 13:30:46 +00:00
Erik van der Kouwe
4bddc57477 Remove debug printfs in breakpoints.c, they should never have been there 2010-04-27 12:25:04 +00:00
Cristiano Giuffrida
0164957abb Unified crash recovery and live update.
RS CHANGES:
- Crash recovery is now implemented like live update. Two instances are kept
side by side and the dead version is live updated into the new one. The endpoint
doesn't change and the failure is not exposed (by default) to other system
services.
- The new instance can be created reactively (when a crash is detected) or
proactively. In the latter case, RS can be instructed to keep a replica of
the system service to perform a hot swap when the service fails. The flag
SF_USE_REPL is set in that case.
- The new flag SF_USE_REPL is supported for services in the boot image and
dynamically started services through the RS interface (i.e. -p option in the
service utility).
- Fixed a free unallocated memory bug for core system services.
2010-04-27 11:17:30 +00:00
Tomas Hruby
30798fc3e1 Removed unused prototype 2010-04-26 23:39:05 +00:00
Tomas Hruby
f51eea4b32 Changed pagefault delivery to VM
this patch changes the way pagefaults are delivered to VM. It adopts
the same model as the out-of-quantum messages sent by kernel to a
scheduler.

- everytime a userspace pagefault occurs, kernel creates a message
  which is sent to VM on behalf of the faulting process

- the process is blocked on delivery to VM in the standard IPC code
  instead of waiting in a spacial in-kernel queue (stack) and is not
  runnable until VM tell kernel that the pagefault is resolved and is
  free to clear the RTS_PAGEFAULT flag.

- VM does not need call kernel and poll the pagefault information
  which saves many (1/2?) calls and kernel calls that return "no more
  data"

- VM notification by kernel does not need to use signals

- each entry in proc table is by 12 bytes smaller (~3k save)
2010-04-26 23:21:26 +00:00
Ben Gras
a131085a5b cd boot workaround for bioses that didn't want to boot >4 image sectors.
boot is a normal binary with a.out again. use 'cdbootblock,' a CDBOOT
variant of bootblock, both from bootblock.s, as the first boot image
that then loads boot, exactly like the bootblock loads boot when booting
from harddisk. the sector numbers (2048 byte iso sectors) are patched in
by writeisofs, like installboot does for bootblock. bootblock unchanged.
2010-04-26 22:07:21 +00:00
Ben Gras
94edf4fa12 vfs: start at vmnt[0] to sync mounted filesystems, not vmnt[1]. 2010-04-26 17:12:34 +00:00
Ben Gras
86e8eff905 remove intr_disabled() as interrupts are always disabled in the kernel now. 2010-04-26 15:32:42 +00:00
Tomas Hruby
1718924b10 Fixed printf warning in the filter driver 2010-04-26 14:44:20 +00:00
Cristiano Giuffrida
0f353411d7 Set IPC status code only for RECEIVE 2010-04-26 14:43:59 +00:00
Kees van Reeuwijk
5b0efc542f Remove a redundant getdomainname() implementation. 2010-04-26 12:43:43 +00:00
David van Moolenbroek
aacbfc41cc intercept puts() in libsys, for gcc 2010-04-23 20:23:33 +00:00
David van Moolenbroek
ee3b5fb5ea fix make(1) error output 2010-04-23 12:04:48 +00:00
Kees van Reeuwijk
74177b215d Also remove awk.old from makefile. 2010-04-22 14:18:35 +00:00
Kees van Reeuwijk
e24ed988d6 Fix some compilation errors with the gcc compiler, fix some recent warnings. 2010-04-22 13:59:34 +00:00
Kees van Reeuwijk
55129194a3 Remove obsolete implementation of awk. 2010-04-22 13:41:35 +00:00
Kees van Reeuwijk
d106968d77 Remove useless symbol declarations from headers, make symbols local where possible, add some explicit initialization to global variables. 2010-04-22 07:49:40 +00:00
Kees van Reeuwijk
87a9a2ecef More accurate make rule. 2010-04-21 14:41:20 +00:00
Kees van Reeuwijk
86a23c1fbd Remove U16_t and most other similar types. Rewrite functions to ansi-style
declaration if necessary.
2010-04-21 11:05:22 +00:00
Kees van Reeuwijk
8a304627a3 Forgot to add two new files to SVN. 2010-04-20 07:17:03 +00:00
Kees van Reeuwijk
e85f78a20b Add some support for wchar_t. 2010-04-19 15:20:24 +00:00
Kees van Reeuwijk
b412fb7ad5 Code cleanup: remove unused #include, variables and code, 2010-04-15 18:49:36 +00:00
David van Moolenbroek
cfb108afc7 fix mfs/isofs signal handling 2010-04-15 16:10:28 +00:00
Erik van der Kouwe
5230a36c2e Add scancode reading capability to TTY 2010-04-15 07:08:04 +00:00
Erik van der Kouwe
7de730afe4 Add scancode reading capability to TTY 2010-04-15 06:55:42 +00:00
Erik van der Kouwe
32f43d7571 Add scancode reading capability to TTY 2010-04-15 06:55:32 +00:00
Kees van Reeuwijk
8005ac2c64 Add timerisclear() macro. 2010-04-14 17:51:39 +00:00
David van Moolenbroek
05f8a5c550 unbreak _open for gcc-compiled programs 2010-04-14 11:07:49 +00:00
Erik van der Kouwe
8b459cfbb3 Provide information on lethal signals (stacktrace and signo) 2010-04-14 09:06:34 +00:00
Kees van Reeuwijk
fa3adedf63 Remove some duplicate declarations in headers.
Explicitly declare some functions as returning void.
2010-04-13 15:22:38 +00:00
Ben Gras
e0792d72d7 vm: util.S not used currently; leave it out. 2010-04-13 15:02:32 +00:00
Ben Gras
5c17d5e02f vm: include no-caching bits in PTF_ALLFLAGS for flags sanity check. 2010-04-13 11:08:08 +00:00
Ben Gras
1f1f8d2207 vm: don't force physical addresses to be nonzero. 2010-04-13 11:01:40 +00:00
Kees van Reeuwijk
bc314bda91 Remove the types Dev_t, _mnx_Gui, _mnx_Uid, and similar.
Use ANSI-style function declarations where necessary.
2010-04-13 10:58:41 +00:00
Tomas Hruby
86378ff645 PM remembers what it should schedule
- while PM implements fork also for RS it needs to remember what to
  schedule and what not. PM_SCHEDULED flag serves this purpose.

- PM only schedules processes that are descendaints of init, i.e. normal
  user processes

- after a process is forked PM schedules for the first time only
  processes that have PM_SCHEDULED set. The others are handled iether
  by kernel or some other scheduler
2010-04-13 10:45:08 +00:00
Ben Gras
5f7c37bb84 vm: remove assert, map in of phys addr 0 is legit sometimes. 2010-04-13 10:39:46 +00:00
Erik van der Kouwe
32713a6b5a Fix date in UPDATING 2010-04-12 17:56:07 +00:00
Ben Gras
27fc7ab1f3 vm: use assert() instead of vm_assert(); remove vm_assert(). 2010-04-12 12:37:28 +00:00
Ben Gras
c78250332d let vm use physically fragmented memory for allocations.
map_copy_ph_block is replaced by map_clone_ph_block, which can
replace a single physical block by multiple physical blocks.

also,
 . merge map_mem.c with region.c, as they manipulate the same
   data structures
 . NOTRUNNABLE removed as sanity check
 . use direct functions for ALLOC_MEM and FREE_MEM again
 . add some checks to shared memory mapping code
 . fix for data structure integrity when using shared memory
 . fix sanity checks
2010-04-12 11:25:24 +00:00
Ben Gras
76fbf21026 ipc server: don't print as many errors, to make ipc test less noisy. 2010-04-12 11:06:15 +00:00
Cristiano Giuffrida
66a8efba53 Fixed escape warning. 2010-04-12 08:39:59 +00:00
Tomas Hruby
9b599bac1d Quantum in fork
- This patch removes the time slice split between parent and child in
  fork.

- The time slice of the parent remains unchanged and the child does
  not have any.

- If the process has a scheduler, the scheduler must assign the
  quantum and priority of the new process and let it run.

- If the child does not inherit a scheduler, it is scheduled by the
  dummy default kernel policy. (servers, drivers, etc.)

- In theory, the scheduler can change the quantum even of the parent
  process and implement any policy for splitting the quantum as
  neither the parent nor the child are runnable.  Sending the
  out-of_quantum message on behalf of the processes may look like the
  right solution, however, the scheduler would probably handle the
  message before the whole fork protocol is finished. This way the
  scheduler has absolute control when the process should become
  runnable.
2010-04-10 15:27:38 +00:00
Tomas Hruby
1a31d158ad Restructure and simplyfycation of the scheduling code in PM a little bit.
- It introduces schedule_process() which makes a kernel call to set
  the scheduling parameters of a process. It is used in the next patch.
2010-04-10 15:24:49 +00:00
Tomas Hruby
512058ca98 This tiny cleanup makes the naming a variables in createpde() more clear. 2010-04-10 15:22:41 +00:00
Tomas Hruby
9fdb773cdb A simpler test whether to use kernel's default scheduling
- this is a small addition to the userspace scheduling.
  proc_kernel_scheduler() tests whether to use the default scheduling
  policy in kernel. It is true if the process' scheduler is NULL _or_
  self. Currently none of the tests was complete.
2010-04-10 15:19:25 +00:00
Tomas Hruby
485a037563 do_schedule() cleanup
- it is not neccessary to test whether the scheduler is a system
  process as the process already head permissions to make this call.

- it is better to test whether the scheduler has permission to make
  changes to this process before testing whether the values are valid.
2010-04-10 15:17:09 +00:00
Cristiano Giuffrida
65ef539739 Driver mapping refactory.
VFS CHANGES:
- dmap table no longer statically initialized in VFS
- Dropped FSSIGNON svrctl call no longer used by INET

INET CHANGES:
- INET announces its presence to VFS just like any other driver

RS CHANGES:
- The boot image dev table contains all the data to initialize VFS' dmap table
- RS interface supports asynchronous up and update operations now
- RS interface extended to support driver style and flags
2010-04-09 21:56:44 +00:00
Ben Gras
c1bfcc9119 port of netbsd's tr 2010-04-08 15:08:31 +00:00
Ben Gras
1164052eea netbsd's original tr/extern.h as tr.h 2010-04-08 15:06:43 +00:00
Ben Gras
836a0957fb original netbsd's tr(1) 2010-04-08 15:04:57 +00:00
Ben Gras
c28e35bd3e no minix tr 2010-04-08 15:04:05 +00:00
Cristiano Giuffrida
98d1cf7064 Fixed gcc -Wall warnings. 2010-04-08 15:02:32 +00:00
Ben Gras
1c8c8aa4d8 isblank() implementation. 2010-04-08 15:00:25 +00:00
Cristiano Giuffrida
48c6bb79f4 Driver refactory for live update and crash recovery.
SYSLIB CHANGES:
- DS calls to publish / retrieve labels consider endpoints instead of u32_t.

VFS CHANGES:
- mapdriver() only adds an entry in the dmap table in VFS.
- dev_up() is only executed upon reception of a driver up event.

INET CHANGES:
- INET no longer searches for existing drivers instances at startup.
- A newtwork driver is (re)initialized upon reception of a driver up event.
- Networking startup is now race-free by design. No need to waste 5 seconds
at startup any more.

DRIVER CHANGES:
- Every driver publishes driver up events when starting for the first time or
in case of restart when recovery actions must be taken in the upper layers.
- Driver up events are published by drivers through DS. 
- For regular drivers, VFS is normally the only subscriber, but not necessarily.
For instance, when the filter driver is in use, it must subscribe to driver
up events to initiate recovery.
- For network drivers, inet is the only subscriber for now.
- Every VFS driver is statically linked with libdriver, every network driver
is statically linked with libnetdriver.

DRIVER LIBRARIES CHANGES:
- Libdriver is extended to provide generic receive() and ds_publish() interfaces
for VFS drivers.
- driver_receive() is a wrapper for sef_receive() also used in driver_task()
to discard spurious messages that were meant to be delivered to a previous
version of the driver.
- driver_receive_mq() is the same as driver_receive() but integrates support
for queued messages.
- driver_announce() publishes a driver up event for VFS drivers and marks
the driver as initialized and expecting a DEV_OPEN message.
- Libnetdriver is introduced to provide similar receive() and ds_publish()
interfaces for network drivers (netdriver_announce() and netdriver_receive()).
- Network drivers all support live update with no state transfer now.

KERNEL CHANGES:
- Added kernel call statectl for state management. Used by driver_announce() to
unblock eventual callers sendrecing to the driver.
2010-04-08 13:41:35 +00:00
Ben Gras
2fd5eb2569 ipc test improvements
. rename testshm.sh to test.sh so all test scripts are called test.sh
 . delete msg* tests as msg* functionality isn't implemented
 . add ipc/test.sh that runs all test.sh scripts in the subdirs
2010-04-08 13:11:37 +00:00
Ben Gras
78806e1b2e more stack for boot 2010-04-08 12:18:57 +00:00
Kees van Reeuwijk
c114df82ec Rename all uses of U8_t to u8_t and remove U8_t, remove unused I8_t,
Remove all uses of U16_t and U32_t in pci-related code.
If necessary to avoid problems, change functions to ansi-style declaration.
2010-04-07 13:35:56 +00:00
Tomas Hruby
25f2145956 Fixed a panic message
- exceptions cannot occur in kernel tasks as we don't have kernel
  tasks anymore
2010-04-07 12:50:43 +00:00
Kees van Reeuwijk
94a81c840a Removed unused variables, added const where possible. 2010-04-07 11:25:51 +00:00
Tomas Hruby
c39eb33b74 A fixed prototype in dec21140A.c 2010-04-07 07:50:44 +00:00
Tomas Hruby
b464da5d73 do_nice.c
- this file is not used and should have been remove in r6557
2010-04-06 13:44:03 +00:00
Tomas Hruby
987b87e2ad Small fixes
- do_sync_ipc() is private

- fixed typo in a comment
2010-04-06 11:29:31 +00:00
Tomas Hruby
a774cc832f do_ipc() rearrangements
this patch does not add or change any functionality of do_ipc(), it
only makes things a little cleaner (hopefully).

Until now do_ipc() was responsible for handling all ipc calls. The
catch is that SENDA is fairly different which results in some ugly
code like this typecasting and variables naming which does not make
much sense for SENDA and makes the code hard to read.

result = mini_senda(caller_ptr, (asynmsg_t *)m_ptr, (size_t)src_dst_e);

As it is called directly from assembly, the new do_ipc() takes as
input values of 3 registers in reg_t variables (it used to be 4,
however, bit_map wasn't used so I removed it), does the checks common
to all ipc calls and call the appropriate handler either for
do_sync_ipc() (all except SENDA) or mini_senda() (for SENDA) while
typecasting the reg_t values correctly. As a result, handling SENDA
differences in do_sync_ipc() is no more needed. Also the code that
uses msg_size variable is improved a little bit.

arch_do_syscall() is simplified too.
2010-04-06 11:24:26 +00:00
Tomas Hruby
b0d37b81c4 RTS_SYS_LOCK and do_runctl()
- No need for RTS_SYS_LOCK as there are no tasks anymore.
2010-04-06 11:18:04 +00:00
Tomas Hruby
cdd6743e88 do_vtimer()
- removed comment which is not true anymore as we don't have any
  tasks. No need to take any special measures.
2010-04-06 11:16:14 +00:00
Arun Thomas
4ed3a0cf3a Convert kernel over to bsdmake 2010-04-01 22:22:33 +00:00
Kees van Reeuwijk
0a04f49d2b Fixed some incorrect uses of printf-like functions. 2010-04-01 14:30:36 +00:00
Kees van Reeuwijk
fc7dced1fa Fix printfs with too few or too many parms, remove unused vars, fix incorrect flag tests, other code cleanup. 2010-04-01 13:25:05 +00:00
Kees van Reeuwijk
c3f649557e Lots of const correctness, other cleanup. 2010-04-01 12:51:31 +00:00
Ben Gras
9fd4c2a20d introduce the fsckopts sysenv, options passed to fsck by /etc/rc.
setting 'fsckopts=-a' makes it much easier to work on a minix machine
remotely and reboot after a crash.
2010-03-31 15:06:53 +00:00
Ben Gras
de93803ab0 only print 'PCI: ignoring bad value ...' once per boot. 2010-03-31 12:29:30 +00:00
Cristiano Giuffrida
d8b42a755d Move kernel signal SIGKNDELAY to system signal SIGSNDELAY and fix broken ptrace. 2010-03-31 08:55:12 +00:00
Thomas Veerman
4d686f1616 Move allocation of temporary inodes for cloned character special devices from
MFS to PFS.
2010-03-30 15:00:09 +00:00
Kees van Reeuwijk
4865e3f4f9 More use of endpoint_t. Other code cleanup. 2010-03-30 14:07:15 +00:00
Lorenzo Cavallaro
2ff73172b4 Fixed missing __UNCONST macro definition in previous patch. 2010-03-30 13:08:14 +00:00
Lorenzo Cavallaro
8dfc7699a6 cdecl calling convention requires to push arguments on the stack in a
reverse order to easily support variadic arguments. Thus, instead of
using the proper stdarg.h macros (that nowadays are
compiler-dependent), it may be tempting to directly take the address of
the last argument and considering it as the start of an array. This is
a shortcut that avoid looping to get all the arguments as the CPU
already pushed them on the stack before the call to the function.

Unfortunately, such an assumption is strictly compiler-dependent and
compilers are free to move the last argument on the stack, as a local
variable, and return the address of the location where the argument was
stored, if asked for. This will break things as the rest of the array's
argument are stored elsewhere (typically, a couple of words above the
location where the argument was stored).

This patch fixes the issue by allowing ACK to take the shortcut and
enabling gcc/llvm-gcc to follow the right way.
2010-03-30 09:36:46 +00:00
Tomas Hruby
63e2d73d1b Fixed brackets in bitmap macros 2010-03-30 08:34:33 +00:00
Ben Gras
f2b87f5fb7 don't print SYSTEM stacktrace on exceptions as it's not scheduled any more. 2010-03-29 15:32:19 +00:00
Tomas Hruby
62203ec287 NOREC_ENTER and NOREC_RETURN checks removed
- the reasons for these checks no longer exist

- these check are problematic on SMP
2010-03-29 11:43:10 +00:00
Ben Gras
bc0e36f402 fix null deref; vmnt->mounted_on is NULL legitimately for root.
changed check+panic to assert().

added assert().
2010-03-29 11:39:54 +00:00
Tomas Hruby
5b52c5aa02 A reliable way for userspace to check if a msg is from kernel
- IPC_FLG_MSG_FROM_KERNEL status flag is returned to userspace if the
  receive was satisfied by s message which was sent by the kernel on
  behalf of a process. This perfectly reliale information.

- MF_SENDING_FROM_KERNEL flag added to processes to be able to set
  IPC_FLG_MSG_FROM_KERNEL when finishing receive if the receiver
  wasn't ready to receive immediately.

- PM is changed to use this information to confirm that the scheduling
  messages are indeed from the kernel and not faked by a process.

  PM uses sef_receive_status()

- get_work() is removed from PM to make the changes simpler
2010-03-29 11:25:01 +00:00
Tomas Hruby
2521cc6bdf Slightly faster IPC
- there are cycles wasted in the IPC call due to a fairly compliacted
  way of copying messages from userland to kernel. Sometimes this
  complicated way (generic though) is used even for copying within the
  kernel address space, sometimes it is used for copying in case _no_
  copying is necessary. The goal of this patch is to improve this a
  little bit.

- the places where a copy is from user to kernel use the
  copy_msg_from_user() kernel-kernel copies are turned into
  assignments and BuildNotifyMessage uses the delivery buffers to
  avoid copying.

- copy_msg_from_user() was introduced when removing the system task
  and is about 2/3 faster then using the current mechanism
  (phys_copy). It also avoids the PHYS_COPY_CATCH macro. Assignment is
  also faster and no copy is the fastest ;-) so perhaps there will be
  some hardly noticable performance gain besides the clean up.
2010-03-29 11:16:37 +00:00
Tomas Hruby
b4cf88a04f Userspace scheduling
- cotributed by Bjorn Swift

- In this first phase, scheduling is moved from the kernel to the PM
  server. The next steps are to a) moving scheduling to its own server
  and b) include useful information in the "out of quantum" message,
  so that the scheduler can make use of this information.

- The kernel process table now keeps record of who is responsible for
  scheduling each process (p_scheduler). When this pointer is NULL,
  the process will be scheduled by the kernel. If such a process runs
  out of quantum, the kernel will simply renew its quantum an requeue
  it.

- When PM loads, it will take over scheduling of all running
  processes, except system processes, using sys_schedctl().
  Essentially, this only results in taking over init. As children
  inherit a scheduler from their parent, user space programs forked by
  init will inherit PM (for now) as their scheduler.

 - Once a process has been assigned a scheduler, and runs out of
   quantum, its RTS_NO_QUANTUM flag will be set and the process
   dequeued. The kernel will send a message to the scheduler, on the
   process' behalf, informing the scheduler that it has run out of
   quantum. The scheduler can take what ever action it pleases, based
   on its policy, and then reschedule the process using the
   sys_schedule() system call.

- Balance queues does not work as before. While the old in-kernel
  function used to renew the quantum of processes in the highest
  priority run queue, the user-space implementation only acts on
  processes that have been bumped down to a lower priority queue.
  This approach reacts slower to changes than the old one, but saves
  us sending a sys_schedule message for each process every time we
  balance the queues. Currently, when processes are moved up a
  priority queue, their quantum is also renewed, but this can be
  fiddled with.

- do_nice has been removed from kernel. PM answers to get- and
  setpriority calls, updates it's own nice variable as well as the
  max_run_queue. This will be refactored once scheduling is moved to a
  separate server. We will probably have PM update it's local nice
  value and then send a message to whoever is scheduling the process.

- changes to fix an issue in do_fork() where processes could run out
  of quantum but bypassing the code path that handles it correctly.
  The future plan is to remove the policy from do_fork() and implement
  it in userspace too.
2010-03-29 11:07:20 +00:00
Tomas Hruby
a3ffc0f7ad Removed NIL_SYS_PROC and NIL_PROC
- NIL_PROC replaced by simple NULLs
2010-03-28 09:54:32 +00:00
Kees van Reeuwijk
98493805fd Lots of const correctness. 2010-03-27 14:31:00 +00:00
Cristiano Giuffrida
9192dbecc9 Preserve the order of IPC messages between two parties.
Currently a sequence of messages between a sender A and a receiver B of the
form: A.asynsend(M1, B); A.send(M2, B) may result in the receiver receiving
M1 first and then M2 or viceversa. This patch makes sure that the original
order M1, M2 is always preserved.

Note that the order of a hypotetical sequence A.asynsend(M1, B);
A.asynsend(M2, B) is already guaranteed by the implementation of
asynsend by design. Other senda-based wrappers can define their own
semantics.
2010-03-27 00:09:22 +00:00
Tomas Hruby
8e5a82fd49 Comment in proc.h
- This comment is not correct as the pproc_addr array does not exist.
2010-03-26 13:19:04 +00:00
Tomas Hruby
1dd6f5573a Direction flag
- ack assumes that the direction flag in eflags is clear when
  assigning two structures. It is implemented by a call to a built-in
  function which is like memcpy but needs the flag to be clear
  otherwise rubish is copied. This patch fixes the kernel entries.
2010-03-26 12:29:52 +00:00
Lorenzo Cavallaro
a16308efdb cdecl calling convention expects the callee to pop the hidden pointer on
struct return. For example, GCC and LLVM comply with this (tested on IA32).

ACK doesn't seem to follow this convention and expects the caller to clean up
the stack. Compiling hand-written ACK-compliant assembly code (returning a 
struct) with GCC or LLVM used to break things (4-bytes misaligned stack).

The patch fixes this problem.
2010-03-24 17:25:17 +00:00
Arun Thomas
5fd3f34273 Minor docs/UPDATING fix 2010-03-24 13:41:38 +00:00
Arun Thomas
14ca3ea017 Sort docs/UPDATING entries reverse chronologically 2010-03-24 10:13:19 +00:00
Arun Thomas
0ea82663e0 Fix crtso building with GCC 2010-03-24 10:11:17 +00:00
Kees van Reeuwijk
407316e451 More const correctness.
Removed prototype for unimplemented getpgid() function.
Removed a value return from a void function.
2010-03-23 14:25:09 +00:00
Tomas Hruby
a6957b7847 Fixed prototype in cat 2010-03-23 13:36:16 +00:00
Tomas Hruby
8451a86f0a Interrupts hadling while idle
- When the cpu halts, the interrupts are enable so the cpu may be
  woken up. When the interrupt handler returns but another interrupt
  is available it is also serviced immediately. This is not a problem
  per-se. It only slightly breaks time accounting as idle accounted is
  for the kernel time in the interrupt handler.
  
  
-  As the big kernel lock is lock/unlocked in the smp branch in the
   time acounting functions as they are called exactly at the places
   we need to take the lock) this leads to a deadlock.

- we make sure that once the interrupt handler returns from the nested
  trap, the interrupts are disabled. This means that only one
  interrupt is serviced after idle is interrupted.

- this requires the loop in apic timer calibration to keep reenabling
  the interrupts. I admit it is a little bit hackish (one line),
  however, this code is a stupid corner case at the boot time.
  Hopefully it does not matter too much.
2010-03-23 13:35:01 +00:00
Cristiano Giuffrida
bde2109b7c IPC status code for receive().
IPC changes:
- receive() is changed to take an additional parameter, which is a pointer to
a status code.
- The status code is filled in by the kernel to provide additional information
to the caller. For now, the kernel only fills in the IPC call used by the
sender.

Syslib changes:
- sef_receive() has been split into sef_receive() (with the original semantics)
and sef_receive_status() which exposes the status code to userland.
- Ideally, every sys process should gradually switch to sef_receive_status()
and use is_ipc_notify() as a dependable way to check for notify.
- SEF has been modified to use is_ipc_notify() and demonstrate how to use the
new status code.
2010-03-23 00:09:11 +00:00
Cristiano Giuffrida
45db6482e8 Prioritized NOTIFY messages for reliable asynchonrous delivery of system events. 2010-03-22 23:44:55 +00:00
Cristiano Giuffrida
ef95bf1bb9 Print stacktrace when a system service fails or when a core dump has to be generated for a user process. 2010-03-22 22:46:29 +00:00
Arun Thomas
436d6012a3 Convert drivers/ and servers/ over to bsdmake
-Move libdriver to lib/
-Install all boot image services on filesystem to aid restartability
2010-03-22 21:25:22 +00:00
Kees van Reeuwijk
c33102ea6b Miscellaneous code cleanup. 2010-03-22 20:43:06 +00:00
Ben Gras
4b2310a7ee only print 1 every 1000 spurious interrupts (per interrupt). 2010-03-22 13:55:51 +00:00
Tomas Hruby
12ef495cac atomicity fix when enabling paging
- before enabling paging VM asks kernel to resize its segments. This
  may cause kernel to segfault if APIC is used and an interrupt
  happens between this and paging enabled. As these are 2 separate
  vmctl calls it is not atomic. This patch fixes this problem. VM does
  not ask kernel to resize the segments in a separate call anymore.
  The new segments limit is part of the "enable paging" call. It
  generalizes this call in such a way that more information can be
  passed as need be or the information may be completely different if
  another architecture requires this.
2010-03-22 07:42:52 +00:00
Tomas Hruby
a5094f7d7f Kernel dumps its registers when exception
- if an exception occurs in kernel and this exception is not handled
  in an sane way and the kernel crashes, it also dumps what was loaded
  in the general purpose registers exactly at the time of the
  exception to help to debug the problem
2010-03-20 14:59:18 +00:00
Erik van der Kouwe
b42c66ed10 this patch adds access to the debug breakpoints to
the kernel. They are not used atm, but having them in trunk allows them
to be easily used when needed. To set a breakpoint that triggers when
the variable foo is written to (the most common use case), one calls:

breakpoint_set(vir2phys((vir_bytes) &foo), 0,
  BREAKPOINT_FLAG_MODE_GLOBAL |
  BREAKPOINT_FLAG_RW_WRITE |
  BREAKPOINT_FLAG_LEN_4);

It can later be disabled using:

breakpoint_set(vir2phys((vir_bytes) &foo), 0,
  BREAKPOINT_FLAG_MODE_OFF);

There are some limitations:

- There are at most four breakpoints (hardware limit); the index of the
  breakpoint (0-3) is specified as the second parameter of
  breakpoint_set.

- The breakpoint exception in the kernel is not handled and causes a
  panic; it would be reasonably easy to change this by inspecing DR6,
  printing a message, disabling the breakpoint and continuing. However,
  in my experience even just a panic can be very useful.

- Breakpoints can be set only in the part of the address space that is
  in every page table. It is useful for the kernel, but to use this for
  user processes would require saving and restoring the debug registers
  as part of the context switch. Although the CPU provides support for
  local breakpoints (I implemened this as BREAKPOINT_FLAG_LOCAL) they
  only work if task switching is used.
2010-03-19 19:15:20 +00:00
Erik van der Kouwe
19ff96081c Specify missing return type 2010-03-19 19:07:00 +00:00
Ben Gras
ec30f25d0c VM: fix kernel mappings for children of non-paged parents. 2010-03-18 17:17:31 +00:00
Tomas Hruby
61348227a7 docs/UPDATING correction 2010-03-18 17:00:32 +00:00
Tomas Hruby
a0602c06a3 Fixed kernel stack comment 2010-03-18 16:18:22 +00:00
Ben Gras
e595328986 remove 3 awk files - don't have generated files in svn. 2010-03-18 14:15:48 +00:00
Ben Gras
f250bfaa13 change messy CREATEPDE macro to clean little function.
forget about the dirtypde bitmap and WIPEPDE/DONEPDE macros too.

check if mapping happens to already be in place, and if so, don't
reload cr3 (on the account of that mapping, that is).

don't reload cr3 unconditionally.
2010-03-18 13:35:41 +00:00
Erik van der Kouwe
c3e73f0793 Provide a warning is a kernel call has been denied, to ease system.conf debugging 2010-03-17 18:23:51 +00:00
Kees van Reeuwijk
4683d6b713 Let awk.old install its awk as /usr/bin/awk.old.
Add one-true-awk as the new awk that installs to /usr/bin/awk.
2010-03-17 16:16:52 +00:00
Kees van Reeuwijk
365495b530 Moved current awk sources to awk.old. 2010-03-17 16:11:48 +00:00
Kees van Reeuwijk
4432f197c1 Add a define for NSIG. 2010-03-17 13:43:34 +00:00
Cristiano Giuffrida
cb176df60f New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
        /usr/src/etc/system.conf updated to ignore default kernel calls: copy
        it (or merge it) to /etc/system.conf.
        The hello driver (/dev/hello) added to the distribution:
        # cd /usr/src/commands/scripts && make clean install
        # cd /dev && MAKEDEV hello

KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.

PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.

SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.

VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().

RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.

DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.

DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 01:15:29 +00:00
David van Moolenbroek
7685e98304 typo 2010-03-16 16:21:28 +00:00
Cristiano Giuffrida
83d1f45578 Fixed a bug in interrupt handling code when removing a handler in case of
a shared IRQ.
2010-03-16 10:20:36 +00:00
Erik van der Kouwe
2ba76cfec6 Minor correction in UPDATING 2010-03-16 08:16:13 +00:00
Arun Thomas
9944688d2b Convert man/ over to new make 2010-03-16 00:15:43 +00:00
Kees van Reeuwijk
d89e33fc92 Suppressed some warnings in the WIFSIGNALED macro. 2010-03-15 18:33:29 +00:00
Thomas Veerman
1749530ec1 Fix bug item #405: missing # in front of comment 2010-03-15 10:42:51 +00:00
Thomas Veerman
bef0e3eb63 - Add support for the ucontext system calls (getcontext, setcontext,
swapcontext, and makecontext).
- Fix VM to not erroneously think the stack segment and data segment have
  collided when a user-space thread invokes brk().
- Add test51 to test ucontext functionality.
- Add man pages for ucontext system calls.
2010-03-12 15:58:41 +00:00
Kees van Reeuwijk
3efbb8f133 Let the commands/simple/tr.c understand about '\t', '\r', and '\n'. 2010-03-12 09:58:44 +00:00
Kees van Reeuwijk
23e97af1b4 Add an UNUSED annotation, and use it in libsys. 2010-03-11 14:23:33 +00:00
Erik van der Kouwe
da25ecf758 Work around KVM unreal mode bug by avoiding unreal mode 2010-03-10 15:32:31 +00:00
Kees van Reeuwijk
5df6b80093 Clean up code in preparation for using gcc warnings. 2010-03-10 13:19:27 +00:00
Ben Gras
0937d6c367 re-establish kernel assert()s.
use the regular <assert.h> assert() instead of vmassert() in
kernel. throw out some #if 0 code. fix a few assert() conditions.
enable by default.
2010-03-10 13:00:05 +00:00
Kees van Reeuwijk
88ac328e6b Add prototypes for a bunch of time-related functions. Surprisingly,
they were in the implementation, but not in the header files.
2010-03-09 22:10:58 +00:00
Kees van Reeuwijk
a34d34bc1f Add a set of declarations to math.h. Since we don't actually have
implementations for these functions, we lean on GNU builtin functions
for using them, so these declarations are also conditional on using
a GNU compiler.
2010-03-09 22:05:20 +00:00
Dirk Vogt
44231405cf fix newsigset/oldsigset references 2010-03-09 20:46:26 +00:00
Kees van Reeuwijk
cf95efbad1 Prevent the use of an unitialized variable for block size in CRC calculation. 2010-03-09 16:21:41 +00:00
Arun Thomas
4206784d82 Flex: Fix install(1) invocation in build 2010-03-09 09:43:53 +00:00
Arun Thomas
1f9ce647cf Move archtypes.h, fpu.h, and stackframe.h
Move archtypes.h to include/ dir, since several servers require it. Move
fpu.h and stackframe.h to arch-specific header directory. Make source
files and makefiles aware of the new header locations.
2010-03-09 09:41:14 +00:00
David van Moolenbroek
27d53256e4 VFS fixes:
- do not use uninitialized req_breadwrite results upon failure
- improve ".." ELEAVEMOUNT correctness check
2010-03-08 22:05:27 +00:00
Kees van Reeuwijk
91655261a1 Also run fixincludes in gcc 4.4.3 2010-03-08 14:51:00 +00:00
Ben Gras
4f063f2925 fix for wrong arg to va_end() in panic() (thanks tveerman) 2010-03-08 14:36:55 +00:00
Arun Thomas
2a8fabf4ad Include directory reorg and makefile updates.
-Convert the include directory over to using bsdmake
 syntax
-Update/add mkfiles
-Modify install(1) so that it can create symlinks
-Update makefiles to use new install(1) options
-Rename /usr/include/ibm to /usr/include/i386
-Create /usr/include/machine symlink to arch header files
-Move vm_i386.h to its new home in the /usr/include/i386
-Update source files to #include the header files at their
 new homes.
-Add new gnu-includes target for building GCC headers
2010-03-08 11:04:59 +00:00
Tomas Hruby
ecf1a36d48 Fix for FPU broken by r6131
- cycles accounting must be called earlier, firstly not to clobber the %ebx
  register, secondly to be correctly called in both branches.
2010-03-05 22:23:03 +00:00
Ben Gras
35a108b911 panic() cleanup.
this change
   - makes panic() variadic, doing full printf() formatting -
     no more NO_NUM, and no more separate printf() statements
     needed to print extra info (or something in hex) before panicing
   - unifies panic() - same panic() name and usage for everyone -
     vm, kernel and rest have different names/syntax currently
     in order to implement their own luxuries, but no longer
   - throws out the 1st argument, to make source less noisy.
     the panic() in syslib retrieves the server name from the kernel
     so it should be clear enough who is panicing; e.g.
         panic("sigaction failed: %d", errno);
     looks like:
         at_wini(73130): panic: sigaction failed: 0
         syslib:panic.c: stacktrace: 0x74dc 0x2025 0x100a
   - throws out report() - printf() is more convenient and powerful
   - harmonizes/fixes the use of panic() - there were a few places
     that used printf-style formatting (didn't work) and newlines
     (messes up the formatting) in panic()
   - throws out a few per-server panic() functions
   - cleans up a tie-in of tty with panic()

merging printf() and panic() statements to be done incrementally.
2010-03-05 15:05:11 +00:00
Kees van Reeuwijk
851dc95566 Move cp_grant_id_t to a more central header file, and uses it more
extensively.
Fix casts that cast the grand id field of some messages to the wrong
type.
2010-03-04 16:15:26 +00:00
Ben Gras
adf0b6fb26 No more E{SRC,DST}DIED errno's, replaced by EDEADSRCDST.
The callers don't care about the difference and had to check 3 error
codes instead of one.
2010-03-03 15:47:16 +00:00
Ben Gras
eedff09bfd top manpage update 2010-03-03 15:46:20 +00:00
Ben Gras
72fc754948 new feature for top - display chain of blocked processes for every
blocked process.
2010-03-03 15:45:43 +00:00
Ben Gras
e6cb76a2e2 no more kprintf - kernel uses libsys printf now, only kputc is special
to the kernel.
2010-03-03 15:45:01 +00:00
Ben Gras
18924ea563 New P_BLOCKEDON for kernel - a macro that encodes the "who is this
process waiting for" logic, which is duplicated a few times in the
kernel. (For a new feature for top.)

Introducing it and throwing out ESRCDIED and EDSTDIED (replaced by
EDEADSRCDST - so we don't have to care which part of the blocking is
failing in system.c) simplifies some code in the kernel and callers that
check for E{DEADSRCDST,ESRCDIED,EDSTDIED}, but don't care about the
difference, a fair bit, and more significantly doesn't duplicate the
'blocked-on' logic.
2010-03-03 15:32:26 +00:00
Arun Thomas
cbd276e4ce Convert library asm files to GAS syntax 2010-03-03 14:27:30 +00:00
Kees van Reeuwijk
bf7397b64e More correctly use cp_grant_id_t.
More correctly use vir_bytes.
More correctly use endpoint_t.
2010-03-02 23:12:13 +00:00
Kees van Reeuwijk
f3c98fdca2 Fixed a number of cases where a bits in an integer were tested
incorrectly, resulting in real (and nasty) bugs.
2010-03-02 12:55:39 +00:00
Tomas Hruby
975efeac31 Typo in VM server 2010-03-02 10:53:17 +00:00
Ben Gras
5af8c345be slight tuning of /etc/mk situation when making release.
- Make the bootstrap /etc/mk be populated from the newly checked out source
  - Don't chmod 755 all of /etc
  - For the 'real' /etc/mk installing, let the /etc/mk ownership and permission
    come from the mtree file, delete the contents of /etc/mk, then copy the .mk
    files over and set reasonable permissions and ownership. (So that the .mk
    get updated from the real usr/src/ copies, and no other junk if anything,
    after the bootstrap phase, whatever happened there.)
2010-03-01 15:53:57 +00:00
Erik van der Kouwe
6b867ec05c #include <minix/ipc.h> in <minix/sef.h> 2010-02-26 10:13:50 +00:00
Erik van der Kouwe
2a67e38d88 #include <minix/ipc.h> in <minix/sef.h> 2010-02-26 10:12:54 +00:00
Arun Thomas
dd6569d342 Copy mkfiles when building world 2010-02-25 22:10:48 +00:00
Ben Gras
7c4cd0e6b0 - new pread(), fnmatch() calls
- split sprintf() and snprintf() to solve a linking problem when
   compiling an application
2010-02-25 17:08:08 +00:00
Arun Thomas
4cb358d999 Replace Minix tar with pax's tar 2010-02-24 11:58:10 +00:00
Arun Thomas
a4af231978 Improve makefile logic for building programs/libs 2010-02-24 11:58:05 +00:00
Kees van Reeuwijk
1ce69592d2 Fixed an array bounds violation.
Let include guards comform to the Minix standard.
2010-02-24 10:39:58 +00:00
Kees van Reeuwijk
3922d45719 Fix an array-bound violation, add some include guards. 2010-02-22 17:44:08 +00:00
Ben Gras
c460974814 remove subdirs that aren't built.
ftp is superseded by other dirs, i86 is not used, httpd* is superseded
by packages, sed is superseded by simple/sed.c.
2010-02-19 16:31:43 +00:00
Ben Gras
8c88a0219b add swifi to the build/install. 2010-02-19 16:16:28 +00:00
Ben Gras
d3b3c9d36d fix some warning in swifi, make it installable 2010-02-19 16:15:25 +00:00
Erik van der Kouwe
1a326acada Flag to load kernel high (not yet used by default), improved debug output 2010-02-19 12:38:38 +00:00
Erik van der Kouwe
e3bfaaa2d0 Remove executable bit on mkdep.1 2010-02-19 12:32:01 +00:00
Kees van Reeuwijk
1ba0936619 Fix some uses of uninitialized variables. 2010-02-19 10:41:02 +00:00
Kees van Reeuwijk
1597e701a0 Remove useless variables and the computations on them. 2010-02-19 10:00:32 +00:00
Kees van Reeuwijk
cf4f92dc21 Lots of cleanup of boot code. 2010-02-17 20:30:29 +00:00
Kees van Reeuwijk
97c169b93a Remove some unused #include.
Remove some unused variables and computations on them.
2010-02-17 20:24:42 +00:00
Arun Thomas
1e9a3c1423 Bump version number to 3.1.7 2010-02-17 12:51:26 +00:00
Arun Thomas
56b99ca816 Get gcc tests building again 2010-02-17 08:45:56 +00:00
Erik van der Kouwe
5af2471a9a Throw out obsolete Atari, Macintosh and Sun code to un-break packages;
credits to Sernin van de Krol's zip-2.31 patch for showing this problem
2010-02-16 19:19:42 +00:00
Arun Thomas
b706112487 Incorporate bsdmake into buildsystem and reorganize libs 2010-02-16 14:41:33 +00:00
Kees van Reeuwijk
6686e9ae9f The function fabsf should return a float, not a double. 2010-02-15 14:25:33 +00:00
David van Moolenbroek
e306663455 fix the somehow newly introduced warnings 2010-02-14 18:39:47 +00:00
Erik van der Kouwe
ff835e0e35 use the verbose=2 boot monitor setting to get extensive output for debugging 2010-02-13 22:11:16 +00:00
Kees van Reeuwijk
df60646f98 Undo the use of #include <...> because it caused some errors. 2010-02-12 14:43:18 +00:00
Tomas Hruby
b5e7af96c9 top update
- it works with the new TSC based time accounting
2010-02-10 15:38:27 +00:00
Tomas Hruby
1b56fdb33c Time accounting based on TSC
- as thre are still KERNEL and IDLE entries, time accounting for
  kernel and idle time works the same as for any other process

- everytime we stop accounting for the currently running process,
  kernel or idle, we read the TSC counter and increment the p_cycles
  entry.

- the process cycles inherently include some of the kernel cycles as
  we can stop accounting for the process only after we save its
  context and we start accounting just before we restore its context

- this assumes that the system does not scale the CPU frequency which
  will be true for ... long time ;-)
2010-02-10 15:36:54 +00:00
Ben Gras
f08f2bd88c new free_contig() and changes to make drivers use it; so now we
have malloc/free, alloc_contig/free_contig and mmap/munmap nicely
paired up.

memory uses malloc/free instead of mmap/munmap as it doesn't have
to be contiguous for the ramdisks (and it might help if it doesn't!).
2010-02-10 13:56:26 +00:00
Tomas Hruby
49284caf2a Fixes broken orinoco compilation in r6119 2010-02-09 16:43:34 +00:00
Tomas Hruby
d845891a50 And of course, as much as I've tried to be careful I forgot to add this file in
r6116 :(
2010-02-09 15:36:29 +00:00
Tomas Hruby
c9da61022b intr_disabled() tests removed
- we don't need to test this in kernel as we always have interrupts
  disabled

- if interrupts are enabled in kernel, it is only at very carefully
  chosen places. There are no such places now.
2010-02-09 15:29:58 +00:00
Tomas Hruby
c6fec6866f No locking in kernel code
- No locking in RTS_(UN)SET macros

- No lock_notify()

- Removed unused lock_send()

- No lock/unlock macros anymore
2010-02-09 15:26:58 +00:00
Kees van Reeuwijk
064cb7583a Lots of small code cleanup: make symbols local, remove unused symbols,
fixed a typo, removed a now unused header file.
Use #include <..> for header files that represent libraries.
2010-02-09 15:23:38 +00:00
Tomas Hruby
391fd926ff TASK_PRIVILEGE and level0() removed
- there are no tasks running, we don't need TASK_PRIVILEGE priviledge anymore

- as there is no ring 1 anymore, there is no need for level0() to call sensitive
  code from ring 1 in ring 0

- 286 related macros removed as clean up
2010-02-09 15:23:31 +00:00
Tomas Hruby
ebba20a65d No CLOCK task
- no kernel tasks are runnable

- clock initialization moved to the end of main()

- the rest of the body of clock_task() is moved to bsp_timer_int_handler() as
  for now we are going to handle this on the bootstrap cpu. A change later is
  possible.
2010-02-09 15:22:43 +00:00
Tomas Hruby
728f0f0c49 Removal of the system task
* Userspace change to use the new kernel calls

	- _taskcall(SYSTASK...) changed to _kernel_call(...)

	- int 32 reused for the kernel calls

	- _do_kernel_call() to make the trap to kernel

	- kernel_call() to make the actuall kernel call from C using
	  _do_kernel_call()

	- unlike ipc call the kernel call always succeeds as kernel is
	  always available, however, kernel may return an error

* Kernel side implementation of kernel calls

	- the SYSTEm task does not run, only the proc table entry is
	  preserved

	- every data_copy(SYSTEM is no data_copy(KERNEL

	- "locking" is an empty operation now as everything runs in
	  kernel

	- sys_task() is replaced by kernel_call() which copies the
	  message into kernel, dispatches the call to its handler and
	  finishes by either copying the results back to userspace (if
	  need be) or by suspending the process because of VM

	- suspended processes are later made runnable once the memory
	  issue is resolved, picked up by the scheduler and only at
	  this time the call is resumed (in fact restarted) which does
	  not need to copy the message from userspace as the message
	  is already saved in the process structure.

	- no ned for the vmrestart queue, the scheduler will restart
	  the system calls

	- no special case in do_vmctl(), all requests remove the
	  RTS_VMREQUEST flag
2010-02-09 15:20:09 +00:00
Tomas Hruby
5e57818431 copy_msg_from_user() and copy_msg_to_user()
- copies a mesage from/to userspace without need of translating
  addresses

- the assumption is that the address space is installed, i.e. ldt and
  cr3 are loaded correctly

- if a pagefault or a general protection occurs while copying from
  userland to kernel (or vice versa) and error is returned which gives
  the caller a chance to respond in a proper way

- error happens _only_ because of a wrong user pointer if the function
  is used correctly

- if the prerequisites of the function do no hold, the function will
  most likely fail as the user address becomes random
2010-02-09 15:15:45 +00:00
Tomas Hruby
ad9ba944d1 Early address space switch
- switch_address_space() implements a switch of the user address space
  for the destination process

- this makes memory of this process easily accessible, e.g. a pointer
  valid in the userspace can be used with a little complexity to
  access the process's memory

- the switch does not happed only just before we return to userspace,
  however, it happens right after we know which process we are going
  to schedule. This happens before we start processing the misc flags
  of this process so its memory is available

- if the process becomes not runnable while processing the mics flags
  we pick a new process and we switch the address space again which
  introduces possibly a little bit more overhead, however, it is
  hopefully hidden by reducing the overheads when we actually access
  the memory
2010-02-09 15:13:52 +00:00
Tomas Hruby
b14a86ca5c Sys calls are called ipc calls now
- the syscalls are pretty much just ipc calls, however, sendrec() is
  used to implement system task (sys) calls

- sendrec() won't be used anymore for this, therefore ipc calls will
  become pure ipc calls
2010-02-09 15:13:07 +00:00
Tomas Hruby
8a03d497b8 System task initialization moved to main()
- the system task initialization code does not really need to be part
  of the system task process. An earlier initialization in kernel is
  cleaner as it does not only initialize the syscalls but also irq
  hooks etc.
2010-02-09 15:12:20 +00:00
David van Moolenbroek
bdd4f5857f Fixes for truncate system calls:
- VFS: check for negative sizes in all truncate calls
- VFS: update file size after truncating with fcntl(F_FREESP)
- VFS: move pos/len checks for F_FREESP with l_len!=0 from FS to VFS
- MFS: do not zero data block for small files when fully truncating
- MFS: do not write out freed indirect blocks after freeing space
- MFS: make truncate work correctly with differing zone/block sizes
- tests: add new test50 for truncate call family
2010-02-09 08:12:37 +00:00
David van Moolenbroek
f029b0e0b1 Kernel: fix sys_irqctl(IRQ_RMPOLICY) 2010-02-09 08:07:47 +00:00
David van Moolenbroek
448f4305e2 a.out.h typo (Bug#398, reported by 7shi) 2010-02-07 12:01:37 +00:00
Tomas Hruby
c5001b0a5f gas2ack fix
- fixed handling of segment overrides for instruction that may use two
  of them in the long format, e.g. movs
2010-02-05 13:53:10 +00:00
Erik van der Kouwe
d70e7ff3b6 Fixes in mkdep.1, suggested by Greg King 2010-02-05 13:07:08 +00:00
Ben Gras
157e82e76a philip's inet tcp fix. 2010-02-04 22:06:10 +00:00
Ben Gras
cb2ee95cf9 only check local benchmark dir if it exists 2010-02-04 18:15:10 +00:00
Ben Gras
4876a324ab also be able to run benchmarks from packages. 2010-02-04 17:52:38 +00:00
Arun Thomas
4b02d003db Import NetBSD's make 2010-02-04 16:52:54 +00:00
Tomas Hruby
8f82633fa2 Removed useless global variable sys_call_code
- we have to same information in the message (m_ptr) where needed
2010-02-03 18:17:01 +00:00
Ben Gras
15b0595013 makefile for benchmarks. 2010-02-03 16:49:15 +00:00
Ben Gras
d6598cc7cd fix for asmconv - stop translating after .sect .end. 2010-02-03 16:03:00 +00:00
Ben Gras
f28a0a5258 remove traces of benchmarks from test/. 2010-02-03 14:32:36 +00:00
Ben Gras
ffb97108c9 move benchmarks to their own dir. 2010-02-03 14:30:02 +00:00
Ben Gras
0985235ba0 forget difference between big and small commands - obsolete with vm. 2010-02-03 14:16:51 +00:00
Erik van der Kouwe
7c9fe576a8 Throw out getpack, replace printenv with a link to env 2010-02-03 13:51:26 +00:00
Ben Gras
35b471ad94 removal of unused vm<->vfs code. 2010-02-03 13:35:17 +00:00
Ben Gras
3bcfb76e45 small asmconv cleanups.
- put asmconv in /usr/bin so it can be invoked without absolute path
 - make it ignore .end in gnu output mode so that it can be invoked
   without '|| true' in the gnu lib makefiles and it doesn't produce the
   messy error message
2010-02-03 13:29:14 +00:00
David van Moolenbroek
c7f1b547cb Statistical profiling fixes:
- PM: get rid of umap warning
- sprofalyze.pl: update with recently added servers and drivers
- sprofalyze.pl: properly truncate process names for sample matching
2010-02-03 12:27:52 +00:00
Tomas Hruby
cca24d06d8 This patch removes the global variables who_p and who_e from the
kernel (sys task).  The main reason is that these would have to become
cpu local variables on SMP.  Once the system task is not a task but a
genuine part of the kernel there is even less reason to have these
extra variables as proc_ptr will already contain all neccessary
information. In addition converting who_e to the process pointer and
back again all the time will be avoided.

Although proc_ptr will contain all important information, accessing it
as a cpu local variable will be fairly expensive, hence the value
would be assigned to some on stack local variable. Therefore it is
better to add the 'caller' argument to the syscall handlers to pass
the value on stack anyway. It also clearly denotes on who's behalf is
the syscall being executed.

This patch also ANSIfies the syscall function headers.

Last but not least, it also fixes a potential bug in virtual_copy_f()
in case the check is disabled. So far the function in case of a
failure could possible reuse an old who_p in case this function had
not been called from the system task.

virtual_copy_f() takes the caller as a parameter too. In case the
checking is disabled, the caller must be NULL and non NULL if it is
enabled as we must be able to suspend the caller.
2010-02-03 09:04:48 +00:00
Erik van der Kouwe
144de8a7b3 Add smallbunzip2 to bzip2 man-page 2010-02-02 15:26:12 +00:00
Erik van der Kouwe
c107dbe1d0 Man-pages on mkdep, cdprobe, loadramdisk and newroot; thanks to Antoine Leca 2010-02-02 15:10:00 +00:00
Kees van Reeuwijk
2db33d5c8c Fix some incorrect testing of bit flags. 2010-02-02 12:24:35 +00:00
Erik van der Kouwe
310876dcec Kill processes which ignore signals thatshould not be ignored 2010-01-31 19:13:20 +00:00
Ben Gras
82ce09234b improve behaviour under VPC, fixes from nicolas tittley. 2010-01-31 18:29:51 +00:00
Kees van Reeuwijk
2fe20e5aaf Fix a complaint about a value return from a void function.
Propagate error codes a bit more.
Some code cleanup.
2010-01-29 14:14:22 +00:00
Kees van Reeuwijk
477b616fe8 Fixed a number of complaints about missing return statements.
Some cases were fixed by declaring the function void, others were fixed
by adding a return <value> statement, thereby avoiding potentially
incorrect behavior (usually in error handling).
Some enum correctness in boot.c.
2010-01-28 13:17:07 +00:00
David van Moolenbroek
564e2a4368 HGFS tweaks 2010-01-27 22:59:03 +00:00
Erik van der Kouwe
6959226707 Increase process table size 2010-01-27 18:37:12 +00:00
Ben Gras
a36a3766b0 ignore .svn dirs when making binary packages 2010-01-27 16:20:28 +00:00
Ben Gras
75a3d4ebde bump version number to 3.1.6, copyright year to 2010. 2010-01-27 16:19:50 +00:00
Kees van Reeuwijk
2ba237cd4e Fixed a number of uses of uninitialized variables by adding assertions
or other sanity checks, code reshuffling, or fixing broken behavior.
2010-01-27 10:23:58 +00:00
Kees van Reeuwijk
c6eb51d66a Rewrite some functions to ANSI style. 2010-01-27 10:19:13 +00:00
Tomas Hruby
e0f7043e04 No need to use memcpy to copy a message of 36 bytes. The overhead just
to call memcpy is half of the inline copy (using gcc -O)
2010-01-27 09:34:47 +00:00
Thomas Veerman
9a7cd8e254 Pipe vnodes are always mapped. 2010-01-27 09:30:39 +00:00
Erik van der Kouwe
d8b8e10ba4 Add notrunc conversion for dd tool 2010-01-27 07:48:06 +00:00
Erik van der Kouwe
3e583f4c04 Add -p flag for install tool 2010-01-27 07:47:29 +00:00
Kees van Reeuwijk
c8a11b5453 Fixed some type inconsistencies in the kernel. 2010-01-26 12:26:06 +00:00
Kees van Reeuwijk
b67f788eea Removed a number of useless #includes 2010-01-26 10:59:01 +00:00
Ben Gras
76f8132545 dec21140A ethernet driver for virtualpc, contributed by nicolas tittley. 2010-01-26 10:20:18 +00:00
David van Moolenbroek
f23a37e10f IPC test set fixes:
- restore original UID before deleting test directory
- do not assume that SIGUSR1 signal is set to default action
2010-01-26 08:05:33 +00:00
David van Moolenbroek
e42952c93f typo 2010-01-25 23:48:14 +00:00
David van Moolenbroek
1ff4a7dbc6 update DS label retrieve calls 2010-01-25 23:23:43 +00:00
David van Moolenbroek
71fe2852f4 HGFS - VMware Shared Folders file system server 2010-01-25 23:18:02 +00:00
David van Moolenbroek
4c2cb6c04f typo 2010-01-25 21:06:07 +00:00
Erik van der Kouwe
ff416204c5 Add dirname function, forgot to commit header before 2010-01-25 18:17:57 +00:00
Erik van der Kouwe
eeaecf1d9c Explicitly mark i8_t as signed 2010-01-25 18:17:04 +00:00
Erik van der Kouwe
f8804c0240 Additions to inttypes.h format strings 2010-01-25 18:16:25 +00:00
Erik van der Kouwe
58024f9eb0 Add character classes for tr 2010-01-25 18:14:54 +00:00
Erik van der Kouwe
6b869823ae Have test40 use /dev/ptypf instead of /dev/ptyp0 2010-01-25 18:14:05 +00:00
Kees van Reeuwijk
a701e290f7 Removed unused symbols.
Made some functions PRIVATE, including ones that aren't used anywhere.
2010-01-25 18:13:48 +00:00
Erik van der Kouwe
0e564a1419 Add IPv6-related header definitions 2010-01-25 18:13:23 +00:00
Erik van der Kouwe
3ec29ae85e Add dirname function 2010-01-25 18:12:28 +00:00
Erik van der Kouwe
a89d141e90 Add getopt_long library function 2010-01-25 18:11:21 +00:00
Ben Gras
515d6ebc9a correct opcode of FNSTSW (hopefully fixes minix under virtualpc) 2010-01-25 16:25:20 +00:00
Tomas Hruby
ee4cff8d66 2 copies of taskcall.c removed
- taskcall.c is 3x in the trunk as part of libc, libsysutil and
  libsys.  It should be only part of libsys.

- only system process should be linked with libsys, therefore using
  raw _taskcall() in service.c is replaced by _syscall()

- the same for minix_rs.c

- lib/other/sys_eniop.c can go without replacement as it is part of
  syslib
2010-01-25 14:22:09 +00:00
David van Moolenbroek
769e5f373a man mount(1): dash escaping consistency 2010-01-22 23:24:02 +00:00
Kees van Reeuwijk
a7cee5bec4 Removed unused symbols.
Minor cleanups.
2010-01-22 22:01:08 +00:00
Tomas Hruby
0cfbe936ce Removed bunch of unused variables in kernel/proc.c 2010-01-22 16:14:57 +00:00
Erik van der Kouwe
af395bab13 Fix number of tests 2010-01-22 11:32:39 +00:00
Erik van der Kouwe
a39cb73e58 IPv6 address family and protocol familyconstants 2010-01-22 10:45:43 +00:00
Erik van der Kouwe
4dfe5f49ba Make int64 constants available under GCC 2010-01-22 10:45:05 +00:00
Kees van Reeuwijk
c43cdf06f8 Removed some uses of uninitialized variables in update.c, presumably remnands of old color support.
Fixed a few cases where free-ed memory blocks were subsequently read.
Removed some unused variables, #includes, other small cleanup.
2010-01-21 22:36:15 +00:00
Ben Gras
6292b96ac8 New 'benchmarks' dir in test/, with first benchmark - unixbench-5.1.2, ported
by Karol Sobczak.
2010-01-21 16:53:42 +00:00
Thomas Veerman
ee2e57b4dc Add return statement after failed dev_open (fixes open count in at_wini) 2010-01-21 15:02:29 +00:00
Kees van Reeuwijk
f30c82b430 Restored idt_reload() prototype. 2010-01-21 11:40:22 +00:00
Erik van der Kouwe
0bc2aad4af Fix parameter parsing in cut 2010-01-21 10:16:05 +00:00
Erik van der Kouwe
9baf8059fb Make function key for RTL8139 optional 2010-01-21 10:15:22 +00:00
Thomas Veerman
fadbbf7b2e Unmount defunct boot ramdisk at bootup 2010-01-21 09:58:07 +00:00
Thomas Veerman
ca9280e097 - Fix dangling symlink regression
- Make open(2) more POSIX compliant
- Add a test case for dangling symlinks and open() syscall with O_CREAT and
  O_EXCL on a symlink.
- Update open(2) man page to reflect change.
2010-01-21 09:32:15 +00:00
Erik van der Kouwe
a5a2073680 create the getaddrinfo and getnameinfo library functions and friends 2010-01-21 06:38:17 +00:00
Kees van Reeuwijk
24964aa706 Removed unused variable ip_port from icmp_router_advertisment(). 2010-01-20 22:02:25 +00:00
Kees van Reeuwijk
a2c8ae42e9 Remove iov_src variables, that were only declared and incremented,
but never used, all over the network drivers.
2010-01-20 21:31:59 +00:00
Kees van Reeuwijk
53f9f943a8 Rewrote a number of cases where variables were used before they initialized. 2010-01-20 17:59:48 +00:00
Kees van Reeuwijk
d6383bef47 Removed some unused tests. 2010-01-20 17:55:14 +00:00
Kees van Reeuwijk
9a755c3a1f Removed unused code in the ethernet driver that was left from an old implementation
Removed/rewritten the use of uninitialized variables in error messages.
2010-01-20 17:02:55 +00:00
Erik van der Kouwe
850f392c86 Fix typo in ENOPSUP definition 2010-01-20 16:36:48 +00:00
David van Moolenbroek
53a6e039de remove SYS_MAPDMA 2010-01-19 21:24:42 +00:00
David van Moolenbroek
f175410902 rename message.m5_c[12] to m5_s[12] 2010-01-19 21:19:59 +00:00
David van Moolenbroek
cff75286df setgroups fix 2010-01-19 21:15:43 +00:00
David van Moolenbroek
61bb82a44b VM information interface 2010-01-19 21:00:20 +00:00
Tomas Hruby
7d51b0cce1 Fixed warnings in watchdog.c 2010-01-19 14:47:25 +00:00
Kees van Reeuwijk
3a892d2312 Fixed some flawed defensive programming in audio drivers. 2010-01-18 21:37:24 +00:00
Erik van der Kouwe
32ad26e698 Use _POSIX_SOURCE rather than _MINIX to protect popen, pclose and snprintf 2010-01-18 18:06:43 +00:00
Ben Gras
daca9de450 Fix to make making a bootable cd possible again.
ow that the image has grown beyond the 1.44M that fits on a floppy.
(previously, the floppy emulation mode was used for cd's.)

the boot cd now uses 'no emulation mode,' where an image is provided on
the cd that is loaded and executed directly. this is the boot monitor.

in order to make this work (the entry point is the same as where the
image is loaded, and the boot monitor needs its a.out header too) and
keep compatability with the same code being used for regular booting, i
prepended 16 bytes that jumps over its header so execution can start
there.

to be able to read the CD (mostly in order to read the boot image),
boot has to use the already present 'extended read' call, but address
the CD using 2k sectors.
2010-01-18 14:10:04 +00:00
Tomas Hruby
5efa92f754 NMI watchdog is an awesome feature for debugging locked up kernels.
There is not that much use for it on a single CPU, however, deadlock
between kernel and system task can be delected. Or a runaway loop.

If a kernel gets locked up the timer interrupts don't occure (as all
interrupts are disabled in kernel mode). The only chance is to
interrupt the kernel by a non-maskable interrupt.

This patch generates NMIs using performance counters. It uses the most
widely available performace counters. As the performance counters are 
highly model-specific this patch is not guaranteed to work on every
machine.  Unfortunately this is also true for KVM :-/ On the other
hand adding this feature for other models is not extremely difficult
and the framework makes it hopefully easy enough.

Depending on the frequency of the CPU an NMI is generated at most
about every 0.5s If the cpu's speed is less then 2Ghz it is generated
at most every 1s. In general an NMI is generated much less often as
the performance counter counts down only if the cpu is not idle.
Therefore the overhead of this feature is fairly minimal even if the
load is high.

Uppon detecting that the kernel is locked up the kernel dumps the 
state of the kernel registers and panics.

Local APIC must be enabled for the watchdog to work.

The code is _always_ compiled in, however, it is only enabled if  
watchdog=<non-zero> is set in the boot monitor.

One corner case is serial console debugging. As dumping a lot of stuff
to the serial link may take a lot of time, the watchdog does not 
detect lockups during this time!!! as it would result in too many
false positives. 10 nmi have to be handled before the lockup is
detected. This means something between ~5s to 10s.

Another corner case is that the watchdog is enabled only after the
paging is enabled as it would be pure madness to try to get it right.
2010-01-16 20:53:55 +00:00
David van Moolenbroek
a8b52644c4 Give SETALARM privilege to atl2 driver 2010-01-16 14:31:35 +00:00
Kees van Reeuwijk
4faed703d9 Added a missing return statement in paired_grant().
Removed lots of unused variables.
2010-01-15 21:45:30 +00:00
Ben Gras
716df202de make C function setgroups() be _setgroups(), called by the asm stub.
initgroups() can then use _setgroups() instead of setgroups().
2010-01-15 17:16:15 +00:00
Tomas Hruby
80d671aea7 _cpuid() - full cpuid instruction wrapper
- the prototype changes to 

	_cpuid(u32_t *eax, u32_t *ebx, u32_t *ecx, u32_t *edx)

- this makes possible to use all the features of the cpuid instruction as
  described in the Intel specs
2010-01-15 15:23:57 +00:00
Ben Gras
45eabea285 Fixed extern declaration from pointer to array 2010-01-15 12:08:57 +00:00
David van Moolenbroek
3537a7b59d Compile and install e1000 driver by default 2010-01-15 10:22:34 +00:00
Cristiano Giuffrida
c5b309ff07 Merge of Wu's GSOC 09 branch (src.20090525.r4372.wu)
Main changes:
- COW optimization for safecopy.
- safemap, a grant-based interface for sharing memory regions between processes.
- Integration with safemap and complete rework of DS, supporting new data types
  natively (labels, memory ranges, memory mapped ranges).
- For further information:
  http://wiki.minix3.org/en/SummerOfCode2009/MemoryGrants

Additional changes not included in the original Wu's branch:
- Fixed unhandled case in VM when using COW optimization for safecopy in case
  of a block that has already been shared as SMAP.
- Better interface and naming scheme for sys_saferevmap and ds_retrieve_map
  calls.
- Better input checking in syslib: check for page alignment when creating
  memory mapping grants.
- DS notifies subscribers when an entry is deleted.
- Documented the behavior of indirect grants in case of memory mapping.
- Test suite in /usr/src/test/safeperf|safecopy|safemap|ds/* reworked
  and extended.
- Minor fixes and general cleanup.
- TO-DO: Grant ids should be generated and managed the way endpoints are to make
sure grant slots are never misreused.
2010-01-14 15:24:16 +00:00
Kees van Reeuwijk
da3b64d8bc Fixed a bug in do_sdevio() that broke I/O size computations.
Removed redundant size computations.
Cleaned up code.
2010-01-14 14:51:23 +00:00
Kees van Reeuwijk
5459f3a607 Removed a whole herd of unused variables.
Some other cleanup.
2010-01-14 13:53:12 +00:00
Kees van Reeuwijk
9d247900c0 Remove obsolete m_ptr calculations in try_one() and mini_senda(). 2010-01-14 12:04:24 +00:00
Tomas Hruby
d96360e4d4 Uninitialized variable fix in VM to kernel protocol
- index must be initialized to 0 otherwise bad things happen like the mappings
  for local APIC are not correct after turning paging on.
2010-01-14 11:30:02 +00:00
Tomas Hruby
98563a4afa Killing Minix by typing Q on serial console
- if debugging on serial console is enabled typing Q kills the system. It is
  handy if the system gets locked up and the timer interrupts still work. Good
  for remote debugging.

- NOT_REACHABLE reintroduced and fixed. It should be used for marking code which
  is not reachable because the previous code _should_ not return. Such places
  are not always obvious
2010-01-14 09:46:16 +00:00
Tomas Hruby
8a2a4f97fc Fixed redundant typecast in lapic write/read macros 2010-01-13 18:23:58 +00:00
Tomas Hruby
42c13951a7 APIC disabled if CPU lacks TSC
- we cannot calibrate local APIC timer in such a case

- fixes possible uninitialized variable problem during calibration if no TSC
2010-01-13 18:22:41 +00:00
Thomas Veerman
cc86693102 - Make packman unmount the packages cd if it was mounted.
- Manpages for packman and packit.
2010-01-13 15:52:55 +00:00
Kees van Reeuwijk
ad4c0ff698 Fixed a bug in apic.c that broke lapic_stop_timer().
Fixed bugs in liveupdate.c that rendered load_state_info() meaningless.
More informative error message in do_config() in service.c.
2010-01-13 14:44:19 +00:00
David van Moolenbroek
6a5660a431 PCI: add 64-bit BAR support 2010-01-13 10:52:47 +00:00
David van Moolenbroek
b31119abf5 Mount updates:
- allow mounting with "none" block device
- allow unmounting by mountpoint
- make VFS aware of file system process labels
- allow m3_ca1 to use the full available message size
- use *printf in u/mount(1), as mount(2) uses it already
- fix reference leaks for some mount error cases in VFS
2010-01-12 23:08:50 +00:00
Erik van der Kouwe
483160f3d4 Add tests for sigsetjmp/siglongjmp 2010-01-12 09:53:39 +00:00
Tomas Hruby
a316221fbf Local apic is dissabled by default
to enable it set no_apic=0 in the boot monitor
2010-01-11 17:21:19 +00:00
Kees van Reeuwijk
f595416e7f Fixed some missing return statements. 2010-01-11 14:22:29 +00:00
Erik van der Kouwe
2baf34f801 Update years in man-pages (thanks to Antoine Leca for pointing this out) 2010-01-09 08:18:26 +00:00
Erik van der Kouwe
f025e5f06b Implementations of readv and writev 2010-01-08 13:40:34 +00:00
Erik van der Kouwe
aec561acc5 Add scalbn family of functions 2010-01-08 07:27:54 +00:00
Erik van der Kouwe
17b10f1bf3 Add fabsf function 2010-01-08 07:27:11 +00:00
Cristiano Giuffrida
d1fd04e72a Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.

SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic 
registration / deregistration of system services.

VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.

RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 01:20:42 +00:00
Erik van der Kouwe
acc3c30855 Prevent nanosleep from potentially overwriting sleep time
suggested by Rene Zatvo
2010-01-07 19:25:18 +00:00
Erik van der Kouwe
aac4b7923f Add ENOTSUP error code 2010-01-07 09:53:31 +00:00
Erik van der Kouwe
1a39ed880a Make get/setsockopt handle SOREUSEADDR 2010-01-07 09:53:08 +00:00
Erik van der Kouwe
413a8083b9 Allow test43 to deal with broken symlinks 2010-01-07 09:52:23 +00:00
Erik van der Kouwe
38ed5b2685 Fix brackets in kernel/arch/i386/include/archconst.h 2010-01-06 08:46:33 +00:00
Erik van der Kouwe
8d97f0253f Fix bracket with different color in netconf(8) man-page 2010-01-06 08:31:11 +00:00
Erik van der Kouwe
33afb396f8 Man-page for netconf(8), contributed by Leith Brandeland 2010-01-06 08:24:06 +00:00
Kees van Reeuwijk
d8f3af3672 Fixed a typing bug.
More explicit type conversion from virual to physical bytes.
Bracket negative #defines for extra paranoia.
Added a forgotten 'void' to a function.
2010-01-06 08:23:14 +00:00
Erik van der Kouwe
49ec221a92 Fix netconf alignment now that there is a number 10"
Note: should fix again when we reach 100 :)
2010-01-06 08:20:12 +00:00
Erik van der Kouwe
c554a39725 Move man-pages for zoneinfo, replace with links 2010-01-06 08:00:39 +00:00
Erik van der Kouwe
bbff2115d6 Oops, forgot to svn add this 2010-01-06 07:49:54 +00:00
Erik van der Kouwe
f9aac2c06b Move man-pages for bzip2, replace with links. 2010-01-06 07:45:45 +00:00
Erik van der Kouwe
a75c9fce4d Man-page for ping, contributed by Leith Brandeland 2010-01-06 07:36:12 +00:00
David van Moolenbroek
ac9ab099c8 General cleanup:
- clean up kernel section of minix/com.h somewhat
- remove ALLOCMEM and VM_ALLOCMEM calls
- remove non-safecopy and minix-vmd support from Inet
- remove SYS_VIRVCOPY and SYS_PHYSVCOPY calls
- remove obsolete segment encoding in SYS_SAFECOPY*
- remove DEVCTL call, svrctl(FSDEVUNMAP), map_driverX
- remove declarations of unimplemented svrctl requests
- remove everything related to swapping to disk
- remove floppysetup.sh
- remove traces of rescue device
- update DESCRIBE.sh with new devices
- some other small changes
2010-01-05 19:39:27 +00:00
David van Moolenbroek
be992434e7 VM: make munmap(2) round length up, not down (reported by Althaf K Backer) 2010-01-05 09:40:07 +00:00
David van Moolenbroek
0dcf5b7aa8 add ptrace(2) TO_NOEXEC flag 2010-01-05 09:30:28 +00:00
David van Moolenbroek
709ca777bd start a.out2com script with 'sh' (Bug#365.1, reported by Antoine Leca) 2010-01-05 09:21:55 +00:00
David van Moolenbroek
bac0e91705 typo (Bug#376, reported by Kees van Reeuwijk) 2010-01-04 12:29:51 +00:00
David van Moolenbroek
c473cfcdda more kernel header typos 2010-01-01 20:18:05 +00:00
Erik van der Kouwe
7bbe4aaaa6 Add man entry for new errno code 2009-12-31 12:09:31 +00:00
Erik van der Kouwe
c42de8045f Added EILSEQ, based on newsgroup post by Leith 2009-12-31 11:48:08 +00:00
David van Moolenbroek
1489f14b37 Driver for Attansic L2 FastEthernet (atl2) 2009-12-30 22:42:44 +00:00
Erik van der Kouwe
41f3075f99 Man-page name order fixes 2009-12-30 20:35:05 +00:00
Erik van der Kouwe
eeeadf65f5 Add timeout to test42 2009-12-30 20:22:21 +00:00
David van Moolenbroek
44e46860c7 Kernel: fix do_stime.c header comment (2) 2009-12-30 14:56:54 +00:00
David van Moolenbroek
010e23e504 Kernel: fix do_stime.c header comment 2009-12-30 14:56:35 +00:00
David van Moolenbroek
d3fc0eca1d mdb(1) fixes:
- allow core file offsets with high bit set
- repair and enable gcc-compiled binary support
- fix bug leading to random command execution
- remove obsolete ptrace.2 manpage
2009-12-29 21:38:26 +00:00
David van Moolenbroek
ac9a5829a2 suppress kernel/VM memory debugging information 2009-12-29 21:35:12 +00:00
David van Moolenbroek
0bafee3d78 unbreak, deprivilege dumpcore(1) 2009-12-29 21:34:06 +00:00
David van Moolenbroek
e423c86009 ptrace(2) modifications:
- add T_GETRANGE/T_SETRANGE to get/set ranges of values
- change EIO error code to EFAULT
- move common-I&D text-to-data translation to umap_local
2009-12-29 21:32:15 +00:00
David van Moolenbroek
8da928d2df unbreak "make dos" in boot (Bug#365, patch by Antoine Leca) 2009-12-24 23:49:23 +00:00
David van Moolenbroek
c8f8d69204 Fix MFS ftruncate crash (Bug#370, reported by Aki Goto) 2009-12-24 23:43:16 +00:00
Erik van der Kouwe
6dc5d42798 Floating point support functions 2009-12-24 20:22:41 +00:00
David van Moolenbroek
5e9a8f05ff unbreak building CDs 2009-12-23 23:59:32 +00:00
David van Moolenbroek
692dc020e1 Correct ping(1) usage string (Bug#372, reported by Leith Brandeland 2009-12-23 23:42:07 +00:00
Cristiano Giuffrida
f24f987b95 Move setuid() hack where it belongs. 2009-12-23 16:26:28 +00:00
Cristiano Giuffrida
6f912993ff Share exec images in RS.
RS CHANGES:
- RS retains information on both labels and process names now. Labels for boot
processes are configured in the boot image priv table. Process names are
inherited from the in-kernel boot image table.
- When RS_REUSE is specified in do_up, RS looks for an existing slot having the
same process name as the one we are about to start. If one is found with
an in-memory copy of its executable image, the image is then shared between
the two processes, rather than copying it again. This behavior can be specified
by using 'service -r' when starting a system service from the command line.
2009-12-23 14:05:20 +00:00
David van Moolenbroek
123683d4a5 Console function keys and color support:
- if "debug_fkeys" boot monitor variable is set to 0:
  - pass Fn, Shift+Fn, Ctrl+Fn, Shift+Ctrl+Fn to applications
  - don't start IS
- update termcap files with function key, color, end key support
2009-12-22 23:30:50 +00:00
David van Moolenbroek
d5471320d9 another warning regression fix 2009-12-22 00:05:09 +00:00
David van Moolenbroek
7a345b3528 no! no new warnings 2009-12-21 23:39:08 +00:00
David van Moolenbroek
92ae5c81ae Filter driver updates:
- optionally vectorize I/O requests to work around hardware bugs
- extend default buffer size to cover MFS's default maximum request size
- use mmap directly, rather than alloc_contig
- add 'nil' checksum type for comparison with layout
- minor style corrections
2009-12-21 23:30:01 +00:00
David van Moolenbroek
492d663444 TTY fixes:
- reenable code to restore screen/cursor at shutdown
- add proper signal checking logic
- lock to first console during shutdown
2009-12-21 23:19:01 +00:00
Cristiano Giuffrida
1f5841c8ed Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
  1. SEF Ping. The event occurs every time RS sends a ping to figure out
  whether a system process is still alive. The default callback implementation
  provided by SEF is to notify RS back to let it know the process is alive
  and kicking.
  2. SEF Live update. The event occurs every time RS sends a prepare to update
  message to let a system process know an update is available and to prepare
  for it. The live update support is very basic for now. SEF only deals with
  verifying if the prepare state can be supported by the process, dumping the
  state for debugging purposes, and providing an event-driven programming
  model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
  * PM notify messages primarily used at shutdown.
  * SYSTEM notify messages primarily used for signals.
  * CLOCK notify messages used for system alarms.
  * Debug messages. IS could still be in charge of fkey handling but would
  forward the debug message to the target process (e.g. PM, if the user
  requested debug information about PM). SEF would then catch the message and
  do nothing unless the process has registered an appropriate callback to
  deal with the event. This simplifies the programming model to print debug
  information, avoids duplicating code, and reduces the effort to print
  debug information.

SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.

RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
  * When an update command is issued (via "service update *"), RS notifies the
  target system process to prepare for a specific update state.
  * If the process doesn't respond back in time, the update is aborted.
  * When the process responds back, RS kills it and marks it for refreshing.
  * The process is then automatically restarted as for a buggy process and can
  start running again.
  * Live update is currently prototyped as a controlled failure.
2009-12-21 14:12:21 +00:00
Thomas Veerman
48ef79f78d Fix typo 2009-12-21 13:59:04 +00:00
David van Moolenbroek
d5dee93bee Support for larger disks.
- MFS, df(1), fsck(1), badblocks(8), de(1x) now compute the
  superblock's s_firstdatazone value if the on-disk value is zero
- mkfs(1) sets s_firstdatazone in the superblock to zero if the
  on-disk field is too small to store the actual value
- more agressive mkfs(1) inode number heuristic, copied from r5261
2009-12-21 11:20:30 +00:00
Thomas Veerman
6aa43dc9e4 Fix typo and a bug causing vnode references to become too low. 2009-12-21 09:36:34 +00:00
Thomas Veerman
bcecad33d5 Fix compilation errors caused by more files not added in previous commit 2009-12-20 21:31:03 +00:00
Thomas Veerman
951c5f6b73 Add PFS (missing in previous commit) 2009-12-20 20:41:50 +00:00
Thomas Veerman
958b25be50 - Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
  the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
  functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
  the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
  - Several path lookup bugs in MFS.
  - A link can be too big for the path buffer.
  - A mountpoint can become inaccessible when the creation of a new inode
    fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
  suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
  unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
  named pipes. However, named pipes still reside on the (M)FS, as they are part
  of the file system on disk. To make this work VFS now has a concept of
  'mapped' inodes, which causes read, write, truncate and stat requests to be
  redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 20:27:14 +00:00
Erik van der Kouwe
ac900e59ba Remove some GCC library warnings 2009-12-17 08:43:31 +00:00
Cristiano Giuffrida
e090013056 Drivers and servers are simply known as services.
/etc CHANGES:
- /etc/drivers.conf has been renamed to /etc/system.conf. Every entry in 
the file is now marked as "service" rather than driver.
- user "service" has been added to password file /etc/passwd.
- docs/UPDATING updated accordingly, as well as every other mention to the old
drivers.conf in the system.

RS CHANGES:
- No more distinction between servers and drivers.
- RS_START has been renamed to RS_UP and the old legacy RS_UP and RS_UP_COPY
dropped.
- RS asks PCI to set / remove ACL entries only for services whose ACL properties
have been set. This change eliminates unnecessary warnings.
- Temporarily minimize the risk of potential races at boot time or when starting
a new service. Upcoming changes will eliminate races completely.
- General cleanup.
2009-12-17 01:53:26 +00:00
Cristiano Giuffrida
b4d6d9db26 Fix bug in IPC deadlock detection code.
The old deadlock code was misplaced and unable to deal with asynchronous
IPC primitives (notify and senda) effectively. As an example, the following
sequence of messages allowed the deadlock detection code to
trigger a false positive:
1. A.notify(B)
2. A.receive(B)
3. B.receive(A)
1. B.notify(A)
The solution is to run the deadlock detection routine only when a process is
about to block in mini_send() or mini_receive().
2009-12-16 23:32:08 +00:00
David van Moolenbroek
d31ad285a0 typo 2009-12-16 12:17:02 +00:00
David van Moolenbroek
d1918e2e9f fix remaining warnings in 'make world' 2009-12-14 20:25:52 +00:00
David van Moolenbroek
14367afaf7 awk: check presence of parameters 2009-12-14 20:24:33 +00:00
David van Moolenbroek
307ad7b3b0 test42: disable attach-to-PM test 2009-12-13 21:45:23 +00:00
Cristiano Giuffrida
f4574783dc Rewrite of boot process
KERNEL CHANGES:
- The kernel only knows about privileges of kernel tasks and the root system
process (now RS).
- Kernel tasks and the root system process are the only processes that are made
schedulable by the kernel at startup. All the other processes in the boot image
don't get their privileges set at startup and are inhibited from running by the
RTS_NO_PRIV flag.
- Removed the assumption on the ordering of processes in the boot image table.
System processes can now appear in any order in the boot image table.
- Privilege ids can now be assigned both statically or dynamically. The kernel
assigns static privilege ids to kernel tasks and the root system process. Each
id is directly derived from the process number.
- User processes now all share the static privilege id of the root user
process (now INIT).
- sys_privctl split: we have more calls now to let RS set privileges for system
processes. SYS_PRIV_ALLOW / SYS_PRIV_DISALLOW are only used to flip the
RTS_NO_PRIV flag and allow / disallow a process from running. SYS_PRIV_SET_SYS /
SYS_PRIV_SET_USER are used to set privileges for a system / user process.
- boot image table flags split: PROC_FULLVM is the only flag that has been
moved out of the privilege flags and is still maintained in the boot image
table. All the other privilege flags are out of the kernel now.

RS CHANGES:
- RS is the only user-space process who gets to run right after in-kernel
startup.
- RS uses the boot image table from the kernel and three additional boot image
info table (priv table, sys table, dev table) to complete the initialization
of the system.
- RS checks that the entries in the priv table match the entries in the boot
image table to make sure that every process in the boot image gets schedulable.
- RS only uses static privilege ids to set privileges for system services in
the boot image.
- RS includes basic memory management support to allocate the boot image buffer
dynamically during initialization. The buffer shall contain the executable
image of all the system services we would like to restart after a crash.
- First step towards decoupling between resource provisioning and resource
requirements in RS: RS must know what resources it needs to restart a process
and what resources it has currently available. This is useful to tradeoff
reliability and resource consumption. When required resources are missing, the
process cannot be restarted. In that case, in the future, a system flag will
tell RS what to do. For example, if CORE_PROC is set, RS should trigger a
system-wide panic because the system can no longer function correctly without
a core system process.

PM CHANGES:
- The process tree built at initialization time is changed to have INIT as root
with pid 0, RS child of INIT and all the system services children of RS. This
is required to make RS in control of all the system services.
- PM no longer registers labels for system services in the boot image. This is
now part of RS's initialization process.
2009-12-11 00:08:19 +00:00
Erik van der Kouwe
af80fd2789 Adjust number of tests 2009-12-09 19:30:39 +00:00
Erik van der Kouwe
6adadade32 Implementation of strto(u)ll, documentation and tests for strto(u)l(l) 2009-12-09 19:01:38 +00:00
Erik van der Kouwe
fcaaad3317 Add Ben's test 44 2009-12-09 13:42:33 +00:00
Erik van der Kouwe
54c05bc2bd Use subdirectory t43 for tests 2009-12-09 07:59:08 +00:00
Erik van der Kouwe
c8e211ddfa Removed non-existant test 44 from Makefile 2009-12-09 07:52:17 +00:00
Ben Gras
8d800b3df7 Make VM fix up memory for kernel that crosses region boundaries
too.

Add a test to make this happen (triggers a vm panic before this commit).
2009-12-08 13:35:52 +00:00
Erik van der Kouwe
bd0933a19b Implementation of getrlimit and getdtablesize 2009-12-07 19:56:40 +00:00
Ben Gras
26ba254a4a Intel Pro/1000 driver written by Niek Linnenbank. 2009-12-07 18:33:41 +00:00
Ben Gras
f0db9bb328 - map in as much memory as is necessary in 4MB chunks to
let boot processes run with segments
 - allow segment-only processes to fork() by copying them
   and giving them an identity page table
2009-12-07 12:10:44 +00:00
Tomas Hruby
51065a1b47 Cooments to warn not to use certains instructions
- gas2ack cannot handle all variants of some instructions. Until this issues is
  addressed, this patch places a big warning where appropriate. This code is not
  supposed to change frequently.
2009-12-07 12:01:05 +00:00
Erik van der Kouwe
45a52f7acc Give test 43 root privileges to prevent errors when run as non-root 2009-12-04 18:58:57 +00:00
Erik van der Kouwe
91d13ae054 Fixed tests to use the right path when run as root 2009-12-04 17:51:06 +00:00
Erik van der Kouwe
09939b454e Fix line which was too long 2009-12-04 17:49:20 +00:00
Erik van der Kouwe
5427ab41c8 Add realpath function 2009-12-04 07:52:22 +00:00
Erik van der Kouwe
150dfbe96d Cleanup getsockopt and add SO_TYPE 2009-12-04 07:26:56 +00:00
Tomas Hruby
ec1fec6c3f A debug print with no meaning removed from VM. 2009-12-03 10:53:56 +00:00
David van Moolenbroek
fe982ca684 FPU: fix field names, compiler warning, long lines 2009-12-02 23:12:46 +00:00
Ben Gras
38fecc5de1 Part of the FPU changes; forgot to add these files in FPU commit. 2009-12-02 16:35:05 +00:00
Ben Gras
207621b6fb rtl8169 driver contributed by Jaswinder Singh Rajput. 2009-12-02 15:59:42 +00:00
Ben Gras
b9825f55e0 previous commit premature and not part of FPU changes. 2009-12-02 15:53:20 +00:00
Erik van der Kouwe
9a10c6c620 Specify types for integer MAX constants 2009-12-02 15:35:09 +00:00
Ben Gras
39484601e7 any blocksize. 2009-12-02 15:33:14 +00:00
Ben Gras
bd42705433 FPU context switching support by Evgeniy Ivanov. 2009-12-02 13:01:48 +00:00
David van Moolenbroek
fce9fd4b4e Add 'getidle' CPU utilization measurement infrastructure 2009-12-02 11:52:26 +00:00
David van Moolenbroek
be2087ecf9 Filter driver by Wu Bingzheng et al 2009-12-02 10:08:58 +00:00
David van Moolenbroek
f197bcb435 Allow servers to run with fewer privileges:
- allow non-root processes to get their own endpoint
- make alloc_contig() call sys_umap() only when requested
2009-12-02 10:06:58 +00:00
David van Moolenbroek
30a7fe5fa9 libdriver changes:
- remove obsolete non-safecopy support
- merge libdriver and libdriver_asyn
- change standard reply model from sendnb to senda
2009-12-02 09:57:48 +00:00
David van Moolenbroek
4924d1a9b5 RS changes:
- add new "control" config directive, to let drivers restart drivers
  (by Jorrit Herder)
- fix bug causing system processes to be started twice sometimes
2009-12-02 09:54:50 +00:00
Ben Gras
7c0cdc61bc fix for race condition - IRQ can happen between clearing the endpoint
of the handling process and before removing the hook. The handler function
will panic then.
2009-12-01 16:46:27 +00:00
David van Moolenbroek
ad259e92af Alternative VirtualBox/Lance driver workaround 2009-11-28 13:28:55 +00:00
David van Moolenbroek
fe7b2f1652 RS fixes:
- fix resource leak (PCI ACLs) when child fails right after exec
- fix resource leak (memory) when child exec fails at all
- fix race condition setting VM call privileges for new child
- make dev_execve() return a proper result, and check this result
- remove RS_EXECFAILED, as it should behave exactly like RS_EXITING
- add more clarifying comments about starting servers
2009-11-28 13:23:45 +00:00
David van Moolenbroek
45123f83d3 PM: remove 'boottime' global variable 2009-11-28 13:22:01 +00:00
David van Moolenbroek
6da61b8f05 fix _NSIG usage 2009-11-28 13:20:50 +00:00
David van Moolenbroek
c6cce1823d Portability: POSIXize some of inet's error codes 2009-11-28 13:18:33 +00:00
David van Moolenbroek
709a739b52 Kernel: unbreak load averages 2009-11-28 13:16:03 +00:00
David van Moolenbroek
6c6e1db676 Kernel: fix faulty trap check 2009-11-28 13:15:07 +00:00
David van Moolenbroek
e06e85b511 Portability: include sys/select.h from sys/time.h 2009-11-22 20:11:06 +00:00
David van Moolenbroek
bdb85248d4 VM: don't send arbitrary status values to kernel 2009-11-22 13:06:18 +00:00
David van Moolenbroek
4d4cb8fa24 Support for read/write on connected UDP sockets 2009-11-19 23:45:46 +00:00
David van Moolenbroek
3926b70b22 Remove dead mini_ds_retrieve_u32 code 2009-11-17 14:10:09 +00:00
Erik van der Kouwe
c85bd7edb9 Patch by Jaswinder Singh Rajput to fix FTP progress display 2009-11-17 08:41:43 +00:00
Tomas Hruby
8a44a44cb9 Local APIC
- local APIC timer used as the source of time

- PIC is still used as the hw interrupt controller as we don't have
  enough info without ACPI or MPS to set up IO APICs

- remapping of APIC when switching paging on, uses the new mechanism
  to tell VM what phys areas to map in kernel's virtual space

- one more step to SMP

based on code by Arun C.
2009-11-16 21:41:44 +00:00
Tomas Hruby
6515c93ecf New instructions in gas2ack
pause
mfence
rdtsc
rdpmc
2009-11-16 21:32:48 +00:00
David van Moolenbroek
2dc9e354f7 ugly double blank line, my fault 2009-11-16 18:22:28 +00:00
Tomas Hruby
9e62bd5241 .align replaced by .balign in mpx386.S 2009-11-13 09:30:45 +00:00
Tomas Hruby
21a5917f3e gas2ack does not understand .align
- as .align is target dependent we for usage of .balign for byte alignment
2009-11-13 09:29:37 +00:00
Tomas Hruby
d653cb457f gas2ack support for rdmsr and wrmsr 2009-11-12 16:19:01 +00:00
Tomas Hruby
cb9faaebfd No need for a special idle queue
- as the idle task is never placed on any run queue, we don't need any special
  idle queue.

- one more queue available for user processes
2009-11-12 08:47:25 +00:00
Tomas Hruby
ad4dcaab71 Idle task never runs
- idle task becomes a pseudo task which is never scheduled. It is never put on
  any run queue and never enters userspace. An entry for this task still remains
  in the process table for time accounting

- Instead of panicing if there is not process to schedule, pick_proc() returns
  NULL which is a signal to put the cpu in an idle state and set everything in
  such a way that after receiving and interrupt it looks like idle task was
  preempted

- idle task is set non-preemptible to avoid handling in the timer interrupt code
  which make userspace scheduling simpler as idle task does not need to be
  handled as a special case.
2009-11-12 08:42:18 +00:00
Tomas Hruby
37a7e1b76b Use of isemptyp() macro instead of testing RTS_SLOT_FREE flag
- some code used to test if only this flag is set, some if also this flag is
  set. This change unifies the test
2009-11-12 08:35:26 +00:00
Tomas Hruby
f98bea8f67 The rest of the r5641 commit 2009-11-11 17:02:45 +00:00
Tomas Hruby
04db2d7184 enable printing of 64-bit ints with gcc. 2009-11-11 12:15:08 +00:00
Tomas Hruby
b3b0a18403 allow kernel to tell VM extra physical addresses it wants mapped in.
used in the future for mapping in local APIC memory.
2009-11-11 12:07:06 +00:00
Tomas Hruby
9ba3b53de8 kernel/proc.h can be included in kernel assembky files
- the gnu .S are compiled with __ASSEMBLY__ macro set which allows us to
  conditionaly remove C stuff from the proc.h file when included in assembly
  files
2009-11-10 09:14:50 +00:00
Tomas Hruby
a972f4bacc All macros defining rts flags are prefixed with RTS_
- macros used with RTS_SET group of macros to define struct proc p_rts_flags are
  now prefixed with RTS_ to make things clear
2009-11-10 09:11:13 +00:00
Tomas Hruby
daf7940c69 pick_proc() called only just before returning to userspace
- new proc_is_runnable() macro to test whether process is runnable. All tests
  whether p_rts_flags == 0 converted to use this macro

- pick_proc() calls removed from enqueue() and dequeue()

- removed the test for recursive calls from pick_proc() as it certainly cannot
  be called recursively now

- PREEMPTED flag to mark processes that were preempted by enqueueuing a higher
  priority process in enqueue()

- enqueue_head() to enqueue PREEMPTED processes again at the head of their
  current priority queue

- NO_QUANTUM flag to block and dequeue processes preempted by timer tick with
  exceeded quantum. They need to be enqueued again in schedcheck()

- next_ptr global variable removed
2009-11-09 17:48:31 +00:00
David van Moolenbroek
86cc12b9a3 pci: extend NR_DRIVERS to cover all system processes 2009-11-09 10:43:46 +00:00
Tomas Hruby
ae75f9d4e5 Removal of the executable flag from files that cannot be executed
- 755 -> 644
2009-11-09 10:26:00 +00:00
David van Moolenbroek
c539fea347 activate new ptrace test, too 2009-11-09 09:26:09 +00:00
David van Moolenbroek
a07f8d7646 Fix ptrace bug when reattaching to a detached process 2009-11-09 08:12:25 +00:00
Tomas Hruby
ebbce7507b Complete ovehaul of mode switching code
- after a trap to kernel, the code automatically switches to kernel
  stack, in the future local to the CPU

- k_reenter variable replaced by a test whether the CS is kernel cs or
  not. The information is passed further if needed. Removes a global
  variable which would need to be cpu local

- no need for global variables describing the exception or trap
  context. This information is kept on stack and a pointer to this
  structure is passed to the C code as a single structure

- removed loadedcr3 variable and its use replaced by reading the %cr3
  register

- no need to redisable interrupts in restart() as they are already
  disabled.

- unified handling of traps that push and don't push errorcode

- removed save() function as the process context is not saved directly
  to process table but saved as required by the trap code. Essentially
  it means that save() code is inlined everywhere not only in the
  exception handling routine

- returning from syscall is more arch independent - it sets the retger
  in C

- top of the x86 stack contains the current CPU id and pointer to the
  currently scheduled process (the one right interrupted) so the mode
  switch code can find where to save the context without need to use
  proc_ptr which will be cpu local in the future and therefore
  difficult to access in assembler and expensive to access in general

- some more clean up of level0 code. No need to read-back the argument
  passed in
  %eax from the proc structure. The mode switch code does not clobber
  %the general registers and hence we can just call what is in %eax

- many assebly macros in sconst.h as they will be reused by the apic
  assembly
2009-11-06 09:08:26 +00:00
Tomas Hruby
f2a1f21a39 Clock task split
- preemption handled in the clock timer interrupt handler, not in the clock task

- more achitecture independent clock timer handling code

- smp ready as each CPU can have its own timer
2009-11-06 09:04:15 +00:00
Tomas Hruby
6eebc03f88 Fix for broken parsing of memory environment string in pci driver
- unfixed parsing could run away from the the string and fail on a correct
  string in complete_bars()

- it reanables the body of complete_bars()
2009-11-06 08:58:05 +00:00
Tomas Hruby
d2c10fb85e inodes - using types with known size
- fixes a problem in inodes truct definitions. The original definitions use
  posix types. These types don't have well defined size. Therefore when
  compiling mkfs on a different system natively the inodes sizes do not match.
  This patch replaces the posix types with interger types of the same size and
  signedness as the original types in use.
2009-11-06 08:55:07 +00:00
Tomas Hruby
0b8e20c89e Changes to the include files in order to make cross-compilation possible.
- The primary reason is that mkfs and installboot need to run natively during
  the cross compilation (host and target versions are compiled). There is a
  collision of include files though. E.g. a.out.h is very minix-specific.
  Therefore some files we moved and replaced by stubs that include the original
  file if compiling on or for Minix :
  
  include/a.out.h -> include/minix/a.out.h
  include/sys/dir.h -> include/minix/dir.h
  include/dirent.h -> include/minix/dirent.h
  include/sys/types.h -> include/minix/types.h

- This does not break any native compilation on Minix. Other headers that were
  including the original files are changed according to include directly the
  new, minix specific location not to pick up the host system includes while
  cross-compiling.

- role of this patch is to make rebasing of the build branch simpler until the
  new build system is merged
2009-11-06 08:46:22 +00:00
Tomas Hruby
616d936638 vmassert reports also the source file in which it was triggered 2009-11-04 15:30:08 +00:00
Tomas Hruby
cf854041ce Hardware interrupts code path cleanup
- the PIC master and slave irq handlers don't pass the irq hook pointer but just
  the irq number. It gives a little bit more information to the C handler as the
  irq number is not lost

- the irq code path is more achitecture independent. i386 hw interrupts are
  called irq and whereever the code is arch independent enough hw_intr_
  functions are called to mask/unmask interrupts

- the legacy PIC is not the only possible interrupt controller in the x86 world,
  therefore the intr_(un)mask functions were renamed to signal their
  functionality explicitly. APIC will add their own.

- masking and unmasking PIC interrupt lines is removed from assembler and all
  the functionality is rewriten in C and moved to i8259.c

- interrupt handlers have to unmask the interrupt line if all irq handlers are
  done. Assembler does not do it anymore
2009-11-04 13:24:56 +00:00
Ben Gras
7e73260cf5 - enable remembering of device memory ranges set by PCI and
told to kernel
  - makes VM ask the kernel if a certain process is allowed
    to map in a range of physical memory (VM rounds it to page
    boundaries afterwards - but it's impossible to map anything
    smaller otherwise so I assume this is safe, i.e. there won't
    be anything else in that page; certainly no regular memory)
  - VM permission check cleanup (no more hardcoded calls, less
    hardcoded logic, more readable main loop), a loose end left
    by GQ
  - remove do_copy warning, as the ipc server triggers this but
    it's no more harmful than the special cases already excluded
    explicitly (VFS, PM, etc).
2009-11-03 11:12:23 +00:00
David van Moolenbroek
56d485c1d6 Various small IS, TTY, isofs fixes
IS:
- do not use p_getfrom_e for a process that is sending
- register with TTY only function keys that are used
- various header and formatting fixes
- proper shutdown code

TTY:
- restore proper Ctrl+F1 dump contents

isofs:
- don't even try to call sys_exit()
2009-11-02 23:04:52 +00:00
David van Moolenbroek
f814fe41be Kernel: add support for indirect grants 2009-11-02 22:30:37 +00:00
David van Moolenbroek
769bed22c8 ash: only execute regular files 2009-11-01 22:25:54 +00:00
David van Moolenbroek
f89388c241 Kernel, servers: remove unused proto.h definitions 2009-10-31 14:11:50 +00:00
David van Moolenbroek
4c263d6002 PM: clean up endpoint info API/ABI 2009-10-31 14:09:28 +00:00
Tomas Hruby
403764c538 Conversion of kernel assembly from ACK to GNU
- .s files removed and replaced by .S as the .S is a standard extension for assembly that needs preprocessing
2009-10-30 16:00:44 +00:00
Tomas Hruby
41d481b065 gas2ack
- an asmconv based tool for conversion from GNU ia32 assembly to ACK assembly
    
    - in contrast to asmconv it is a one way tool only
    
    - as the GNU assembly in Minix does not prefix global C symbols with _ gas2ack
      detects such symbols and prefixes them to be compliant with the ACK convention
    
    - gas2ack preserves comments and unexpanded macros
    
    - bunch of fixes to the asmconv GNU->ACK direction
    
    - support of more instructions that ACK does not know but are in use in Minix
    
    - it is meant as a temporary solution as long as ACK will be a supported
      compiler for the core system
2009-10-30 15:57:35 +00:00
10451 changed files with 1348999 additions and 335827 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__*

10
LICENSE Executable file → Normal file
View File

@@ -50,3 +50,13 @@ observe the conditions of the GPL with respect to this software. As
clearly stated in Article 2 of the GPL, when GPL and nonGPL software are
distributed together on the same medium, this aggregation does not cause
the license of either part to apply to the other part.
Acknowledgements
This product includes software developed by the University of
California, Berkeley and its contributors.
This product includes software developed by Softweyr LLC, the
University of California, Berkeley, and its contributors.

129
Makefile Executable file → Normal file
View File

@@ -1,6 +1,8 @@
# Master Makefile to compile everything in /usr/src except the system.
MAKE = exec make -$(MAKEFLAGS)
.include <bsd.own.mk>
MAKE=make
usage:
@echo ""
@@ -8,13 +10,13 @@ usage:
@echo "Root privileges are required for some actions."
@echo ""
@echo "Usage:"
@echo " make world # Compile everything (libraries & commands)"
@echo " make includes # Install include files from src/"
@echo " make libraries # Compile and install libraries"
@echo " make cmds # Compile all, commands, but don't install"
@echo " make install # Compile and install commands"
@echo " make depend # Generate required .depend files"
@echo " make clean # Remove all compiler results"
@echo " make world # Compile everything (libraries & commands)"
@echo " make includes # Install include files from src/"
@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 gnu-includes # Install include files for GCC"
@echo " make clean # Remove all compiler results"
@echo ""
@echo "Run 'make' in tools/ to create a new MINIX configuration."
@echo ""
@@ -27,45 +29,96 @@ usage:
# 'make install' target.
#
# etcfiles has to be done first.
world: includes depend libraries cmds install postinstall
world: mkfiles etcfiles includes libraries dep-all install etcforce
mkfiles:
make -C share/mk install
includes:
cd include && $(MAKE) install gcc
$(MAKE) -C include includes
$(MAKE) -C lib includes NBSD_LIBC=yes
libraries:
cd lib && $(MAKE) all install
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
cmds:
if [ -f commands/Makefile ] ; then cd commands && $(MAKE) all; fi
libraries: includes
$(MAKE) -C lib dependall install
install::
if [ -f commands/Makefile ] ; then cd commands && $(MAKE) install; fi
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::
mkdep kernel
mkdep servers
mkdep drivers
cd kernel && $(MAKE) $@
cd servers && $(MAKE) $@
cd drivers && $(MAKE) $@
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:
$(MAKE) -C etc install
clean::
cd lib && $(MAKE) $@
test ! -f commands/Makefile || { cd commands && $(MAKE) $@; }
etcforce:
$(MAKE) -C etc installforce
etcfiles::
cd etc && $(MAKE) install
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
clean::
cd test && $(MAKE) $@
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
all install clean::
cd boot && $(MAKE) $@
cd man && $(MAKE) $@ # First manpages, then commands
test ! -f commands/Makefile || { cd commands && $(MAKE) $@; }
cd tools && $(MAKE) $@
cd servers && $(MAKE) $@
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
$(MAKE) -C test clean
postinstall:
cd etc && $(MAKE) $@
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

7
benchmarks/Makefile Normal file
View File

@@ -0,0 +1,7 @@
# Makefile for the benchmarks.
all::
chmod 755 run
all clean::
for b in *bench*; do cd $$b && $(MAKE) $@; done

51
benchmarks/run Normal file
View File

@@ -0,0 +1,51 @@
#!/bin/sh
set -e
make
BENCHDIR=/usr/local/benchmarks
basebenchmarks=`echo *bench*`
if [ -d $BENCHDIR ]
then packagebenchmarks=`(cd $BENCHDIR && echo *bench*)`
fi
runbench() {
bench=$1
out="Results/$bench.`date +%Y%m%d.%H%M%S`"
if [ -d $bench ]
then dir=$bench
fi
if [ -d $BENCHDIR/$bench ]
then dir=$BENCHDIR/$bench
fi
clear
echo "Running $dir."
echo "Saving output to $out."
echo ""
( cd $dir && sh run.sh 2>&1 ) | tee $out
}
clear
n=1
for b in $basebenchmarks $packagebenchmarks
do echo "$n. $b"
eval "n$n=$b"
n=`expr $n + 1`
done
echo
echo -n "Run which benchmark or 'all'? "
read bench
eval var=\$n$bench
if [ "$bench" = all ]
then for b in $basebenchmarks $packagebenchmarks
do runbench $b
done
else if [ -d "$var" -o -d "$BENCHDIR/$var" ]
then runbench $var
else echo "Unknown benchmark $var."
exit 1
fi
fi

View File

@@ -0,0 +1,246 @@
##############################################################################
# UnixBench v5.1.1
# Based on The BYTE UNIX Benchmarks - Release 3
# Module: Makefile SID: 3.9 5/15/91 19:30:15
#
##############################################################################
# Bug reports, patches, comments, suggestions should be sent to:
# David C Niemi <niemi@tux.org>
#
# Original Contacts at Byte Magazine:
# Ben Smith or Tom Yager at BYTE Magazine
# bensmith@bytepb.byte.com tyager@bytepb.byte.com
#
##############################################################################
# Modification Log: 7/28/89 cleaned out workload files
# 4/17/90 added routines for installing from shar mess
# 7/23/90 added compile for dhrystone version 2.1
# (this is not part of Run file. still use old)
# removed HZ from everything but dhry.
# HZ is read from the environment, if not
# there, you must define it in this file
# 10/30/90 moved new dhrystone into standard set
# new pgms (dhry included) run for a specified
# time rather than specified number of loops
# 4/5/91 cleaned out files not needed for
# release 3 -- added release 3 files -ben
# 10/22/97 added compiler options for strict ANSI C
# checking for gcc and DEC's cc on
# Digital Unix 4.x (kahn@zk3.dec.com)
# 09/26/07 changes for UnixBench 5.0
# 09/30/07 adding ubgears, GRAPHIC_TESTS switch
# 10/14/07 adding large.txt
##############################################################################
##############################################################################
# CONFIGURATION
##############################################################################
SHELL = /bin/sh
# GRAPHICS TESTS: Uncomment the definition of "GRAPHIC_TESTS" to enable
# the building of the graphics benchmarks. This will require the
# X11 libraries on your system.
#
# Comment the line out to disable these tests.
# GRAPHIC_TESTS = defined
# Set "GL_LIBS" to the libraries needed to link a GL program.
GL_LIBS = -lGL -lXext -lX11
# OPTIMISATION SETTINGS:
## Very generic
OPTON = -O
## For Linux 486/Pentium, GCC 2.7.x and 2.8.x
#OPTON = -O2 -fomit-frame-pointer -fforce-addr -fforce-mem -ffast-math \
# -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2
## For Linux, GCC previous to 2.7.0
#OPTON = -O2 -fomit-frame-pointer -fforce-addr -fforce-mem -ffast-math -m486
#OPTON = -O2 -fomit-frame-pointer -fforce-addr -fforce-mem -ffast-math \
# -m386 -malign-loops=1 -malign-jumps=1 -malign-functions=1
## For Solaris 2, or general-purpose GCC 2.7.x
#OPTON = -O2 -fomit-frame-pointer -fforce-addr -ffast-math -Wall
## For Digital Unix v4.x, with DEC cc v5.x
#OPTON = -O4
#CFLAGS = -DTIME -std1 -verbose -w0
## generic gcc CFLAGS. -DTIME must be included.
CFLAGS += $(CPPFLAGS) -DTIME -DMINIX=1 -D_MINIX=1 -D_POSIX_SOURCE=1
##############################################################################
# END CONFIGURATION
##############################################################################
# local directories
PROGDIR = ./pgms
SRCDIR = ./src
TESTDIR = ./testdir
RESULTDIR = ./results
TMPDIR = ./tmp
# other directories
INCLDIR = /usr/include
LIBDIR = /lib
SCRIPTS = unixbench.logo multi.sh tst.sh index.base
SOURCES = arith.c big.c context1.c \
dummy.c execl.c \
fstime.c hanoi.c \
pipe.c spawn.c \
syscall.c looper.c timeit.c time-polling.c \
dhry_1.c dhry_2.c dhry.h whets.c ubgears.c
TESTS = sort.src cctest.c dc.dat large.txt
# ifdef GRAPHIC_TESTS
# GRAPHIC_BINS = $(PROGDIR)/ubgears
# else
GRAPHIC_BINS =
# endif
# Program binaries.
BINS = $(PROGDIR)/arithoh $(PROGDIR)/register $(PROGDIR)/short \
$(PROGDIR)/int $(PROGDIR)/long $(PROGDIR)/float $(PROGDIR)/double \
$(PROGDIR)/hanoi $(PROGDIR)/syscall $(PROGDIR)/context1 \
$(PROGDIR)/pipe $(PROGDIR)/spawn $(PROGDIR)/execl \
$(PROGDIR)/dhry2 $(PROGDIR)/dhry2reg $(PROGDIR)/looper \
$(PROGDIR)/fstime $(PROGDIR)/whetstone-double $(GRAPHIC_BINS)
## These compile only on some platforms...
# $(PROGDIR)/poll $(PROGDIR)/poll2 $(PROGDIR)/select
# Required non-binary files.
REQD = $(BINS) $(PROGDIR)/unixbench.logo \
$(PROGDIR)/multi.sh $(PROGDIR)/tst.sh $(PROGDIR)/index.base \
$(PROGDIR)/gfx-x11 \
$(TESTDIR)/sort.src $(TESTDIR)/cctest.c $(TESTDIR)/dc.dat \
$(TESTDIR)/large.txt
# ######################### the big ALL ############################
all: distr programs
## Ick!!! What is this about??? How about let's not chmod everything bogusly.
# @chmod 744 * $(SRCDIR)/* $(PROGDIR)/* $(TESTDIR)/* $(DOCDIR)/*
# ####################### a check for Run ######################
check: $(REQD)
make all
# ##############################################################
# distribute the files out to subdirectories if they are in this one
distr:
@echo "Checking distribution of files"
# scripts
@if test ! -d $(PROGDIR) \
; then \
mkdir $(PROGDIR) \
; mv $(SCRIPTS) $(PROGDIR) \
; else \
echo "$(PROGDIR) exists" \
; fi
# C sources
@if test ! -d $(SRCDIR) \
; then \
mkdir $(SRCDIR) \
; mv $(SOURCES) $(SRCDIR) \
; else \
echo "$(SRCDIR) exists" \
; fi
# test data
@if test ! -d $(TESTDIR) \
; then \
mkdir $(TESTDIR) \
; mv $(TESTS) $(TESTDIR) \
; else \
echo "$(TESTDIR) exists" \
; fi
# temporary work directory
@if test ! -d $(TMPDIR) \
; then \
mkdir $(TMPDIR) \
; else \
echo "$(TMPDIR) exists" \
; fi
# directory for results
@if test ! -d $(RESULTDIR) \
; then \
mkdir $(RESULTDIR) \
; else \
echo "$(RESULTDIR) exists" \
; fi
programs: $(BINS)
# Individual programs
$(PROGDIR)/arithoh: $(SRCDIR)/arith.c
$(CC) -o $(PROGDIR)/arithoh ${CFLAGS} ${OPTON} -Darithoh $(SRCDIR)/arith.c
$(PROGDIR)/register: $(SRCDIR)/arith.c
$(CC) -o $(PROGDIR)/register ${CFLAGS} ${OPTON} -Ddatum='register int' $(SRCDIR)/arith.c
$(PROGDIR)/short: $(SRCDIR)/arith.c
$(CC) -o $(PROGDIR)/short ${CFLAGS} ${OPTON} -Ddatum=short $(SRCDIR)/arith.c
$(PROGDIR)/int: $(SRCDIR)/arith.c
$(CC) -o $(PROGDIR)/int ${CFLAGS} ${OPTON} -Ddatum=int $(SRCDIR)/arith.c
$(PROGDIR)/long: $(SRCDIR)/arith.c
$(CC) -o $(PROGDIR)/long ${CFLAGS} ${OPTON} -Ddatum=long $(SRCDIR)/arith.c
$(PROGDIR)/float: $(SRCDIR)/arith.c
$(CC) -o $(PROGDIR)/float ${CFLAGS} ${OPTON} -Ddatum=float $(SRCDIR)/arith.c
$(PROGDIR)/double: $(SRCDIR)/arith.c
$(CC) -o $(PROGDIR)/double ${CFLAGS} ${OPTON} -Ddatum=double $(SRCDIR)/arith.c
$(PROGDIR)/whetstone-double: $(SRCDIR)/whets.c
$(CC) -o $(PROGDIR)/whetstone-double ${CFLAGS} ${OPTON} -DDP -DUNIX -DUNIXBENCH $(SRCDIR)/whets.c -lm
$(PROGDIR)/hanoi: $(SRCDIR)/hanoi.c
$(CC) -o $(PROGDIR)/hanoi ${CFLAGS} ${OPTON} $(SRCDIR)/hanoi.c
$(PROGDIR)/poll: $(SRCDIR)/time-polling.c
$(CC) -DHAS_POLL -DUNIXBENCH -o $(PROGDIR)/poll ${CFLAGS} ${OPTON} $(SRCDIR)/time-polling.c
$(PROGDIR)/poll2: $(SRCDIR)/time-polling.c
$(CC) -DHAS_POLL2 -DUNIXBENCH -o $(PROGDIR)/poll2 ${CFLAGS} ${OPTON} $(SRCDIR)/time-polling.c
$(PROGDIR)/select: $(SRCDIR)/time-polling.c
$(CC) -DHAS_SELECT -DUNIXBENCH -o $(PROGDIR)/select ${CFLAGS} ${OPTON} $(SRCDIR)/time-polling.c
$(PROGDIR)/fstime: $(SRCDIR)/fstime.c
$(CC) -o $(PROGDIR)/fstime ${CFLAGS} ${OPTON} $(SRCDIR)/fstime.c
$(PROGDIR)/syscall: $(SRCDIR)/syscall.c
$(CC) -o $(PROGDIR)/syscall ${CFLAGS} ${OPTON} $(SRCDIR)/syscall.c
$(PROGDIR)/context1: $(SRCDIR)/context1.c
$(CC) -o $(PROGDIR)/context1 ${CFLAGS} ${OPTON} $(SRCDIR)/context1.c
$(PROGDIR)/pipe: $(SRCDIR)/pipe.c
$(CC) -o $(PROGDIR)/pipe ${CFLAGS} ${OPTON} $(SRCDIR)/pipe.c
$(PROGDIR)/spawn: $(SRCDIR)/spawn.c
$(CC) -o $(PROGDIR)/spawn ${CFLAGS} ${OPTON} $(SRCDIR)/spawn.c
$(PROGDIR)/execl: $(SRCDIR)/execl.c $(SRCDIR)/big.c
$(CC) -o $(PROGDIR)/execl ${CFLAGS} ${OPTON} $(SRCDIR)/execl.c
$(PROGDIR)/dhry2: $(SRCDIR)/dhry_1.c $(SRCDIR)/dhry_2.c $(SRCDIR)/dhry.h
cd $(SRCDIR); $(CC) -c ${CFLAGS} -DHZ=${HZ} ${OPTON} dhry_1.c
cd $(SRCDIR); $(CC) -c ${CFLAGS} -DHZ=${HZ} ${OPTON} dhry_2.c
$(CC) -o $(PROGDIR)/dhry2 ${CFLAGS} ${OPTON} $(SRCDIR)/dhry_1.o $(SRCDIR)/dhry_2.o
cd $(SRCDIR); rm -f dhry_1.o dhry_2.o
$(PROGDIR)/dhry2reg: $(SRCDIR)/dhry_1.c $(SRCDIR)/dhry_2.c $(SRCDIR)/dhry.h
cd $(SRCDIR); $(CC) -c ${CFLAGS} -DREG=register -DHZ=${HZ} ${OPTON} dhry_1.c
cd $(SRCDIR); $(CC) -c ${CFLAGS} -DREG=register -DHZ=${HZ} ${OPTON} dhry_2.c
$(CC) -o $(PROGDIR)/dhry2reg ${CFLAGS} ${OPTON} $(SRCDIR)/dhry_1.o $(SRCDIR)/dhry_2.o
cd $(SRCDIR); rm -f dhry_1.o dhry_2.o
$(PROGDIR)/looper: $(SRCDIR)/looper.c
$(CC) -o $(PROGDIR)/looper ${CFLAGS} ${OPTON} $(SRCDIR)/looper.c
$(PROGDIR)/ubgears: $(SRCDIR)/ubgears.c
$(CC) -o $(PROGDIR)/ubgears ${CFLAGS} ${OPTON} $(SRCDIR)/ubgears.c $(GL_LIBS)
# Run the benchmarks and create the reports
run:
sh ./Run
clean:
rm -f $(BINS) core *~ */*~
spotless: clean
rm -f $(RESULTDIR)/* $(TMPDIR)/*
## END ##

View File

@@ -0,0 +1,406 @@
Version 5.1.2 -- 2007-12-26
================================================================
To use Unixbench:
1. UnixBench from version 5.1 on has both system and graphics tests.
If you want to use the graphic tests, edit the Makefile and make sure
that the line "GRAPHIC_TESTS = defined" is not commented out; then check
that the "GL_LIBS" definition is OK for your system. Also make sure
that the "x11perf" command is on your search path.
If you don't want the graphics tests, then comment out the
"GRAPHIC_TESTS = defined" line. Note: comment it out, don't
set it to anything.
2. Do "make".
3. Do "Run" to run the system test; "Run graphics" to run the graphics
tests; "Run gindex" to run both.
You will need perl, as Run is written in perl.
For more information on using the tests, read "USAGE".
For information on adding tests into the benchmark, see "WRITING_TESTS".
===================== RELEASE NOTES =====================================
======================== Dec 07 ==========================
v5.1.2
One big fix: if unixbench is installed in a directory whose pathname contains
a space, it should now run (previously it failed).
To avoid possible clashes, the environment variables unixbench uses are now
prefixed with "UB_". These are all optional, and for most people will be
completely unnecessary, but if you want you can set these:
UB_BINDIR Directory where the test programs live.
UB_TMPDIR Temp directory, for temp files.
UB_RESULTDIR Directory to put results in.
UB_TESTDIR Directory where the tests are executed.
And a couple of tiny fixes:
* In pgms/tst.sh, changed "sort -n +1" to "sort -n -k 1"
* In Makefile, made it clearer that GRAPHIC_TESTS should be commented
out (not set to 0) to disable graphics
Thanks to nordi for pointing these out.
Ian Smith, December 26, 2007
johantheghost at yahoo period com
======================== Oct 07 ==========================
v5.1.1
It turns out that the setting of LANG is crucial to the results. This
explains why people in different regions were seeing odd results, and also
why runlevel 1 produced odd results -- runlevel 1 doesn't set LANG, and
hence reverts to ASCII, whereas most people use a UTF-8 encoding, which is
much slower in some tests (eg. shell tests).
So now we manually set LANG to "en_US.utf8", which is configured with the
variable "$language". Don't change this if you want to share your results.
We also report the language settings in use.
See "The Language Setting" in USAGE for more info. Thanks to nordi for
pointing out the LANG issue.
I also added the "grep" and "sysexec" tests. These are non-index tests,
and "grep" uses the system's grep, so it's not much use for comparing
different systems. But some folks on the OpenSuSE list have been finding
these useful. They aren't in any of the main test groups; do "Run grep
sysexec" to run them.
Index Changes
-------------
The setting of LANG will affect consistency with systems where this is
not the default value. However, it should produce more consistent results
in future.
Ian Smith, October 15, 2007
johantheghost at yahoo period com
======================== Oct 07 ==========================
v5.1
The major new feature in this version is the addition of graphical
benchmarks. Since these may not compile on all systems, you can enable/
disable them with the GRAPHIC_TESTS variable in the Makefile.
As before, each test is run for 3 or 10 iterations. However, we now discard
the worst 1/3 of the scores before averaging the remainder. The logic is
that a glitch in the system (background process waking up, for example) may
make one or two runs go slow, so let's discard those. Hopefully this will
produce more consistent and repeatable results. Check the log file
for a test run to see the discarded scores.
Made the tests compile and run on x86-64/Linux (fixed an execl bug passing
int instead of pointer).
Also fixed some general bugs.
Thanks to Stefan Esser for help and testing / bug reporting.
Index Changes
-------------
The tests are now divided into categories, and each category generates
its own index. This keeps the graphics test results separate from
the system tests.
The "graphics" test and corresponding index are new.
The "discard the worst scores" strategy should produce slightly higher
test scores, but at least they should (hopefully!) be more consistent.
The scores should not be higher than the best scores you would have got
with 5.0, so this should not be a huge consistency issue.
Ian Smith, October 11, 2007
johantheghost at yahoo period com
======================== Sep 07 ==========================
v5.0
All the work I've done on this release is Linux-based, because that's
the only Unix I have access to. I've tried to make it more OS-agnostic
if anything; for example, it no longer has to figure out the format reported
by /usr/bin/time. However, it's possible that portability has been damaged.
If anyone wants to fix this, please feel free to mail me patches.
In particular, the analysis of the system's CPUs is done via /proc/cpuinfo.
For systems which don't have this, please make appropriate changes in
getCpuInfo() and getSystemInfo().
The big change has been to make the tests multi-CPU aware. See the
"Multiple CPUs" section in "USAGE" for details. Other changes:
* Completely rewrote Run in Perl; drastically simplified the way data is
processed. The confusing system of interlocking shell and awk scripts is
now just one script. Various intermediate files used to store and process
results are now replaced by Perl data structures internal to the script.
* Removed from the index runs file system read and write tests which were
ignored for the index and wasted about 10 minutes per run (see fstime.c).
The read and write tests can now be selected individually. Made fstime.c
take parameters, so we no longer need to build 3 versions of it.
* Made the output file names unique; they are built from
hostname-date-sequence.
* Worked on result reporting, error handling, and logging. See TESTS.
We now generate both text and HTML reports.
* Removed some obsolete files.
Index Changes
-------------
The index is still based on David Niemi's SPARCstation 20-61 (rated at 10.0),
and the intention in the changes I've made has been to keep the tests
unchanged, in order to maintain consistency with old result sets.
However, the following changes have been made to the index:
* The Pipe-based Context Switching test (context1) was being dropped
from the index report in v4.1.0 due to a bug; I've put it back in.
* I've added shell1 to the index, to get a measure of how the shell tests
scale with multiple CPUs (shell8 already exercises all the CPUs, even
in single-copy mode). I made up the baseline score for this by
extrapolation.
Both of these test can be dropped, if you wish, by editing the "TEST
SPECIFICATIONS" section of Run.
Ian Smith, September 20, 2007
johantheghost at yahoo period com
======================== Aug 97 ==========================
v4.1.0
Double precision Whetstone put in place instead of the old "double" benchmark.
Removal of some obsolete files.
"system" suite adds shell8.
perlbench and poll added as "exhibition" (non-index) benchmarks.
Incorporates several suggestions by Andre Derrick Balsa <andrewbalsa@usa.net>
Code cleanups to reduce compiler warnings by David C Niemi <niemi@tux.org>
and Andy Kahn <kahn@zk3.dec.com>; Digital Unix options by Andy Kahn.
======================== Jun 97 ==========================
v4.0.1
Minor change to fstime.c to fix overflow problems on fast machines. Counting
is now done in units of 256 (smallest BUFSIZE) and unsigned longs are used,
giving another 23 dB or so of headroom ;^) Results should be virtually
identical aside from very small rounding errors.
======================== Dec 95 ==========================
v4.0
Byte no longer seems to have anything to do with this benchmark, and I was
unable to reach any of the original authors; so I have taken it upon myself
to clean it up.
This is version 4. Major assumptions made in these benchmarks have changed
since they were written, but they are nonetheless popular (particularly for
measuring hardware for Linux). Some changes made:
- The biggest change is to put a lot more operating system-oriented
tests into the index. I experimented for a while with a decibel-like
logarithmic scale, but finally settled on using a geometric mean for
the final index (the individual scores are a normalized, and their
logs are averaged; the resulting value is exponentiated).
"George", certain SPARCstation 20-61 with 128 MB RAM, a SPARC Storage
Array, and Solaris 2.3 is my new baseline; it is rated at 10.0 in each
of the index scores for a final score of 10.0.
Overall I find the geometric averaging is a big improvement for
avoiding the skew that was once possible (e.g. a Pentium-75 which got
40 on the buggy version of fstime, such that fstime accounted for over
half of its total score and hence wildly skewed its average).
I also expect that the new numbers look different enough from the old
ones that no one is too likely to casually mistake them for each other.
I am finding new SPARCs running Solaris 2.4 getting about 15-20, and
my 486 DX2-66 Compaq running Linux 1.3.45 got a 9.1. It got
understandably poor scores on CPU and FPU benchmarks (a horrible
1.8 on "double" and 1.3 on "fsdisk"); but made up for it by averaging
over 20 on the OS-oriented benchmarks. The Pentium-75 running
Linux gets about 20 (and it *still* runs Windows 3.1 slowly. Oh well).
- It is difficult to get a modern compiler to even consider making
dhry2 without registers, short of turning off *all* optimizations.
This is also not a terribly meaningful test, even if it were possible,
as noone compiles without registers nowadays. Replaced this benchmark
with dhry2reg in the index, and dropped it out of usage in general as
it is so hard to make a legitimate one.
- fstime: this had some bugs when compiled on modern systems which return
the number of bytes read/written for read(2)/write(2) calls. The code
assumed that a negative return code was given for EOF, but most modern
systems return 0 (certainly on SunOS 4, Solaris2, and Linux, which is
what counts for me). The old code yielded wildly inflated read scores,
would eat up tens of MB of disk space on fast systems, and yielded
roughly 50% lower than normal copy scores than it should have.
Also, it counted partial blocks *fully*; made it count the proportional
part of the block which was actually finished.
Made bigger and smaller variants of fstime which are designed to beat
up the disk I/O and the buffer cache, respectively. Adjusted the
sleeps so that they are short for short benchmarks.
- Instead of 1,2,4, and 8-shell benchmarks, went to 1, 8, and 16 to
give a broader range of information (and to run 1 fewer test).
The only real problem with this is that not many iterations get
done with 16 at a time on slow systems, so there are some significant
rounding errors; 8 therefore still used for the benchmark. There is
also the problem that the last (uncompleted) loop is counted as a full
loop, so it is impossible to score below 1.0 lpm (which gave my laptop
a break). Probably redesigning Shell to do each loop a bit more
quickly (but with less intensity) would be a good idea.
This benchmark appears to be very heavily influenced by the speed
of the loader, by which shell is being used as /bin/sh, and by how
well-compiled some of the common shell utilities like grep, sed, and
sort are. With a consistent tool set it is also a good indicator of
the bandwidth between main memory and the CPU (e.g. Pentia score about
twice as high as 486es due to their 64-bit bus). Small, sometimes
broken shells like "ash-linux" do particularly well here, while big,
robust shells like bash do not.
- "dc" is a somewhat iffy benchmark, because there are two versions of
it floating around, one being small, very fast, and buggy, and one
being more correct but slow. It was never in the index anyway.
- Execl is a somewhat troubling benchmark in that it yields much higher
scores if compiled statically. I frown on this practice because it
distorts the scores away from reflecting how programs are really used
(i.e. dynamically linked).
- Arithoh is really more an indicator of the compiler quality than of
the computer itself. For example, GCC 2.7.x with -O2 and a few extra
options optimizes much of it away, resulting in about a 1200% boost
to the score. Clearly not a good one for the index.
I am still a bit unhappy with the variance in some of the benchmarks, most
notably the fstime suite; and with how long it takes to run. But I think
it gets significantly more reliable results than the older version in less
time.
If anyone has ideas on how to make these benchmarks faster, lower-variance,
or more meaningful; or has nice, new, portable benchmarks to add, don't
hesitate to e-mail me.
David C Niemi <niemi@tux.org> 7 Dec 1995
======================== May 91 ==========================
This is version 3. This set of programs should be able to determine if
your system is BSD or SysV. (It uses the output format of time (1)
to see. If you have any problems, contact me (by email,
preferably): ben@bytepb.byte.com
---
The document doc/bench.doc describes the basic flow of the
benchmark system. The document doc/bench3.doc describes the major
changes in design of this version. As a user of the benchmarks,
you should understand some of the methods that have been
implemented to generate loop counts:
Tests that are compiled C code:
The function wake_me(second, func) is included (from the file
timeit.c). This function uses signal and alarm to set a countdown
for the time request by the benchmark administration script
(Run). As soon as the clock is started, the test is run with a
counter keeping track of the number of loops that the test makes.
When alarm sends its signal, the loop counter value is sent to stderr
and the program terminates. Since the time resolution, signal
trapping and other factors don't insure that the test is for the
precise time that was requested, the test program is also run
from the time (1) command. The real time value returned from time
(1) is what is used in calculating the number of loops per second
(or minute, depending on the test). As is obvious, there is some
overhead time that is not taken into account, therefore the
number of loops per second is not absolute. The overhead of the
test starting and stopping and the signal and alarm calls is
common to the overhead of real applications. If a program loads
quickly, the number of loops per second increases; a phenomenon
that favors systems that can load programs quickly. (Setting the
sticky bit of the test programs is not considered fair play.)
Test that use existing UNIX programs or shell scripts:
The concept is the same as that of compiled tests, except the
alarm and signal are contained in separate compiled program,
looper (source is looper.c). Looper uses an execvp to invoke the
test with its arguments. Here, the overhead includes the
invocation and execution of looper.
--
The index numbers are generated from a baseline file that is in
pgms/index.base. You can put tests that you wish in this file.
All you need to do is take the results/log file from your
baseline machine, edit out the comment and blank lines, and sort
the result (vi/ex command: 1,$!sort). The sort in necessary
because the process of generating the index report uses join (1).
You can regenerate the reports by running "make report."
--
========================= Jan 90 =============================
Tom Yager has joined the effort here at BYTE; he is responsible
for many refinements in the UNIX benchmarks.
The memory access tests have been deleted from the benchmarks.
The file access tests have been reversed so that the test is run
for a fixed time. The amount of data transfered (written, read,
and copied) is the variable. !WARNING! This test can eat up a
large hunk of disk space.
The initial line of all shell scripts has been changed from the
SCO and XENIX form (:) to the more standard form "#! /bin/sh".
But different systems handle shell switching differently. Check
the documentation on your system and find out how you are
supposed to do it. Or, simpler yet, just run the benchmarks from
the Bourne shell. (You may need to set SHELL=/bin/sh as well.)
The options to Run have not been checked in a while. They may no
longer function. Next time, I'll get back on them. There needs to
be another option added (next time) that halts testing between
each test. !WARNING! Some systems have caches that are not getting flushed
before the next test or iteration is run. This can cause
erroneous values.
========================= Sept 89 =============================
The database (db) programs now have a tuneable message queue space.
queue space. The default set in the Run script is 1024 bytes.
Other major changes are in the format of the times. We now show
Arithmetic and Geometric mean and standard deviation for User
Time, System Time, and Real Time. Generally, in reporting, we
plan on using the Real Time values with the benchs run with one
active user (the bench user). Comments and arguments are requested.
contact: BIX bensmith or rick_g

1868
benchmarks/unixbench-5.1.2/Run Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,394 @@
Running the Tests
=================
All the tests are executed using the "Run" script in the top-level directory.
The simplest way to generate results is with the commmand:
./Run
This will run a standard "index" test (see "The BYTE Index" below), and
save the report in the "results" directory, with a filename like
hostname-2007-09-23-01
An HTML version is also saved.
If you want to generate both the basic system index and the graphics index,
then do:
./Run gindex
If your system has more than one CPU, the tests will be run twice -- once
with a single copy of each test running at once, and once with N copies,
where N is the number of CPUs. Some categories of tests, however (currently
the graphics tests) will only run with a single copy.
Since the tests are based on constant time (variable work), a "system"
run usually takes about 29 minutes; the "graphics" part about 18 minutes.
A "gindex" run on a dual-core machine will do 2 "system" passes (single-
and dual-processing) and one "graphics" run, for a total around one and
a quarter hours.
============================================================================
Detailed Usage
==============
The Run script takes a number of options which you can use to customise a
test, and you can specify the names of the tests to run. The full usage
is:
Run [ -q | -v ] [-i <n> ] [-c <n> [-c <n> ...]] [test ...]
The option flags are:
-q Run in quiet mode.
-v Run in verbose mode.
-i <count> Run <count> iterations for each test -- slower tests
use <count> / 3, but at least 1. Defaults to 10 (3 for
slow tests).
-c <n> Run <n> copies of each test in parallel.
The -c option can be given multiple times; for example:
./Run -c 1 -c 4
will run a single-streamed pass, then a 4-streamed pass. Note that some
tests (currently the graphics tests) will only run in a single-streamed pass.
The remaining non-flag arguments are taken to be the names of tests to run.
The default is to run "index". See "Tests" below.
When running the tests, I do *not* recommend switching to single-user mode
("init 1"). This seems to change the results in ways I don't understand,
and it's not realistic (unless your system will actually be running in this
mode, of course). However, if using a windowing system, you may want to
switch to a minimal window setup (for example, log in to a "twm" session),
so that randomly-churning background processes don't randomise the results
too much. This is particularly true for the graphics tests.
============================================================================
Tests
=====
The available tests are organised into categories; when generating index
scores (see "The BYTE Index" below) the results for each category are
produced separately. The categories are:
system The original Unix system tests (not all are actually
in the index)
2d 2D graphics tests (not all are actually in the index)
3d 3D graphics tests
misc Various non-indexed tests
The following individual tests are available:
system:
dhry2reg Dhrystone 2 using register variables
whetstone-double Double-Precision Whetstone
syscall System Call Overhead
pipe Pipe Throughput
context1 Pipe-based Context Switching
spawn Process Creation
execl Execl Throughput
fstime-w File Write 1024 bufsize 2000 maxblocks
fstime-r File Read 1024 bufsize 2000 maxblocks
fstime File Copy 1024 bufsize 2000 maxblocks
fsbuffer-w File Write 256 bufsize 500 maxblocks
fsbuffer-r File Read 256 bufsize 500 maxblocks
fsbuffer File Copy 256 bufsize 500 maxblocks
fsdisk-w File Write 4096 bufsize 8000 maxblocks
fsdisk-r File Read 4096 bufsize 8000 maxblocks
fsdisk File Copy 4096 bufsize 8000 maxblocks
shell1 Shell Scripts (1 concurrent) (runs "looper 60 multi.sh 1")
shell8 Shell Scripts (8 concurrent) (runs "looper 60 multi.sh 8")
shell16 Shell Scripts (8 concurrent) (runs "looper 60 multi.sh 16")
2d:
2d-rects 2D graphics: rectangles
2d-lines 2D graphics: lines
2d-circle 2D graphics: circles
2d-ellipse 2D graphics: ellipses
2d-shapes 2D graphics: polygons
2d-aashapes 2D graphics: aa polygons
2d-polys 2D graphics: complex polygons
2d-text 2D graphics: text
2d-blit 2D graphics: images and blits
2d-window 2D graphics: windows
3d:
ubgears 3D graphics: gears
misc:
C C Compiler Throughput ("looper 60 $cCompiler cctest.c")
arithoh Arithoh (huh?)
short Arithmetic Test (short) (this is arith.c configured for
"short" variables; ditto for the ones below)
int Arithmetic Test (int)
long Arithmetic Test (long)
float Arithmetic Test (float)
double Arithmetic Test (double)
dc Dc: sqrt(2) to 99 decimal places (runs
"looper 30 dc < dc.dat", using your system's copy of "dc")
hanoi Recursion Test -- Tower of Hanoi
grep Grep for a string in a large file, using your system's
copy of "grep"
sysexec Exercise fork() and exec().
The following pseudo-test names are aliases for combinations of other
tests:
arithmetic Runs arithoh, short, int, long, float, double,
and whetstone-double
dhry Alias for dhry2reg
dhrystone Alias for dhry2reg
whets Alias for whetstone-double
whetstone Alias for whetstone-double
load Runs shell1, shell8, and shell16
misc Runs C, dc, and hanoi
speed Runs the arithmetic and system groups
oldsystem Runs execl, fstime, fsbuffer, fsdisk, pipe, context1,
spawn, and syscall
system Runs oldsystem plus shell1, shell8, and shell16
fs Runs fstime-w, fstime-r, fstime, fsbuffer-w,
fsbuffer-r, fsbuffer, fsdisk-w, fsdisk-r, and fsdisk
shell Runs shell1, shell8, and shell16
index Runs the tests which constitute the official index:
the oldsystem group, plus dhry2reg, whetstone-double,
shell1, and shell8
See "The BYTE Index" below for more information.
graphics Runs the tests which constitute the graphics index:
2d-rects, 2d-ellipse, 2d-aashapes, 2d-text, 2d-blit,
2d-window, and ubgears
gindex Runs the index and graphics groups, to generate both
sets of index results
all Runs all tests
============================================================================
The BYTE Index
==============
The purpose of this test is to provide a basic indicator of the performance
of a Unix-like system; hence, multiple tests are used to test various
aspects of the system's performance. These test results are then compared
to the scores from a baseline system to produce an index value, which is
generally easier to handle than the raw sores. The entire set of index
values is then combined to make an overall index for the system.
Since 1995, the baseline system has been "George", a SPARCstation 20-61
with 128 MB RAM, a SPARC Storage Array, and Solaris 2.3, whose ratings
were set at 10.0. (So a system which scores 520 is 52 times faster than
this machine.) Since the numbers are really only useful in a relative
sense, there's no particular reason to update the base system, so for the
sake of consistency it's probably best to leave it alone. George's scores
are in the file "pgms/index.base"; this file is used to calculate the
index scores for any particular run.
Over the years, various changes have been made to the set of tests in the
index. Although there is a desire for a consistent baseline, various tests
have been determined to be misleading, and have been removed; and a few
alternatives have been added. These changes are detailed in the README,
and should be born in mind when looking at old scores.
A number of tests are included in the benchmark suite which are not part of
the index, for various reasons; these tests can of course be run manually.
See "Tests" above.
============================================================================
Graphics Tests
==============
As of version 5.1, UnixBench now contains some graphics benchmarks. These
are intended to give a rough idea of the general graphics performance of
a system.
The graphics tests are in categories "2d" and "3d", so the index scores
for these tests are separate from the basic system index. This seems
like a sensible division, since the graphics performance of a system
depends largely on the graphics adaptor.
The tests currently consist of some 2D "x11perf" tests and "ubgears".
* The 2D tests are a selection of the x11perf tests, using the host
system's x11perf command (which must be installed and in the search
path). Only a few of the x11perf tests are used, in the interests
of completing a test run in a reasonable time; if you want to do
detailed diagnosis of an X server or graphics chip, then use x11perf
directly.
* The 3D test is "ubgears", a modified version of the familiar "glxgears".
This version runs for 5 seconds to "warm up", then performs a timed
run and displays the average frames-per-second.
On multi-CPU systems, the graphics tests will only run in single-processing
mode. This is because the meaning of running two copies of a test at once
is dubious; and the test windows tend to overlay each other, meaning that
the window behind isn't actually doing any work.
============================================================================
Multiple CPUs
=============
If your system has multiple CPUs, the default behaviour is to run the selected
tests twice -- once with one copy of each test program running at a time,
and once with N copies, where N is the number of CPUs. (You can override
this with the "-c" option; see "Detailed Usage" above.) This is designed to
allow you to assess:
- the performance of your system when running a single task
- the performance of your system when running multiple tasks
- the gain from your system's implementation of parallel processing
The results, however, need to be handled with care. Here are the results
of two runs on a dual-processor system, one in single-processing mode, one
dual-processing:
Test Single Dual Gain
-------------------- ------ ------ ----
Dhrystone 2 562.5 1110.3 97%
Double Whetstone 320.0 640.4 100%
Execl Throughput 450.4 880.3 95%
File Copy 1024 759.4 595.9 -22%
File Copy 256 535.8 438.8 -18%
File Copy 4096 1261.8 1043.4 -17%
Pipe Throughput 481.0 979.3 104%
Pipe-based Switching 326.8 1229.0 276%
Process Creation 917.2 1714.1 87%
Shell Scripts (1) 1064.9 1566.3 47%
Shell Scripts (8) 1567.7 1709.9 9%
System Call Overhead 944.2 1445.5 53%
-------------------- ------ ------ ----
Index Score: 678.2 1026.2 51%
As expected, the heavily CPU-dependent tasks -- dhrystone, whetstone,
execl, pipe throughput, process creation -- show close to 100% gain when
running 2 copies in parallel.
The Pipe-based Context Switching test measures context switching overhead
by sending messages back and forth between 2 processes. I don't know why
it shows such a huge gain with 2 copies (ie. 4 processes total) running,
but it seems to be consistent on my system. I think this may be an issue
with the SMP implementation.
The System Call Overhead shows a lesser gain, presumably because it uses a
lot of CPU time in single-threaded kernel code. The shell scripts test with
8 concurrent processes shows no gain -- because the test itself runs 8
scripts in parallel, it's already using both CPUs, even when the benchmark
is run in single-stream mode. The same test with one process per copy
shows a real gain.
The filesystem throughput tests show a loss, instead of a gain, when
multi-processing. That there's no gain is to be expected, since the tests
are presumably constrained by the throughput of the I/O subsystem and the
disk drive itself; the drop in performance is presumably down to the
increased contention for resources, and perhaps greater disk head movement.
So what tests should you use, how many copies should you run, and how should
you interpret the results? Well, that's up to you, since it depends on
what it is you're trying to measure.
Implementation
--------------
The multi-processing mode is implemented at the level of test iterations.
During each iteration of a test, N slave processes are started using fork().
Each of these slaves executes the test program using fork() and exec(),
reads and stores the entire output, times the run, and prints all the
results to a pipe. The Run script reads the pipes for each of the slaves
in turn to get the results and times. The scores are added, and the times
averaged.
The result is that each test program has N copies running at once. They
should all finish at around the same time, since they run for constant time.
If a test program itself starts off K multiple processes (as with the shell8
test), then the effect will be that there are N * K processes running at
once. This is probably not very useful for testing multi-CPU performance.
============================================================================
The Language Setting
====================
The $LANG environment variable determines how programs abnd library
routines interpret text. This can have a big impact on the test results.
If $LANG is set to POSIX, or is left unset, text is treated as ASCII; if
it is set to en_US.UTF-8, foir example, then text is treated as being
encoded in UTF-8, which is more complex and therefore slower. Setting
it to other languages can have varying results.
To ensure consistency between test runs, the Run script now (as of version
5.1.1) sets $LANG to "en_US.utf8".
This setting which is configured with the variable "$language". You
should not change this if you want to share your results to allow
comparisons between systems; however, you may want to change it to see
how different language settings affect performance.
Each test report now includes the language settings in use. The reported
language is what is set in $LANG, and is not necessarily supported by the
system; but we also report the character mapping and collation order which
are actually in use (as reported by "locale").
============================================================================
Interpreting the Results
========================
Interpreting the results of these tests is tricky, and totally depends on
what you're trying to measure.
For example, are you trying to measure how fast your CPU is? Or how good
your compiler is? Because these tests are all recompiled using your host
system's compiler, the performance of the compiler will inevitably impact
the performance of the tests. Is this a problem? If you're choosing a
system, you probably care about its overall speed, which may well depend
on how good its compiler is; so including that in the test results may be
the right answer. But you may want to ensure that the right compiler is
used to build the tests.
On the other hand, with the vast majority of Unix systems being x86 / PC
compatibles, running Linux and the GNU C compiler, the results will tend
to be more dependent on the hardware; but the versions of the compiler and
OS can make a big difference. (I measured a 50% gain between SUSE 10.1
and OpenSUSE 10.2 on the same machine.) So you may want to make sure that
all your test systems are running the same version of the OS; or at least
publish the OS and compuiler versions with your results. Then again, it may
be compiler performance that you're interested in.
The C test is very dubious -- it tests the speed of compilation. If you're
running the exact same compiler on each system, OK; but otherwise, the
results should probably be discarded. A slower compilation doesn't say
anything about the speed of your system, since the compiler may simply be
spending more time to super-optimise the code, which would actually make it
faster.
This will be particularly true on architectures like IA-64 (Itanium etc.)
where the compiler spends huge amounts of effort scheduling instructions
to run in parallel, with a resultant significant gain in execution speed.
Some tests are even more dubious in terms of host-dependency -- for example,
the "dc" test uses the host's version of dc (a calculator program). The
version of this which is available can make a huge difference to the score,
which is why it's not in the index group. Read through the release notes
for more on these kinds of issues.
Another age-old issue is that of the benchmarks being too trivial to be
meaningful. With compilers getting ever smarter, and performing more
wide-ranging flow path analyses, the danger of parts of the benchmarks
simply being optimised out of existance is always present.
All in all, the "index" and "gindex" tests (see above) are designed to
give a reasonable measure of overall system performance; but the results
of any test run should always be used with care.

View File

@@ -0,0 +1,133 @@
Writing a Test
==============
Writing a test program is pretty easy. Basically, a test is configured via
a monster array in the Run script, which specifics (among other things) the
program to execute and the parameters to pass it.
The test itself is simply a program which is given the optional parameters
on the command line, and produces logging data on stdout and its results on
stderr.
============================================================================
Test Configuration
==================
In Run, all tests are named in the "$testList" array. This names the
individual tests, and also sets up aliases for groups of tests, eg. "index".
The test specifications are in the "$testParams" array. This contains the
details of each individual test as a hash. The fields in the hash are:
* "logmsg": the full name to display for this test.
* "cat": the category this test belongs to; must be configured
in $testCats.
* "prog": the name of the program to execute; defaults to the name of
the benchmark.
* "repeat": number of passes to run; either 'short' (the default),
'long', or 'single'. For 'short' and 'long', the actual numbers of
passes are given by $shortIterCount and $longIterCount, which are
configured at the top of the script or by the "-i" flag. 'single'
means just run one pass; this should be used for test which do their
own multi-pass handling internally.
* "stdout": non-0 to add the test's stdout to the log file; defaults to 1.
Set to 0 for tests that are too wordy.
* "stdin": name of a file to send to the program's stdin; default null.
* "options": options to be put on the program's command line; default null.
============================================================================
Output Format
=============
The results on stderr take the form of a line header and fields, separated
by "|" characters. A result line can be one of:
COUNT|score|timebase|label
TIME|seconds
ERROR|message
Any other text on stderr is treated as if it were:
ERROR|text
Any output to stdout is placed in a log file, and can be used for debugging.
COUNT
-----
The COUNT line is the line used to report a test score.
* "score" is the result, typically the number of loops performed during
the run
* "timebase" is the time base used for the final report to the user. A
value of 1 reports the score as is; a value of 60, for example, divides
the time taken by 60 to get loops per minute. Atimebase of zero indicates
that the score is already a rate, ie. a count of things per second.
* "label" is the label to use for the score; like "lps" (loops per
second), etc.
TIME
----
The TIME line is optionally used to report the time taken. The Run script
normally measures this, but if your test has signifant overhead outside the
actual test loop, you should use TIME to report the time taken for the actual
test. The argument is the time in seconds in floating-point.
ERROR
-----
The argument is an error message; this will abort the benchmarking run and
display the message.
Any output to stderr which is not a formatted line will be treated as an
error message, so use of ERROR is optional.
============================================================================
Test Examples
=============
Iteration Count
---------------
The simplest thing is to count the number of loops executed in a given time;
see eg. arith.c. The utlilty functions in timeit.c can be used to implement
the fixed time interval, which is generally passed in on the command line.
The result is reported simply as the number of iterations completed:
fprintf(stderr,"COUNT|%lu|1|lps\n", iterations);
The bnenchmark framework will measure the time taken itself. If the test
code has significant overhead (eg. a "pump-priming" pass), then you should
explicitly report the time taken for the test by adding a line like this:
fprintf(stderr, "TIME|%.1f\n", seconds);
If you want results reported as loops per minute, then set timebase to 60:
fprintf(stderr,"COUNT|%lu|60|lpm\n", iterations);
Note that this only affects the final report; all times passed to or
from the test are still in seconds.
Rate
----
The other technique is to calculate the rate (things per second) in the test,
and report that directly. To do this, just set timebase to 0:
fprintf(stderr, "COUNT|%ld|0|KBps\n", kbytes_per_sec);
Again, you can use TIME to explicitly report the time taken:
fprintf(stderr, "TIME|%.1f\n", end - start);
but this isn't so important since you've already calculated the rate.

View File

@@ -0,0 +1,476 @@
#!/usr/bin/perl -w
use strict;
############################################################################
# gfx-x11: a front-end for x11perf. Runs a selected x11perf test, and
# produces output in the format needed by UnixBench.
############################################################################
# Modification Log:
# 2007.09.26 Ian Smith Created
############################################################################
# This program runs sets of x11perf tests, indexes the results against
# a common base reference system (see $testData below), and reports the
# final score.
#
# Usage:
# gfx-x11 <group> <reps> <time>
# where:
# <group> is one of the test groups defined in $testGroups below
# <reps> is the number of repeats to do per test (the -repeat
# argument to x11perf)
# <time> is the number of seconds to run each repeat for (the
# -time argument to x11perf)
# Note that x11perf runs a calibration pass before the requested number
# of test passes. The score we compute for a test is the average of the
# test passes, divided by the base value in $testData, times 1000.0.
# The final score we report is the average of the test scores.
############################################################################
# TEST DATA
############################################################################
# This array lists all of the x11perf tests, together with their scores
# on an HP Compaq nc8430, with an ATI Mobility Radeon X1600 (256MB)
# graphics adapter. There isn't anything special about this reference
# system, but scaling all the scores back to a single reference system
# allows us to average them in a roughly meaningful way, which in turn
# allows us to produce sensible scores for the test groups defined below.
#
# The results we report are indexed to these values, at a base of 1000.0.
my $testData = {
'dot' => [ 31700000.0, "Dot" ],
'rect1' => [ 18400000.0, "1x1 rectangle" ],
'rect10' => [ 7180000.0, "10x10 rectangle" ],
'rect100' => [ 110000.0, "100x100 rectangle" ],
'rect500' => [ 4110.0, "500x500 rectangle" ],
'srect1' => [ 15800000.0, "1x1 stippled rectangle (8x8 stipple)" ],
'srect10' => [ 7400000.0, "10x10 stippled rectangle (8x8 stipple)" ],
'srect100' => [ 110000.0, "100x100 stippled rectangle (8x8 stipple)" ],
'srect500' => [ 4110.0, "500x500 stippled rectangle (8x8 stipple)" ],
'osrect1' => [ 15900000.0, "1x1 opaque stippled rectangle (8x8 stipple)" ],
'osrect10' => [ 7170000.0, "10x10 opaque stippled rectangle (8x8 stipple)" ],
'osrect100' => [ 110000.0, "100x100 opaque stippled rectangle (8x8 stipple)" ],
'osrect500' => [ 4110.0, "500x500 opaque stippled rectangle (8x8 stipple)" ],
'tilerect1' => [ 15800000.0, "1x1 tiled rectangle (4x4 tile)" ],
'tilerect10' => [ 7170000.0, "10x10 tiled rectangle (4x4 tile)" ],
'tilerect100' => [ 110000.0, "100x100 tiled rectangle (4x4 tile)" ],
'tilerect500' => [ 4110.0, "500x500 tiled rectangle (4x4 tile)" ],
'oddsrect1' => [ 2990000.0, "1x1 stippled rectangle (17x15 stipple)" ],
'oddsrect10' => [ 1490000.0, "10x10 stippled rectangle (17x15 stipple)" ],
'oddsrect100' => [ 55600.0, "100x100 stippled rectangle (17x15 stipple)" ],
'oddsrect500' => [ 2360.0, "500x500 stippled rectangle (17x15 stipple)" ],
'oddosrect1' => [ 2990000.0, "1x1 opaque stippled rectangle (17x15 stipple)" ],
'oddosrect10' => [ 1430000.0, "10x10 opaque stippled rectangle (17x15 stipple)" ],
'oddosrect100' => [ 54500.0, "100x100 opaque stippled rectangle (17x15 stipple)" ],
'oddosrect500' => [ 2320.0, "500x500 opaque stippled rectangle (17x15 stipple)" ],
'oddtilerect1' => [ 2990000.0, "1x1 tiled rectangle (17x15 tile)" ],
'oddtilerect10' => [ 1430000.0, "10x10 tiled rectangle (17x15 tile)" ],
'oddtilerect100' => [ 54500.0, "100x100 tiled rectangle (17x15 tile)" ],
'oddtilerect500' => [ 2320.0, "500x500 tiled rectangle (17x15 tile)" ],
'bigsrect1' => [ 4300000.0, "1x1 stippled rectangle (161x145 stipple)" ],
'bigsrect10' => [ 705000.0, "10x10 stippled rectangle (161x145 stipple)" ],
'bigsrect100' => [ 12300.0, "100x100 stippled rectangle (161x145 stipple)" ],
'bigsrect500' => [ 524.0, "500x500 stippled rectangle (161x145 stipple)" ],
'bigosrect1' => [ 3980000.0, "1x1 opaque stippled rectangle (161x145 stipple)" ],
'bigosrect10' => [ 644000.0, "10x10 opaque stippled rectangle (161x145 stipple)" ],
'bigosrect100' => [ 12800.0, "100x100 opaque stippled rectangle (161x145 stipple)" ],
'bigosrect500' => [ 584.0, "500x500 opaque stippled rectangle (161x145 stipple)" ],
'bigtilerect1' => [ 5970000.0, "1x1 tiled rectangle (161x145 tile)" ],
'bigtilerect10' => [ 684000.0, "10x10 tiled rectangle (161x145 tile)" ],
'bigtilerect100' => [ 16200.0, "100x100 tiled rectangle (161x145 tile)" ],
'bigtilerect500' => [ 872.0, "500x500 tiled rectangle (161x145 tile)" ],
'eschertilerect1' => [ 5940000.0, "1x1 tiled rectangle (216x208 tile)" ],
'eschertilerect10' => [ 639000.0, "10x10 tiled rectangle (216x208 tile)" ],
'eschertilerect100' => [ 18000.0, "100x100 tiled rectangle (216x208 tile)" ],
'eschertilerect500' => [ 922.0, "500x500 tiled rectangle (216x208 tile)" ],
'seg1' => [ 28800000.0, "1-pixel line segment" ],
'seg10' => [ 4460000.0, "10-pixel line segment" ],
'seg100' => [ 470000.0, "100-pixel line segment" ],
'seg500' => [ 94600.0, "500-pixel line segment" ],
'seg100c1' => [ 449000.0, "100-pixel line segment (1 kid)" ],
'seg100c2' => [ 432000.0, "100-pixel line segment (2 kids)" ],
'seg100c3' => [ 421000.0, "100-pixel line segment (3 kids)" ],
'dseg10' => [ 3720000.0, "10-pixel dashed segment" ],
'dseg100' => [ 687000.0, "100-pixel dashed segment" ],
'ddseg100' => [ 454000.0, "100-pixel double-dashed segment" ],
'hseg10' => [ 7020000.0, "10-pixel horizontal line segment" ],
'hseg100' => [ 2170000.0, "100-pixel horizontal line segment" ],
'hseg500' => [ 456000.0, "500-pixel horizontal line segment" ],
'vseg10' => [ 3990000.0, "10-pixel vertical line segment" ],
'vseg100' => [ 411000.0, "100-pixel vertical line segment" ],
'vseg500' => [ 82400.0, "500-pixel vertical line segment" ],
'whseg10' => [ 2880000.0, "10x1 wide horizontal line segment" ],
'whseg100' => [ 616000.0, "100x10 wide horizontal line segment" ],
'whseg500' => [ 33300.0, "500x50 wide horizontal line segment" ],
'wvseg10' => [ 2890000.0, "10x1 wide vertical line segment" ],
'wvseg100' => [ 584000.0, "100x10 wide vertical line segment" ],
'wvseg500' => [ 31700.0, "500x50 wide vertical line segment" ],
'line1' => [ 28300000.0, "1-pixel line" ],
'line10' => [ 4470000.0, "10-pixel line" ],
'line100' => [ 472000.0, "100-pixel line" ],
'line500' => [ 94200.0, "500-pixel line" ],
'dline10' => [ 3640000.0, "10-pixel dashed line" ],
'dline100' => [ 673000.0, "100-pixel dashed line" ],
'ddline100' => [ 453000.0, "100-pixel double-dashed line" ],
'wline10' => [ 908000.0, "10x1 wide line" ],
'wline100' => [ 146000.0, "100x10 wide line" ],
'wline500' => [ 30600.0, "500x50 wide line" ],
'wdline100' => [ 69900.0, "100x10 wide dashed line" ],
'wddline100' => [ 60600.0, "100x10 wide double-dashed line" ],
'orect10' => [ 5100000.0, "10x10 rectangle outline" ],
'orect100' => [ 709000.0, "100x100 rectangle outline" ],
'orect500' => [ 146000.0, "500x500 rectangle outline" ],
'worect10' => [ 4530000.0, "10x10 wide rectangle outline" ],
'worect100' => [ 204000.0, "100x100 wide rectangle outline" ],
'worect500' => [ 9790.0, "500x500 wide rectangle outline" ],
'circle1' => [ 5160000.0, "1-pixel circle" ],
'circle10' => [ 1160000.0, "10-pixel circle" ],
'circle100' => [ 141000.0, "100-pixel circle" ],
'circle500' => [ 28900.0, "500-pixel circle" ],
'dcircle100' => [ 98400.0, "100-pixel dashed circle" ],
'ddcircle100' => [ 75000.0, "100-pixel double-dashed circle" ],
'wcircle10' => [ 780000.0, "10-pixel wide circle" ],
'wcircle100' => [ 90900.0, "100-pixel wide circle" ],
'wcircle500' => [ 11300.0, "500-pixel wide circle" ],
'wdcircle100' => [ 8100.0, "100-pixel wide dashed circle" ],
'wddcircle100' => [ 8300.0, "100-pixel wide double-dashed circle" ],
'pcircle10' => [ 1270000.0, "10-pixel partial circle" ],
'pcircle100' => [ 212000.0, "100-pixel partial circle" ],
'wpcircle10' => [ 104000.0, "10-pixel wide partial circle" ],
'wpcircle100' => [ 39000.0, "100-pixel wide partial circle" ],
'fcircle1' => [ 61300000.0, "1-pixel solid circle" ],
'fcircle10' => [ 1720000.0, "10-pixel solid circle" ],
'fcircle100' => [ 120000.0, "100-pixel solid circle" ],
'fcircle500' => [ 5170.0, "500-pixel solid circle" ],
'fcpcircle10' => [ 981000.0, "10-pixel fill chord partial circle" ],
'fcpcircle100' => [ 205000.0, "100-pixel fill chord partial circle" ],
'fspcircle10' => [ 876000.0, "10-pixel fill slice partial circle" ],
'fspcircle100' => [ 187000.0, "100-pixel fill slice partial circle" ],
'ellipse10' => [ 1410000.0, "10-pixel ellipse" ],
'ellipse100' => [ 172000.0, "100-pixel ellipse" ],
'ellipse500' => [ 35100.0, "500-pixel ellipse" ],
'dellipse100' => [ 114000.0, "100-pixel dashed ellipse" ],
'ddellipse100' => [ 88900.0, "100-pixel double-dashed ellipse" ],
'wellipse10' => [ 889000.0, "10-pixel wide ellipse" ],
'wellipse100' => [ 124000.0, "100-pixel wide ellipse" ],
'wellipse500' => [ 15600.0, "500-pixel wide ellipse" ],
'wdellipse100' => [ 7730.0, "100-pixel wide dashed ellipse" ],
'wddellipse100' => [ 6680.0, "100-pixel wide double-dashed ellipse" ],
'pellipse10' => [ 1350000.0, "10-pixel partial ellipse" ],
'pellipse100' => [ 260000.0, "100-pixel partial ellipse" ],
'wpellipse10' => [ 97900.0, "10-pixel wide partial ellipse" ],
'wpellipse100' => [ 16800.0, "100-pixel wide partial ellipse" ],
'fellipse10' => [ 2110000.0, "10-pixel filled ellipse" ],
'fellipse100' => [ 212000.0, "100-pixel filled ellipse" ],
'fellipse500' => [ 11000.0, "500-pixel filled ellipse" ],
'fcpellipse10' => [ 1060000.0, "10-pixel fill chord partial ellipse" ],
'fcpellipse100' => [ 296000.0, "100-pixel fill chord partial ellipse" ],
'fspellipse10' => [ 945000.0, "10-pixel fill slice partial ellipse" ],
'fspellipse100' => [ 269000.0, "100-pixel fill slice partial ellipse" ],
'triangle1' => [ 2460000.0, "Fill 1x1 equivalent triangle" ],
'triangle10' => [ 969000.0, "Fill 10x10 equivalent triangle" ],
'triangle100' => [ 97000.0, "Fill 100x100 equivalent triangle" ],
'trap1' => [ 2630000.0, "Fill 1x1 trapezoid" ],
'trap10' => [ 1260000.0, "Fill 10x10 trapezoid" ],
'trap100' => [ 106000.0, "Fill 100x100 trapezoid" ],
'trap300' => [ 11600.0, "Fill 300x300 trapezoid" ],
'strap1' => [ 2010000.0, "Fill 1x1 stippled trapezoid (8x8 stipple)" ],
'strap10' => [ 910000.0, "Fill 10x10 stippled trapezoid (8x8 stipple)" ],
'strap100' => [ 104000.0, "Fill 100x100 stippled trapezoid (8x8 stipple)" ],
'strap300' => [ 11700.0, "Fill 300x300 stippled trapezoid (8x8 stipple)" ],
'ostrap1' => [ 2000000.0, "Fill 1x1 opaque stippled trapezoid (8x8 stipple)" ],
'ostrap10' => [ 907000.0, "Fill 10x10 opaque stippled trapezoid (8x8 stipple)" ],
'ostrap100' => [ 104000.0, "Fill 100x100 opaque stippled trapezoid (8x8 stipple)" ],
'ostrap300' => [ 11600.0, "Fill 300x300 opaque stippled trapezoid (8x8 stipple)" ],
'tiletrap1' => [ 1430000.0, "Fill 1x1 tiled trapezoid (4x4 tile)" ],
'tiletrap10' => [ 778000.0, "Fill 10x10 tiled trapezoid (4x4 tile)" ],
'tiletrap100' => [ 104000.0, "Fill 100x100 tiled trapezoid (4x4 tile)" ],
'tiletrap300' => [ 11600.0, "Fill 300x300 tiled trapezoid (4x4 tile)" ],
'oddstrap1' => [ 1700000.0, "Fill 1x1 stippled trapezoid (17x15 stipple)" ],
'oddstrap10' => [ 296000.0, "Fill 10x10 stippled trapezoid (17x15 stipple)" ],
'oddstrap100' => [ 18600.0, "Fill 100x100 stippled trapezoid (17x15 stipple)" ],
'oddstrap300' => [ 2090.0, "Fill 300x300 stippled trapezoid (17x15 stipple)" ],
'oddostrap1' => [ 1830000.0, "Fill 1x1 opaque stippled trapezoid (17x15 stipple)" ],
'oddostrap10' => [ 296000.0, "Fill 10x10 opaque stippled trapezoid (17x15 stipple)" ],
'oddostrap100' => [ 18400.0, "Fill 100x100 opaque stippled trapezoid (17x15 stipple)" ],
'oddostrap300' => [ 2080.0, "Fill 300x300 opaque stippled trapezoid (17x15 stipple)" ],
'oddtiletrap1' => [ 1710000.0, "Fill 1x1 tiled trapezoid (17x15 tile)" ],
'oddtiletrap10' => [ 296000.0, "Fill 10x10 tiled trapezoid (17x15 tile)" ],
'oddtiletrap100' => [ 18400.0, "Fill 100x100 tiled trapezoid (17x15 tile)" ],
'oddtiletrap300' => [ 2080.0, "Fill 300x300 tiled trapezoid (17x15 tile)" ],
'bigstrap1' => [ 1510000.0, "Fill 1x1 stippled trapezoid (161x145 stipple)" ],
'bigstrap10' => [ 235000.0, "Fill 10x10 stippled trapezoid (161x145 stipple)" ],
'bigstrap100' => [ 9110.0, "Fill 100x100 stippled trapezoid (161x145 stipple)" ],
'bigstrap300' => [ 1260.0, "Fill 300x300 stippled trapezoid (161x145 stipple)" ],
'bigostrap1' => [ 1480000.0, "Fill 1x1 opaque stippled trapezoid (161x145 stipple)" ],
'bigostrap10' => [ 213000.0, "Fill 10x10 opaque stippled trapezoid (161x145 stipple)" ],
'bigostrap100' => [ 8830.0, "Fill 100x100 opaque stippled trapezoid (161x145 stipple)" ],
'bigostrap300' => [ 1420.0, "Fill 300x300 opaque stippled trapezoid (161x145 stipple)" ],
'bigtiletrap1' => [ 1630000.0, "Fill 1x1 tiled trapezoid (161x145 tile)" ],
'bigtiletrap10' => [ 272000.0, "Fill 10x10 tiled trapezoid (161x145 tile)" ],
'bigtiletrap100' => [ 12900.0, "Fill 100x100 tiled trapezoid (161x145 tile)" ],
'bigtiletrap300' => [ 2350.0, "Fill 300x300 tiled trapezoid (161x145 tile)" ],
'eschertiletrap1' => [ 1650000.0, "Fill 1x1 tiled trapezoid (216x208 tile)" ],
'eschertiletrap10' => [ 273000.0, "Fill 10x10 tiled trapezoid (216x208 tile)" ],
'eschertiletrap100' => [ 13400.0, "Fill 100x100 tiled trapezoid (216x208 tile)" ],
'eschertiletrap300' => [ 2450.0, "Fill 300x300 tiled trapezoid (216x208 tile)" ],
'aatrap1' => [ 260000.0, "Fill 1x1 aa trap" ],
'aatrap10' => [ 23500.0, "Fill 10x10 aa trap" ],
'aatrap100' => [ 13300.0, "Fill 100x100 aa trap" ],
'aatrap300' => [ 4450.0, "Fill 300x300 aa trap" ],
'aa4trap1' => [ 2150.0, "Fill 1x1 aa trap with 4 bit alpha" ],
'aa4trap10' => [ 2130.0, "Fill 10x10 aa trap with 4 bit alpha" ],
'aa4trap100' => [ 1890.0, "Fill 100x100 aa trap with 4 bit alpha" ],
'aa4trap300' => [ 1460.0, "Fill 300x300 aa trap with 4 bit alpha" ],
'aa1trap1' => [ 2200000.0, "Fill 1x1 aa trap with 1 bit alpha" ],
'aa1trap10' => [ 357000.0, "Fill 10x10 aa trap with 1 bit alpha" ],
'aa1trap100' => [ 167000.0, "Fill 100x100 aa trap with 1 bit alpha" ],
'aa1trap300' => [ 67000.0, "Fill 300x300 aa trap with 1 bit alpha" ],
'aatrap2x1' => [ 368000.0, "Fill 2x1 aa trap" ],
'aatrap2x10' => [ 25700.0, "Fill 2x10 aa trap" ],
'aatrap2x100' => [ 12400.0, "Fill 2x100 aa trap" ],
'aatrap2x300' => [ 5710.0, "Fill 2x300 aa trap" ],
'aatrapezoid1' => [ 372000.0, "Fill 1x1 aa trapezoid" ],
'aatrapezoid10' => [ 137000.0, "Fill 10x10 aa trapezoid" ],
'aatrapezoid100' => [ 9590.0, "Fill 100x100 aa trapezoid" ],
'aatrapezoid300' => [ 1420.0, "Fill 300x300 aa trapezoid" ],
'addaatrapezoid1' => [ 433000.0, "Fill 1x1 aa pre-added trapezoid" ],
'addaatrapezoid10' => [ 24100.0, "Fill 10x10 aa pre-added trapezoid" ],
'addaatrapezoid100' => [ 13300.0, "Fill 100x100 aa pre-added trapezoid" ],
'addaatrapezoid300' => [ 4460.0, "Fill 300x300 aa pre-added trapezoid" ],
'complex10' => [ 655000.0, "Fill 10x10 equivalent complex polygon" ],
'complex100' => [ 87000.0, "Fill 100x100 equivalent complex polygons" ],
'64poly10convex' => [ 481000.0, "Fill 10x10 64-gon (Convex)" ],
'64poly100convex' => [ 105000.0, "Fill 100x100 64-gon (Convex)" ],
'64poly10complex' => [ 353000.0, "Fill 10x10 64-gon (Complex)" ],
'64poly100complex' => [ 105000.0, "Fill 100x100 64-gon (Complex)" ],
'ftext' => [ 2200000.0, "Char in 80-char line (6x13)" ],
'f8text' => [ 1970000.0, "Char in 70-char line (8x13)" ],
'f9text' => [ 1690000.0, "Char in 60-char line (9x15)" ],
'f14text16' => [ 679000.0, "Char16 in 40-char line (k14)" ],
'f24text16' => [ 272000.0, "Char16 in 23-char line (k24)" ],
'tr10text' => [ 2520000.0, "Char in 80-char line (TR 10)" ],
'tr24text' => [ 940000.0, "Char in 30-char line (TR 24)" ],
'polytext' => [ 2230000.0, "Char in 20/40/20 line (6x13, TR 10)" ],
'polytext16' => [ 369000.0, "Char16 in 7/14/7 line (k14, k24)" ],
'fitext' => [ 1350000.0, "Char in 80-char image line (6x13)" ],
'f8itext' => [ 1130000.0, "Char in 70-char image line (8x13)" ],
'f9itext' => [ 902000.0, "Char in 60-char image line (9x15)" ],
'f14itext16' => [ 449000.0, "Char16 in 40-char image line (k14)" ],
'f24itext16' => [ 169000.0, "Char16 in 23-char image line (k24)" ],
'tr10itext' => [ 1590000.0, "Char in 80-char image line (TR 10)" ],
'tr24itext' => [ 435000.0, "Char in 30-char image line (TR 24)" ],
'aa10text' => [ 53200.0, "Char in 80-char aa line (Charter 10)" ],
'aa24text' => [ 13300.0, "Char in 30-char aa line (Charter 24)" ],
'aaftext' => [ 45200.0, "Char in 80-char aa line (Courier 12)" ],
'a10text' => [ 53100.0, "Char in 80-char a line (Charter 10)" ],
'a24text' => [ 13300.0, "Char in 30-char a line (Charter 24)" ],
'aftext' => [ 45200.0, "Char in 80-char a line (Courier 12)" ],
'rgb10text' => [ 49400.0, "Char in 80-char rgb line (Charter 10)" ],
'rgb24text' => [ 10200.0, "Char in 30-char rgb line (Charter 24)" ],
'rgbftext' => [ 42200.0, "Char in 80-char rgb line (Courier 12)" ],
'caa10text' => [ 15300.0, "Char in 80-char aa core line (Charter 10)" ],
'caa24text' => [ 2540.0, "Char in 30-char aa core line (Charter 24)" ],
'caaftext' => [ 10900.0, "Char in 80-char aa core line (Courier 12)" ],
'ca10text' => [ 15300.0, "Char in 80-char a core line (Charter 10)" ],
'ca24text' => [ 2540.0, "Char in 30-char a core line (Charter 24)" ],
'caftext' => [ 10900.0, "Char in 80-char a core line (Courier 12)" ],
'rgb10text' => [ 15000.0, "Char in 80-char rgb core line (Charter 10)" ],
'rgb24text' => [ 2510.0, "Char in 30-char rgb core line (Charter 24)" ],
'rgbftext' => [ 10700.0, "Char in 80-char rgb core line (Courier 12)" ],
'scroll10' => [ 1310000.0, "Scroll 10x10 pixels" ],
'scroll100' => [ 52000.0, "Scroll 100x100 pixels" ],
'scroll500' => [ 2190.0, "Scroll 500x500 pixels" ],
'copywinwin10' => [ 1030000.0, "Copy 10x10 from window to window" ],
'copywinwin100' => [ 52200.0, "Copy 100x100 from window to window" ],
'copywinwin500' => [ 2080.0, "Copy 500x500 from window to window" ],
'copypixwin10' => [ 502000.0, "Copy 10x10 from pixmap to window" ],
'copypixwin100' => [ 20300.0, "Copy 100x100 from pixmap to window" ],
'copypixwin500' => [ 1020.0, "Copy 500x500 from pixmap to window" ],
'copywinpix10' => [ 7730.0, "Copy 10x10 from window to pixmap" ],
'copywinpix100' => [ 127.0, "Copy 100x100 from window to pixmap" ],
'copywinpix500' => [ 5.0, "Copy 500x500 from window to pixmap" ],
'copypixpix10' => [ 1260000.0, "Copy 10x10 from pixmap to pixmap" ],
'copypixpix100' => [ 56300.0, "Copy 100x100 from pixmap to pixmap" ],
'copypixpix500' => [ 2470.0, "Copy 500x500 from pixmap to pixmap" ],
'copyplane10' => [ 466000.0, "Copy 10x10 1-bit deep plane" ],
'copyplane100' => [ 13700.0, "Copy 100x100 1-bit deep plane" ],
'copyplane500' => [ 671.0, "Copy 500x500 1-bit deep plane" ],
'deepcopyplane10' => [ 151000.0, "Copy 10x10 n-bit deep plane" ],
'deepcopyplane100' => [ 6090.0, "Copy 100x100 n-bit deep plane" ],
'deepcopyplane500' => [ 278.0, "Copy 500x500 n-bit deep plane" ],
'putimage10' => [ 434000.0, "PutImage 10x10 square" ],
'putimage100' => [ 13600.0, "PutImage 100x100 square" ],
'putimage500' => [ 713.0, "PutImage 500x500 square" ],
'putimagexy10' => [ 321.0, "PutImage XY 10x10 square" ],
'putimagexy100' => [ 3.2, "PutImage XY 100x100 square" ],
'putimagexy500' => [ 0.1, "PutImage XY 500x500 square" ],
'shmput10' => [ 465000.0, "ShmPutImage 10x10 square" ],
'shmput100' => [ 20200.0, "ShmPutImage 100x100 square" ],
'shmput500' => [ 1020.0, "ShmPutImage 500x500 square" ],
'shmputxy10' => [ 31400.0, "ShmPutImage XY 10x10 square" ],
'shmputxy100' => [ 458.0, "ShmPutImage XY 100x100 square" ],
'shmputxy500' => [ 19.0, "ShmPutImage XY 500x500 square" ],
'getimage10' => [ 6650.0, "GetImage 10x10 square" ],
'getimage100' => [ 77.0, "GetImage 100x100 square" ],
'getimage500' => [ 3.1, "GetImage 500x500 square" ],
'getimagexy10' => [ 320.0, "GetImage XY 10x10 square" ],
'getimagexy100' => [ 3.2, "GetImage XY 100x100 square" ],
'getimagexy500' => [ 0.1, "GetImage XY 500x500 square" ],
'noop' => [ 8760000.0, "X protocol NoOperation" ],
'pointer' => [ 54800.0, "QueryPointer" ],
'prop' => [ 50900.0, "GetProperty" ],
'gc' => [ 1190000.0, "Change graphics context" ],
'create' => [ 597000.0, "Create and map subwindows (25 kids)" ],
'ucreate' => [ 1100000.0, "Create unmapped window (25 kids)" ],
'map' => [ 1350000.0, "Map window via parent (25 kids)" ],
'unmap' => [ 3360000.0, "Unmap window via parent (25 kids)" ],
'destroy' => [ 1190000.0, "Destroy window via parent (25 kids)" ],
'popup' => [ 660000.0, "Hide/expose window via popup (25 kids)" ],
'move' => [ 120000.0, "Move window (25 kids)" ],
'umove' => [ 1990000.0, "Moved unmapped window (25 kids)" ],
'movetree' => [ 877000.0, "Move window via parent (25 kids)" ],
'resize' => [ 136000.0, "Resize window (25 kids)" ],
'uresize' => [ 1870000.0, "Resize unmapped window (25 kids)" ],
'circulate' => [ 56300.0, "Circulate window (25 kids)" ],
'ucirculate' => [ 3630000.0, "Circulate Unmapped window (25 kids)" ],
};
# This array defines named groups of tests. This is designed to allow
# for simpler runs of related tests.
#
# Note that this array does *not* include all the x11perf tests. The idea
# here is to run a representative sampling of the available tests, to get
# a general idea of a system's performance, without taking forever to
# do it. If you want to do detailed analysis of an X server or graphics
# chip, then use x11perf directly.
my $testGroups = {
'rects' => [ "rect10", "rect100", "oddtilerect10", "eschertilerect100" ],
'lines' => [ "seg100c3", "wvseg100", "ddline100", "worect500" ],
'circle' => [ "circle500", "wddcircle100", "wpcircle100", "fspcircle100" ],
'ellipse' => [ "ddellipse100", "wddellipse100", "pellipse10", "fspellipse100" ],
'shapes' => [ "triangle10", "trap300", "oddostrap300", "eschertiletrap300" ],
'aashapes' => [ "aa4trap300", "aa1trap10", "aatrap2x300", "addaatrapezoid300" ],
'polys' => [ "complex10", "64poly100convex", "64poly10complex", "64poly100complex" ],
'text' => [ "polytext16", "rgb24text", "caa10text", "ca24text" ],
'blit' => [ "scroll100", "copypixwin10", "deepcopyplane10", "putimagexy500" ],
'window' => [ "popup", "move", "movetree", "resize" ],
};
############################################################################
# CODE
############################################################################
# Exec the given command, and catch its standard output.
# We return an array containing the PID and the filehandle on the
# process' standard output. It's up to the caller to wait for the command
# to terminate.
sub command {
my ( $cmd ) = @_;
my $pid = open(my $childFd, "-|");
if (!defined($pid)) {
die("Run: fork() failed (undef)\n");
} elsif ($pid == 0) {
exec($cmd);
die("Run: exec() failed (returned)\n");
}
return ( $pid, $childFd );
}
# Get data from running a system command. Used for things like getting
# the host OS from `uname -o` etc.
#
# Ignores initial blank lines from the command and returns the first
# non-blank line, with white space trimmed off.
sub runTest {
my ( $test, $reps, $time ) = @_;
my $tdata = $testData->{$test};
if (!defined($tdata)) {
printf STDERR "gfx-x11: No such test: %s\n", $test;
exit(9);
}
my $cmd = sprintf "x11perf -repeat %d -subs 25 -time %d -%s",
$reps, $time, $test;
my ( $pid, $fd ) = command($cmd);
my $average = 0;
while (<$fd>) {
chomp;
# Display the output for logging.
printf "%s\n", $_;
# Save the score.
my ( $reps, $per, $rate ) =
( m:([0-9]+)\s+trep\s+@\s+([0-9.]+)\s+msec\s+\(\s*([0-9.]+)/sec\): );
$average = $rate if (defined($rate));
}
# Close the command and wait for it to die. Bomb out if it failed.
# close($fd);
my $p = waitpid($pid, 0);
my $status = $?;
exit($status) if ($status != 0);
# Calculate and return the weighted result.
my $score = $average / $tdata->[0] * 1000.0;
printf "Test %s: %d --> %.1f\n", $test, $average, $score;
return $score;
}
sub runGroup {
my ( $group, $reps, $time ) = @_;
my $gdata = $testGroups->{$group};
if (!defined($gdata)) {
printf STDERR "gfx-x11: No such test group: %s\n", $group;
exit(9);
}
my $count = 0;
my $total = 0;
foreach my $test (@$gdata) {
$total += runTest($test, $reps, $time);
++$count;
}
$total /= $count;
$total;
}
############################################################################
# MAIN
############################################################################
sub main {
my @args = @_;
if (scalar(@args) < 3) {
printf STDERR "Usage: gfx-x11 group reps time\n";
exit(9);
}
my $reps = $args[1];
my $time = $args[2];
my $score = runGroup($args[0], $reps, $time);
printf STDERR "COUNT|%.1f|0|score\n", $score;
return 0;
}
exit(main(@ARGV));

View File

@@ -0,0 +1,46 @@
# Baseline benchmark scores, used for calculating index results.
# Scores from "George", a SPARCstation 20-61.
dhry2reg|10|lps|116700|116700|2
whetstone-double|10|MWIPS|55.0|55.0|2
execl|20|lps|43.0|43.0|1
fstime|20|KBps|3960|3960|1
fsbuffer|20|KBps|1655|1655|1
fsdisk|20|KBps|5800|5800|1
pipe|10|lps|12440|12440|2
context1|10|lps|4000|4000|2
spawn|20|lps|126|126|1
shell8|60|lpm|6|6|1
syscall|10|lps|15000|15000|2
# The shell1 test was added to the index in 5.0, and this baseline score
# was extrapolated to roughly match George's performance.
shell1|60|lpm|42.4|42.4|1
# The 2D baseline scores were derived from a test run on an HP Compaq nc8430
# with an ATI Mobility Radeon X1600 Video (256MB) — this is a fairly
# common modern adaptor with 3D. The baseline scores here are then
# 1/66.6 of the values from that run, to bring them roughly in line with
# George. (The HP has an index score of 666.6 single-process.)
2d-rects|3|score|15|15|1
#2d-lines|3|score|15|15|1
#2d-circle|3|score|15|15|1
2d-ellipse|3|score|15|15|1
#2d-shapes|3|score|15|15|1
2d-aashapes|3|score|15|15|1
#2d-polys|3|score|15|15|1
2d-text|3|score|15|15|1
2d-blit|3|score|15|15|1
2d-window|3|score|15|15|1
# The gears test score is derived from a test run on an HP Compaq nc8430
# with an ATI Mobility Radeon X1600 Video (256MB) — this is a fairly
# common modern adaptor with 3D. The baseline scores here are then
# 1/66.6 of the values from that run, to bring them roughly in line with
# George.
ubgears|20|fps|33.4|33.4|3
# The grep and sysexec tests were added in 5.1.1; they are not index tests,
# but these baseline scores were added for convenience.
grep|30|lpm|1|1|3
sysexec|10|lps|25|25|10

View File

@@ -0,0 +1,23 @@
#! /bin/sh
###############################################################################
# The BYTE UNIX Benchmarks - Release 3
# Module: multi.sh SID: 3.4 5/15/91 19:30:24
#
###############################################################################
# Bug reports, patches, comments, suggestions should be sent to:
#
# Ben Smith or Rick Grehan at BYTE Magazine
# ben@bytepb.UUCP rick_g@bytepb.UUCP
#
###############################################################################
# Modification Log:
#
###############################################################################
ID="@(#)multi.sh:3.4 -- 5/15/91 19:30:24";
instance=1
while [ $instance -le $1 ]; do
/bin/sh "$UB_BINDIR/tst.sh" &
instance=`expr $instance + 1`
done
wait

View File

@@ -0,0 +1,19 @@
#! /bin/sh
###############################################################################
# The BYTE UNIX Benchmarks - Release 3
# Module: tst.sh SID: 3.4 5/15/91 19:30:24
#
###############################################################################
# Bug reports, patches, comments, suggestions should be sent to:
#
# Ben Smith or Rick Grehan at BYTE Magazine
# ben@bytepb.UUCP rick_g@bytepb.UUCP
#
###############################################################################
# Modification Log:
#
###############################################################################
ID="@(#)tst.sh:3.4 -- 5/15/91 19:30:24";
sort >sort.$$ <sort.src
grep the sort.$$ | tee grep.$$ | wc > wc.$$
rm sort.$$ grep.$$ wc.$$

View File

@@ -0,0 +1,14 @@
# # # # # # # ##### ###### # # #### # #
# # ## # # # # # # # ## # # # # #
# # # # # # ## ##### ##### # # # # ######
# # # # # # ## # # # # # # # # #
# # # ## # # # # # # # ## # # # #
#### # # # # # ##### ###### # # #### # #
Version 5.1.2 Based on the Byte Magazine Unix Benchmark
Multi-CPU version Version 5 revisions by Ian Smith,
Sunnyvale, CA, USA
December 22, 2007 johantheghost at yahoo period com

View File

@@ -0,0 +1,4 @@
#!/bin/sh
export CC=cc
export MINIX=1
./Run

View File

@@ -0,0 +1,108 @@
/*******************************************************************************
* The BYTE UNIX Benchmarks - Release 3
* Module: arith.c SID: 3.3 5/15/91 19:30:19
*
*******************************************************************************
* Bug reports, patches, comments, suggestions should be sent to:
*
* Ben Smith, Rick Grehan or Tom Yager
* ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
*
*******************************************************************************
* Modification Log:
* May 12, 1989 - modified empty loops to avoid nullifying by optimizing
* compilers
* August 28, 1990 - changed timing relationship--now returns total number
* of iterations (ty)
* November 9, 1990 - made changes suggested by Keith Cantrell
* (digi!kcantrel) to defeat optimization
* to non-existence
* October 22, 1997 - code cleanup to remove ANSI C compiler warnings
* Andy Kahn <kahn@zk3.dec.com>
*
******************************************************************************/
char SCCSid[] = "@(#) @(#)arith.c:3.3 -- 5/15/91 19:30:19";
/*
* arithmetic test
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "timeit.c"
int dumb_stuff(int);
unsigned long iter;
/* this function is called when the alarm expires */
void report(int sig)
{
fprintf(stderr,"COUNT|%ld|1|lps\n", iter);
exit(0);
}
int main(int argc, char *argv[])
{
int duration;
int result = 0;
if (argc != 2) {
printf("Usage: %s duration\n", argv[0]);
exit(1);
}
duration = atoi(argv[1]);
/* set up alarm call */
iter = 0; /* init iteration count */
wake_me(duration, report);
/* this loop will be interrupted by the alarm call */
while (1)
{
/* in switching to time-based (instead of iteration-based),
the following statement was added. It should not skew
the timings too much--there was an increment and test
in the "while" expression above. The only difference is
that now we're incrementing a long instead of an int. (ty) */
++iter;
/* the loop calls a function to insure that something is done
the results of the function are fed back in (just so they
they won't be thrown away. A loop with
unused assignments may get optimized out of existence */
result = dumb_stuff(result);
}
}
/************************** dumb_stuff *******************/
int dumb_stuff(i)
int i;
{
#ifndef arithoh
datum x, y, z;
z = 0;
#endif
/*
* 101
* sum i*i/(i*i-1)
* i=2
*/
/* notice that the i value is always reset by the loop */
for (i=2; i<=101; i++)
{
#ifndef arithoh
x = i;
y = x*x;
z += y/(y-1);
}
return(x+y+z);
#else
}
return(0);
#endif
}

View File

@@ -0,0 +1,595 @@
/*******************************************************************************
* The BYTE UNIX Benchmarks - Release 3
* Module: big.c SID: 3.3 5/15/91 19:30:18
*
*******************************************************************************
* Bug reports, patches, comments, suggestions should be sent to:
*
* Ben Smith, Rick Grehan or Tom Yager
* ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
*
*******************************************************************************
* Modification Log:
* 10/22/97 - code cleanup to remove ANSI C compiler warnings
* Andy Kahn <kahn@zk3.dec.com>
*
******************************************************************************/
/*
* dummy code for execl test [ old version of makework.c ]
*
* makework [ -r rate ] [ -c copyfile ] nusers
*
* job streams are specified on standard input with lines of the form
* full_path_name_for_command [ options ] [ <standard_input_file ]
*
* "standard input" is send to all nuser instances of the commands in the
* job streams at a rate not in excess of "rate" characters per second
* per command
*
*/
/* this code is included in other files and therefore has no SCCSid */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
#include <fcntl.h>
#include <time.h>
#include <string.h>
#include <sys/wait.h>
#define DEF_RATE 5.0
#define GRANULE 5
#define CHUNK 60
#define MAXCHILD 12
#define MAXWORK 10
/* Can't seem to get this declared in the headers... */
extern int kill(pid_t pid, int sig);
void wrapup(char *);
void onalarm(int);
void pipeerr(int sig);
void grunt(int sig);
void getwork(void);
#if debug
void dumpwork(void);
#endif
void fatal(char *s);
float thres;
float est_rate = DEF_RATE;
int nusers; /* number of concurrent users to be simulated by
* this process */
int firstuser; /* ordinal identification of first user for this
* process */
int nwork = 0; /* number of job streams */
int exit_status = 0; /* returned to parent */
int sigpipe; /* pipe write error flag */
struct st_work {
char *cmd; /* name of command to run */
char **av; /* arguments to command */
char *input; /* standard input buffer */
int inpsize; /* size of standard input buffer */
char *outf; /* standard output (filename) */
} work[MAXWORK];
struct {
int xmit; /* # characters sent */
char *bp; /* std input buffer pointer */
int blen; /* std input buffer length */
int fd; /* stdin to command */
int pid; /* child PID */
char *line; /* start of input line */
int firstjob; /* inital piece of work */
int thisjob; /* current piece of work */
} child[MAXCHILD], *cp;
int main(int argc, char *argv[])
{
int i;
int l;
int fcopy = 0; /* fd for copy output */
int master = 1; /* the REAL master, == 0 for clones */
int nchild; /* no. of children for a clone to run */
int done; /* count of children finished */
int output; /* aggregate output char count for all
children */
int c;
int thiswork = 0; /* next job stream to allocate */
int nch; /* # characters to write */
int written; /* # characters actully written */
char logname[15]; /* name of the log file(s) */
int pvec[2]; /* for pipes */
char *p;
char *prog; /* my name */
#if ! debug
freopen("masterlog.00", "a", stderr);
#endif
prog = argv[0];
while (argc > 1 && argv[1][0] == '-') {
p = &argv[1][1];
argc--;
argv++;
while (*p) {
switch (*p) {
case 'r':
est_rate = atoi(argv[1]);
sscanf(argv[1], "%f", &est_rate);
if (est_rate <= 0) {
fprintf(stderr, "%s: bad rate, reset to %.2f chars/sec\n", prog, DEF_RATE);
est_rate = DEF_RATE;
}
argc--;
argv++;
break;
case 'c':
fcopy = open(argv[1], 1);
if (fcopy < 0)
fcopy = creat(argv[1], 0600);
if (fcopy < 0) {
fprintf(stderr, "%s: cannot open copy file '%s'\n",
prog, argv[1]);
exit(2);
}
lseek(fcopy, 0L, 2); /* append at end of file */
argc--;
argv++;
break;
default:
fprintf(stderr, "%s: bad flag '%c'\n", prog, *p);
exit(4);
}
p++;
}
}
if (argc < 2) {
fprintf(stderr, "%s: missing nusers\n", prog);
exit(4);
}
nusers = atoi(argv[1]);
if (nusers < 1) {
fprintf(stderr, "%s: impossible nusers (%d<-%s)\n", prog, nusers, argv[1]);
exit(4);
}
fprintf(stderr, "%d Users\n", nusers);
argc--;
argv++;
/* build job streams */
getwork();
#if debug
dumpwork();
#endif
/* clone copies of myself to run up to MAXCHILD jobs each */
firstuser = MAXCHILD;
fprintf(stderr, "master pid %d\n", getpid());
fflush(stderr);
while (nusers > MAXCHILD) {
fflush(stderr);
if (nusers >= 2*MAXCHILD)
/* the next clone must run MAXCHILD jobs */
nchild = MAXCHILD;
else
/* the next clone must run the leftover jobs */
nchild = nusers - MAXCHILD;
if ((l = fork()) == -1) {
/* fork failed */
fatal("** clone fork failed **\n");
goto bepatient;
} else if (l > 0) {
fprintf(stderr, "master clone pid %d\n", l);
/* I am the master with nchild fewer jobs to run */
nusers -= nchild;
firstuser += MAXCHILD;
continue;
} else {
/* I am a clone, run MAXCHILD jobs */
#if ! debug
sprintf(logname, "masterlog.%02d", firstuser/MAXCHILD);
freopen(logname, "w", stderr);
#endif
master = 0;
nusers = nchild;
break;
}
}
if (master)
firstuser = 0;
close(0);
for (i = 0; i < nusers; i++ ) {
fprintf(stderr, "user %d job %d ", firstuser+i, thiswork);
if (pipe(pvec) == -1) {
/* this is fatal */
fatal("** pipe failed **\n");
goto bepatient;
}
fflush(stderr);
if ((child[i].pid = fork()) == 0) {
int fd;
/* the command */
if (pvec[0] != 0) {
close(0);
dup(pvec[0]);
}
#if ! debug
sprintf(logname, "userlog.%02d", firstuser+i);
freopen(logname, "w", stderr);
#endif
for (fd = 3; fd < 24; fd++)
close(fd);
if (work[thiswork].outf[0] != '\0') {
/* redirect std output */
char *q;
for (q = work[thiswork].outf; *q != '\n'; q++) ;
*q = '\0';
if (freopen(work[thiswork].outf, "w", stdout) == NULL) {
fprintf(stderr, "makework: cannot open %s for std output\n",
work[thiswork].outf);
fflush(stderr);
}
*q = '\n';
}
execv(work[thiswork].cmd, work[thiswork].av);
/* don't expect to get here! */
fatal("** exec failed **\n");
goto bepatient;
}
else if (child[i].pid == -1) {
fatal("** fork failed **\n");
goto bepatient;
}
else {
close(pvec[0]);
child[i].fd = pvec[1];
child[i].line = child[i].bp = work[thiswork].input;
child[i].blen = work[thiswork].inpsize;
child[i].thisjob = thiswork;
child[i].firstjob = thiswork;
fprintf(stderr, "pid %d pipe fd %d", child[i].pid, child[i].fd);
if (work[thiswork].outf[0] != '\0') {
char *q;
fprintf(stderr, " > ");
for (q=work[thiswork].outf; *q != '\n'; q++)
fputc(*q, stderr);
}
fputc('\n', stderr);
thiswork++;
if (thiswork >= nwork)
thiswork = 0;
}
}
fflush(stderr);
srand(time(0));
thres = 0;
done = output = 0;
for (i = 0; i < nusers; i++) {
if (child[i].blen == 0)
done++;
else
thres += est_rate * GRANULE;
}
est_rate = thres;
signal(SIGALRM, onalarm);
signal(SIGPIPE, pipeerr);
alarm(GRANULE);
while (done < nusers) {
for (i = 0; i < nusers; i++) {
cp = &child[i];
if (cp->xmit >= cp->blen) continue;
l = rand() % CHUNK + 1; /* 1-CHUNK chars */
if (l == 0) continue;
if (cp->xmit + l > cp->blen)
l = cp->blen - cp->xmit;
p = cp->bp;
cp->bp += l;
cp->xmit += l;
#if debug
fprintf(stderr, "child %d, %d processed, %d to go\n", i, cp->xmit, cp->blen - cp->xmit);
#endif
while (p < cp->bp) {
if (*p == '\n' || (p == &cp->bp[-1] && cp->xmit >= cp->blen)) {
/* write it out */
nch = p - cp->line + 1;
if ((written = write(cp->fd, cp->line, nch)) != nch) {
/* argh! */
cp->line[nch] = '\0';
fprintf(stderr, "user %d job %d cmd %s ",
firstuser+i, cp->thisjob, cp->line);
fprintf(stderr, "write(,,%d) returns %d\n", nch, written);
if (sigpipe)
fatal("** SIGPIPE error **\n");
else
fatal("** write error **\n");
goto bepatient;
}
if (fcopy)
write(fcopy, cp->line, p - cp->line + 1);
#if debug
fprintf(stderr, "child %d gets \"", i);
{
char *q = cp->line;
while (q <= p) {
if (*q >= ' ' && *q <= '~')
fputc(*q, stderr);
else
fprintf(stderr, "\\%03o", *q);
q++;
}
}
fputc('"', stderr);
#endif
cp->line = &p[1];
}
p++;
}
if (cp->xmit >= cp->blen) {
done++;
close(cp->fd);
#if debug
fprintf(stderr, "child %d, close std input\n", i);
#endif
}
output += l;
}
while (output > thres) {
pause();
#if debug
fprintf(stderr, "after pause: output, thres, done %d %.2f %d\n", output, thres, done);
#endif
}
}
bepatient:
alarm(0);
/****
* If everything is going OK, we should simply be able to keep
* looping unitil 'wait' fails, however some descendent process may
* be in a state from which it can never exit, and so a timeout
* is used.
* 5 minutes should be ample, since the time to run all jobs is of
* the order of 5-10 minutes, however some machines are painfully slow,
* so the timeout has been set at 20 minutes (1200 seconds).
****/
signal(SIGALRM, grunt);
alarm(1200);
while ((c = wait(&l)) != -1) {
for (i = 0; i < nusers; i++) {
if (c == child[i].pid) {
fprintf(stderr, "user %d job %d pid %d done", firstuser+i, child[i].thisjob, c);
if (l != 0) {
if (l & 0x7f)
fprintf(stderr, " status %d", l & 0x7f);
if (l & 0xff00)
fprintf(stderr, " exit code %d", (l>>8) & 0xff);
exit_status = 4;
}
fputc('\n', stderr);
c = child[i].pid = -1;
break;
}
}
if (c != -1) {
fprintf(stderr, "master clone done, pid %d ", c);
if (l != 0) {
if (l & 0x7f)
fprintf(stderr, " status %d", l & 0x7f);
if (l & 0xff00)
fprintf(stderr, " exit code %d", (l>>8) & 0xff);
exit_status = 4;
}
fputc('\n', stderr);
}
}
alarm(0);
wrapup("Finished waiting ...");
exit(0);
}
void onalarm(int foo)
{
thres += est_rate;
signal(SIGALRM, onalarm);
alarm(GRANULE);
}
void grunt(int sig)
{
/* timeout after label "bepatient" in main */
exit_status = 4;
wrapup("Timed out waiting for jobs to finish ...");
}
void pipeerr(int sig)
{
sigpipe++;
}
void wrapup(char *reason)
{
int i;
int killed = 0;
fflush(stderr);
for (i = 0; i < nusers; i++) {
if (child[i].pid > 0 && kill(child[i].pid, SIGKILL) != -1) {
if (!killed) {
killed++;
fprintf(stderr, "%s\n", reason);
fflush(stderr);
}
fprintf(stderr, "user %d job %d pid %d killed off\n", firstuser+i, child[i].thisjob, child[i].pid);
fflush(stderr);
}
}
exit(exit_status);
}
#define MAXLINE 512
void getwork(void)
{
int i;
int f;
int ac=0;
char *lp = (void *)0;
char *q = (void *)0;
struct st_work *w = (void *)0;
char line[MAXLINE];
char c;
while (fgets(line, MAXLINE, stdin) != NULL) {
if (nwork >= MAXWORK) {
fprintf(stderr, "Too many jobs specified, .. increase MAXWORK\n");
exit(4);
}
w = &work[nwork];
lp = line;
i = 1;
while (*lp && *lp != ' ') {
i++;
lp++;
}
w->cmd = (char *)malloc(i);
strncpy(w->cmd, line, i-1);
w->cmd[i-1] = '\0';
w->inpsize = 0;
w->input = "";
/* start to build arg list */
ac = 2;
w->av = (char **)malloc(2*sizeof(char *));
q = w->cmd;
while (*q) q++;
q--;
while (q >= w->cmd) {
if (*q == '/') {
q++;
break;
}
q--;
}
w->av[0] = q;
while (*lp) {
if (*lp == ' ') {
/* space */
lp++;
continue;
}
else if (*lp == '<') {
/* standard input for this job */
q = ++lp;
while (*lp && *lp != ' ') lp++;
c = *lp;
*lp = '\0';
if ((f = open(q, 0)) == -1) {
fprintf(stderr, "cannot open input file (%s) for job %d\n",
q, nwork);
exit(4);
}
/* gobble input */
w->input = (char *)malloc(512);
while ((i = read(f, &w->input[w->inpsize], 512)) > 0) {
w->inpsize += i;
w->input = (char *)realloc(w->input, w->inpsize+512);
}
w->input = (char *)realloc(w->input, w->inpsize);
close(f);
/* extract stdout file name from line beginning "C=" */
w->outf = "";
for (q = w->input; q < &w->input[w->inpsize-10]; q++) {
if (*q == '\n' && strncmp(&q[1], "C=", 2) == 0) {
w->outf = &q[3];
break;
}
}
#if debug
if (*w->outf) {
fprintf(stderr, "stdout->");
for (q=w->outf; *q != '\n'; q++)
fputc(*q, stderr);
fputc('\n', stderr);
}
#endif
}
else {
/* a command option */
ac++;
w->av = (char **)realloc(w->av, ac*sizeof(char *));
q = lp;
i = 1;
while (*lp && *lp != ' ') {
lp++;
i++;
}
w->av[ac-2] = (char *)malloc(i);
strncpy(w->av[ac-2], q, i-1);
w->av[ac-2][i-1] = '\0';
}
}
w->av[ac-1] = (char *)0;
nwork++;
}
}
#if debug
void dumpwork(void)
{
int i;
int j;
for (i = 0; i < nwork; i++) {
fprintf(stderr, "job %d: cmd: %s\n", i, work[i].cmd);
j = 0;
while (work[i].av[j]) {
fprintf(stderr, "argv[%d]: %s\n", j, work[i].av[j]);
j++;
}
fprintf(stderr, "input: %d chars text: ", work[i].inpsize);
if (work[i].input == (char *)0)
fprintf(stderr, "<NULL>\n");
else {
register char *pend;
char *p;
char c;
p = work[i].input;
while (*p) {
pend = p;
while (*pend && *pend != '\n')
pend++;
c = *pend;
*pend = '\0';
fprintf(stderr, "%s\n", p);
*pend = c;
p = &pend[1];
}
}
}
}
#endif
void fatal(char *s)
{
int i;
fprintf(stderr, s);
fflush(stderr);
perror("Reason?");
fflush(stderr);
for (i = 0; i < nusers; i++) {
if (child[i].pid > 0 && kill(child[i].pid, SIGKILL) != -1) {
fprintf(stderr, "pid %d killed off\n", child[i].pid);
fflush(stderr);
}
}
exit_status = 4;
}

View File

@@ -0,0 +1,125 @@
/*******************************************************************************
* The BYTE UNIX Benchmarks - Release 3
* Module: context1.c SID: 3.3 5/15/91 19:30:18
*
*******************************************************************************
* Bug reports, patches, comments, suggestions should be sent to:
*
* Ben Smith, Rick Grehan or Tom Yager
* ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
*
*******************************************************************************
* Modification Log:
* $Header: context1.c,v 3.4 87/06/22 14:22:59 kjmcdonell Beta $
* August 28, 1990 - changed timing routines--now returns total number of
* iterations in specified time period
* October 22, 1997 - code cleanup to remove ANSI C compiler warnings
* Andy Kahn <kahn@zk3.dec.com>
*
******************************************************************************/
char SCCSid[] = "@(#) @(#)context1.c:3.3 -- 5/15/91 19:30:18";
/*
* Context switching via synchronized unbuffered pipe i/o
*
*/
#ifdef MINIX
#include <signal.h>
#endif
#ifdef LINUX
#include <sys/types.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "timeit.c"
unsigned long iter;
#ifdef MINIX
pid_t child;
#endif
void report(int sig)
{
fprintf(stderr, "COUNT|%lu|1|lps\n", iter);
#ifdef MINIX
kill(child, SIGKILL);
#endif
exit(0);
}
int main(int argc, char *argv[])
{
int duration;
unsigned long check;
int p1[2], p2[2];
if (argc != 2) {
fprintf(stderr, "Usage: context duration\n");
exit(1);
}
duration = atoi(argv[1]);
/* set up alarm call */
iter = 0;
wake_me(duration, report);
if (pipe(p1) || pipe(p2)) {
perror("pipe create failed");
exit(1);
}
#ifndef MINIX
if (fork()) { /* parent process */
#else
if ((child = fork())) {
#endif
/* master, write p1 & read p2 */
close(p1[0]); close(p2[1]);
while (1) {
if (write(p1[1], (char *)&iter, sizeof(iter)) != sizeof(iter)) {
if ((errno != 0) && (errno != EINTR))
perror("master write failed");
exit(1);
}
if (read(p2[0], (char *)&check, sizeof(check)) != sizeof(check)) {
if ((errno != 0) && (errno != EINTR))
perror("master read failed");
exit(1);
}
if (check != iter) {
fprintf(stderr, "Master sync error: expect %lu, got %lu\n",
iter, check);
exit(2);
}
iter++;
}
}
else { /* child process */
unsigned long iter1;
iter1 = 0;
/* slave, read p1 & write p2 */
close(p1[1]); close(p2[0]);
while (1) {
if (read(p1[0], (char *)&check, sizeof(check)) != sizeof(check)) {
if ((errno != 0) && (errno != EINTR))
perror("slave read failed");
exit(1);
}
if (check != iter1) {
fprintf(stderr, "Slave sync error: expect %lu, got %lu\n",
iter, check);
exit(2);
}
if (write(p2[1], (char *)&iter1, sizeof(iter1)) != sizeof(check)) {
if ((errno != 0) && (errno != EINTR))
perror("slave write failed");
exit(1);
}
iter1++;
}
}
}

View File

@@ -0,0 +1,435 @@
/*****************************************************************************
* The BYTE UNIX Benchmarks - Release 3
* Module: dhry.h SID: 3.4 5/15/91 19:30:21
*
*****************************************************************************
* Bug reports, patches, comments, suggestions should be sent to:
*
* Ben Smith, Rick Grehan or Tom Yager
* ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
*
*****************************************************************************
* Modification Log:
* addapted from:
*
*
* "DHRYSTONE" Benchmark Program
* -----------------------------
*
* Version: C, Version 2.1
*
* File: dhry.h (part 1 of 3)
*
* Date: May 25, 1988
*
* Author: Reinhold P. Weicker
* Siemens AG, AUT E 51
* Postfach 3220
* 8520 Erlangen
* Germany (West)
* Phone: [+49]-9131-7-20330
* (8-17 Central European Time)
* Usenet: ..!mcvax!unido!estevax!weicker
*
* Original Version (in Ada) published in
* "Communications of the ACM" vol. 27., no. 10 (Oct. 1984),
* pp. 1013 - 1030, together with the statistics
* on which the distribution of statements etc. is based.
*
* In this C version, the following C library functions are used:
* - strcpy, strcmp (inside the measurement loop)
* - printf, scanf (outside the measurement loop)
* In addition, Berkeley UNIX system calls "times ()" or "time ()"
* are used for execution time measurement. For measurements
* on other systems, these calls have to be changed.
*
* Collection of Results:
* Reinhold Weicker (address see above) and
*
* Rick Richardson
* PC Research. Inc.
* 94 Apple Orchard Drive
* Tinton Falls, NJ 07724
* Phone: (201) 834-1378 (9-17 EST)
* Usenet: ...!seismo!uunet!pcrat!rick
*
* Please send results to Rick Richardson and/or Reinhold Weicker.
* Complete information should be given on hardware and software used.
* Hardware information includes: Machine type, CPU, type and size
* of caches; for microprocessors: clock frequency, memory speed
* (number of wait states).
* Software information includes: Compiler (and runtime library)
* manufacturer and version, compilation switches, OS version.
* The Operating System version may give an indication about the
* compiler; Dhrystone itself performs no OS calls in the measurement loop.
*
* The complete output generated by the program should be mailed
* such that at least some checks for correctness can be made.
*
***************************************************************************
*
* History: This version C/2.1 has been made for two reasons:
*
* 1) There is an obvious need for a common C version of
* Dhrystone, since C is at present the most popular system
* programming language for the class of processors
* (microcomputers, minicomputers) where Dhrystone is used most.
* There should be, as far as possible, only one C version of
* Dhrystone such that results can be compared without
* restrictions. In the past, the C versions distributed
* by Rick Richardson (Version 1.1) and by Reinhold Weicker
* had small (though not significant) differences.
*
* 2) As far as it is possible without changes to the Dhrystone
* statistics, optimizing compilers should be prevented from
* removing significant statements.
*
* This C version has been developed in cooperation with
* Rick Richardson (Tinton Falls, NJ), it incorporates many
* ideas from the "Version 1.1" distributed previously by
* him over the UNIX network Usenet.
* I also thank Chaim Benedelac (National Semiconductor),
* David Ditzel (SUN), Earl Killian and John Mashey (MIPS),
* Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley)
* for their help with comments on earlier versions of the
* benchmark.
*
* Changes: In the initialization part, this version follows mostly
* Rick Richardson's version distributed via Usenet, not the
* version distributed earlier via floppy disk by Reinhold Weicker.
* As a concession to older compilers, names have been made
* unique within the first 8 characters.
* Inside the measurement loop, this version follows the
* version previously distributed by Reinhold Weicker.
*
* At several places in the benchmark, code has been added,
* but within the measurement loop only in branches that
* are not executed. The intention is that optimizing compilers
* should be prevented from moving code out of the measurement
* loop, or from removing code altogether. Since the statements
* that are executed within the measurement loop have NOT been
* changed, the numbers defining the "Dhrystone distribution"
* (distribution of statements, operand types and locality)
* still hold. Except for sophisticated optimizing compilers,
* execution times for this version should be the same as
* for previous versions.
*
* Since it has proven difficult to subtract the time for the
* measurement loop overhead in a correct way, the loop check
* has been made a part of the benchmark. This does have
* an impact - though a very minor one - on the distribution
* statistics which have been updated for this version.
*
* All changes within the measurement loop are described
* and discussed in the companion paper "Rationale for
* Dhrystone version 2".
*
* Because of the self-imposed limitation that the order and
* distribution of the executed statements should not be
* changed, there are still cases where optimizing compilers
* may not generate code for some statements. To a certain
* degree, this is unavoidable for small synthetic benchmarks.
* Users of the benchmark are advised to check code listings
* whether code is generated for all statements of Dhrystone.
*
* Version 2.1 is identical to version 2.0 distributed via
* the UNIX network Usenet in March 1988 except that it corrects
* some minor deficiencies that were found by users of version 2.0.
* The only change within the measurement loop is that a
* non-executed "else" part was added to the "if" statement in
* Func_3, and a non-executed "else" part removed from Proc_3.
*
***************************************************************************
*
* Defines: The following "Defines" are possible:
* -DREG=register (default: Not defined)
* As an approximation to what an average C programmer
* might do, the "register" storage class is applied
* (if enabled by -DREG=register)
* - for local variables, if they are used (dynamically)
* five or more times
* - for parameters if they are used (dynamically)
* six or more times
* Note that an optimal "register" strategy is
* compiler-dependent, and that "register" declarations
* do not necessarily lead to faster execution.
* -DNOSTRUCTASSIGN (default: Not defined)
* Define if the C compiler does not support
* assignment of structures.
* -DNOENUMS (default: Not defined)
* Define if the C compiler does not support
* enumeration types.
* -DTIMES (default)
* -DTIME
* The "times" function of UNIX (returning process times)
* or the "time" function (returning wallclock time)
* is used for measurement.
* For single user machines, "time ()" is adequate. For
* multi-user machines where you cannot get single-user
* access, use the "times ()" function. If you have
* neither, use a stopwatch in the dead of night.
* "printf"s are provided marking the points "Start Timer"
* and "Stop Timer". DO NOT use the UNIX "time(1)"
* command, as this will measure the total time to
* run this program, which will (erroneously) include
* the time to allocate storage (malloc) and to perform
* the initialization.
* -DHZ=nnn
* In Berkeley UNIX, the function "times" returns process
* time in 1/HZ seconds, with HZ = 60 for most systems.
* CHECK YOUR SYSTEM DESCRIPTION BEFORE YOU JUST APPLY
* A VALUE.
*
***************************************************************************
*
* Compilation model and measurement (IMPORTANT):
*
* This C version of Dhrystone consists of three files:
* - dhry.h (this file, containing global definitions and comments)
* - dhry_1.c (containing the code corresponding to Ada package Pack_1)
* - dhry_2.c (containing the code corresponding to Ada package Pack_2)
*
* The following "ground rules" apply for measurements:
* - Separate compilation
* - No procedure merging
* - Otherwise, compiler optimizations are allowed but should be indicated
* - Default results are those without register declarations
* See the companion paper "Rationale for Dhrystone Version 2" for a more
* detailed discussion of these ground rules.
*
* For 16-Bit processors (e.g. 80186, 80286), times for all compilation
* models ("small", "medium", "large" etc.) should be given if possible,
* together with a definition of these models for the compiler system used.
*
**************************************************************************
*
* Dhrystone (C version) statistics:
*
* [Comment from the first distribution, updated for version 2.
* Note that because of language differences, the numbers are slightly
* different from the Ada version.]
*
* The following program contains statements of a high level programming
* language (here: C) in a distribution considered representative:
*
* assignments 52 (51.0 %)
* control statements 33 (32.4 %)
* procedure, function calls 17 (16.7 %)
*
* 103 statements are dynamically executed. The program is balanced with
* respect to the three aspects:
*
* - statement type
* - operand type
* - operand locality
* operand global, local, parameter, or constant.
*
* The combination of these three aspects is balanced only approximately.
*
* 1. Statement Type:
* ----------------- number
*
* V1 = V2 9
* (incl. V1 = F(..)
* V = Constant 12
* Assignment, 7
* with array element
* Assignment, 6
* with record component
* --
* 34 34
*
* X = Y +|-|"&&"|"|" Z 5
* X = Y +|-|"==" Constant 6
* X = X +|- 1 3
* X = Y *|/ Z 2
* X = Expression, 1
* two operators
* X = Expression, 1
* three operators
* --
* 18 18
*
* if .... 14
* with "else" 7
* without "else" 7
* executed 3
* not executed 4
* for ... 7 | counted every time
* while ... 4 | the loop condition
* do ... while 1 | is evaluated
* switch ... 1
* break 1
* declaration with 1
* initialization
* --
* 34 34
*
* P (...) procedure call 11
* user procedure 10
* library procedure 1
* X = F (...)
* function call 6
* user function 5
* library function 1
* --
* 17 17
* ---
* 103
*
* The average number of parameters in procedure or function calls
* is 1.82 (not counting the function values as implicit parameters).
*
*
* 2. Operators
* ------------
* number approximate
* percentage
*
* Arithmetic 32 50.8
*
* + 21 33.3
* - 7 11.1
* * 3 4.8
* / (int div) 1 1.6
*
* Comparison 27 42.8
*
* == 9 14.3
* /= 4 6.3
* > 1 1.6
* < 3 4.8
* >= 1 1.6
* <= 9 14.3
*
* Logic 4 6.3
*
* && (AND-THEN) 1 1.6
* | (OR) 1 1.6
* ! (NOT) 2 3.2
*
* -- -----
* 63 100.1
*
*
* 3. Operand Type (counted once per operand reference):
* ---------------
* number approximate
* percentage
*
* Integer 175 72.3 %
* Character 45 18.6 %
* Pointer 12 5.0 %
* String30 6 2.5 %
* Array 2 0.8 %
* Record 2 0.8 %
* --- -------
* 242 100.0 %
*
* When there is an access path leading to the final operand (e.g. a record
* component), only the final data type on the access path is counted.
*
*
* 4. Operand Locality:
* -------------------
* number approximate
* percentage
*
* local variable 114 47.1 %
* global variable 22 9.1 %
* parameter 45 18.6 %
* value 23 9.5 %
* reference 22 9.1 %
* function result 6 2.5 %
* constant 55 22.7 %
* --- -------
* 242 100.0 %
*
*
* The program does not compute anything meaningful, but it is syntactically
* and semantically correct. All variables have a value assigned to them
* before they are used as a source operand.
*
* There has been no explicit effort to account for the effects of a
* cache, or to balance the use of long or short displacements for code or
* data.
*
***************************************************************************
*/
/* Compiler and system dependent definitions: */
#ifndef TIME
#define TIMES
#endif
/* Use times(2) time function unless */
/* explicitly defined otherwise */
#ifdef TIMES
#include <sys/types.h>
#include <sys/times.h>
/* for "times" */
#endif
#define Mic_secs_Per_Second 1000000.0
/* Berkeley UNIX C returns process times in seconds/HZ */
#ifdef NOSTRUCTASSIGN
#define structassign(d, s) memcpy(&(d), &(s), sizeof(d))
#else
#define structassign(d, s) d = s
#endif
#ifdef NOENUM
#define Ident_1 0
#define Ident_2 1
#define Ident_3 2
#define Ident_4 3
#define Ident_5 4
typedef int Enumeration;
#else
typedef enum {Ident_1, Ident_2, Ident_3, Ident_4, Ident_5}
Enumeration;
#endif
/* for boolean and enumeration types in Ada, Pascal */
/* General definitions: */
#include <stdio.h>
/* for strcpy, strcmp */
#define Null 0
/* Value of a Null pointer */
#define true 1
#define false 0
typedef int One_Thirty;
typedef int One_Fifty;
typedef char Capital_Letter;
typedef int Boolean;
typedef char Str_30 [31];
typedef int Arr_1_Dim [50];
typedef int Arr_2_Dim [50] [50];
typedef struct record
{
struct record *Ptr_Comp;
Enumeration Discr;
union {
struct {
Enumeration Enum_Comp;
int Int_Comp;
char Str_Comp [31];
} var_1;
struct {
Enumeration E_Comp_2;
char Str_2_Comp [31];
} var_2;
struct {
char Ch_1_Comp;
char Ch_2_Comp;
} var_3;
} variant;
} Rec_Type, *Rec_Pointer;

View File

@@ -0,0 +1,427 @@
/*****************************************************************************
* The BYTE UNIX Benchmarks - Release 3
* Module: dhry_1.c SID: 3.4 5/15/91 19:30:21
*
*****************************************************************************
* Bug reports, patches, comments, suggestions should be sent to:
*
* Ben Smith, Rick Grehan or Tom Yager
* ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
*
*****************************************************************************
*
* *** WARNING **** With BYTE's modifications applied, results obtained with
* ******* this version of the Dhrystone program may not be applicable
* to other versions.
*
* Modification Log:
* 10/22/97 - code cleanup to remove ANSI C compiler warnings
* Andy Kahn <kahn@zk3.dec.com>
*
* Adapted from:
*
* "DHRYSTONE" Benchmark Program
* -----------------------------
*
* Version: C, Version 2.1
*
* File: dhry_1.c (part 2 of 3)
*
* Date: May 25, 1988
*
* Author: Reinhold P. Weicker
*
***************************************************************************/
char SCCSid[] = "@(#) @(#)dhry_1.c:3.4 -- 5/15/91 19:30:21";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dhry.h"
#include "timeit.c"
unsigned long Run_Index;
Enumeration Func_1(Capital_Letter, Capital_Letter);
void report(int sig)
{
fprintf(stderr,"COUNT|%ld|1|lps\n", Run_Index);
exit(0);
}
/* Global Variables: */
Rec_Pointer Ptr_Glob,
Next_Ptr_Glob;
int Int_Glob;
Boolean Bool_Glob;
char Ch_1_Glob,
Ch_2_Glob;
int Arr_1_Glob [50];
int Arr_2_Glob [50] [50];
#ifndef REG
Boolean Reg = false;
#define REG
/* REG becomes defined as empty */
/* i.e. no register variables */
#else
Boolean Reg = true;
#endif
/* variables for time measurement: */
#ifdef TIMES
struct tms time_info;
extern int times ();
/* see library function "times" */
#define Too_Small_Time 120
/* Measurements should last at least about 2 seconds */
#endif
#ifdef TIME
#define Too_Small_Time 2
/* Measurements should last at least 2 seconds */
#endif
long Begin_Time,
End_Time,
User_Time;
float Microseconds,
Dhrystones_Per_Second;
/* end of variables for time measurement */
void Proc_1 (REG Rec_Pointer Ptr_Val_Par);
void Proc_2 (One_Fifty *Int_Par_Ref);
void Proc_3 (Rec_Pointer *Ptr_Ref_Par);
void Proc_4 (void);
void Proc_5 (void);
extern Boolean Func_2(Str_30, Str_30);
extern void Proc_6(Enumeration, Enumeration *);
extern void Proc_7(One_Fifty, One_Fifty, One_Fifty *);
extern void Proc_8(Arr_1_Dim, Arr_2_Dim, int, int);
int main (int argc, char *argv[])
/* main program, corresponds to procedures */
/* Main and Proc_0 in the Ada version */
{
int duration;
One_Fifty Int_1_Loc;
REG One_Fifty Int_2_Loc;
One_Fifty Int_3_Loc;
REG char Ch_Index;
Enumeration Enum_Loc;
Str_30 Str_1_Loc;
Str_30 Str_2_Loc;
/* Initializations */
Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
Ptr_Glob->Ptr_Comp = Next_Ptr_Glob;
Ptr_Glob->Discr = Ident_1;
Ptr_Glob->variant.var_1.Enum_Comp = Ident_3;
Ptr_Glob->variant.var_1.Int_Comp = 40;
strcpy (Ptr_Glob->variant.var_1.Str_Comp,
"DHRYSTONE PROGRAM, SOME STRING");
strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");
Arr_2_Glob [8][7] = 10;
/* Was missing in published program. Without this statement, */
/* Arr_2_Glob [8][7] would have an undefined value. */
/* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */
/* overflow may occur for this array element. */
#ifdef PRATTLE
printf ("\n");
printf ("Dhrystone Benchmark, Version 2.1 (Language: C)\n");
printf ("\n");
if (Reg)
{
printf ("Program compiled with 'register' attribute\n");
printf ("\n");
}
else
{
printf ("Program compiled without 'register' attribute\n");
printf ("\n");
}
printf ("Please give the number of runs through the benchmark: ");
{
int n;
scanf ("%d", &n);
Number_Of_Runs = n;
}
printf ("\n");
printf ("Execution starts, %d runs through Dhrystone\n", Number_Of_Runs);
#endif /* PRATTLE */
if (argc != 2) {
fprintf(stderr, "Usage: %s duration\n", argv[0]);
exit(1);
}
duration = atoi(argv[1]);
Run_Index = 0;
wake_me(duration, report);
/***************/
/* Start timer */
/***************/
#ifdef SELF_TIMED
#ifdef TIMES
times (&time_info);
Begin_Time = (long) time_info.tms_utime;
#endif
#ifdef TIME
Begin_Time = time ( (long *) 0);
#endif
#endif /* SELF_TIMED */
for (Run_Index = 1; ; ++Run_Index)
{
Proc_5();
Proc_4();
/* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
Int_1_Loc = 2;
Int_2_Loc = 3;
strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
Enum_Loc = Ident_2;
Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
/* Bool_Glob == 1 */
while (Int_1_Loc < Int_2_Loc) /* loop body executed once */
{
Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
/* Int_3_Loc == 7 */
Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
/* Int_3_Loc == 7 */
Int_1_Loc += 1;
} /* while */
/* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
/* Int_Glob == 5 */
Proc_1 (Ptr_Glob);
for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
/* loop body executed twice */
{
if (Enum_Loc == Func_1 (Ch_Index, 'C'))
/* then, not executed */
{
Proc_6 (Ident_1, &Enum_Loc);
strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
Int_2_Loc = Run_Index;
Int_Glob = Run_Index;
}
}
/* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
Int_2_Loc = Int_2_Loc * Int_1_Loc;
Int_1_Loc = Int_2_Loc / Int_3_Loc;
Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
/* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
Proc_2 (&Int_1_Loc);
/* Int_1_Loc == 5 */
} /* loop "for Run_Index" */
/**************/
/* Stop timer */
/**************/
#ifdef SELF_TIMED
#ifdef TIMES
times (&time_info);
End_Time = (long) time_info.tms_utime;
#endif
#ifdef TIME
End_Time = time ( (long *) 0);
#endif
#endif /* SELF_TIMED */
/* BYTE version never executes this stuff */
#ifdef SELF_TIMED
printf ("Execution ends\n");
printf ("\n");
printf ("Final values of the variables used in the benchmark:\n");
printf ("\n");
printf ("Int_Glob: %d\n", Int_Glob);
printf (" should be: %d\n", 5);
printf ("Bool_Glob: %d\n", Bool_Glob);
printf (" should be: %d\n", 1);
printf ("Ch_1_Glob: %c\n", Ch_1_Glob);
printf (" should be: %c\n", 'A');
printf ("Ch_2_Glob: %c\n", Ch_2_Glob);
printf (" should be: %c\n", 'B');
printf ("Arr_1_Glob[8]: %d\n", Arr_1_Glob[8]);
printf (" should be: %d\n", 7);
printf ("Arr_2_Glob[8][7]: %d\n", Arr_2_Glob[8][7]);
printf (" should be: Number_Of_Runs + 10\n");
printf ("Ptr_Glob->\n");
printf (" Ptr_Comp: %d\n", (int) Ptr_Glob->Ptr_Comp);
printf (" should be: (implementation-dependent)\n");
printf (" Discr: %d\n", Ptr_Glob->Discr);
printf (" should be: %d\n", 0);
printf (" Enum_Comp: %d\n", Ptr_Glob->variant.var_1.Enum_Comp);
printf (" should be: %d\n", 2);
printf (" Int_Comp: %d\n", Ptr_Glob->variant.var_1.Int_Comp);
printf (" should be: %d\n", 17);
printf (" Str_Comp: %s\n", Ptr_Glob->variant.var_1.Str_Comp);
printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n");
printf ("Next_Ptr_Glob->\n");
printf (" Ptr_Comp: %d\n", (int) Next_Ptr_Glob->Ptr_Comp);
printf (" should be: (implementation-dependent), same as above\n");
printf (" Discr: %d\n", Next_Ptr_Glob->Discr);
printf (" should be: %d\n", 0);
printf (" Enum_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
printf (" should be: %d\n", 1);
printf (" Int_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
printf (" should be: %d\n", 18);
printf (" Str_Comp: %s\n",
Next_Ptr_Glob->variant.var_1.Str_Comp);
printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n");
printf ("Int_1_Loc: %d\n", Int_1_Loc);
printf (" should be: %d\n", 5);
printf ("Int_2_Loc: %d\n", Int_2_Loc);
printf (" should be: %d\n", 13);
printf ("Int_3_Loc: %d\n", Int_3_Loc);
printf (" should be: %d\n", 7);
printf ("Enum_Loc: %d\n", Enum_Loc);
printf (" should be: %d\n", 1);
printf ("Str_1_Loc: %s\n", Str_1_Loc);
printf (" should be: DHRYSTONE PROGRAM, 1'ST STRING\n");
printf ("Str_2_Loc: %s\n", Str_2_Loc);
printf (" should be: DHRYSTONE PROGRAM, 2'ND STRING\n");
printf ("\n");
User_Time = End_Time - Begin_Time;
if (User_Time < Too_Small_Time)
{
printf ("Measured time too small to obtain meaningful results\n");
printf ("Please increase number of runs\n");
printf ("\n");
}
else
{
#ifdef TIME
Microseconds = (float) User_Time * Mic_secs_Per_Second
/ (float) Number_Of_Runs;
Dhrystones_Per_Second = (float) Number_Of_Runs / (float) User_Time;
#else
Microseconds = (float) User_Time * Mic_secs_Per_Second
/ ((float) HZ * ((float) Number_Of_Runs));
Dhrystones_Per_Second = ((float) HZ * (float) Number_Of_Runs)
/ (float) User_Time;
#endif
printf ("Microseconds for one run through Dhrystone: ");
printf ("%6.1f \n", Microseconds);
printf ("Dhrystones per Second: ");
printf ("%6.1f \n", Dhrystones_Per_Second);
printf ("\n");
}
#endif /* SELF_TIMED */
}
void Proc_1 (REG Rec_Pointer Ptr_Val_Par)
/* executed once */
{
REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp;
/* == Ptr_Glob_Next */
/* Local variable, initialized with Ptr_Val_Par->Ptr_Comp, */
/* corresponds to "rename" in Ada, "with" in Pascal */
structassign (*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob);
Ptr_Val_Par->variant.var_1.Int_Comp = 5;
Next_Record->variant.var_1.Int_Comp
= Ptr_Val_Par->variant.var_1.Int_Comp;
Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp;
Proc_3 (&Next_Record->Ptr_Comp);
/* Ptr_Val_Par->Ptr_Comp->Ptr_Comp
== Ptr_Glob->Ptr_Comp */
if (Next_Record->Discr == Ident_1)
/* then, executed */
{
Next_Record->variant.var_1.Int_Comp = 6;
Proc_6 (Ptr_Val_Par->variant.var_1.Enum_Comp,
&Next_Record->variant.var_1.Enum_Comp);
Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp;
Proc_7 (Next_Record->variant.var_1.Int_Comp, 10,
&Next_Record->variant.var_1.Int_Comp);
}
else /* not executed */
structassign (*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp);
} /* Proc_1 */
void Proc_2 (One_Fifty *Int_Par_Ref)
/* executed once */
/* *Int_Par_Ref == 1, becomes 4 */
{
One_Fifty Int_Loc;
Enumeration Enum_Loc;
Enum_Loc = 0;
Int_Loc = *Int_Par_Ref + 10;
do /* executed once */
if (Ch_1_Glob == 'A')
/* then, executed */
{
Int_Loc -= 1;
*Int_Par_Ref = Int_Loc - Int_Glob;
Enum_Loc = Ident_1;
} /* if */
while (Enum_Loc != Ident_1); /* true */
} /* Proc_2 */
void Proc_3 (Rec_Pointer *Ptr_Ref_Par)
/* executed once */
/* Ptr_Ref_Par becomes Ptr_Glob */
{
if (Ptr_Glob != Null)
/* then, executed */
*Ptr_Ref_Par = Ptr_Glob->Ptr_Comp;
Proc_7 (10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp);
} /* Proc_3 */
void Proc_4 (void) /* without parameters */
/* executed once */
{
Boolean Bool_Loc;
Bool_Loc = Ch_1_Glob == 'A';
Bool_Glob = Bool_Loc | Bool_Glob;
Ch_2_Glob = 'B';
} /* Proc_4 */
void Proc_5 (void) /* without parameters */
/*******/
/* executed once */
{
Ch_1_Glob = 'A';
Bool_Glob = false;
} /* Proc_5 */
/* Procedure for the assignment of structures, */
/* if the C compiler doesn't support this feature */
#ifdef NOSTRUCTASSIGN
memcpy (d, s, l)
register char *d;
register char *s;
register int l;
{
while (l--) *d++ = *s++;
}
#endif

View File

@@ -0,0 +1,209 @@
/*****************************************************************************
* The BYTE UNIX Benchmarks - Release 3
* Module: dhry_2.c SID: 3.4 5/15/91 19:30:22
*
*****************************************************************************
* Bug reports, patches, comments, suggestions should be sent to:
*
* Ben Smith, Rick Grehan or Tom Yager
* ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
*
*****************************************************************************
* Modification Log:
* 10/22/97 - code cleanup to remove ANSI C compiler warnings
* Andy Kahn <kahn@zk3.dec.com>
*
* Adapted from:
*
* "DHRYSTONE" Benchmark Program
* -----------------------------
*
* **** WARNING **** See warning in n.dhry_1.c
*
* Version: C, Version 2.1
*
* File: dhry_2.c (part 3 of 3)
*
* Date: May 25, 1988
*
* Author: Reinhold P. Weicker
*
****************************************************************************/
/* SCCSid is defined in dhry_1.c */
#include <string.h>
#include "dhry.h"
#ifndef REG
#define REG
/* REG becomes defined as empty */
/* i.e. no register variables */
#endif
extern int Int_Glob;
extern char Ch_1_Glob;
void Proc_6(Enumeration, Enumeration *);
void Proc_7(One_Fifty, One_Fifty, One_Fifty *);
void Proc_8(Arr_1_Dim, Arr_2_Dim, int, int);
Enumeration Func_1(Capital_Letter, Capital_Letter);
Boolean Func_2(Str_30, Str_30);
Boolean Func_3(Enumeration);
void Proc_6 (Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par)
/* executed once */
/* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
{
*Enum_Ref_Par = Enum_Val_Par;
if (! Func_3 (Enum_Val_Par))
/* then, not executed */
*Enum_Ref_Par = Ident_4;
switch (Enum_Val_Par)
{
case Ident_1:
*Enum_Ref_Par = Ident_1;
break;
case Ident_2:
if (Int_Glob > 100)
/* then */
*Enum_Ref_Par = Ident_1;
else *Enum_Ref_Par = Ident_4;
break;
case Ident_3: /* executed */
*Enum_Ref_Par = Ident_2;
break;
case Ident_4: break;
case Ident_5:
*Enum_Ref_Par = Ident_3;
break;
} /* switch */
} /* Proc_6 */
void Proc_7 (Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref)
One_Fifty Int_1_Par_Val;
One_Fifty Int_2_Par_Val;
One_Fifty *Int_Par_Ref;
/**********************************************/
/* executed three times */
/* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */
/* Int_Par_Ref becomes 7 */
/* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */
/* Int_Par_Ref becomes 17 */
/* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */
/* Int_Par_Ref becomes 18 */
{
One_Fifty Int_Loc;
Int_Loc = Int_1_Par_Val + 2;
*Int_Par_Ref = Int_2_Par_Val + Int_Loc;
} /* Proc_7 */
void Proc_8 (Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val)
/*********************************************************************/
/* executed once */
/* Int_Par_Val_1 == 3 */
/* Int_Par_Val_2 == 7 */
Arr_1_Dim Arr_1_Par_Ref;
Arr_2_Dim Arr_2_Par_Ref;
int Int_1_Par_Val;
int Int_2_Par_Val;
{
REG One_Fifty Int_Index;
REG One_Fifty Int_Loc;
Int_Loc = Int_1_Par_Val + 5;
Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val;
Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc];
Arr_1_Par_Ref [Int_Loc+30] = Int_Loc;
for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index)
Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc;
Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1;
Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc];
Int_Glob = 5;
} /* Proc_8 */
Enumeration Func_1 (Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val)
/*************************************************/
/* executed three times */
/* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */
/* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */
/* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */
{
Capital_Letter Ch_1_Loc;
Capital_Letter Ch_2_Loc;
Ch_1_Loc = Ch_1_Par_Val;
Ch_2_Loc = Ch_1_Loc;
if (Ch_2_Loc != Ch_2_Par_Val)
/* then, executed */
return (Ident_1);
else /* not executed */
{
Ch_1_Glob = Ch_1_Loc;
return (Ident_2);
}
} /* Func_1 */
Boolean Func_2 (Str_1_Par_Ref, Str_2_Par_Ref)
/*************************************************/
/* executed once */
/* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */
/* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */
Str_30 Str_1_Par_Ref;
Str_30 Str_2_Par_Ref;
{
REG One_Thirty Int_Loc;
Capital_Letter Ch_Loc;
Ch_Loc = 'A';
Int_Loc = 2;
while (Int_Loc <= 2) /* loop body executed once */
if (Func_1 (Str_1_Par_Ref[Int_Loc],
Str_2_Par_Ref[Int_Loc+1]) == Ident_1)
/* then, executed */
{
Ch_Loc = 'A';
Int_Loc += 1;
} /* if, while */
if (Ch_Loc >= 'W' && Ch_Loc < 'Z')
/* then, not executed */
Int_Loc = 7;
if (Ch_Loc == 'R')
/* then, not executed */
return (true);
else /* executed */
{
if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0)
/* then, not executed */
{
Int_Loc += 7;
Int_Glob = Int_Loc;
return (true);
}
else /* executed */
return (false);
} /* if Ch_Loc */
} /* Func_2 */
Boolean Func_3 (Enum_Par_Val)
/***************************/
/* executed once */
/* Enum_Par_Val == Ident_3 */
Enumeration Enum_Par_Val;
{
Enumeration Enum_Loc;
Enum_Loc = Enum_Par_Val;
if (Enum_Loc == Ident_3)
/* then, executed */
return (true);
else /* not executed */
return (false);
} /* Func_3 */

View File

@@ -0,0 +1,319 @@
/*******************************************************************************
* The BYTE UNIX Benchmarks - Release 3
* Module: dummy.c SID: 3.3 5/15/91 19:30:19
*
*******************************************************************************
* Bug reports, patches, comments, suggestions should be sent to:
*
* Ben Smith, Rick Grehan or Tom Yager
* ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
*
*******************************************************************************
* Modification Log:
* 10/22/97 - code cleanup to remove ANSI C compiler warnings
* Andy Kahn <kahn@zk3.dec.com>
*
******************************************************************************/
/*
* Hacked up C program for use in the standard shell.? scripts of
* the multiuser test. This is based upon makework.c, and is typically
* edited using edscript.2 before compilation.
*
* $Header: dummy.c,v 3.4 87/06/23 15:54:53 kjmcdonell Beta $
*/
char SCCSid[] = "@(#) @(#)dummy.c:3.3 -- 5/15/91 19:30:19";
#include <stdio.h>
#include <signal.h>
#define DEF_RATE 5.0
#define GRANULE 5
#define CHUNK 60
#define MAXCHILD 12
#define MAXWORK 10
float thres;
float est_rate = DEF_RATE;
int nusers; /* number of concurrent users to be simulated by
* this process */
int firstuser; /* ordinal identification of first user for this
* process */
int nwork = 0; /* number of job streams */
int exit_status = 0; /* returned to parent */
int sigpipe; /* pipe write error flag */
struct st_work {
char *cmd; /* name of command to run */
char **av; /* arguments to command */
char *input; /* standard input buffer */
int inpsize; /* size of standard input buffer */
} work[MAXWORK];
struct {
int xmit; /* # characters sent */
char *bp; /* std input buffer pointer */
int blen; /* std input buffer length */
int fd; /* stdin to command */
int pid; /* child PID */
char *line; /* start of input line */
int firstjob; /* inital piece of work */
int thisjob; /* current piece of work */
} child[MAXCHILD], *cp;
main(argc, argv)
int argc;
char *argv[];
{
int i;
int l;
int fcopy = 0; /* fd for copy output */
int master = 1; /* the REAL master, == 0 for clones */
int nchild; /* no. of children for a clone to run */
int done; /* count of children finished */
int output; /* aggregate output char count for all
children */
int c;
int thiswork = 0; /* next job stream to allocate */
int nch; /* # characters to write */
int written; /* # characters actully written */
char logname[15]; /* name of the log file(s) */
void onalarm(void);
void pipeerr(void);
void wrapup(void);
void grunt(void);
char *malloc();
int pvec[2]; /* for pipes */
char *p;
char *prog; /* my name */
#if ! debug
freopen("masterlog.00", "a", stderr);
#endif
fprintf(stderr, "*** New Run *** ");
prog = argv[0];
while (argc > 1 && argv[1][0] == '-') {
p = &argv[1][1];
argc--;
argv++;
while (*p) {
switch (*p) {
case 'r':
/* code DELETED here */
argc--;
argv++;
break;
case 'c':
/* code DELETED here */
lseek(fcopy, 0L, 2); /* append at end of file */
break;
default:
fprintf(stderr, "%s: bad flag '%c'\n", prog, *p);
exit(4);
}
p++;
}
}
if (argc < 2) {
fprintf(stderr, "%s: missing nusers\n", prog);
exit(4);
}
nusers = atoi(argv[1]);
if (nusers < 1) {
fprintf(stderr, "%s: impossible nusers (%d<-%s)\n", prog, nusers, argv[1]);
exit(4);
}
fprintf(stderr, "%d Users\n", nusers);
argc--;
argv++;
/* build job streams */
getwork();
#if debug
dumpwork();
#endif
/* clone copies of myself to run up to MAXCHILD jobs each */
firstuser = MAXCHILD;
fprintf(stderr, "master pid %d\n", getpid());
fflush(stderr);
while (nusers > MAXCHILD) {
fflush(stderr);
if (nusers >= 2*MAXCHILD)
/* the next clone must run MAXCHILD jobs */
nchild = MAXCHILD;
else
/* the next clone must run the leftover jobs */
nchild = nusers - MAXCHILD;
if ((l = fork()) == -1) {
/* fork failed */
fatal("** clone fork failed **\n");
goto bepatient;
} else if (l > 0) {
fprintf(stderr, "master clone pid %d\n", l);
/* I am the master with nchild fewer jobs to run */
nusers -= nchild;
firstuser += MAXCHILD;
continue;
} else {
/* I am a clone, run MAXCHILD jobs */
#if ! debug
sprintf(logname, "masterlog.%02d", firstuser/MAXCHILD);
freopen(logname, "w", stderr);
#endif
master = 0;
nusers = nchild;
break;
}
}
if (master)
firstuser = 0;
close(0);
/* code DELETED here */
fflush(stderr);
srand(time(0));
thres = 0;
done = output = 0;
for (i = 0; i < nusers; i++) {
if (child[i].blen == 0)
done++;
else
thres += est_rate * GRANULE;
}
est_rate = thres;
signal(SIGALRM, onalarm);
signal(SIGPIPE, pipeerr);
alarm(GRANULE);
while (done < nusers) {
for (i = 0; i < nusers; i++) {
cp = &child[i];
if (cp->xmit >= cp->blen) continue;
l = rand() % CHUNK + 1; /* 1-CHUNK chars */
if (l == 0) continue;
if (cp->xmit + l > cp->blen)
l = cp->blen - cp->xmit;
p = cp->bp;
cp->bp += l;
cp->xmit += l;
#if debug
fprintf(stderr, "child %d, %d processed, %d to go\n", i, cp->xmit, cp->blen - cp->xmit);
#endif
while (p < cp->bp) {
if (*p == '\n' || (p == &cp->bp[-1] && cp->xmit >= cp->blen)) {
/* write it out */
nch = p - cp->line + 1;
if ((written = write(cp->fd, cp->line, nch)) != nch) {
/* code DELETED here */
}
if (fcopy)
write(fcopy, cp->line, p - cp->line + 1);
#if debug
fprintf(stderr, "child %d gets \"", i);
{
char *q = cp->line;
while (q <= p) {
if (*q >= ' ' && *q <= '~')
fputc(*q, stderr);
else
fprintf(stderr, "\\%03o", *q);
q++;
}
}
fputc('"', stderr);
#endif
cp->line = &p[1];
}
p++;
}
if (cp->xmit >= cp->blen) {
done++;
close(cp->fd);
#if debug
fprintf(stderr, "child %d, close std input\n", i);
#endif
}
output += l;
}
while (output > thres) {
pause();
#if debug
fprintf(stderr, "after pause: output, thres, done %d %.2f %d\n", output, thres, done);
#endif
}
}
bepatient:
alarm(0);
/****
* If everything is going OK, we should simply be able to keep
* looping unitil 'wait' fails, however some descendent process may
* be in a state from which it can never exit, and so a timeout
* is used.
* 5 minutes should be ample, since the time to run all jobs is of
* the order of 5-10 minutes, however some machines are painfully slow,
* so the timeout has been set at 20 minutes (1200 seconds).
****/
/* code DELETED here */
}
onalarm()
{
thres += est_rate;
signal(SIGALRM, onalarm);
alarm(GRANULE);
}
grunt()
{
/* timeout after label "bepatient" in main */
exit_status = 4;
wrapup();
}
pipeerr()
{
sigpipe++;
}
wrapup()
{
/* DUMMY, real code dropped */
}
getwork()
{
/* DUMMY, real code dropped */
gets();
strncpy();
malloc(); realloc();
open(); close();
}
fatal(s)
char *s;
{
int i;
fprintf(stderr, s);
fflush(stderr);
perror("Reason?");
for (i = 0; i < nusers; i++) {
if (child[i].pid > 0 && kill(child[i].pid, SIGKILL) != -1)
fprintf(stderr, "pid %d killed off\n", child[i].pid);
}
fflush(stderr);
exit_status = 4;
return;
}

View File

@@ -0,0 +1,91 @@
/*******************************************************************************
* The BYTE UNIX Benchmarks - Release 3
* Module: execl.c SID: 3.3 5/15/91 19:30:19
*
*******************************************************************************
* Bug reports, patches, comments, suggestions should be sent to:
*
* Ben Smith, Rick Grehan or Tom Yager
* ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
*
*******************************************************************************
* Modification Log:
* $Header: execl.c,v 3.5 87/06/22 15:37:08 kjmcdonell Beta $
* August 28, 1990 - Modified timing routines
* October 22, 1997 - code cleanup to remove ANSI C compiler warnings
* Andy Kahn <kahn@zk3.dec.com>
*
******************************************************************************/
/*
* Execing
*
*/
char SCCSid[] = "@(#) @(#)execl.c:3.3 -- 5/15/91 19:30:19";
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
char bss[8*1024]; /* something worthwhile */
#define main dummy
#include "big.c" /* some real code */
#undef main
int main(int argc, char *argv[]) /* the real program */
{
unsigned long iter = 0;
char *ptr;
char *fullpath;
int duration;
char count_str[12], start_str[24], path_str[256], *dur_str;
time_t start_time, this_time;
#ifdef DEBUG
int count;
for(count = 0; count < argc; ++ count)
printf("%s ",argv[count]);
printf("\n");
#endif
if (argc < 2)
{
fprintf(stderr, "Usage: %s duration\n", argv[0]);
exit(1);
}
duration = atoi(argv[1]);
if (duration > 0)
/* the first invocation */
{
dur_str = argv[1];
if((ptr = getenv("UB_BINDIR")) != NULL)
sprintf(path_str,"%s/execl",ptr);
fullpath=path_str;
time(&start_time);
}
else /* one of those execl'd invocations */
{
/* real duration follow the phoney null duration */
duration = atoi(argv[2]);
dur_str = argv[2];
iter = (unsigned long)atoi(argv[3]); /* where are we now ? */
sscanf(argv[4], "%lu", (unsigned long *) &start_time);
fullpath = argv[0];
}
sprintf(count_str, "%lu", ++iter); /* increment the execl counter */
sprintf(start_str, "%lu", (unsigned long) start_time);
time(&this_time);
if (this_time - start_time >= duration) { /* time has run out */
fprintf(stderr, "COUNT|%lu|1|lps\n", iter);
exit(0);
}
execl(fullpath, fullpath, "0", dur_str, count_str, start_str, (void *) 0);
fprintf(stderr, "Exec failed at iteration %lu\n", iter);
perror("Reason");
exit(1);
}

View File

@@ -0,0 +1,471 @@
/*******************************************************************************
* The BYTE UNIX Benchmarks - Release 3
* Module: fstime.c SID: 3.5 5/15/91 19:30:19
*
*******************************************************************************
* Bug reports, patches, comments, suggestions should be sent to:
*
* Ben Smith, Rick Grehan or Tom Yager
* ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
*
*******************************************************************************
* Modification Log:
* $Header: fstime.c,v 3.4 87/06/22 14:23:05 kjmcdonell Beta $
* 10/19/89 - rewrote timing calcs and added clock check (Ben Smith)
* 10/26/90 - simplify timing, change defaults (Tom Yager)
* 11/16/90 - added better error handling and changed output format (Ben Smith)
* 11/17/90 - changed the whole thing around (Ben Smith)
* 2/22/91 - change a few style elements and improved error handling (Ben Smith)
* 4/17/91 - incorporated suggestions from Seckin Unlu (seckin@sumac.intel.com)
* 4/17/91 - limited size of file, will rewind when reaches end of file
* 7/95 - fixed mishandling of read() and write() return codes
* Carl Emilio Prelz <fluido@telepac.pt>
* 12/95 - Massive changes. Made sleep time proportional increase with run
* time; added fsbuffer and fsdisk variants; added partial counting
* of partial reads/writes (was *full* credit); added dual syncs.
* David C Niemi <niemi@tux.org>
* 10/22/97 - code cleanup to remove ANSI C compiler warnings
* Andy Kahn <kahn@zk3.dec.com>
* 9/24/07 - Separate out the read and write tests;
* output the actual time used in the results.
* Ian Smith <johantheghost at yahoo period com>
******************************************************************************/
char SCCSid[] = "@(#) @(#)fstime.c:3.5 -- 5/15/91 19:30:19";
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>
#define SECONDS 10
#define MAX_BUFSIZE 8192
/* This must be set to the smallest BUFSIZE or 1024, whichever is smaller */
#define COUNTSIZE 256
#define HALFCOUNT (COUNTSIZE/2) /* Half of COUNTSIZE */
#define FNAME0 "dummy0"
#define FNAME1 "dummy1"
#ifndef MINIX
extern void sync(void);
#else
extern int sync(void);
#endif
int w_test(int timeSecs);
int r_test(int timeSecs);
int c_test(int timeSecs);
long read_score = 1, write_score = 1, copy_score = 1;
/****************** GLOBALS ***************************/
/* The buffer size for the tests. */
int bufsize = 1024;
/*
* The max number of 1024-byte blocks in the file.
* Don't limit it much, so that memory buffering
* can be overcome.
*/
int max_blocks = 2000;
/* The max number of BUFSIZE blocks in the file. */
int max_buffs = 2000;
/* Countable units per 1024 bytes */
int count_per_k;
/* Countable units per bufsize */
int count_per_buf;
/* The actual buffer. */
/* char *buf = 0; */
/* Let's carry on using a static buffer for this, like older versions
* of the code did. It turns out that if you use a malloc buffer,
* it goes 50% slower on reads, when using a 4k buffer -- at least on
* my OpenSUSE 10.2 system.
* What up wit dat?
*/
char buf[MAX_BUFSIZE];
int f;
int g;
int i;
void stop_count(int);
void clean_up(int);
int sigalarm = 0;
/******************** MAIN ****************************/
int main(int argc, char *argv[])
{
/* The number of seconds to run for. */
int seconds = SECONDS;
/* The type of test to run. */
char test = 'c';
int status;
int i;
for (i = 1; i < argc; ++i) {
if (argv[i][0] == '-') {
switch (argv[i][1]) {
case 'c':
case 'r':
case 'w':
test = argv[i][1];
break;
case 'b':
bufsize = atoi(argv[++i]);
break;
case 'm':
max_blocks = atoi(argv[++i]);
break;
case 't':
seconds = atoi(argv[++i]);
break;
case 'd':
if (chdir(argv[++i]) < 0) {
perror("fstime: chdir");
exit(1);
}
break;
default:
fprintf(stderr, "Usage: fstime [-c|-r|-w] [-b <bufsize>] [-m <max_blocks>] [-t <seconds>]\n");
exit(2);
}
} else {
fprintf(stderr, "Usage: fstime [-c|-r|-w] [-b <bufsize>] [-m <max_blocks>] [-t <seconds>]\n");
exit(2);
}
}
if (bufsize < COUNTSIZE || bufsize > MAX_BUFSIZE) {
fprintf(stderr, "fstime: buffer size must be in range %d-%d\n",
COUNTSIZE, 1024*1024);
exit(3);
}
if (max_blocks < 1 || max_blocks > 1024*1024) {
fprintf(stderr, "fstime: max blocks must be in range %d-%d\n",
1, 1024*1024);
exit(3);
}
if (seconds < 1 || seconds > 3600) {
fprintf(stderr, "fstime: time must be in range %d-%d seconds\n",
1, 3600);
exit(3);
}
max_buffs = max_blocks * 1024 / bufsize;
count_per_k = 1024 / COUNTSIZE;
count_per_buf = bufsize / COUNTSIZE;
/*
if ((buf = malloc(bufsize)) == 0) {
fprintf(stderr, "fstime: failed to malloc %d bytes\n", bufsize);
exit(4);
}
*/
if((f = creat(FNAME0, 0600)) == -1) {
perror("fstime: creat");
exit(1);
}
close(f);
if((g = creat(FNAME1, 0600)) == -1) {
perror("fstime: creat");
exit(1);
}
close(g);
if( (f = open(FNAME0, 2)) == -1) {
perror("fstime: open");
exit(1);
}
if( ( g = open(FNAME1, 2)) == -1 ) {
perror("fstime: open");
exit(1);
}
/* fill buffer */
for (i=0; i < bufsize; ++i)
buf[i] = i & 0xff;
signal(SIGKILL,clean_up);
/*
* Run the selected test.
* When I got here, this program ran full 30-second tests for
* write, read, and copy, outputting the results for each. BUT
* only the copy results are actually used in the benchmark index.
* With multiple iterations and three sets of FS tests, that amounted
* to about 10 minutes of wasted time per run.
*
* So, I've made the test selectable. Except that the read and write
* passes are used to create the test file and calibrate the rates used
* to tweak the results of the copy test. So, for copy tests, we do
* a few seconds of write and read to prime the pump.
*
* Note that this will also pull the file into the FS cache on any
* modern system prior to the copy test. Whether this is good or
* bad is a matter of perspective, but it's how it was when I got
* here.
*
* Ian Smith <johantheghost at yahoo period com> 21 Sep 2007
*/
switch (test) {
case 'w':
status = w_test(seconds);
break;
case 'r':
w_test(2);
status = r_test(seconds);
break;
case 'c':
w_test(2);
r_test(2);
status = c_test(seconds);
break;
default:
fprintf(stderr, "fstime: unknown test \'%c\'\n", test);
exit(6);
}
if (status) {
clean_up(0);
exit(1);
}
clean_up(0);
exit(0);
}
static double getFloatTime(void)
{
struct timeval t;
gettimeofday(&t, 0);
return (double) t.tv_sec + (double) t.tv_usec / 1000000.0;
}
/*
* Run the write test for the time given in seconds.
*/
int w_test(int timeSecs)
{
unsigned long counted = 0L;
unsigned long tmp;
long f_blocks;
double start, end;
extern int sigalarm;
/* Sync and let it settle */
sync();
sleep(2);
sync();
sleep(2);
/* Set an alarm. */
sigalarm = 0;
signal(SIGALRM, stop_count);
alarm(timeSecs);
start = getFloatTime();
while (!sigalarm) {
for(f_blocks=0; f_blocks < max_buffs; ++f_blocks) {
if ((tmp=write(f, buf, bufsize)) != bufsize) {
if (errno != EINTR) {
perror("fstime: write");
return(-1);
}
stop_count(0);
counted += ((tmp+HALFCOUNT)/COUNTSIZE);
} else
counted += count_per_buf;
}
lseek(f, 0L, 0); /* rewind */
}
/* stop clock */
end = getFloatTime();
write_score = (long) ((double) counted / ((end - start) * count_per_k));
printf("Write done: %ld in %.4f, score %ld\n",
counted, end - start, write_score);
/*
* Output the test results. Use the true time.
*/
fprintf(stderr, "COUNT|%ld|0|KBps\n", write_score);
fprintf(stderr, "TIME|%.1f\n", end - start);
return(0);
}
/*
* Run the read test for the time given in seconds.
*/
int r_test(int timeSecs)
{
unsigned long counted = 0L;
unsigned long tmp;
double start, end;
extern int sigalarm;
extern int errno;
/* Sync and let it settle */
sync();
sleep(2);
sync();
sleep(2);
/* rewind */
errno = 0;
lseek(f, 0L, 0);
/* Set an alarm. */
sigalarm = 0;
signal(SIGALRM, stop_count);
alarm(timeSecs);
start = getFloatTime();
while (!sigalarm) {
/* read while checking for an error */
if ((tmp=read(f, buf, bufsize)) != bufsize) {
switch(errno) {
case 0:
case EINVAL:
lseek(f, 0L, 0); /* rewind at end of file */
counted += (tmp+HALFCOUNT)/COUNTSIZE;
continue;
case EINTR:
stop_count(0);
counted += (tmp+HALFCOUNT)/COUNTSIZE;
break;
default:
perror("fstime: read");
return(-1);
break;
}
} else
counted += count_per_buf;
}
/* stop clock */
end = getFloatTime();
read_score = (long) ((double) counted / ((end - start) * count_per_k));
printf("Read done: %ld in %.4f, score %ld\n",
counted, end - start, read_score);
/*
* Output the test results. Use the true time.
*/
fprintf(stderr, "COUNT|%ld|0|KBps\n", read_score);
fprintf(stderr, "TIME|%.1f\n", end - start);
return(0);
}
/*
* Run the copy test for the time given in seconds.
*/
int c_test(int timeSecs)
{
unsigned long counted = 0L;
unsigned long tmp;
double start, end;
extern int sigalarm;
sync();
sleep(2);
sync();
sleep(1);
/* rewind */
errno = 0;
lseek(f, 0L, 0);
/* Set an alarm. */
sigalarm = 0;
signal(SIGALRM, stop_count);
alarm(timeSecs);
start = getFloatTime();
while (!sigalarm) {
if ((tmp=read(f, buf, bufsize)) != bufsize) {
switch(errno) {
case 0:
case EINVAL:
lseek(f, 0L, 0); /* rewind at end of file */
lseek(g, 0L, 0); /* rewind the output too */
continue;
case EINTR:
/* part credit for leftover bytes read */
counted += ( (tmp * write_score) /
(read_score + write_score)
+ HALFCOUNT) / COUNTSIZE;
stop_count(0);
break;
default:
perror("fstime: copy read");
return(-1);
break;
}
} else {
if ((tmp=write(g, buf, bufsize)) != bufsize) {
if (errno != EINTR) {
perror("fstime: copy write");
return(-1);
}
counted += (
/* Full credit for part of buffer written */
tmp +
/* Plus part credit having read full buffer */
( ((bufsize - tmp) * write_score) /
(read_score + write_score) )
+ HALFCOUNT) / COUNTSIZE;
stop_count(0);
} else
counted += count_per_buf;
}
}
/* stop clock */
end = getFloatTime();
copy_score = (long) ((double) counted / ((end - start) * count_per_k));
printf("Copy done: %ld in %.4f, score %ld\n",
counted, end - start, copy_score);
/*
* Output the test results. Use the true time.
*/
fprintf(stderr, "COUNT|%ld|0|KBps\n", copy_score);
fprintf(stderr, "TIME|%.1f\n", end - start);
return(0);
}
void stop_count(int sig)
{
extern int sigalarm;
sigalarm = 1;
}
void clean_up(int sig)
{
unlink(FNAME0);
unlink(FNAME1);
}

View File

@@ -0,0 +1,75 @@
/*******************************************************************************
* The BYTE UNIX Benchmarks - Release 3
* Module: hanoi.c SID: 3.3 5/15/91 19:30:20
*
*******************************************************************************
* Bug reports, patches, comments, suggestions should be sent to:
*
* Ben Smith, Rick Grehan or Tom Yager
* ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
*
*******************************************************************************
* Modification Log:
* $Header: hanoi.c,v 3.5 87/08/06 08:11:14 kenj Exp $
* August 28, 1990 - Modified timing routines (ty)
* October 22, 1997 - code cleanup to remove ANSI C compiler warnings
* Andy Kahn <kahn@zk3.dec.com>
*
******************************************************************************/
char SCCSid[] = "@(#) @(#)hanoi.c:3.3 -- 5/15/91 19:30:20";
#define other(i,j) (6-(i+j))
#include <stdio.h>
#include <stdlib.h>
#include "timeit.c"
void mov(int n, int f, int t);
unsigned long iter = 0;
int num[4];
long cnt;
void report(int sig)
{
fprintf(stderr,"COUNT|%ld|1|lps\n", iter);
exit(0);
}
int main(int argc, char *argv[])
{
int disk=10, /* default number of disks */
duration;
if (argc < 2) {
fprintf(stderr,"Usage: %s duration [disks]\n", argv[0]);
exit(1);
}
duration = atoi(argv[1]);
if(argc > 2) disk = atoi(argv[2]);
num[1] = disk;
wake_me(duration, report);
while(1) {
mov(disk,1,3);
iter++;
}
exit(0);
}
void mov(int n, int f, int t)
{
int o;
if(n == 1) {
num[f]--;
num[t]++;
return;
}
o = other(f,t);
mov(n-1,f,o);
mov(1,f,t);
mov(n-1,o,t);
}

View File

@@ -0,0 +1,103 @@
/*******************************************************************************
* The BYTE UNIX Benchmarks - Release 1
* Module: looper.c SID: 1.4 5/15/91 19:30:22
*
*******************************************************************************
* Bug reports, patches, comments, suggestions should be sent to:
*
* Ben Smith or Tom Yager at BYTE Magazine
* ben@bytepb.byte.com tyager@bytepb.byte.com
*
*******************************************************************************
* Modification Log:
*
* February 25, 1991 -- created (Ben S.)
* October 22, 1997 - code cleanup to remove ANSI C compiler warnings
* Andy Kahn <kahn@zk3.dec.com>
*
******************************************************************************/
char SCCSid[] = "@(#) @(#)looper.c:1.4 -- 5/15/91 19:30:22";
/*
* Shell Process creation
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include "timeit.c"
unsigned long iter;
char *cmd_argv[28];
int cmd_argc;
void report(int sig)
{
fprintf(stderr,"COUNT|%lu|60|lpm\n", iter);
exit(0);
}
int main(int argc, char *argv[])
{
int slave, count, duration;
int status;
if (argc < 2)
{
fprintf(stderr,"Usage: %s duration command [args..]\n", argv[0]);
fprintf(stderr," duration in seconds\n");
exit(1);
}
if((duration = atoi(argv[1])) < 1)
{
fprintf(stderr,"Usage: %s duration command [arg..]\n", argv[0]);
fprintf(stderr," duration in seconds\n");
exit(1);
}
/* get command */
cmd_argc=argc-2;
for( count=2;count < argc; ++count)
cmd_argv[count-2]=argv[count];
#ifdef DEBUG
printf("<<%s>>",cmd_argv[0]);
for(count=1;count < cmd_argc; ++count)
printf(" <%s>", cmd_argv[count]);
putchar('\n');
exit(0);
#endif
iter = 0;
wake_me(duration, report);
while (1)
{
if ((slave = fork()) == 0)
{ /* execute command */
execvp(cmd_argv[0],cmd_argv);
exit(99);
}
else if (slave < 0)
{
/* woops ... */
fprintf(stderr,"Fork failed at iteration %lu\n", iter);
perror("Reason");
exit(2);
}
else
/* master */
wait(&status);
if (status == 99 << 8)
{
fprintf(stderr, "Command \"%s\" didn't exec\n", cmd_argv[0]);
exit(2);
}
else if (status != 0)
{
fprintf(stderr,"Bad wait status: 0x%x\n", status);
exit(2);
}
iter++;
}
}

View File

@@ -0,0 +1,66 @@
/*******************************************************************************
* The BYTE UNIX Benchmarks - Release 3
* Module: pipe.c SID: 3.3 5/15/91 19:30:20
*
*******************************************************************************
* Bug reports, patches, comments, suggestions should be sent to:
*
* Ben Smith, Rick Grehan or Tom Yager
* ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
*
*******************************************************************************
* Modification Log:
* $Header: pipe.c,v 3.5 87/06/22 14:32:36 kjmcdonell Beta $
* August 29, 1990 - modified timing routines (ty)
* October 22, 1997 - code cleanup to remove ANSI C compiler warnings
* Andy Kahn <kahn@zk3.dec.com>
*
******************************************************************************/
char SCCSid[] = "@(#) @(#)pipe.c:3.3 -- 5/15/91 19:30:20";
/*
* pipe -- test single process pipe throughput (no context switching)
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "timeit.c"
unsigned long iter;
void report(int sig)
{
fprintf(stderr,"COUNT|%ld|1|lps\n", iter);
exit(0);
}
int main(int argc, char *argv[])
{
char buf[512];
int pvec[2], duration;
if (argc != 2) {
fprintf(stderr,"Usage: %s duration\n", argv[0]);
exit(1);
}
duration = atoi(argv[1]);
pipe(pvec);
wake_me(duration, report);
iter = 0;
while (1) {
if (write(pvec[1], buf, sizeof(buf)) != sizeof(buf)) {
if ((errno != EINTR) && (errno != 0))
fprintf(stderr,"write failed, error %d\n", errno);
}
if (read(pvec[0], buf, sizeof(buf)) != sizeof(buf)) {
if ((errno != EINTR) && (errno != 0))
fprintf(stderr,"read failed, error %d\n", errno);
}
iter++;
}
}

View File

@@ -0,0 +1,78 @@
/*******************************************************************************
* The BYTE UNIX Benchmarks - Release 3
* Module: spawn.c SID: 3.3 5/15/91 19:30:20
*
*******************************************************************************
* Bug reports, patches, comments, suggestions should be sent to:
*
* Ben Smith, Rick Grehan or Tom Yagerat BYTE Magazine
* ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
*
*******************************************************************************
* Modification Log:
* $Header: spawn.c,v 3.4 87/06/22 14:32:48 kjmcdonell Beta $
* August 29, 1990 - Modified timing routines (ty)
* October 22, 1997 - code cleanup to remove ANSI C compiler warnings
* Andy Kahn <kahn@zk3.dec.com>
*
******************************************************************************/
char SCCSid[] = "@(#) @(#)spawn.c:3.3 -- 5/15/91 19:30:20";
/*
* Process creation
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include "timeit.c"
unsigned long iter;
void report(int sig)
{
fprintf(stderr,"COUNT|%lu|1|lps\n", iter);
exit(0);
}
int main(int argc, char *argv[])
{
int slave, duration;
int status;
if (argc != 2) {
fprintf(stderr,"Usage: %s duration \n", argv[0]);
exit(1);
}
duration = atoi(argv[1]);
iter = 0;
wake_me(duration, report);
while (1) {
if ((slave = fork()) == 0) {
/* slave .. boring */
#if debug
printf("fork OK\n");
#endif
/* kill it right away */
exit(0);
} else if (slave < 0) {
/* woops ... */
fprintf(stderr,"Fork failed at iteration %lu\n", iter);
perror("Reason");
exit(2);
} else
/* master */
wait(&status);
if (status != 0) {
fprintf(stderr,"Bad wait status: 0x%x\n", status);
exit(2);
}
iter++;
#if debug
printf("Child %d done.\n", slave);
#endif
}
}

View File

@@ -0,0 +1,107 @@
/*******************************************************************************
* The BYTE UNIX Benchmarks - Release 3
* Module: syscall.c SID: 3.3 5/15/91 19:30:21
*
*******************************************************************************
* Bug reports, patches, comments, suggestions should be sent to:
*
* Ben Smith, Rick Grehan or Tom Yager at BYTE Magazine
* ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
*
*******************************************************************************
* Modification Log:
* $Header: syscall.c,v 3.4 87/06/22 14:32:54 kjmcdonell Beta $
* August 29, 1990 - Modified timing routines
* October 22, 1997 - code cleanup to remove ANSI C compiler warnings
* Andy Kahn <kahn@zk3.dec.com>
*
******************************************************************************/
/*
* syscall -- sit in a loop calling the system
*
*/
char SCCSid[] = "@(#) @(#)syscall.c:3.3 -- 5/15/91 19:30:21";
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "timeit.c"
unsigned long iter;
void report(int sig)
{
fprintf(stderr,"COUNT|%ld|1|lps\n", iter);
exit(0);
}
int main(int argc, char *argv[])
{
char *test;
int duration;
if (argc < 2) {
fprintf(stderr,"Usage: %s duration [ test ]\n", argv[0]);
fprintf(stderr,"test is one of:\n");
fprintf(stderr," \"mix\" (default), \"close\", \"getpid\", \"exec\"\n");
exit(1);
}
if (argc > 2)
test = argv[2];
else
test = "mix";
duration = atoi(argv[1]);
iter = 0;
wake_me(duration, report);
switch (test[0]) {
case 'm':
while (1) {
close(dup(0));
getpid();
getuid();
umask(022);
iter++;
}
/* NOTREACHED */
case 'c':
while (1) {
close(dup(0));
iter++;
}
/* NOTREACHED */
case 'g':
while (1) {
getpid();
iter++;
}
/* NOTREACHED */
case 'e':
while (1) {
pid_t pid = fork();
if (pid < 0) {
fprintf(stderr,"%s: fork failed\n", argv[0]);
exit(1);
} else if (pid == 0) {
execl("/bin/true", (char *) 0);
fprintf(stderr,"%s: exec /bin/true failed\n", argv[0]);
exit(1);
} else {
if (waitpid(pid, NULL, 0) < 0) {
fprintf(stderr,"%s: waitpid failed\n", argv[0]);
exit(1);
}
}
iter++;
}
/* NOTREACHED */
}
exit(9);
}

View File

@@ -0,0 +1,573 @@
/* Programme to test how long it takes to select(2), poll(2) and poll2(2) a
large number of file descriptors.
Copyright 1997 Richard Gooch rgooch@atnf.csiro.au
Distributed under the GNU General Public License.
To compile this programme, use gcc -O2 -o time-polling time-polling.c
Extra compile flags:
Add -DHAS_SELECT if your operating system has the select(2) system call
Add -DHAS_POLL if your operating system has the poll(2) system call
Add -DHAS_POLL2 if your operating system has the poll2(2) system call
Usage: time-polling [num_iter] [num_to_test] [num_active] [-v]
NOTE: on many systems the default limit on file descriptors is less than
1024. You should try to increase this limit to 1024 before doing the test.
Something like "limit descriptors 1024" or "limit openfiles 1024" should do
the trick. On some systems (like IRIX), doing the test on a smaller number
gives a *much* smaller time per descriptor, which shows that time taken
does not scale linearly with number of descriptors, which is non-optimal.
In the tests I've done, I try to use 1024 descriptors.
The benchmark results are available at:
http://www.atnf.csiro.au/~rgooch/benchmarks.html
If you want to contribute results, please email them to me. Please specify
if you want to be acknowledged.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Richard Gooch may be reached by email at rgooch@atnf.csiro.au
The postal address is:
Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia.
*/
#ifdef UNIXBENCH
#define OUT stdout
#else
#define OUT stderr
#endif
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/resource.h>
#ifdef HAS_POLL
# include <sys/poll.h>
#endif
#ifdef HAS_POLL2
# include <linux/poll2.h>
#endif
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#define TRUE 1
#define FALSE 0
#ifdef UNIXBENCH
#define MAX_ITERATIONS 1000
#else
#define MAX_ITERATIONS 30
#endif
#define MAX_FDS 40960
#define CONST const
#define ERRSTRING strerror (errno)
typedef int flag;
/*
static inline int find_first_set_bit (CONST void *array, int size)
*/
static int find_first_set_bit (CONST void *array, int size)
/* [SUMMARY] Find the first bit set in a bitfield.
<array> A pointer to the bitfield. This must be aligned on a long boundary.
<size> The number of bits in the bitfield.
[RETURNS] The index of the first set bit. If no bits are set, <<size>> + 1
is returned.
*/
{
int index;
unsigned long word;
unsigned int ul_size = 8 * sizeof (unsigned long);
CONST unsigned long *ul_array = array;
/* Find first word with any bit set */
for (index = 0; (*ul_array == 0) && (index < size);
index += ul_size, ++ul_array);
/* Find first bit set in word */
for (word = *ul_array; !(word & 1) && (index < size);
++index, word = word >> 1);
return (index);
} /* End Function find_first_set_bit */
/*
static inline int find_next_set_bit (CONST void *array, int size, int offset)
*/
static int find_next_set_bit (CONST void *array, int size, int offset)
/* [SUMMARY] Find the next bit set in a bitfield.
<array> A pointer to the bitfield. This must be aligned on a long boundary.
<size> The number of bits in the bitfield.
<offset> The offset of the current bit in the bitfield. The current bit is
ignored.
[RETURNS] The index of the next set bit. If no more bits are set,
<<size>> + 1 is returned.
*/
{
int index, tmp;
unsigned long word;
unsigned int ul_size = 8 * sizeof (unsigned long);
CONST unsigned long *ul_array = array;
if (++offset >= size) return (offset);
index = offset;
/* Jump to the long word containing the next bit */
tmp = offset / ul_size;
ul_array += tmp;
offset -= tmp * ul_size;
if ( (offset == 0) || (*ul_array == 0) )
return (find_first_set_bit (ul_array, size - index) + index);
/* There is a bit set somewhere in this word */
if ( ( (word = *ul_array) != 0 ) && ( (word = word >> offset) != 0 ) )
{
/* There is a bit set somewhere in this word at or after the offset
position */
for (; (word & 1) == 0; word = word >> 1, ++index);
return (index);
}
/* Have to go to subsequent word(s) */
index += ul_size - offset;
return (find_first_set_bit (++ul_array, size - index) + index);
} /* End Function find_next_set_bit */
struct callback_struct
{
void (*input_func) (void *info);
void (*output_func) (void *info);
void (*exception_func) (void *info);
void *info;
};
static int total_bits = 0;
struct callback_struct callbacks[MAX_FDS];
static void test_func (void *info)
{
++total_bits;
}
#ifdef HAS_SELECT
static void time_select (fd_set *input_fds, fd_set *output_fds,
fd_set *exception_fds, int max_fd, int num_iter,
long *times)
/* [SUMMARY] Time how long it takes to select(2) file descriptors.
<input_fds> The input masks.
<output_fds> The output masks.
<exception_fds> The exception masks.
<max_fd> The highest file descriptor in the fd_sets.
<num_iter> The number of iterations.
<times> The time taken (in microseconds) for each iteration.
[RETURNS] Nothing.
*/
{
int fd, count, nready;
fd_set i_fds, o_fds, e_fds;
struct timeval time1, time2, tv;
/* Warm the cache a bit */
memcpy (&i_fds, input_fds, sizeof i_fds);
memcpy (&o_fds, output_fds, sizeof i_fds);
memcpy (&e_fds, exception_fds, sizeof i_fds);
tv.tv_sec = 0;
tv.tv_usec = 0;
select (max_fd + 1, &i_fds, &o_fds, &e_fds, &tv);
for (count = 0; count < num_iter; ++count)
{
total_bits = 0;
gettimeofday (&time1, NULL);
memcpy (&i_fds, input_fds, sizeof i_fds);
memcpy (&o_fds, output_fds, sizeof i_fds);
memcpy (&e_fds, exception_fds, sizeof i_fds);
tv.tv_sec = 0;
tv.tv_usec = 0;
nready = select (max_fd + 1, &i_fds, &o_fds, &e_fds, &tv);
if (nready == -1)
{
fprintf (stderr, "Error selecting\t%s\n", ERRSTRING);
exit (2);
}
if (nready < 1)
{
fprintf (stderr, "Error: nready: %d\n", nready);
exit (1);
}
/* Scan the output */
for (fd = find_first_set_bit (&e_fds, sizeof e_fds * 8); fd <= max_fd;
fd = find_next_set_bit (&e_fds, sizeof e_fds * 8, fd) )
{
(*callbacks[fd].exception_func) (callbacks[fd].info);
}
for (fd = find_first_set_bit (&i_fds, sizeof i_fds * 8); fd <= max_fd;
fd = find_next_set_bit (&i_fds, sizeof i_fds * 8, fd) )
{
(*callbacks[fd].input_func) (callbacks[fd].info);
}
for (fd = find_first_set_bit (&o_fds, sizeof o_fds * 8); fd <= max_fd;
fd = find_next_set_bit (&o_fds, sizeof o_fds * 8, fd) )
{
(*callbacks[fd].output_func) (callbacks[fd].info);
}
gettimeofday (&time2, NULL);
times[count] = (time2.tv_sec - time1.tv_sec) * 1000000;
times[count] += time2.tv_usec - time1.tv_usec;
}
} /* End Function time_select */
#endif /* HAS_SELECT */
#ifdef HAS_POLL
static void time_poll (struct pollfd *pollfd_array, int start_index,
int num_to_test, int num_iter, long *times)
/* [SUMMARY] Time how long it takes to poll(2) file descriptors.
<pollfd_array> The array of pollfd structures.
<start_index> The start index in the array of pollfd structures.
<num_to_test> The number of file descriptors to test.
<num_iter> The number of iterations.
<times> The time taken (in microseconds) for each iteration.
[RETURNS] Nothing.
*/
{
short revents;
int fd, count, nready;
struct timeval time1, time2;
struct pollfd *pollfd_ptr, *stop_pollfd;
/* Warm the cache a bit */
poll (pollfd_array + start_index, num_to_test, 0);
for (count = 0; count < num_iter; ++count)
{
total_bits = 0;
gettimeofday (&time1, NULL);
nready = poll (pollfd_array + start_index, num_to_test, 0);
if (nready == -1)
{
fprintf (stderr, "Error polling\t%s\n", ERRSTRING);
exit (2);
}
if (nready < 1)
{
fprintf (stderr, "Error: nready: %d\n", nready);
exit (1);
}
stop_pollfd = pollfd_array + start_index + num_to_test;
for (pollfd_ptr = pollfd_array + start_index; TRUE; ++pollfd_ptr)
{
if (pollfd_ptr->revents == 0) continue;
/* Have an active descriptor */
revents = pollfd_ptr->revents;
fd = pollfd_ptr->fd;
if (revents & POLLPRI)
(*callbacks[fd].exception_func) (callbacks[fd].info);
if (revents & POLLIN)
(*callbacks[fd].input_func) (callbacks[fd].info);
if (revents & POLLOUT)
(*callbacks[fd].output_func) (callbacks[fd].info);
if (--nready == 0) break;
}
gettimeofday (&time2, NULL);
times[count] = (time2.tv_sec - time1.tv_sec) * 1000000;
times[count] += time2.tv_usec - time1.tv_usec;
}
} /* End Function time_poll */
#endif /* HAS_POLL */
#ifdef HAS_POLL2
static void time_poll2 (struct poll2ifd *poll2ifd_array, int start_index,
int num_to_test, int num_iter, long *times)
/* [SUMMARY] Time how long it takes to poll2(2) file descriptors.
<poll2ifd_array> The array of poll2ifd structures.
<start_index> The start index in the array of pollfd structures.
<num_to_test> The number of file descriptors to test.
<num_iter> The number of iterations.
<times> The time taken (in microseconds) for each iteration.
[RETURNS] Nothing.
*/
{
short revents;
int fd, count, nready, i;
struct timeval time1, time2;
struct poll2ofd poll2ofd_array[MAX_FDS];
/* Warm the cache a bit */
poll2 (poll2ifd_array + start_index, poll2ofd_array, num_to_test, 0);
for (count = 0; count < num_iter; ++count)
{
total_bits = 0;
gettimeofday (&time1, NULL);
nready = poll2 (poll2ifd_array + start_index, poll2ofd_array,
num_to_test, 0);
if (nready == -1)
{
times[count] = -1;
if (errno == ENOSYS) return; /* Must do this first */
fprintf (stderr, "Error calling poll2(2)\t%s\n", ERRSTRING);
exit (2);
}
if (nready < 1)
{
fprintf (stderr, "Error: nready: %d\n", nready);
exit (1);
}
for (i = 0; i < nready; ++i)
{
revents = poll2ofd_array[i].revents;
fd = poll2ofd_array[i].fd;
if (revents & POLLPRI)
(*callbacks[fd].exception_func) (callbacks[fd].info);
if (revents & POLLIN)
(*callbacks[fd].input_func) (callbacks[fd].info);
if (revents & POLLOUT)
(*callbacks[fd].output_func) (callbacks[fd].info);
}
gettimeofday (&time2, NULL);
times[count] = (time2.tv_sec - time1.tv_sec) * 1000000;
times[count] += time2.tv_usec - time1.tv_usec;
}
} /* End Function time_poll2 */
#endif /* HAS_POLL2 */
int main (argc, argv)
int argc;
char *argv[];
{
flag failed = FALSE;
flag verbose = FALSE;
int first_fd = -1;
int fd, max_fd, count, total_fds;
int num_to_test, num_active;
#ifdef UNIXBENCH
int max_iter = 1000;
#else
int max_iter = 10;
#endif
#ifdef HAS_SELECT
long select_total = 0;
fd_set input_fds, output_fds, exception_fds;
long select_times[MAX_ITERATIONS];
#endif
#ifdef HAS_POLL
int start_index;
long poll_total = 0;
struct pollfd pollfd_array[MAX_FDS];
long poll_times[MAX_ITERATIONS];
#endif
#ifdef HAS_POLL2
long poll2_total = 0;
struct poll2ifd poll2ifd_array[MAX_FDS];
struct poll2ofd poll2ofd_array[MAX_FDS];
long poll2_times[MAX_ITERATIONS];
#endif
#if 0
extern char *sys_errlist[];
#endif
#ifdef HAS_SELECT
FD_ZERO (&input_fds);
FD_ZERO (&output_fds);
FD_ZERO (&exception_fds);
#endif
#ifdef HAS_POLL
memset (pollfd_array, 0, sizeof pollfd_array);
#endif
/* Allocate file descriptors */
total_fds = 0;
max_fd = 0;
while (!failed)
{
if ( ( fd = dup (1) ) == -1 )
{
if (errno != EMFILE)
{
fprintf (stderr, "Error dup()ing\t%s\n", ERRSTRING);
exit (1);
}
failed = TRUE;
continue;
}
if (fd >= MAX_FDS)
{
fprintf (stderr, "File descriptor: %d larger than max: %d\n",
fd, MAX_FDS - 1);
exit (1);
}
callbacks[fd].input_func = test_func;
callbacks[fd].output_func = test_func;
callbacks[fd].exception_func = test_func;
callbacks[fd].info = NULL;
if (fd > max_fd) max_fd = fd;
if (first_fd < 0) first_fd = fd;
#ifdef HAS_POLL
pollfd_array[fd].fd = fd;
pollfd_array[fd].events = 0;
#endif
#ifdef HAS_POLL2
poll2ifd_array[fd].fd = fd;
poll2ifd_array[fd].events = 0;
#endif
}
total_fds = max_fd + 1;
/* Process the command-line arguments */
if (argc > 5)
{
fputs ("Usage:\ttime-polling [num_iter] [num_to_test] [num_active] [-v]\n",
stderr);
exit (1);
}
if (argc > 1) max_iter = atoi (argv[1]);
if (max_iter > MAX_ITERATIONS)
{
fprintf (stderr, "num_iter too large\n");
exit (1);
}
if (argc > 2) num_to_test = atoi (argv[2]);
else num_to_test = total_fds - first_fd;
if (argc > 3) num_active = atoi (argv[3]);
else num_active = 1;
if (argc > 4)
{
if (strcmp (argv[4], "-v") != 0)
{
fputs ("Usage:\ttime-polling [num_iter] [num_to_test] [num_active] [-v]\n",
stderr);
exit (1);
}
verbose = TRUE;
}
/* Sanity tests */
if (num_to_test > total_fds - first_fd) num_to_test = total_fds - first_fd;
if (num_active > total_fds - first_fd) num_active = total_fds - first_fd;
/* Set activity monitoring flags */
for (fd = total_fds - num_to_test; fd < total_fds; ++fd)
{
#ifdef HAS_SELECT
FD_SET (fd, &exception_fds);
FD_SET (fd, &input_fds);
#endif
#ifdef HAS_POLL
pollfd_array[fd].events = POLLPRI | POLLIN;
#endif
#ifdef HAS_POLL2
poll2ifd_array[fd].events = POLLPRI | POLLIN;
#endif
}
for (fd = total_fds - num_active; fd < total_fds; ++fd)
{
#ifdef HAS_SELECT
FD_SET (fd, &output_fds);
#endif
#ifdef HAS_POLL
pollfd_array[fd].events |= POLLOUT;
#endif
#ifdef HAS_POLL2
poll2ifd_array[fd].events |= POLLOUT;
#endif
}
fprintf (OUT, "Num fds: %d, polling descriptors %d-%d\n",
total_fds, total_fds - num_to_test, max_fd);
/* First do all the tests, then print the results */
#ifdef HAS_SELECT
time_select (&input_fds, &output_fds, &exception_fds, max_fd, max_iter,
select_times);
#endif
#ifdef HAS_POLL
start_index = total_fds - num_to_test;
time_poll (pollfd_array, start_index, num_to_test, max_iter, poll_times);
#endif
#ifdef HAS_POLL2
start_index = total_fds - num_to_test;
time_poll2 (poll2ifd_array, start_index, num_to_test, max_iter,
poll2_times);
#endif
/* Now print out all the times */
fputs ("All times in microseconds\n", OUT);
fputs ("ITERATION\t", OUT);
#ifdef HAS_SELECT
fprintf (OUT, "%-12s", "select(2)");
#endif
#ifdef HAS_POLL
fprintf (OUT, "%-12s", "poll(2)");
#endif
#ifdef HAS_POLL2
if (poll2_times[0] >= 0) fprintf (OUT, "%-12s", "poll2(2)");
#endif
for (count = 0; count < max_iter; ++count)
{
if (verbose) fprintf (OUT, "\n%d\t\t", count);
#ifdef HAS_SELECT
if (verbose) fprintf (OUT, "%-12ld", select_times[count]);
select_total += select_times[count];
#endif
#ifdef HAS_POLL
if (verbose) fprintf (OUT, "%-12ld", poll_times[count]);
poll_total += poll_times[count];
#endif
#ifdef HAS_POLL2
if ( verbose && (poll2_times[0] >= 0) )
fprintf (OUT, "%-12ld", poll2_times[count]);
poll2_total += poll2_times[count];
#endif
}
fputs ("\n\naverage\t\t", OUT);
#ifdef HAS_SELECT
fprintf (OUT, "%-12ld", select_total / max_iter);
#endif
#ifdef HAS_POLL
fprintf (OUT, "%-12ld", poll_total / max_iter);
#endif
#ifdef HAS_POLL2
if (poll2_times[0] >= 0)
fprintf (OUT, "%-12ld", poll2_total / max_iter);
#endif
putc ('\n', OUT);
fputs ("Per fd\t\t", OUT);
#ifdef HAS_SELECT
fprintf (OUT, "%-12.2f",
(float) select_total / (float) max_iter / (float) num_to_test);
#ifdef UNIXBENCH
fprintf (stderr, "lps\t%.2f\t%.1f\n",
1000000 * (float) max_iter * (float) num_to_test
/ (float) select_total, (float)select_total / 1000000);
#endif
#endif
#ifdef HAS_POLL
fprintf (OUT, "%-12.2f",
(float) poll_total / (float) max_iter / (float) num_to_test);
#ifdef UNIXBENCH
fprintf (stderr, "lps\t%.2f\t%.1f\n",
1000000 * (float) max_iter * (float) num_to_test
/ (float) poll_total, (float)poll_total / 1000000);
#endif
#endif
#ifdef HAS_POLL2
if (poll2_times[0] >= 0) {
fprintf (OUT, "%-12.2f",
(float) poll2_total / (float) max_iter / (float) num_to_test);
#ifdef UNIXBENCH
fprintf (stderr, "lps\t%.2f\t%.1f\n",
1000000 * (float) max_iter * (float) num_to_test
/ (float) poll2_total, (float)poll2_total / 1000000);
#endif
}
#endif
fputs ("<- the most important value\n", OUT);
exit(0);
} /* End Function main */

View File

@@ -0,0 +1,39 @@
/*******************************************************************************
*
* The BYTE UNIX Benchmarks - Release 3
* Module: timeit.c SID: 3.3 5/15/91 19:30:21
*******************************************************************************
* Bug reports, patches, comments, suggestions should be sent to:
*
* Ben Smith, Rick Grehan or Tom Yager
* ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
*
*******************************************************************************
* Modification Log:
* May 12, 1989 - modified empty loops to avoid nullifying by optimizing
* compilers
* August 28, 1990 - changed timing relationship--now returns total number
* of iterations (ty)
* October 22, 1997 - code cleanup to remove ANSI C compiler warnings
* Andy Kahn <kahn@zk3.dec.com>
*
******************************************************************************/
/* this module is #included in other modules--no separate SCCS ID */
/*
* Timing routine
*
*/
#include <signal.h>
#include <unistd.h>
void wake_me(int seconds, void (*func)(int))
{
/* set up the signal handler */
signal(SIGALRM, func);
/* get the clock running */
alarm(seconds);
}

View File

@@ -0,0 +1,650 @@
/*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* $XFree86: xc/programs/glxgears/glxgears.c,v 1.3tsi Exp $ */
/*
* This is a port of the infamous "gears" demo to straight GLX (i.e. no GLUT)
* Port by Brian Paul 23 March 2001
*
* Exact timing added by Behdad Esfahbod to achieve a fixed speed regardless
* of frame rate. November 2003
*
* Printer support added by Roland Mainz <roland.mainz@nrubsig.org>. April 2004
*
* This version modified by Ian Smith, 30 Sept 2007, to make ubgears.
* ubgears is cusoimised for use in the UnixBench benchmarking suite.
* Some redundant stuff is gone, and the -time option is added.
* Mainly it's forked so we don't use the host's version, which could change
* from platform to platform.
*
* Command line options:
* -display Set X11 display for output.
* -info Print additional GLX information.
* -time <t> Run for <t> seconds and produce a performance report.
* -h Print this help page.
* -v Verbose output.
*
*/
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <GL/gl.h>
#include <GL/glx.h>
#include <sys/time.h>
#include <sched.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#ifndef M_PI
#define M_PI 3.14159265
#endif /* !M_PI */
/* Turn a NULL pointer string into an empty string */
#define NULLSTR(x) (((x)!=NULL)?(x):(""))
#define Log(x) { if(verbose) printf x; }
#define Msg(x) { printf x; }
/* Globla vars */
/* program name (from argv[0]) */
static const char *ProgramName;
/* verbose output what the program is doing */
static Bool verbose = False;
/* time in microseconds to run for; -1 means forever. */
static int runTime = -1;
/* Time at which start_time(void) was called. */
static struct timeval clockStart;
/* XXX this probably isn't very portable */
/* return current time (in seconds) */
static void
start_time(void)
{
(void) gettimeofday(&clockStart, 0);
}
/*
* return time (in microseconds) since start_time(void) was called.
*
* The older version of this function randomly returned negative results.
* This version won't, up to 2000 seconds and some.
*/
static long
current_time(void)
{
struct timeval tv;
long secs, micros;
(void) gettimeofday(&tv, 0);
secs = tv.tv_sec - clockStart.tv_sec;
micros = tv.tv_usec - clockStart.tv_usec;
if (micros < 0) {
--secs;
micros += 1000000;
}
return secs * 1000000 + micros;
}
static
void usage(void)
{
fprintf (stderr, "usage: %s [options]\n", ProgramName);
fprintf (stderr, "-display\tSet X11 display for output.\n");
fprintf (stderr, "-info\t\tPrint additional GLX information.\n");
fprintf (stderr, "-time t\t\tRun for t seconds and report performance.\n");
fprintf (stderr, "-h\t\tPrint this help page.\n");
fprintf (stderr, "-v\t\tVerbose output.\n");
fprintf (stderr, "\n");
exit(EXIT_FAILURE);
}
static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
static GLint gear1, gear2, gear3;
static GLfloat angle = 0.0;
static GLint speed = 60;
static GLboolean printInfo = GL_FALSE;
/*
*
* Draw a gear wheel. You'll probably want to call this function when
* building a display list since we do a lot of trig here.
*
* Input: inner_radius - radius of hole at center
* outer_radius - radius at center of teeth
* width - width of gear
* teeth - number of teeth
* tooth_depth - depth of tooth
*/
static void
gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
GLint teeth, GLfloat tooth_depth)
{
GLint i;
GLfloat r0, r1, r2, maxr2, minr2;
GLfloat angle, da;
GLfloat u, v, len;
r0 = inner_radius;
r1 = outer_radius - tooth_depth / 2.0;
maxr2 = r2 = outer_radius + tooth_depth / 2.0;
minr2 = r2;
da = 2.0 * M_PI / teeth / 4.0;
glShadeModel(GL_FLAT);
glNormal3f(0.0, 0.0, 1.0);
/* draw front face */
glBegin(GL_QUAD_STRIP);
for (i = 0; i <= teeth; i++) {
angle = i * 2.0 * M_PI / teeth;
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
if (i < teeth) {
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
width * 0.5);
}
}
glEnd();
/* draw front sides of teeth */
glBegin(GL_QUADS);
for (i = 0; i < teeth; i++) {
angle = i * 2.0 * M_PI / teeth;
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
width * 0.5);
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
width * 0.5);
r2 = minr2;
}
r2 = maxr2;
glEnd();
glNormal3f(0.0, 0.0, -1.0);
/* draw back face */
glBegin(GL_QUAD_STRIP);
for (i = 0; i <= teeth; i++) {
angle = i * 2.0 * M_PI / teeth;
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
if (i < teeth) {
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
-width * 0.5);
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
}
}
glEnd();
/* draw back sides of teeth */
glBegin(GL_QUADS);
da = 2.0 * M_PI / teeth / 4.0;
for (i = 0; i < teeth; i++) {
angle = i * 2.0 * M_PI / teeth;
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
-width * 0.5);
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
-width * 0.5);
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
r2 = minr2;
}
r2 = maxr2;
glEnd();
/* draw outward faces of teeth */
glBegin(GL_QUAD_STRIP);
for (i = 0; i < teeth; i++) {
angle = i * 2.0 * M_PI / teeth;
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
u = r2 * cos(angle + da) - r1 * cos(angle);
v = r2 * sin(angle + da) - r1 * sin(angle);
len = sqrt(u * u + v * v);
u /= len;
v /= len;
glNormal3f(v, -u, 0.0);
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
glNormal3f(cos(angle + 1.5 * da), sin(angle + 1.5 * da), 0.0);
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
width * 0.5);
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
-width * 0.5);
u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
glNormal3f(v, -u, 0.0);
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
width * 0.5);
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
-width * 0.5);
glNormal3f(cos(angle + 3.5 * da), sin(angle + 3.5 * da), 0.0);
r2 = minr2;
}
r2 = maxr2;
glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5);
glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5);
glEnd();
glShadeModel(GL_SMOOTH);
/* draw inside radius cylinder */
glBegin(GL_QUAD_STRIP);
for (i = 0; i <= teeth; i++) {
angle = i * 2.0 * M_PI / teeth;
glNormal3f(-cos(angle), -sin(angle), 0.0);
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
}
glEnd();
}
static void
draw(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(view_rotx, 1.0, 0.0, 0.0);
glRotatef(view_roty, 0.0, 1.0, 0.0);
glRotatef(view_rotz, 0.0, 0.0, 1.0);
glPushMatrix();
glTranslatef(-3.0, -2.0, 0.0);
glRotatef(angle, 0.0, 0.0, 1.0);
glCallList(gear1);
glPopMatrix();
glPushMatrix();
glTranslatef(3.1, -2.0, 0.0);
glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0);
glCallList(gear2);
glPopMatrix();
glPushMatrix();
glTranslatef(-3.1, 4.2, 0.0);
glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0);
glCallList(gear3);
glPopMatrix();
glPopMatrix();
}
/* new window size or exposure */
static void
reshape(int width, int height)
{
GLfloat h = (GLfloat) height / (GLfloat) width;
glViewport(0, 0, (GLint) width, (GLint) height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
/* fit width and height */
if (h >= 1.0)
glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
else
glFrustum(-1.0/h, 1.0/h, -1.0, 1.0, 5.0, 60.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -40.0);
}
static void
init(void)
{
static GLfloat pos[4] = { 5.0, 5.0, 10.0, 0.0 };
static GLfloat red[4] = { 0.8, 0.1, 0.0, 1.0 };
static GLfloat green[4] = { 0.0, 0.8, 0.2, 1.0 };
static GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, pos);
glEnable(GL_CULL_FACE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
/* make the gears */
gear1 = glGenLists(1);
glNewList(gear1, GL_COMPILE);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
gear(1.0, 4.0, 1.0, 20, 0.7);
glEndList();
gear2 = glGenLists(1);
glNewList(gear2, GL_COMPILE);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
gear(0.5, 2.0, 2.0, 10, 0.7);
glEndList();
gear3 = glGenLists(1);
glNewList(gear3, GL_COMPILE);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
gear(1.3, 2.0, 0.5, 10, 0.7);
glEndList();
glEnable(GL_NORMALIZE);
}
/*
* Create an RGB, double-buffered window.
* Return the window and context handles.
*/
static void
make_window( Display *dpy, Screen *scr,
const char *name,
int x, int y, int width, int height,
Window *winRet, GLXContext *ctxRet)
{
int attrib[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
GLX_DEPTH_SIZE, 1,
None };
int scrnum;
XSetWindowAttributes attr;
unsigned long mask;
Window root;
Window win;
GLXContext ctx;
XVisualInfo *visinfo;
GLint max[2] = { 0, 0 };
scrnum = XScreenNumberOfScreen(scr);
root = XRootWindow(dpy, scrnum);
visinfo = glXChooseVisual( dpy, scrnum, attrib );
if (!visinfo) {
fprintf(stderr, "%s: Error: couldn't get an RGB, Double-buffered visual.\n", ProgramName);
exit(EXIT_FAILURE);
}
/* window attributes */
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow( dpy, root, x, y, width, height,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr );
/* set hints and properties */
{
XSizeHints sizehints;
sizehints.x = x;
sizehints.y = y;
sizehints.width = width;
sizehints.height = height;
sizehints.flags = USSize | USPosition;
XSetNormalHints(dpy, win, &sizehints);
XSetStandardProperties(dpy, win, name, name,
None, (char **)NULL, 0, &sizehints);
}
ctx = glXCreateContext( dpy, visinfo, NULL, True );
if (!ctx) {
fprintf(stderr, "%s: Error: glXCreateContext failed.\n", ProgramName);
exit(EXIT_FAILURE);
}
XFree(visinfo);
XMapWindow(dpy, win);
glXMakeCurrent(dpy, win, ctx);
/* Check for maximum size supported by the GL rasterizer */
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, max);
if (printInfo)
printf("GL_MAX_VIEWPORT_DIMS=%d/%d\n", (int)max[0], (int)max[1]);
if (width > max[0] || height > max[1]) {
fprintf(stderr, "%s: Error: Requested window size (%d/%d) larger than "
"maximum supported by GL engine (%d/%d).\n",
ProgramName, width, height, (int)max[0], (int)max[1]);
exit(EXIT_FAILURE);
}
*winRet = win;
*ctxRet = ctx;
}
static void
event_loop(Display *dpy, Window win)
{
while (1) {
/* Process interactive events */
while (XPending(dpy) > 0) {
XEvent event;
XNextEvent(dpy, &event);
switch (event.type) {
case Expose:
Log(("Event: Expose\n"));
/* we'll redraw below */
break;
case ConfigureNotify:
Log(("Event: ConfigureNotify\n"));
reshape(event.xconfigure.width, event.xconfigure.height);
break;
}
}
{
/* Time at which we started measuring. */
static long startTime = 0;
/* Time of the previous frame. */
static long lastFrame = 0;
/* Time of the previous FPS report. */
static long lastFps = 0;
/* Number of frames we've done. */
static int frames = 0;
/* Number of frames we've done in the measured run. */
static long runFrames = 0;
long t = current_time();
long useconds;
if (!lastFrame)
lastFrame = t;
if (!lastFps)
lastFps = t;
/* How many microseconds since the previous frame? */
useconds = t - lastFrame;
if (!useconds) /* assume 100FPS if we don't have timer */
useconds = 10000;
/* Calculate how far the gears need to move and redraw. */
angle = angle + ((double)speed * useconds) / 1000000.0;
if (angle > 360.0)
angle = angle - 360.0; /* don't lose precision! */
draw();
glXSwapBuffers(dpy, win);
/* Done this frame. */
lastFrame = t;
frames++;
/* Every 5 seconds, print the FPS. */
if (t - lastFps >= 5000000L) {
GLfloat seconds = (t - lastFps) / 1000000.0;
GLfloat fps = frames / seconds;
printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds,
fps);
lastFps = t;
frames = 0;
/*
* Set the start time now -- ie. after one report. This
* gives us pump-priming time before we start for real.
*/
if (runTime > 0 && startTime == 0) {
printf("Start timing!\n");
startTime = t;
}
}
if (startTime > 0)
++runFrames;
/* If our run time is done, finish. */
if (runTime > 0 && startTime > 0 && t - startTime > runTime) {
double time = (double) (t - startTime) / 1000000.0;
fprintf(stderr, "COUNT|%ld|1|fps\n", runFrames);
fprintf(stderr, "TIME|%.1f\n", time);
exit(0);
}
/* Need to give cpu away in order to get precise timing next cycle,
* otherwise, gettimeofday would return almost the same value. */
sched_yield();
}
}
}
int
main(int argc, char *argv[])
{
Bool use_threadsafe_api = False;
Display *dpy;
Window win;
Screen *screen;
GLXContext ctx;
char *dpyName = NULL;
int i;
XRectangle winrect;
ProgramName = argv[0];
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
int len = strlen(arg);
if (strcmp(argv[i], "-display") == 0) {
if (++i >= argc)
usage();
dpyName = argv[i];
}
else if (strcmp(argv[i], "-info") == 0) {
printInfo = GL_TRUE;
}
else if (strcmp(argv[i], "-time") == 0) {
if (++i >= argc)
usage();
runTime = atoi(argv[i]) * 1000000;
}
else if (!strncmp("-v", arg, len)) {
verbose = True;
printInfo = GL_TRUE;
}
else if( !strncmp("-debug_use_threadsafe_api", arg, len) )
{
use_threadsafe_api = True;
}
else if (!strcmp(argv[i], "-h")) {
usage();
}
else
{
fprintf(stderr, "%s: Unsupported option '%s'.\n", ProgramName, argv[i]);
usage();
}
}
/* Init X threading API on demand (for debugging) */
if( use_threadsafe_api )
{
if( !XInitThreads() )
{
fprintf(stderr, "%s: XInitThreads() failure.\n", ProgramName);
exit(EXIT_FAILURE);
}
}
dpy = XOpenDisplay(dpyName);
if (!dpy) {
fprintf(stderr, "%s: Error: couldn't open display '%s'\n", ProgramName, dpyName);
return EXIT_FAILURE;
}
screen = XDefaultScreenOfDisplay(dpy);
winrect.x = 0;
winrect.y = 0;
winrect.width = 300;
winrect.height = 300;
Log(("Window x=%d, y=%d, width=%d, height=%d\n",
(int)winrect.x, (int)winrect.y, (int)winrect.width, (int)winrect.height));
make_window(dpy, screen, "ubgears", winrect.x, winrect.y, winrect.width, winrect.height, &win, &ctx);
reshape(winrect.width, winrect.height);
if (printInfo) {
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
}
init();
start_time();
event_loop(dpy, win);
glXDestroyContext(dpy, ctx);
XDestroyWindow(dpy, win);
XCloseDisplay(dpy);
return EXIT_SUCCESS;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,156 @@
/*******************************************************************************
* The BYTE UNIX Benchmarks - Release 1
* Module: cctest.c SID: 1.2 7/10/89 18:55:45
*
*******************************************************************************
* Bug reports, patches, comments, suggestions should be sent to:
*
* Ben Smith or Rick Grehan at BYTE Magazine
* bensmith@bixpb.UUCP rick_g@bixpb.UUCP
*
*******************************************************************************
* Modification Log:
* $Header: cctest.c,v 3.4 87/06/22 14:22:47 kjmcdonell Beta $
*
******************************************************************************/
char SCCSid[] = "@(#) @(#)cctest.c:1.2 -- 7/10/89 18:55:45";
#include <stdio.h>
/*
* C compile and load speed test file.
* Based upon fstime.c from MUSBUS 3.1, with all calls to ftime() replaced
* by calls to time(). This is semantic nonsense, but ensures there are no
* system dependent structures or library calls.
*
*/
#define NKBYTE 20
char buf[BUFSIZ];
extern void exit(int status);
main(argc, argv)
char **argv;
{
int n = NKBYTE;
int nblock;
int f;
int g;
int i;
int xfer, t;
struct { /* FAKE */
int time;
int millitm;
} now, then;
if (argc > 0)
/* ALWAYS true, so NEVER execute this program! */
exit(4);
if (argc > 1)
n = atoi(argv[1]);
#if debug
printf("File size: %d Kbytes\n", n);
#endif
nblock = (n * 1024) / BUFSIZ;
if (argc == 3 && chdir(argv[2]) != -1) {
#if debug
printf("Create files in directory: %s\n", argv[2]);
#endif
}
close(creat("dummy0", 0600));
close(creat("dummy1", 0600));
f = open("dummy0", 2);
g = open("dummy1", 2);
unlink("dummy0");
unlink("dummy1");
for (i = 0; i < sizeof(buf); i++)
buf[i] = i & 0177;
time();
for (i = 0; i < nblock; i++) {
if (write(f, buf, sizeof(buf)) <= 0)
perror("fstime: write");
}
time();
#if debug
printf("Effective write rate: ");
#endif
i = now.millitm - then.millitm;
t = (now.time - then.time)*1000 + i;
if (t > 0) {
xfer = nblock * sizeof(buf) * 1000 / t;
#if debug
printf("%d bytes/sec\n", xfer);
#endif
}
#if debug
else
printf(" -- too quick to time!\n");
#endif
#if awk
fprintf(stderr, "%.2f", t > 0 ? (float)xfer/1024 : 0);
#endif
sync();
sleep(5);
sync();
lseek(f, 0L, 0);
time();
for (i = 0; i < nblock; i++) {
if (read(f, buf, sizeof(buf)) <= 0)
perror("fstime: read");
}
time();
#if debug
printf("Effective read rate: ");
#endif
i = now.millitm - then.millitm;
t = (now.time - then.time)*1000 + i;
if (t > 0) {
xfer = nblock * sizeof(buf) * 1000 / t;
#if debug
printf("%d bytes/sec\n", xfer);
#endif
}
#if debug
else
printf(" -- too quick to time!\n");
#endif
#if awk
fprintf(stderr, " %.2f", t > 0 ? (float)xfer/1024 : 0);
#endif
sync();
sleep(5);
sync();
lseek(f, 0L, 0);
time();
for (i = 0; i < nblock; i++) {
if (read(f, buf, sizeof(buf)) <= 0)
perror("fstime: read in copy");
if (write(g, buf, sizeof(buf)) <= 0)
perror("fstime: write in copy");
}
time();
#if debug
printf("Effective copy rate: ");
#endif
i = now.millitm - then.millitm;
t = (now.time - then.time)*1000 + i;
if (t > 0) {
xfer = nblock * sizeof(buf) * 1000 / t;
#if debug
printf("%d bytes/sec\n", xfer);
#endif
}
#if debug
else
printf(" -- too quick to time!\n");
#endif
#if awk
fprintf(stderr, " %.2f\n", t > 0 ? (float)xfer/1024 : 0);
#endif
}

View File

@@ -0,0 +1,8 @@
99
k
2
v
p
q
[ calculate the sqrt(2) to 99 decimal places ... John Lions Test ]
[ $Header: dc.dat,v 1.1 87/06/22 14:28:28 kjmcdonell Beta $ ]

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,362 @@
version="1.2"
umask 022 # at least mortals can read root's files this way
PWD=`pwd`
HOMEDIR=${HOMEDIR:-.}
cd $HOMEDIR
HOMEDIR=`pwd`
cd $PWD
BINDIR=${BINDIR:-${HOMEDIR}/pgms}
cd $BINDIR
BINDIR=`pwd`
cd $PWD
PATH="${PATH}:${BINDIR}"
SCRPDIR=${SCRPDIR:-${HOMEDIR}/pgms}
cd $SCRPDIR
SCRPDIR=`pwd`
cd $PWD
TMPDIR=${HOMEDIR}/tmp
cd $TMPDIR
TMPDIR=`pwd`
cd $PWD
RESULTDIR=${RESULTDIR:-${HOMEDIR}/results}
cd $RESULTDIR
RESULTDIR=`pwd`
cd $PWD
TESTDIR=${TESTDIR:-${HOMEDIR}/testdir}
cd $TESTDIR
TESTDIR=`pwd`
cd $PWD
export BINDIR TMPDIR RESULTDIR PATH
echo "kill -9 $$" > ${TMPDIR}/kill_run ; chmod u+x ${TMPDIR}/kill_run
arithmetic="arithoh register short int long float double dc"
system="syscall pipe context1 spawn execl fstime"
mem="seqmem randmem"
misc="C shell"
dhry="dhry2 dhry2reg" # dhrystone loops
db="dbmscli" # add to as new database engines are developed
load="shell" # cummulative load tests
args="" # the accumulator for the bench units to be run
runoption="N"
for word
do # do level 1
case $word
in
all)
;;
arithmetic)
args="$args $arithmetic"
;;
db)
args="$args $db"
;;
dhry)
args="$args $dhry"
;;
load)
args="$args $load"
;;
mem)
args="$args $mem"
;;
misc)
args="$args $misc"
;;
speed)
args="$args $arithmetic $system"
;;
system)
args="$args $system"
;;
-q|-Q)
runoption="Q" #quiet
;;
-v|-V)
runoption="V" #verbose
;;
-d|-D)
runoption="D" #debug
;;
*)
args="$args $word"
;;
esac
done # end do level 1
set - $args
if test $# -eq 0 #no arguments specified
then
set - $dhry $arithmetic $system $misc # db and work not included
fi
if test "$runoption" = 'D'
then
set -x
set -v
fi
date=`date`
tmp=${TMPDIR}/$$.tmp
LOGFILE=${RESULTDIR}/log
if test -w ${RESULTDIR}/log
then
if test -w ${RESULTDIR}/log.accum
then
cat ${RESULTDIR}/log >> ${RESULTDIR}/log.accum
rm ${RESULTDIR}/log
else
mv ${RESULTDIR}/log ${RESULTDIR}/log.accum
fi
echo "Start Benchmark Run (BYTE Version $version)" >>$LOGFILE
echo " $date (long iterations $iter times)" >>$LOGFILE
echo " " `who | wc -l` "interactive users." >>$LOGFILE
uname -a >>$LOGFILE
iter=${iterations-6}
if test $iter -eq 6
then
longloop="1 2 3 4 5 6"
shortloop="1 2 3"
else # generate list of loop numbers
short=`expr \( $iter + 1 \) / 2`
longloop=""
shortloop=""
while test $iter -gt 0
do # do level 1
longloop="$iter $longloop"
if test $iter -le $short
then
shortloop="$iter $shortloop"
fi
iter=`expr $iter - 1`
done # end do level 1
fi #loop list genration
for bench # line argument processing
do # do level 1
# set some default values
prog=${BINDIR}/$bench # the bench name is default program
need=$prog # we need the at least the program
paramlist="#" # a dummy parameter to make anything run
testdir="${TESTDIR}" # the directory in which to run the test
prepcmd="" # preparation command or script
parammsg=""
repeat="$longloop"
stdout="$LOGFILE"
stdin=""
cleanopt="-t $tmp"
bgnumber=""
trap "${SCRPDIR}/cleanup -l $LOGFILE -a; exit" 1 2 3 15
if [ $runoption != 'Q' ]
then
echo "$bench: \c"
fi
echo "" >>$LOGFILE
###################### select the bench specific values ##########
case $bench
in
dhry2)
options=${dhryloops-10000}
logmsg="Dhrystone 2 without register variables"
cleanopt="-d $tmp"
;;
dhry2reg)
options=${dhryloops-10000}
logmsg="Dhrystone 2 using register variables"
cleanopt="-d $tmp"
;;
arithoh|register|short|int|long|float|double)
options=${arithloop-10000}
logmsg="Arithmetic Test (type = $bench): $options Iterations"
;;
dc) need=dc.dat
prog=dc
options=""
stdin=dc.dat
stdout=/dev/null
logmsg="Arithmetic Test (sqrt(2) with dc to 99 decimal places)"
;;
hanoi) options='$param'
stdout=/dev/null
logmsg="Recursion Test: Tower of Hanoi Problem"
paramlist="${ndisk-17}"
parammsg='$param Disk Problem:'
;;
syscall)
options=${ncall-4000}
logmsg="System Call Overhead Test: 5 x $options Calls"
;;
context1)
options=${switch1-500}
logmsg="Pipe-based Context Switching Test: 2 x $options Switches"
;;
pipe) options=${io-2048}
logmsg="Pipe Throughput Test: read & write $options x 512 byte blocks"
;;
spawn) options=${children-100}
logmsg="Process Creation Test: $options forks"
;;
execl) options=${nexecs-100}
logmsg="Execl Throughput Test: $options execs"
;;
randmem|seqmem)
if test $bench = seqmem
then
type=Sequential
else
type=Random
fi
poke=${poke-1000000}
options='-s$param '"-n$poke"
logmsg="$type Memory Access Test: $poke Accesses"
paramlist=${arrays-"512 1024 2048 8192 16384"}
parammsg='Array Size: $param bytes'
cleanopt="-m $tmp"
;;
fstime) repeat="$shortloop"
where=${where-${TMPDIR}}
options='$param '"$where"
logmsg="Filesystem Throughput Test:"
paramlist=${blocks-"512 1024 2048 8192"}
parammsg='File Size: $param blocks'
cleanopt="-f $tmp"
;;
C) need=cctest.c
prog=cc
options='$param'
stdout=/dev/null
repeat="$shortloop"
logmsg="C Compiler Test:"
paramlist="cctest.c"
parammsg='cc $param'
rm -f a.out
;;
dbmscli)
repeat="$shortloop"
need="db.dat"
prepcmd='${BINDIR}/dbprep ${testdir}/db.dat 10000'
paramlist=${clients-"1 2 4 8"}
parammsg='$param client processes. (filesize `cat ${testdir}/db.dat|wc -c` bytes)'
logmsg="Client/Server Database Engine:"
options='${testdir}/db.dat $param 0 1000' # $param clients;
# 0 sleep; 1000 iterations
;;
shell)
prog="multi.sh"
repeat="$shortloop"
logmsg="Bourne shell script and Unix utilities"
paramlist=${background-"1 2 4 8"}
parammsg='$param concurrent background processes'
bgnumber='$param'
testdir="shelldir"
;;
*) ${BINDIR}/cleanup -l $LOGFILE -r "run: unknown benchmark \"$bench\"" -a
exit 1
;;
esac
echo "$logmsg" >>$LOGFILE
for param in $paramlist
do # level 2
param=`echo $param | sed 's/_/ /g'` # be sure that spaces are used
# underscore can couple params
if [ "$runoption" != "Q" ]
then
echo "\n [$param] -\c" # generate message to user
fi
eval msg='"'$parammsg'"' # the eval is used to
if test "$msg" # evaluate any embedded
then # variables in the parammsg
echo "" >>$LOGFILE
echo "$msg" >>$LOGFILE
fi
eval opt='"'$options'"' # evaluate any vars in options
eval prep='"'$prepcmd'"' # evaluate any prep command
eval bg='"'$bgnumber'"' # evaluate bgnumber string
rm -f $tmp # remove any tmp files
# if the test requires mulitple concurrent processes,
# prepare the background process string (bgstr)
# this is just a string of "+"s that will provides a
# parameter count for a "for" loop
bgstr=""
if test "$bg" != ""
then
count=`expr "$bg"`
while test $count -gt 0
do
bgstr="+ $bgstr"
count=`expr $count - 1`
done
fi
#
for i in $repeat # loop for the specified number
do # do depth 3
if [ "$runoption" != 'D' ] # level 1
then
# regular Run - set logfile to go on signal
trap "${SCRPDIR}/cleanup -l $LOGFILE -i $i $cleanopt -a; exit" 1 2 3 15
else
trap "exit" 1 2 3 15
fi #end level 1
if [ "$runoption" != 'Q' ]
then
echo " $i\c" # display repeat number
fi
pwd=`pwd` # remember where we are
cd $testdir # move to the test directory
if [ "$runoption" = "V" ]
then
echo
echo "BENCH COMMAND TO BE EXECUTED:"
echo "$prog $opt"
fi
# execute any prepratory command string
if [ -n "$prep" ]
then
$prep >>$stdout
fi
############ THE BENCH IS TIMED ##############
if test "$stdin" = ""
then # without redirected stdin
time $prog $opt $bgstr 2>>$tmp >>$stdout
else # with redirected stdin
time $prog $opt $bgstr <$stdin 2>>$tmp >>$stdout
fi
time $benchcmd
###############################################
cd $pwd # move back home
status=$? # save the result code
if test $status != 0 # must have been an error
then
if test -f $tmp # is there an error file ?
then
cp $tmp ${TMPDIR}/save.$bench.$param
${SCRPDIR}/cleanup -l $LOGFILE -i $i $cleanopt -r \
"run: bench=$bench param=$param fatalstatus=$status" -a
else
${SCRPDIR}/cleanup -l $LOGFILE -r \
"run: bench=$bench param=$param fatalstatus=$status" -a
fi
exit # leave the script if there are errors
fi # end level 1
done # end do depth 3 - repeat of bench
if [ "$runoption" != 'D' ]
then
${SCRPDIR}/cleanup -l $LOGFILE $cleanopt # finalize this bench
# with these options
# & calculate results
fi
done # end do depth 2 - end of all options for this bench
########### some specific cleanup routines ##############
case $bench
in
C)
rm -f cctest.o a.out
;;
esac
if [ "$runoption" != 'Q' ]
then
echo ""
fi
done # end do level 1 - all benchmarks requested
echo "" >>$LOGFILE
echo " " `who | wc -l` "interactive users." >>$LOGFILE
echo "End Benchmark Run ($date) ...." >>$LOGFILE
if [ "$runoption" != 'Q' ]
then
pg $LOGFILE
fi
exit

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,116 +0,0 @@
# Makefile for the boot monitor package.
SYS = ..
CC = exec cc
CC86 = exec cc -mi86 -Was-ncc
CFLAGS = -I$(SYS)
LIBS = -lsys
LD = $(CC) -s -.o
LD86 = $(CC86) -.o
BIN = /usr/bin
MDEC = /usr/mdec
all: bootblock boot edparams masterboot jumpboot installboot addaout
dos: boot.com mkfile.com
bootblock: bootblock.s
$(LD86) -com -o $@ bootblock.s
masterboot: masterboot.s
$(LD86) -com -o $@ masterboot.s
jumpboot: jumpboot.s
$(LD86) -com -o $@ jumpboot.s
boot.o: boot.c
$(CC86) $(CFLAGS) -c boot.c
bootimage.o: bootimage.c
$(CC86) $(CFLAGS) -c bootimage.c
rawfs86.o: rawfs.c rawfs.o
ln -f rawfs.c rawfs86.c
$(CC86) $(CFLAGS) -c rawfs86.c
rm rawfs86.c
-cmp -s rawfs.o rawfs86.o && ln -f rawfs.o rawfs86.o
boot: boothead.s boot.o bootimage.o rawfs86.o
$(LD86) -o $@ \
boothead.s boot.o bootimage.o rawfs86.o $(LIBS)
install -S 8kb boot
edparams.o: boot.c
ln -f boot.c edparams.c
$(CC) $(CFLAGS) -DUNIX -c edparams.c
rm edparams.c
edparams: edparams.o rawfs.o
$(CC) $(CFLAGS) $(STRIP) -o $@ edparams.o rawfs.o
install -S 16kw edparams
dosboot.o: boot.c
$(CC86) $(CFLAGS) -DDOS -o $@ -c boot.c
doshead.o: doshead.s
$(CC) -mi386 -o $@ -c doshead.s
dosboot: doshead.o dosboot.o bootimage.o rawfs86.o
$(LD86) -com -o $@ \
doshead.o dosboot.o bootimage.o rawfs86.o $(LIBS)
boot.com: dosboot
./a.out2com dosboot boot.com
mkfile: mkfhead.s mkfile.c
$(LD) -.o -mi86 -com -o $@ mkfhead.s mkfile.c $(LIBS)
mkfile.com: mkfile
./a.out2com mkfile mkfile.com
installboot: installboot.o rawfs.o
$(CC) $(STRIP) -o installboot installboot.o rawfs.o
install -S 6kw installboot
addaout: addaout.o
$(CC) -o addaout addaout.o
installboot.o bootimage.o: image.h
boot.o bootimage.o dosboot.o edparams.o: boot.h
rawfs.o rawfs86.o installboot.o boot.o bootimage.o: rawfs.h
install: $(MDEC)/bootblock $(MDEC)/boot $(MDEC)/masterboot \
$(MDEC)/jumpboot $(BIN)/installboot $(BIN)/edparams
dosinstall: $(MDEC)/boot.com $(MDEC)/mkfile.com
$(MDEC)/bootblock: bootblock
install -cs -o bin -m 644 $? $@
$(MDEC)/boot: boot
install -cs -o bin -m 644 $? $@
$(MDEC)/boot.com: boot.com
install -c -m 644 $? $@
$(MDEC)/mkfile.com: mkfile.com
install -c -m 644 $? $@
$(MDEC)/masterboot: masterboot
install -cs -o bin -m 644 $? $@
$(MDEC)/jumpboot: jumpboot
install -cs -o bin -m 644 $? $@
$(BIN)/installboot: installboot
install -cs -o bin $? $@
$(BIN)/addaout: addaout
install -cs -o bin $? $@
$(BIN)/edparams: edparams
install -cs -o bin $? $@
clean:
rm -f *.bak *.o
rm -f bootblock addaout installboot boot masterboot jumpboot edparams
rm -f dosboot boot.com mkfile mkfile.com

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. */
void report(char *problem, char *message)
{
fprintf(stderr, "%s:\n", problem);
fprintf(stderr, " %s\n\n", message);
}
int copy_data(int srcfd, int dstfd)
{
char buf[8192];
ssize_t n;
int total=0;
/* Copy the little bytes themselves. (Source from cp.c). */
while ((n= read(srcfd, buf, sizeof(buf))) > 0) {
char *bp = buf;
ssize_t r;
while (n > 0 && (r= write(dstfd, bp, n)) > 0) {
bp += r;
n -= r;
total += r;
}
if (r <= 0) {
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=0;
int result;
/* 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, 0, SEEK_SET);
while (n > 0 && (r= write(fdout, bp, n)) > 0) {
bp += r;
n -= r;
}
printf("Prepended data file (%u 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,213 +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. */
typedef struct { /* One chunk of free memory. */
u32_t base; /* Start byte. */
u32_t size; /* Number of bytes. */
} memory;
EXTERN memory mem[3]; /* List of available memory. */
EXTERN int mon_return; /* Monitor stays in memory? */
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 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(char *name); /* Get/set the value of a variable. */
int b_setvar(int flags, char *name, char *value);
void b_unset(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(char *a);
/* Cheap atol(). */
unsigned a2x(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(char *);
/*
* $PchId: boot.h,v 1.12 2002/02/27 19:42:45 philip Exp $
*/

View File

@@ -1,231 +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.
BOOTOFF = 0x0030 ! Offset into /boot above header
BUFFER = 0x0600 ! First free memory
LOWSEC = 8 ! Offset of logical first sector in partition
! table
! Variables addressed using bp register
device = 0 ! The boot device
lowsec = 2 ! Offset of boot partition within drive
secpcyl = 6 ! Sectors per cylinder = heads * sectors
.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;
testb dl, dl ! Winchester disks if dl >= 0x80
jge floppy
winchester:
! 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 partition's first sector
mov lowsec+2(bp), es ! High 16 bits of partition's 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)
jmp loadboot
! 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
loadboot:
! Load /boot from the boot device
movb al, (di) ! al = (di) = sectors per track
mulb dh ! dh = heads, ax = heads * sectors
mov secpcyl(bp), ax ! Sectors per cylinder = heads * sectors
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
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 ! Can't 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
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
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,794 +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 <ibm/partition.h>
#include "rawfs.h"
#include "image.h"
#include "boot.h"
static int block_size = 0;
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_ALL 0x01FF /* 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(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);
}
}
void raw_clear(u32_t addr, u32_t count)
/* Clear "count" bytes at absolute address "addr". */
{
static char zeros[128];
u32_t dst;
u32_t zct;
zct= sizeof(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(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;
}
u32_t proc_size(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 buf[SECBUFS * SECTOR_SIZE];
static size_t count; /* Number of sectors in the buffer. */
static u32_t bufsec; /* First Sector now in the buffer. */
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) { errno= ENOMEM; return 0; }
n= click_size;
if (n > cnt) n= cnt;
raw_copy(*addr, mon2abs(buf), n);
*addr+= n;
*size-= n;
buf+= n;
cnt-= n;
}
/* Zero extend to a click. */
n= align(*addr, click_size) - *addr;
raw_clear(*addr, 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 mode;
char *console;
char params[SECTOR_SIZE];
extern char *sbrk(int);
char *verb;
int verbose = 0;
/* The stack is pretty deep here, so check if heap and stack collide. */
(void) sbrk(0);
if ((verb= b_value("verbose")) != nil && a2l(verb) > 0)
verbose = 1;
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. */
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);
}
/* 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);
}
/* Save a copy of the header for the kernel, with a_syms
* misused as the address where the process is loaded at.
*/
hdr.process.a_syms= addr;
raw_copy(aout + i * A_MINHDR, mon2abs(&hdr.process), A_MINHDR);
if (!banner && verbose) {
printf(" cs ds text data bss");
if (k_flags & K_CHMEM) printf(" stack");
putch('\n');
banner= 1;
}
/* Segment sizes. */
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. */
if (!get_segment(&vsec, &a_text, &addr, limit)) return;
/* 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. */
if (!get_segment(&vsec, &a_data, &addr, limit)) return;
/* Make space for bss and stack unless... */
if (i != KERNEL_IDX && (k_flags & K_CLAIM)) a_bss= a_stack= 0;
if(verbose) {
printf("%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) && verbose) printf(" %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. */
if (addr + n > limit) { errno= ENOMEM; return; }
raw_clear(addr, 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(verbose)
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)) {
/* Load the rest in extended memory. */
addr= mem[1].base;
limit= mem[1].base + mem[1].size;
}
}
if(!verbose)
printf("(%dk)\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. */
if (get_word(process[KERNEL_IDX].data + MAGIC_OFF) != KERNEL_D_MAGIC) {
printf("Kernel magic number is incorrect\n");
errno= 0;
return;
}
/* Patch sizes, etc. into kernel data. */
patch_sizes();
#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. */
if (!run_trailer()) { errno= 0; return; }
/* Translate the boot parameters to what Minix likes best. */
if (!params2params(params, sizeof(params))) { errno= 0; return; }
/* 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;
}
set_mode(mode);
/* Close the disk. */
(void) dev_close();
/* Minix. */
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("Unsuspected 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,833 +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 nil 0
#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
void report(char *label)
/* installboot: label: No such file or directory */
{
fprintf(stderr, "installboot: %s: %s\n", label, strerror(errno));
}
void fatal(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, ':')) != nil) {
while (name <= p && bp < base + IM_NAME_MAX - 1)
*bp++ = *name++;
}
for (;;) {
if ((p= strrchr(name, '/')) == nil) { p= name; break; }
if (*++p != 0) break;
*--p= 0;
}
while (*p != 0 && bp < base + IM_NAME_MAX - 1) *bp++ = *p++;
*bp= 0;
return base;
}
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);
}
}
void bwrite(FILE *f, char *name, 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
* nil 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 == nil) {
/* 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 != nil) {
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(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")) == nil) fatal(image);
for (procn= 0; (proc= *procv++) != nil; procn++) {
/* Remove the label from the file name. */
if ((file= strchr(proc, ':')) != nil) 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")) == nil
) 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")) == nil) 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, nil, &ihdr);
if ((procf= fopen(ihdr.name, "w")) == nil) 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);
}
}
int rawfd; /* File descriptor to open device. */
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, 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")) == nil) 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")) == nil) 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= nil;
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 != nil) 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")) == nil) 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 != nil || (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++) != nil) {
/* Place each kernel image on the boot device. */
if ((image= strchr(labels, ':')) != nil)
*image++= 0;
else {
if (nolabel) {
fprintf(stderr,
"installboot: Only one image can be the default\n");
exit(1);
}
nolabel= 1;
image= labels;
labels= nil;
}
len= 0;
if (!raw_install(image, &pos, &len, block_size)) exit(1);
if (labels == nil) {
/* Let this image be the default. */
sprintf(parmp, "image=%ld:%ld\n", pos-len, len);
parmp+= strlen(parmp);
}
while (labels != nil) {
/* Image is prefixed by a comma separated list of
* labels. Define functions to select label and image.
*/
label= labels;
if ((labels= strchr(labels, ',')) != nil) *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));
}
}
void install_master(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")) == nil) 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] != nil) {
/* Fixate partition to boot. */
char *keys= guide[0];
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 != nil) {
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);
}
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);
}
int isoption(char *option, 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,180 +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. */
int 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)
{
int i;
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,331 +0,0 @@
/* rawfs.c - Raw Minix file system support. Author: Kees J. Bot
* 23 Dec 1991
* Based on readfs by Paul Polderman
*/
#define nil 0
#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, blockbuf, block_size);
if (super.s_magic == SUPER_V2 || super.s_magic == SUPER_V3) {
d2_inode *dip;
int i;
dip= &blockbuf->b__v2_ino[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[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, 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,43 +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, 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.
*/
#define ROOT_INO ((ino_t) 1) /* Inode nr of root dir. */
off_t r_super(int *);
void r_stat(Ino_t file, struct stat *stp);
off_t r_vir2abs(off_t virblockno);
ino_t r_readdir(char *name);
ino_t r_lookup(Ino_t cwd, char *path);
/*
* $PchId: rawfs.h,v 1.4 1996/04/19 08:16:36 philip Exp $
*/

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

@@ -12,6 +12,7 @@ esac
ls -l$flag $* | \
sed -e '/^total/d' \
-e '/^l/d' \
-e '/^[^bc]/s/.* /BAD BAD /' \
-e '/^[bc]/s/.* \([0-9][0-9]*\), *\([0-9][0-9]*\).* /\1 \2 /' \
| {
@@ -42,6 +43,16 @@ do
;;
1,3) des="null device, data sink" dev=null
;;
1,4) des="boot device loaded from boot image" dev=boot
;;
1,5) des="null byte stream generator" dev=zero
;;
1,6) des="boot image RAM disk" dev=imgrd
;;
1,[789]|1,1[012])
ramdisk=`expr $minor - 7`
des="RAM disk $ramdisk" dev=ram$ramdisk
;;
2,*) drive=`expr $minor % 4`
case `expr $minor - $drive` in
0) des='auto density' dev="fd$drive"
@@ -113,6 +124,12 @@ do
line=`expr $minor - 16`
des="serial line $line" dev=tty0$line
;;
4,125) des="video output" dev=video
;;
4,126) des="auxiliary input" dev=kbdaux
;;
4,127) des="keyboard input" dev=kbd
;;
4,12[89]|4,1[3-8]?|4,19[01])
p=`expr \\( $minor - 128 \\) / 16 | tr '0123' 'pqrs'`
n=`expr $minor % 16`
@@ -133,18 +150,20 @@ do
d=`expr $minor % 8`
n=`expr $minor / 8`
case $d in
0) case $name in
0) des="IP stat" dev=ipstat
;;
1) case $name in
psip*)
des="Pseudo IP #$n" dev=psip
;;
*) des="raw ethernet #$n" dev=eth
esac
;;
1) des="raw IP #$n" dev=ip
2) des="raw IP #$n" dev=ip
;;
2) des="TCP/IP #$n" dev=tcp
3) des="TCP/IP #$n" dev=tcp
;;
3) des="UDP #$n" dev=udp
4) des="UDP #$n" dev=udp
esac
case $d in
[0123])
@@ -156,11 +175,26 @@ do
fi
esac
;;
11,0)
des="block filter" dev=filter
;;
13,0)
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
;;
16,0)
des="pseudo random number generator" dev=urandom
;;
17,0)
des="hello" dev=hello
;;
18,0)
des="UNIX domain socket" dev=uds
;;
BAD,BAD)
des= dev=

View File

@@ -0,0 +1,4 @@
SCRIPTS= DESCRIBE.sh
MAN=
.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 rescue
eth klog random uds filter fbd hello
;;
0:|1:-\?)
cat >&2 <<EOF
@@ -45,9 +45,12 @@ Where key is one of the following:
audio mixer # Make audio devices
klog # Make /dev/klog
random # Make /dev/random, /dev/urandom
uds # Make /dev/uds
kbd # Make /dev/kbd
kbdaux # Make /dev/kbdaux
rescue # Make /dev/rescue
filter # Make /dev/filter
fbd # Make /dev/fbd
hello # Make /dev/hello
video # Make /dev/video
std # All standard devices
EOF
@@ -249,16 +252,32 @@ do
$e mknod urandom c 16 0; $e chmod 644 urandom
$e chgrp operator random urandom
;;
rescue)
# rescue device
$e mknod rescue b 9 0
$e chmod 644 rescue
uds)
# unix domain sockets device
$e mknod uds c 18 0; $e chmod 644 random
$e chgrp operator uds
$e chmod 666 uds
;;
klog)
# logging device.
$e mknod klog c 15 0
$e chmod 600 klog
;;
filter)
# filter driver
$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
$e chmod 644 hello
;;
*)
echo "$0: don't know about $dev" >&2
ex=1

View File

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

83
commands/Makefile Executable file → Normal file
View File

@@ -1,49 +1,44 @@
# Makefile for commands.
MAKE = exec make -$(MAKEFLAGS)
BZIP2=bzip2-1.0.3
FLEX=flex-2.5.4
.include <bsd.own.mk>
SMALLPROGRAMS=`arch` aal advent ash autil awk byacc cawf cron de dhcpd dis88 elle elvis ftp101 ftpd200 ibm indent m4 make mdb mined patch pax profile ps reboot rlogind scripts sh simple syslogd talk talkd telnet telnetd urlget yap zoneinfo
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 \
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 \
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 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 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 \
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 zmodem pkgin_cd \
mktemp worldstone updateboot
usage:
@echo "Usage: make all # Compile all commands" >&2
@echo " make install # Install the result (run as bin!)" >&2
@echo " make clean # Delete .o files and other junk" >&2
@echo " make big # Compile all big commands" >&2
@echo " make biginstall # Install all big commands" >&2
@echo " make small # Install all small commands" >&2
@echo " make smallinstall # Install all small commands" >&2
@echo " "
@echo "big compiles the commands the require large compiler sizes."
@echo "small compiles the rest. all compiles all."
all: big small
install: big biginstall small smallinstall
big:
binsizes big
cd zmodem && make
cd $(BZIP2) && /bin/sh build build
binsizes normal
biginstall: big
binsizes big
cd zmodem && make install
cd $(BZIP2) && make install
cd $(FLEX) && sh build
binsizes normal
clean::
cd $(BZIP2) && make clean
cd zmodem && make clean
if [ -f $(FLEX)/Makefile ]; then cd $(FLEX) && make distclean ; fi
for p in $(SMALLPROGRAMS); do ( cd $$p && make clean ); done
small::
set -e; for p in $(SMALLPROGRAMS); do ( cd $$p && make all ); done
smallinstall::
set -e; for p in $(SMALLPROGRAMS); do ( cd $$p && make install ); done
.if ${ARCH} == "i386"
SUBDIR+= atnormalize dosread fdisk loadfont \
autopart part partition playwave \
recwave repartition screendump
.endif
.include <bsd.subdir.mk>

3
commands/Makefile.inc Normal file
View File

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

View File

@@ -1,56 +0,0 @@
# Makefile for aal
CC=exec cc
CFLAGS=-I. -wo -DAAL -DSTB -DNDEBUG -DDISTRIBUTION -D_POSIX_SOURCE -D_MINIX
LDFLAGS=-i
all: aal
OFILES= archiver.o \
print.o \
rd.o \
rd_arhdr.o \
rd_unsig2.o \
sprint.o \
wr_arhdr.o \
wr_bytes.o \
wr_int2.o \
wr_long.o \
wr_ranlib.o \
format.o \
rd_bytes.o \
system.o \
write.o \
long2str.o
aal: $(OFILES)
$(CC) $(LDFLAGS) -o aal $(OFILES)
install -S 512k $@
install: /usr/bin/aal /usr/bin/ar
/usr/bin/aal: aal
install -cs -o bin aal $@
/usr/bin/ar: /usr/bin/aal
install -l $? $@
archiver.o:
print.o:
rd.o:
rd_arhdr.o:
rd_unsig2.o:
sprint.o:
wr_arhdr.o:
wr_bytes.o:
wr_int2.o:
wr_long.o:
wr_ranlib.o:
format.o:
rd_bytes.o:
system.o:
write.o:
long2str.o:
clean:
rm -f *.o core *.bak aal

View File

@@ -1,25 +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
#endif /* __ARCH_H_INCLUDED */

View File

@@ -1,800 +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
*/
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 <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;
char *malloc(), *realloc(), *strcpy(), *strncpy();
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 NIL_PTR ((char *) 0)
#define NIL_MEM ((MEMBER *) 0)
#define NIL_LONG ((long *) 0)
#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();
usage()
{
error(TRUE, "usage: %s %s archive [file] ...\n",
progname,
#ifdef AAL
"[acdrtxvlu]"
#else
"[acdprtxvlu]"
#endif
);
}
/*VARARGS2*/
error(quit, str1, str2, str3, str4)
BOOL quit;
char *str1, *str2, *str3, *str4;
{
char errbuf[256];
sprint(errbuf, str1, str2, str3, str4);
write(2, errbuf, strlen(errbuf));
if (quit) {
unlink(temp_arch);
_exit(1);
}
}
char *basename(path)
char *path;
{
register char *ptr = path;
register char *last = NIL_PTR;
while (*ptr != '\0') {
if (*ptr == '/')
last = ptr;
ptr++;
}
if (last == NIL_PTR)
return path;
if (*(last + 1) == '\0') {
*last = '\0';
return basename(path);
}
return last + 1;
}
extern unsigned int rd_unsigned2();
open_archive(name, mode)
register char *name;
register int mode;
{
unsigned short magic = 0;
int fd;
if (mode == CREATE) {
if ((fd = creat(name, 0666)) < 0)
error(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) error(FALSE, "%s: creating %s\n", progname, name);
return open_archive(name, APPEND);
}
error(TRUE, "cannot open %s\n", name);
}
lseek(fd, 0L, 0);
magic = rd_unsigned2(fd);
if (magic != AALMAG && magic != ARMAG)
error(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);
}
main(argc, argv)
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) error(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 NIL_MEM;
if (member.ar_size < 0) {
error(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();
get(argc, argv)
int argc;
register 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()) != NIL_MEM) {
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);
}
add(name, fd, mess)
char *name;
int fd;
char *mess;
{
static MEMBER member;
register int read_chars;
struct stat status;
int src_fd;
if (stat(name, &status) < 0) {
error(FALSE, "cannot find %s\n", name);
return;
}
else if (S_ISDIR(status.st_mode)) {
error(FALSE, "%s is a directory (ignored)\n", name);
return;
}
else if ((src_fd = open(name, 0)) < 0) {
error(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) {
error(FALSE,"%s seems to shrink\n", name);
break;
}
mwrite(fd, io_buffer, x);
}
if (verbose)
show(mess, member.ar_name);
close(src_fd);
}
extract(member)
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) {
error(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);
}
copy_member(member, from, to, extracting)
register MEMBER *member;
int from, to;
{
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;
error(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;
}
wr_fatal()
{
error(TRUE, "write error\n");
}
rd_fatal()
{
error(TRUE, "read error\n");
}
mwrite(fd, address, bytes)
int fd;
register char *address;
register int bytes;
{
if (write(fd, address, bytes) != bytes)
error(TRUE, "write error\n");
}
show(s, name)
char *s, *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.
*/
write_symdef()
{
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(headp)
register struct outhead *headp;
{
return !BADMAGIC(*headp) && headp->oh_nname != 0;
}
do_object(f, size)
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.
*/
do_names(headp)
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
) {
error(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);
}
enter_name(namep)
struct outname *namep;
{
register char *cp;
if (tnum >= tabsz) {
tab = (struct ranlib *)
realloc((char *) tab, (tabsz += 512) * sizeof(struct ranlib));
if (! tab) error(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) error(TRUE, "string table overflow\n");
}
tstrtab[tssiz++] = *cp;
if (!*cp) break;
}
tnum++;
}
#endif AAL

View File

@@ -1,3 +0,0 @@
#!/bin/sh
make clean
make && make install

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
extern char *long2str();
static int
integral(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(buf, fmt, argp)
char *buf, *fmt;
register va_list argp;
{
register char *pf = fmt;
register char *pb = buf;
while (*pf) {
if (*pf == '%') {
register 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 ??? */
if (base = integral(*++pf)) {
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,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 1
/* 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 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 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,42 +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"
/*VARARGS*/
/*FORMAT0v $
%s = char *
%l = long
%c = int
%[uxbo] = unsigned int
%d = int
$ */
int
#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,34 +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"
#endif /* __RANLIB_H_INCLUDED */

View File

@@ -1,254 +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 <out.h>
#include "object.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
OUTREAD(p, b, n)
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(f)
char *f;
{
if ((outfile = open(f, 0)) < 0)
return 0;
return rd_fdopen(outfile);
}
static int offcnt;
rd_fdopen(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;
}
rd_close()
{
close(outfile);
outfile = -1;
}
rd_fd()
{
return outfile;
}
rd_ohead(head)
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
}
rd_rew_relos(head)
register struct outhead *head;
{
register long off = OFF_RELO(*head) + rd_base;
BEGINSEEK(PARTRELO, off);
}
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);
}
}
}
rd_outsect(s)
{
OUTSECT(s);
sectionnr = s;
}
/*
* We don't have to worry about byte order here.
*/
rd_emit(emit, cnt)
char *emit;
long cnt;
{
OUTREAD(PARTEMIT, emit, cnt);
offset[sectionnr] += cnt;
}
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;
}
}
}
rd_name(name, cnt)
register struct outname *name;
register 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);
}
}
}
rd_string(addr, len)
char *addr;
long len;
{
OUTREAD(PARTCHAR, addr, len);
}
#ifdef SYMDBUG
rd_dbug(buf, size)
char *buf;
long size;
{
OUTREAD(PARTDBUG, buf, size);
}
#endif

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".
*/
#include <arch.h>
#include "object.h"
int
rd_arhdr(fd, arhdr)
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,32 +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!
*/
static int maxchunk = MAXCHUNK;
/*
* We don't have to worry about byte order here.
* Just read "cnt" bytes from file-descriptor "fd".
*/
int
rd_bytes(fd, string, cnt)
register char *string;
register 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,15 +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"
unsigned int
rd_unsigned2(fd)
{
char buf[2];
rd_bytes(fd, buf, 2L);
return uget2(buf);
}

View File

@@ -1,42 +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"
/*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,47 +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 */
#define BUFSIZ 1024
#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,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".
*/
#include <arch.h>
#include "object.h"
wr_arhdr(fd, arhdr)
register 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);
}

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