summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2012-07-01 02:12:43 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2012-07-01 02:12:43 +0000
commit13ea39a34766fcbecd96ab94bcdf798b08e9bb60 (patch)
tree1e1463b03838a6f36868a4dafc7e652358a51857
parent1f8d504f631531c199d7c6154a0dc442d80ea4a7 (diff)
parent7e15f3d69a83a34ac62cbbee944a0bfbfa92724e (diff)
Merge branch 'master' into xkb
Conflicts: config.make.in configure.in
-rw-r--r--Makeconf14
-rw-r--r--Makefile12
-rw-r--r--README.CVS7
-rw-r--r--auth/auth.c212
-rw-r--r--boot/boot.c2
-rw-r--r--bsdfsck/fsck.h2
-rw-r--r--bsdfsck/preen.c2
-rw-r--r--bsdfsck/utilities.c2
-rw-r--r--config.make.in6
-rw-r--r--config/ttys8
-rwxr-xr-xconfigure163
-rw-r--r--configure.in7
-rw-r--r--console-client/bdf.c4
-rw-r--r--console-client/bdf.h8
-rw-r--r--console-client/driver.c2
-rw-r--r--console-client/ncursesw.c2
-rw-r--r--console-client/pc-kbd.c6
-rw-r--r--console-client/vga-dynacolor.c2
-rw-r--r--console-client/vga-dynafont.c27
-rw-r--r--console-client/vga-hw.h2
-rw-r--r--console-client/vga-support.c54
-rw-r--r--console-client/vga.c2
-rw-r--r--console/Makefile4
-rw-r--r--console/console.c2
-rw-r--r--console/display.c2
-rw-r--r--console/hurd.ti2
-rw-r--r--daemons/console-run.c18
-rw-r--r--daemons/lmail.c14
-rw-r--r--daemons/runsystem.sh2
-rw-r--r--daemons/runttys.c2
-rw-r--r--doc/Makefile10
-rw-r--r--doc/hurd.texi2
-rw-r--r--exec/do-bunzip2.c2
-rw-r--r--exec/exec.c2
-rw-r--r--ext2fs/Makefile2
-rw-r--r--ext2fs/balloc.c2
-rw-r--r--ext2fs/dir.c2
-rw-r--r--ext2fs/ext2_fs.h23
-rw-r--r--ext2fs/ext2fs.h26
-rw-r--r--ext2fs/ialloc.c5
-rw-r--r--ext2fs/pager.c7
-rw-r--r--ext2fs/xinl.c2
-rw-r--r--fatfs/Makefile1
-rw-r--r--fatfs/dir.c2
-rw-r--r--fatfs/fat.h2
-rw-r--r--fatfs/pager.c2
-rw-r--r--ftpfs/dir.c4
-rw-r--r--ftpfs/ftpfs.h4
-rw-r--r--hostmux/hostmux-xinl.c4
-rw-r--r--hostmux/hostmux.h11
-rw-r--r--hostmux/leaf.c2
-rw-r--r--hurd/console.h2
-rw-r--r--hurd/default_pager.defs1
-rw-r--r--hurd/hurd_types.h2
-rw-r--r--hurd/io.defs2
-rw-r--r--include/Makefile2
-rw-r--r--isofs/lookup.c4
-rw-r--r--isofs/rr.c2
-rw-r--r--libdiskfs/boot-start.c14
-rw-r--r--libdiskfs/diskfs.h15
-rw-r--r--libdiskfs/extern-inline.c2
-rw-r--r--libdiskfs/io-pathconf.c1
-rw-r--r--libfshelp/fshelp.h4
-rw-r--r--libfshelp/perms-checkdirmod.c2
-rw-r--r--libftpconn/fname.c2
-rw-r--r--libftpconn/ftpconn.h15
-rw-r--r--libftpconn/priv.h12
-rw-r--r--libftpconn/reply.c2
-rw-r--r--libftpconn/unix.c2
-rw-r--r--libftpconn/xinl.c2
-rw-r--r--libnetfs/io-pathconf.c1
-rw-r--r--libpager/demuxer.c20
-rw-r--r--libpager/notify-stubs.c43
-rw-r--r--libpager/pager-memcpy.c11
-rw-r--r--libpager/pager.h4
-rw-r--r--libpager/priv.h9
-rw-r--r--libpager/seqnos.c26
-rw-r--r--libpager/stubs.c18
-rw-r--r--libpipe/pipe-funcs.c2
-rw-r--r--libpipe/pipe.h56
-rw-r--r--libpipe/pq-funcs.c2
-rw-r--r--libpipe/pq.h47
-rw-r--r--libports/bucket-iterate.c2
-rw-r--r--libports/manage-multithread.c7
-rw-r--r--libports/manage-one-thread.c2
-rw-r--r--libps/fmt.c12
-rw-r--r--libps/procstat.c6
-rw-r--r--libps/ps.h14
-rw-r--r--libshouldbeinlibc/cacheq.c2
-rw-r--r--libshouldbeinlibc/idvec-funcs.c2
-rw-r--r--libshouldbeinlibc/idvec.c2
-rw-r--r--libshouldbeinlibc/idvec.h25
-rw-r--r--libshouldbeinlibc/localhost.c23
-rw-r--r--libshouldbeinlibc/maptime-funcs.c2
-rw-r--r--libshouldbeinlibc/maptime.h17
-rw-r--r--libshouldbeinlibc/ugids-xinl.c4
-rw-r--r--libshouldbeinlibc/ugids.c4
-rw-r--r--libshouldbeinlibc/ugids.h19
-rw-r--r--libstore/argp.c2
-rw-r--r--libstore/kids.c4
-rw-r--r--libstore/store.h18
-rw-r--r--libstore/xinl.c2
-rw-r--r--libthreads/alpha/thread.c2
-rw-r--r--libthreads/cprocs.c3
-rw-r--r--libthreads/cthread_internals.h16
-rw-r--r--libthreads/i386/thread.c32
-rw-r--r--libthreads/mig_support.c2
-rw-r--r--libthreads/rwlock.c2
-rw-r--r--libthreads/rwlock.h23
-rw-r--r--libtreefs/Makefile4
-rw-r--r--libtreefs/mig-decls.h9
-rw-r--r--libtreefs/treefs.h37
-rw-r--r--libtreefs/xinl.c3
-rw-r--r--libtrivfs/file-reparent.c5
-rw-r--r--libtrivfs/trivfs.h2
-rw-r--r--login/utmp.c4
-rw-r--r--mach-defpager/Makefile6
-rw-r--r--mach-defpager/default_pager.c (renamed from serverboot/default_pager.c)398
-rw-r--r--mach-defpager/default_pager.h43
-rw-r--r--mach-defpager/kalloc.c (renamed from serverboot/kalloc.c)10
-rw-r--r--mach-defpager/kalloc.h30
-rw-r--r--mach-defpager/main.c2
-rw-r--r--mach-defpager/queue.h (renamed from serverboot/queue.h)0
-rw-r--r--mach-defpager/setup.c14
-rw-r--r--mach-defpager/wiring.c (renamed from serverboot/wiring.c)1
-rw-r--r--mach-defpager/wiring.h (renamed from serverboot/wiring.h)0
-rw-r--r--nfs/Makefile6
-rw-r--r--nfs/mount.c4
-rw-r--r--nfs/ops.c13
-rw-r--r--nfs/rpc.c2
-rw-r--r--pfinet/Makefile104
-rw-r--r--pfinet/ethernet.c67
-rw-r--r--pfinet/linux-src/arch/sparc/lib/checksum.S2
-rw-r--r--pfinet/linux-src/include/linux/b1lli.h2
-rw-r--r--pfinet/linux-src/include/linux/cdk.h2
-rw-r--r--pfinet/linux-src/include/linux/cdrom.h2
-rw-r--r--pfinet/linux-src/include/linux/coda_opstats.h2
-rw-r--r--pfinet/linux-src/include/linux/cyclades.h4
-rw-r--r--pfinet/linux-src/include/linux/isdn.h4
-rw-r--r--pfinet/linux-src/include/linux/isdn_ppp.h2
-rw-r--r--pfinet/linux-src/include/linux/isdnif.h4
-rw-r--r--pfinet/linux-src/include/linux/ixjuser.h4
-rw-r--r--pfinet/linux-src/include/linux/loop.h2
-rw-r--r--pfinet/linux-src/include/linux/module.h2
-rw-r--r--pfinet/linux-src/include/linux/notifier.h2
-rw-r--r--pfinet/linux-src/include/linux/poll.h2
-rw-r--r--pfinet/linux-src/include/linux/rtnetlink.h2
-rw-r--r--pfinet/linux-src/include/linux/socket.h2
-rw-r--r--pfinet/linux-src/include/linux/soundcard.h2
-rw-r--r--pfinet/linux-src/include/linux/telephony.h4
-rw-r--r--pfinet/linux-src/include/linux/tpqic02.h6
-rw-r--r--pfinet/linux-src/include/linux/tty_ldisc.h2
-rw-r--r--pfinet/linux-src/include/linux/wavefront.h2
-rw-r--r--pfinet/linux-src/include/linux/wireless.h2
-rw-r--r--pfinet/linux-src/include/net/pkt_sched.h2
-rw-r--r--pfinet/linux-src/include/net/tcp.h6
-rw-r--r--pfinet/linux-src/net/core/dev.c2
-rw-r--r--pfinet/linux-src/net/core/sock.c4
-rw-r--r--pfinet/linux-src/net/ipv4/fib_semantics.c2
-rw-r--r--pfinet/linux-src/net/ipv4/icmp.c2
-rw-r--r--pfinet/linux-src/net/ipv4/ip_fw.c2
-rw-r--r--pfinet/linux-src/net/ipv4/ip_gre.c2
-rw-r--r--pfinet/linux-src/net/ipv4/ip_masq_quake.c4
-rw-r--r--pfinet/linux-src/net/ipv4/ip_options.c9
-rw-r--r--pfinet/linux-src/net/ipv4/ip_output.c2
-rw-r--r--pfinet/linux-src/net/ipv4/ipconfig.c2
-rw-r--r--pfinet/linux-src/net/ipv4/ipip.c2
-rw-r--r--pfinet/linux-src/net/ipv4/raw.c2
-rw-r--r--pfinet/linux-src/net/ipv4/tcp.c2
-rw-r--r--pfinet/linux-src/net/ipv4/tcp_input.c8
-rw-r--r--pfinet/linux-src/net/ipv4/tcp_ipv4.c2
-rw-r--r--pfinet/linux-src/net/ipv4/tcp_output.c2
-rw-r--r--pfinet/linux-src/net/ipv6/addrconf.c4
-rw-r--r--pfinet/linux-src/net/ipv6/af_inet6.c2
-rw-r--r--pfinet/linux-src/net/ipv6/icmpv6.c8
-rw-r--r--pfinet/linux-src/net/ipv6/ip6_fib.c2
-rw-r--r--pfinet/linux-src/net/ipv6/ip6_input.c2
-rw-r--r--pfinet/linux-src/net/ipv6/ip6_output.c2
-rw-r--r--pfinet/linux-src/net/ipv6/ndisc.c4
-rw-r--r--pfinet/linux-src/net/ipv6/udp_ipv6.c2
-rw-r--r--pfinet/main.c4
-rw-r--r--pfinet/options.c2
-rw-r--r--pfinet/socket-ops.c14
-rw-r--r--pfinet/tunnel.c3
-rw-r--r--pflocal/Makefile2
-rw-r--r--pflocal/io.c2
-rw-r--r--pflocal/pf.c4
-rw-r--r--pflocal/socket.c4
-rw-r--r--proc/info.c4
-rw-r--r--proc/mgt.c2
-rw-r--r--release/SOURCES.0.02
-rw-r--r--release/mkfsimage.sh6
-rw-r--r--serverboot/Makefile53
-rw-r--r--serverboot/assert.h50
-rw-r--r--serverboot/bootstrap.c438
-rw-r--r--serverboot/bunzip2.c169
-rw-r--r--serverboot/def_pager_setup.c152
-rw-r--r--serverboot/defs.h95
-rw-r--r--serverboot/dir.h142
-rw-r--r--serverboot/disk_inode.h101
-rw-r--r--serverboot/disk_inode_ffs.h99
-rw-r--r--serverboot/elf-load.c143
-rw-r--r--serverboot/exec.c147
-rw-r--r--serverboot/ext2_file_io.c983
-rw-r--r--serverboot/ffs_compat.c65
-rw-r--r--serverboot/ffs_compat.h54
-rw-r--r--serverboot/ffs_file_io.c969
-rw-r--r--serverboot/file_io.c317
-rw-r--r--serverboot/file_io.h200
-rw-r--r--serverboot/fs.h455
-rw-r--r--serverboot/gets.c90
-rw-r--r--serverboot/gunzip.c188
-rw-r--r--serverboot/load.c555
-rw-r--r--serverboot/mach-exec.h130
-rw-r--r--serverboot/minix_ffs_compat.c62
-rw-r--r--serverboot/minix_ffs_compat.h43
-rw-r--r--serverboot/minix_file_io.c851
-rw-r--r--serverboot/minix_fs.h107
-rw-r--r--serverboot/minix_super.h49
-rw-r--r--serverboot/panic.c58
-rw-r--r--serverboot/strfcns.c74
-rw-r--r--storeio/dev.c6
-rw-r--r--storeio/pager.c4
-rw-r--r--sutils/clookup.c2
-rwxr-xr-xsutils/e2os.sh4
-rw-r--r--sutils/fsck.c2
-rw-r--r--sutils/fstab.c26
-rw-r--r--tasks2
-rw-r--r--term/Makefile2
-rw-r--r--term/main.c2
-rw-r--r--term/munge.c4
-rw-r--r--term/term.h47
-rw-r--r--term/users.c2
-rw-r--r--term/xinl.c2
-rw-r--r--tmpfs/dir.c22
-rw-r--r--tmpfs/node.c25
-rw-r--r--tmpfs/pager-stubs.c4
-rw-r--r--tmpfs/tmpfs.c28
-rw-r--r--trans/Makefile1
-rw-r--r--trans/proxy-defpager.c1
-rw-r--r--trans/streamio.c3
-rw-r--r--ufs-fsck/utilities.c2
-rw-r--r--ufs/Makefile2
-rw-r--r--ufs/alloc.c6
-rw-r--r--ufs/dir.c2
-rw-r--r--ufs/inode.c2
-rw-r--r--ufs/ufs.h34
-rw-r--r--ufs/xinl.c2
-rw-r--r--utils/devprobe.c2
-rw-r--r--utils/ftpcp.c2
-rw-r--r--utils/ftpdir.c2
-rw-r--r--utils/login.c2
-rw-r--r--utils/mount.c2
-rw-r--r--utils/shd.c2
-rw-r--r--utils/storeinfo.c4
-rw-r--r--utils/vmstat.c4
-rw-r--r--utils/w.c2
257 files changed, 1635 insertions, 7704 deletions
diff --git a/Makeconf b/Makeconf
index 8c2bd0c9..b6134ef4 100644
--- a/Makeconf
+++ b/Makeconf
@@ -35,9 +35,6 @@
# Put this first so it's the default
all:
-# What version of the Hurd is this?
-hurd-version := 0.3
-
# Figure out how to locate the parent directory from here.
ifeq (.,$(dir))
.. =
@@ -273,6 +270,15 @@ $(libdir)/$(libname).so: $(libdir)/$(libname).so.$(hurd-version)
$(addprefix $(includedir)/$(installhdrsubdir)/,$(installhdrs)): $(includedir)/$(installhdrsubdir)/%: %
$(INSTALL_DATA) $< $@
+# Arrange to have the shared libraries available locally in one single
+# directory. This is not used by the build system itself, but is just for easy
+# testing.
+local-libdir = lib
+../$(local-libdir)/$(libname).so.$(hurd-version): $(libname).so.$(hurd-version)
+ @test -d $(@D)/ || $(MKINSTALLDIRS) $(@D)
+ ln -sf ../$(dir)/$< $@
+libs: ../$(local-libdir)/$(libname).so.$(hurd-version)
+
endif
# Provide default.
@@ -382,7 +388,7 @@ $(..)$(dir).d: $(srcdir)/Makefile
echo $(dir): $(hurd-bug-addr-dir-dep) $(addprefix lib,$(HURDLIBS)) > $@
# Making a snapshot
-distfiles = Makefile ChangeLog $(SRCS) $(LCLHDRS) $(DIST_FILES)
+distfiles = Makefile $(SRCS) $(LCLHDRS) $(DIST_FILES)
lndist: $(distfiles) $(top_srcdir)/hurd-snap/$(dir) FORCE
ln $(addprefix $(srcdir)/,$(distfiles)) $(top_srcdir)/hurd-snap/$(dir)
diff --git a/Makefile b/Makefile
index 3194473c..e0ba0523 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
#
# Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2004,
-# 2006, 2009 Free Software Foundation, Inc.
+# 2006, 2009, 2011 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
@@ -21,7 +21,7 @@ makemode := misc
include ./Makeconf
-DIST_FILES = COPYING Makeconf config.make.in configure.in configure \
+DIST_FILES = ChangeLog COPYING Makeconf config.make.in configure.in configure \
move-if-change hurd.boot build.mk.in build.mkcf.in aclocal.m4 \
README NEWS tasks INSTALL INSTALL-cross version.h.in
@@ -35,13 +35,17 @@ lib-subdirs = libshouldbeinlibc libihash libiohelp libports libthreads \
# Hurd programs
prog-subdirs = auth proc exec init term \
- ufs ext2fs isofs nfs tmpfs fatfs \
+ ufs ext2fs isofs tmpfs fatfs \
storeio pflocal pfinet defpager mach-defpager \
- login daemons nfsd boot console \
+ login daemons boot console \
hostmux usermux ftpfs trans \
console-client utils sutils ufs-fsck ufs-utils \
benchmarks fstests
+ifeq ($(HAVE_SUN_RPC),yes)
+prog-subdirs += nfs nfsd
+endif
+
# Other directories
other-subdirs = hurd doc config release include
diff --git a/README.CVS b/README.CVS
index 781acdeb..92a2392d 100644
--- a/README.CVS
+++ b/README.CVS
@@ -17,6 +17,13 @@ GNU Mach at least 1.3
GNU C library CVS from 2004-03-09 or later
GNU C compiler at least 3.3.2
+Optionally, a Sun RPC implementation is needed to build the NFS
+translator and daemon:
+
+GNU C library at most 2.13
+TI-RPC (currently fails to build on GNU, see
+ <http://lists.debian.org/debian-hurd/2010/12/msg00007.html>.)
+
Obviously, you also need somewhat recent versions of binutils, make,
bash and some other tools. No hard requirements are currently known
for these, though.
diff --git a/auth/auth.c b/auth/auth.c
index 2afeaf7a..11db0f8f 100644
--- a/auth/auth.c
+++ b/auth/auth.c
@@ -251,11 +251,22 @@ S_auth_makeauth (struct authhandle *auth,
/* Transaction handling. */
-/* A pending transaction. */
-struct pending
+/* Since the user is responsible for freeing the rendezvous port, it has to
+ * wait for the server to have finished transmitting uids.
+ *
+ * The server thus waits for the user to give it uids (unless it was already
+ * there), transmits them and provides the passthrough port.
+ *
+ * The user gives the uids and waits for the passthrough port from the server.
+ *
+ * If the user is early, it has to tell the server it arrived.
+ */
+
+/* A pending user. */
+struct pending_user
{
- hurd_ihash_locp_t locp; /* Position in one of the ihash tables. */
- struct condition wakeup; /* The waiter is blocked on this condition. */
+ hurd_ihash_locp_t locp; /* Position in the pending_users ihash table. */
+ struct condition wakeup; /* The reader is blocked on this condition. */
/* The user's auth handle. */
struct authhandle *user;
@@ -264,11 +275,18 @@ struct pending
mach_port_t passthrough;
};
+/* A pending server. */
+struct pending_server
+ {
+ hurd_ihash_locp_t locp; /* Position in the pending_servers ihash table. */
+ struct condition wakeup; /* The server is blocked on this condition. */
+ };
+
/* Table of pending transactions keyed on RENDEZVOUS. */
struct hurd_ihash pending_users
- = HURD_IHASH_INITIALIZER (offsetof (struct pending, locp));
+ = HURD_IHASH_INITIALIZER (offsetof (struct pending_user, locp));
struct hurd_ihash pending_servers
- = HURD_IHASH_INITIALIZER (offsetof (struct pending, locp));
+ = HURD_IHASH_INITIALIZER (offsetof (struct pending_server, locp));
struct mutex pending_lock = MUTEX_INITIALIZER;
/* Implement auth_user_authenticate as described in <hurd/auth.defs>. */
@@ -280,7 +298,9 @@ S_auth_user_authenticate (struct authhandle *userauth,
mach_port_t *newport,
mach_msg_type_name_t *newporttype)
{
- struct pending *s;
+ struct pending_server *s;
+ struct pending_user u;
+ error_t err;
if (! userauth)
return EOPNOTSUPP;
@@ -288,65 +308,54 @@ S_auth_user_authenticate (struct authhandle *userauth,
if (rendezvous == MACH_PORT_DEAD) /* Port died in transit. */
return EINVAL;
+ u.user = userauth;
+ condition_init (&u.wakeup);
+
mutex_lock (&pending_lock);
- /* Look for this port in the server list. */
- s = hurd_ihash_find (&pending_servers, rendezvous);
- if (s)
- {
- /* Found it! Extract the port. */
- *newport = s->passthrough;
- *newporttype = MACH_MSG_TYPE_MOVE_SEND;
+ err = hurd_ihash_add (&pending_users, rendezvous, &u);
+ if (err) {
+ mutex_unlock (&pending_lock);
+ return err;
+ }
- /* Remove it from the pending list. */
- hurd_ihash_locp_remove (&pending_servers, s->locp);
+ /* Give the server the auth port.
+ We need to add a ref in case the port dies. */
+ ports_port_ref (userauth);
- /* Give the server the auth port and wake the RPC up.
- We need to add a ref in case the port dies. */
- s->user = userauth;
- ports_port_ref (userauth);
+ /* Look for this rendezvous in the server list. */
+ s = hurd_ihash_find (&pending_servers, rendezvous);
+ if (s) {
+ /* Found it! */
- condition_signal (&s->wakeup);
- mutex_unlock (&pending_lock);
+ /* Remove it from the pending list. */
+ hurd_ihash_locp_remove (&pending_servers, s->locp);
- mach_port_deallocate (mach_task_self (), rendezvous);
- return 0;
- }
- else
+ /* Tell it we eventually arrived. */
+ condition_signal (&s->wakeup);
+ }
+
+ ports_interrupt_self_on_port_death (userauth, rendezvous);
+ /* Wait for server answer. */
+ if (hurd_condition_wait (&u.wakeup, &pending_lock) &&
+ hurd_ihash_find (&pending_users, rendezvous))
+ /* We were interrupted; remove our record. */
{
- /* No pending server RPC for this port.
- Create a pending user RPC record. */
- struct pending u;
- error_t err;
+ hurd_ihash_locp_remove (&pending_users, u.locp);
+ err = EINTR;
+ }
- err = hurd_ihash_add (&pending_users, rendezvous, &u);
- if (! err)
- {
- /* Store the user auth port and wait for the server RPC to wake
- us up. */
- u.user = userauth;
- condition_init (&u.wakeup);
- ports_interrupt_self_on_port_death (userauth, rendezvous);
- if (hurd_condition_wait (&u.wakeup, &pending_lock)
- && hurd_ihash_find (&pending_users, rendezvous))
- /* We were interrupted; remove our record. */
- {
- hurd_ihash_locp_remove (&pending_users, u.locp);
- err = EINTR;
- }
- }
- /* The server side has already removed U from the ihash table. */
- mutex_unlock (&pending_lock);
+ mutex_unlock (&pending_lock);
- if (! err)
- {
- /* The server RPC has set the port and signalled U.wakeup. */
- *newport = u.passthrough;
- *newporttype = MACH_MSG_TYPE_MOVE_SEND;
- mach_port_deallocate (mach_task_self (), rendezvous);
- }
- return err;
+ if (! err)
+ {
+ /* Extract the port. */
+ *newport = u.passthrough;
+ *newporttype = MACH_MSG_TYPE_MOVE_SEND;
+ mach_port_deallocate (mach_task_self (), rendezvous);
}
+
+ return err;
}
/* Implement auth_server_authenticate as described in <hurd/auth.defs>. */
@@ -366,7 +375,7 @@ S_auth_server_authenticate (struct authhandle *serverauth,
uid_t **agids,
size_t *nagids)
{
- struct pending *u;
+ struct pending_user *u;
struct authhandle *user;
error_t err;
@@ -378,66 +387,69 @@ S_auth_server_authenticate (struct authhandle *serverauth,
mutex_lock (&pending_lock);
- /* Look for this port in the user list. */
+ /* Look for this rendezvous in the user list. */
u = hurd_ihash_find (&pending_users, rendezvous);
- if (u)
+ if (! u)
{
- /* Remove it from the pending list. */
- hurd_ihash_locp_remove (&pending_users, u->locp);
-
- /* Found it! We must add a ref because the one held by the
- user RPC might die as soon as we unlock pending_lock. */
- user = u->user;
- ports_port_ref (user);
-
- /* Give the user the new port and wake the RPC up. */
- u->passthrough = newport;
-
- condition_signal (&u->wakeup);
- mutex_unlock (&pending_lock);
- }
- else
- {
- /* No pending user RPC for this port.
- Create a pending server RPC record. */
- struct pending s;
-
+ /* User not here yet, have to wait for it. */
+ struct pending_server s;
+ condition_init (&s.wakeup);
err = hurd_ihash_add (&pending_servers, rendezvous, &s);
if (! err)
- {
- /* Store the new port and wait for the user RPC to wake us up. */
- s.passthrough = newport;
- condition_init (&s.wakeup);
+ {
ports_interrupt_self_on_port_death (serverauth, rendezvous);
- if (hurd_condition_wait (&s.wakeup, &pending_lock)
- && hurd_ihash_find (&pending_servers, rendezvous))
+ if (hurd_condition_wait (&s.wakeup, &pending_lock) &&
+ hurd_ihash_find (&pending_servers, rendezvous))
/* We were interrupted; remove our record. */
{
hurd_ihash_locp_remove (&pending_servers, s.locp);
err = EINTR;
}
- }
- /* The user side has already removed S from the ihash table. */
+ else
+ {
+ u = hurd_ihash_find (&pending_users, rendezvous);
+ if (! u)
+ /* User still not here, odd! */
+ err = EINTR;
+ }
+ }
+ }
+
+ if (u)
+ {
+ error_t err2;
+
+ /* Remove it from the pending list. */
+ hurd_ihash_locp_remove (&pending_users, u->locp);
+
+ /* Found it! */
+ user = u->user;
+
mutex_unlock (&pending_lock);
- if (err)
- return err;
+ /* Tell third party. */
+ err2 = auth_server_authenticate_reply (reply, reply_type, 0,
+ user->euids.ids, user->euids.num,
+ user->auids.ids, user->auids.num,
+ user->egids.ids, user->egids.num,
+ user->agids.ids, user->agids.num);
+
+ if (err2)
+ mach_port_deallocate (mach_task_self (), reply);
+
+ mutex_lock (&pending_lock);
+
+ /* Give the user the new port and wake the RPC up. */
+ u->passthrough = newport;
- /* The user RPC has set the port (with a ref) and signalled S.wakeup. */
- user = s.user;
+ condition_signal (&u->wakeup);
}
- /* Extract the ids. We must use a separate reply stub so
- we can deref the user auth handle after the reply uses its
- contents. */
- err = auth_server_authenticate_reply (reply, reply_type, 0,
- user->euids.ids, user->euids.num,
- user->auids.ids, user->auids.num,
- user->egids.ids, user->egids.num,
- user->agids.ids, user->agids.num);
+ mutex_unlock (&pending_lock);
if (err)
- mach_port_deallocate (mach_task_self (), reply);
+ return err;
+
ports_port_deref (user);
mach_port_deallocate (mach_task_self (), rendezvous);
return MIG_NO_REPLY;
diff --git a/boot/boot.c b/boot/boot.c
index 68ba2461..2b143844 100644
--- a/boot/boot.c
+++ b/boot/boot.c
@@ -827,7 +827,7 @@ read_reply ()
if (! spin_try_lock (&readlock))
return;
- /* Since we're commited to servicing the read, no one else need do so. */
+ /* Since we're committed to servicing the read, no one else need do so. */
should_read = 0;
ioctl (0, FIONREAD, &avail);
diff --git a/bsdfsck/fsck.h b/bsdfsck/fsck.h
index c418f66c..04bb7698 100644
--- a/bsdfsck/fsck.h
+++ b/bsdfsck/fsck.h
@@ -209,7 +209,7 @@ struct inodesc {
* To check if a block has been found as a duplicate it is only
* necessary to search from duplist through muldup. To find the
* total number of times that a block has been found as a duplicate
- * the entire list must be searched for occurences of the block
+ * the entire list must be searched for occurrences of the block
* in question. The following diagram shows a sample list where
* w (found twice), x (found once), y (found three times), and z
* (found once) are duplicate block numbers:
diff --git a/bsdfsck/preen.c b/bsdfsck/preen.c
index 7893a5e1..5650f900 100644
--- a/bsdfsck/preen.c
+++ b/bsdfsck/preen.c
@@ -51,7 +51,7 @@ struct part {
struct part *next; /* forward link of partitions on disk */
char *name; /* device name */
char *fsname; /* mounted filesystem name */
- long auxdata; /* auxillary data for application */
+ long auxdata; /* auxiliary data for application */
} *badlist, **badnext = &badlist;
struct disk {
diff --git a/bsdfsck/utilities.c b/bsdfsck/utilities.c
index 2141e7f8..1c281b1b 100644
--- a/bsdfsck/utilities.c
+++ b/bsdfsck/utilities.c
@@ -520,7 +520,7 @@ errexit(s1, s2, s3, s4)
}
/*
- * An unexpected inconsistency occured.
+ * An unexpected inconsistency occurred.
* Die if preening, otherwise just print message and continue.
*/
/* VARARGS1 */
diff --git a/config.make.in b/config.make.in
index 6aed976f..b8002a17 100644
--- a/config.make.in
+++ b/config.make.in
@@ -1,5 +1,8 @@
# @configure_input@
+# What version of the Hurd is this?
+hurd-version := @PACKAGE_VERSION@
+
# Machine architecture.
machine = @host_cpu@
asm_syntax = @asm_syntax@
@@ -74,6 +77,9 @@ X11_LIBS = @X11_LIBS@
XKB_BASE = @XKB_BASE@
X11_KEYSYMDEF_H = @X11_KEYSYMDEF_H@
+# Whether Sun RPC support is available.
+HAVE_SUN_RPC = @HAVE_SUN_RPC@
+
# Installation tools.
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/config/ttys b/config/ttys
index 14922eb3..2b3464d1 100644
--- a/config/ttys
+++ b/config/ttys
@@ -4,5 +4,11 @@
# name program type status comments
-console "/libexec/getty 9600" mach-color on secure trusted console
+console "/libexec/getty 9600" mach-gnu-color on secure trusted console
+tty1 "/libexec/getty 38400" hurd on secure trusted console
+tty2 "/libexec/getty 38400" hurd on secure trusted console
+tty3 "/libexec/getty 38400" hurd on secure trusted console
+tty4 "/libexec/getty 38400" hurd on secure trusted console
+tty5 "/libexec/getty 38400" hurd on secure trusted console
+tty6 "/libexec/getty 38400" hurd on secure trusted console
#com0 "/libexec/getty 9600" dialup on secure
diff --git a/configure b/configure
index db1574fb..1fab7980 100755
--- a/configure
+++ b/configure
@@ -1,7 +1,9 @@
#! /bin/sh
# From configure.in Id: configure.in,v 1.38 2008/11/17 11:34:18 tschwinge Exp .
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.67.
+# Generated by GNU Autoconf 2.67 for GNU Hurd 0.3.
+#
+# Report bugs to <bug-hurd@gnu.org>.
#
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -229,10 +231,11 @@ fi
$as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
$as_echo "$0: be upgraded to zsh 4.3.4 or later."
else
- $as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
-$0: including any error possibly output before this
-$0: message. Then install a modern shell, or manually run
-$0: the script under such a shell if you do have one."
+ $as_echo "$0: Please tell bug-autoconf@gnu.org and bug-hurd@gnu.org
+$0: about your system, including any error possibly output
+$0: before this message. Then install a modern shell, or
+$0: manually run the script under such a shell if you do
+$0: have one."
fi
exit 1
fi
@@ -548,12 +551,12 @@ MFLAGS=
MAKEFLAGS=
# Identity of this package.
-PACKAGE_NAME=
-PACKAGE_TARNAME=
-PACKAGE_VERSION=
-PACKAGE_STRING=
-PACKAGE_BUGREPORT=
-PACKAGE_URL=
+PACKAGE_NAME='GNU Hurd'
+PACKAGE_TARNAME='hurd'
+PACKAGE_VERSION='0.3'
+PACKAGE_STRING='GNU Hurd 0.3'
+PACKAGE_BUGREPORT='bug-hurd@gnu.org'
+PACKAGE_URL='http://www.gnu.org/software/hurd/'
ac_unique_file="hurd/hurd_types.h"
ac_default_prefix=
@@ -595,6 +598,7 @@ ac_includes_default="\
ac_subst_vars='LTLIBOBJS
LIBOBJS
+HAVE_SUN_RPC
LIBNCURSESW
NCURSESW_INCLUDE
boot_store_types
@@ -729,7 +733,7 @@ sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
includedir='${prefix}/include'
oldincludedir='/usr/include'
-docdir='${datarootdir}/doc/${PACKAGE}'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
infodir='${datarootdir}/info'
htmldir='${docdir}'
dvidir='${docdir}'
@@ -1231,7 +1235,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures this package to adapt to many kinds of systems.
+\`configure' configures GNU Hurd 0.3 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1279,7 +1283,7 @@ Fine tuning of the installation directories:
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
- --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]
+ --docdir=DIR documentation root [DATAROOTDIR/doc/hurd]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
@@ -1295,7 +1299,9 @@ _ACEOF
fi
if test -n "$ac_init_help"; then
-
+ case $ac_init_help in
+ short | recursive ) echo "Configuration of GNU Hurd 0.3:";;
+ esac
cat <<\_ACEOF
Optional Features:
@@ -1336,7 +1342,9 @@ Some influential environment variables:
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
-Report bugs to the package provider.
+Report bugs to <bug-hurd@gnu.org>.
+GNU Hurd home page: <http://www.gnu.org/software/hurd/>.
+General help using GNU software: <http://www.gnu.org/gethelp/>.
_ACEOF
ac_status=$?
fi
@@ -1399,7 +1407,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-configure
+GNU Hurd configure 0.3
generated by GNU Autoconf 2.67
Copyright (C) 2010 Free Software Foundation, Inc.
@@ -1671,6 +1679,10 @@ $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+( $as_echo "## ------------------------------- ##
+## Report this to bug-hurd@gnu.org ##
+## ------------------------------- ##"
+ ) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
@@ -1764,7 +1776,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by $as_me, which was
+It was created by GNU Hurd $as_me 0.3, which was
generated by GNU Autoconf 2.67. Invocation command line was
$ $0 $@
@@ -2023,7 +2035,7 @@ $as_echo "$as_me: loading site script $ac_site_file" >&6;}
|| { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "failed to load site script $ac_site_file
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
done
@@ -2165,7 +2177,7 @@ fi
$as_echo "$ac_cv_build" >&6; }
case $ac_cv_build in
*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;;
+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
esac
build=$ac_cv_build
ac_save_IFS=$IFS; IFS='-'
@@ -2198,7 +2210,7 @@ fi
$as_echo "$ac_cv_host" >&6; }
case $ac_cv_host in
*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;;
+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
esac
host=$ac_cv_host
ac_save_IFS=$IFS; IFS='-'
@@ -2219,12 +2231,12 @@ gnu*) ;;
none) as_fn_error $? "
*** You must specify a host of $host_cpu-gnu or $host_cpu-$host_vendor-gnu
*** to configure; you will need to use the same host specification
-*** to configure other packages for the GNU/Hurd system." "$LINENO" 5 ;;
+*** to configure other packages for the GNU/Hurd system." "$LINENO" 5 ;;
*) as_fn_error $? "this is the gnu os, host cannot be $host_os
*** Host configuration must be \`MACHINE-gnu' or \`MACHINE-VENDOR-gnu'.
*** To cross-compile, you must specify both --host and --build;
*** for example \`--build=$host --host=$host_cpu-gnu'.
-*** Run $0 --help for more information." "$LINENO" 5 ;;
+*** Run $0 --help for more information." "$LINENO" 5 ;;
esac
case "$host_cpu" in
@@ -2727,7 +2739,7 @@ fi
test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "no acceptable C compiler found in \$PATH
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
# Provide some information about the compiler.
$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
@@ -2842,7 +2854,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "C compiler cannot create executables
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
@@ -2885,7 +2897,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f conftest conftest$ac_cv_exeext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
@@ -2944,7 +2956,7 @@ $as_echo "$ac_try_echo"; } >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot run C compiled programs.
If you meant to cross compile, use \`--host'.
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
fi
fi
@@ -2996,7 +3008,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot compute suffix of object files: cannot compile
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f conftest.$ac_cv_objext conftest.$ac_ext
fi
@@ -4049,7 +4061,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
ac_ext=c
@@ -4329,7 +4341,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "Please install required libraries or use --without-parted.
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
@@ -4382,7 +4394,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "Please install required libraries or use --without-parted.
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
@@ -4434,7 +4446,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "Please install required libraries or use --without-parted.
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
@@ -4486,7 +4498,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "Please install required libraries or use --without-parted.
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
@@ -4608,6 +4620,75 @@ $as_echo "$hurd_cv_includedir_ncursesw" >&6; }
+# Check for Sun RPC headers and library.
+ac_fn_c_check_header_mongrel "$LINENO" "rpc/types.h" "ac_cv_header_rpc_types_h" "$ac_includes_default"
+if test "x$ac_cv_header_rpc_types_h" = x""yes; then :
+ HAVE_SUN_RPC=yes
+else
+ HAVE_SUN_RPC=no
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clnt_create" >&5
+$as_echo_n "checking for library containing clnt_create... " >&6; }
+if test "${ac_cv_search_clnt_create+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char clnt_create ();
+int
+main ()
+{
+return clnt_create ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' ; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_clnt_create=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if test "${ac_cv_search_clnt_create+set}" = set; then :
+ break
+fi
+done
+if test "${ac_cv_search_clnt_create+set}" = set; then :
+
+else
+ ac_cv_search_clnt_create=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clnt_create" >&5
+$as_echo "$ac_cv_search_clnt_create" >&6; }
+ac_res=$ac_cv_search_clnt_create
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+ :
+else
+ HAVE_SUN_RPC=no
+fi
+
+
+
if test -f ./$ac_unique_file; then
# Configuring in source directory; don't create any Makefiles.
makefiles=
@@ -5164,7 +5245,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by $as_me, which was
+This file was extended by GNU Hurd $as_me 0.3, which was
generated by GNU Autoconf 2.67. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -5211,13 +5292,15 @@ Usage: $0 [OPTION]... [TAG]...
Configuration files:
$config_files
-Report bugs to the package provider."
+Report bugs to <bug-hurd@gnu.org>.
+GNU Hurd home page: <http://www.gnu.org/software/hurd/>.
+General help using GNU software: <http://www.gnu.org/gethelp/>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-config.status
+GNU Hurd config.status 0.3
configured by $0, generated by GNU Autoconf 2.67,
with options \\"\$ac_cs_config\\"
@@ -5332,7 +5415,7 @@ do
"config.make") CONFIG_FILES="$CONFIG_FILES config.make" ;;
"${makefiles}") CONFIG_FILES="$CONFIG_FILES ${makefiles}" ;;
- *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;;
+ *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
done
@@ -5538,7 +5621,7 @@ do
esac
case $ac_mode$ac_tag in
:[FHL]*:*);;
- :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;;
+ :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
:[FH]-) ac_tag=-:-;;
:[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
esac
@@ -5566,7 +5649,7 @@ do
[\\/$]*) false;;
*) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
esac ||
- as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;;
+ as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
esac
case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
as_fn_append ac_file_inputs " '$ac_f'"
@@ -5593,7 +5676,7 @@ $as_echo "$as_me: creating $ac_file" >&6;}
case $ac_tag in
*:-:* | *:-) cat >"$tmp/stdin" \
- || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
esac
;;
esac
diff --git a/configure.in b/configure.in
index 978de1e2..0891aecc 100644
--- a/configure.in
+++ b/configure.in
@@ -1,7 +1,7 @@
dnl Process this file with autoconf to produce a configure script.
AC_REVISION([$Id: configure.in,v 1.38 2008/11/17 11:34:18 tschwinge Exp $])
AC_PREREQ(2.54) dnl Minimum Autoconf version required.
-AC_INIT
+AC_INIT([GNU Hurd], [0.3], [bug-hurd@gnu.org])
AC_CONFIG_SRCDIR([hurd/hurd_types.h]) dnl File to look for in srcdir.
AC_PREFIX_DEFAULT() dnl Default to empty prefix, not /usr/local.
@@ -271,6 +271,11 @@ AC_SUBST([have_x11])
AC_SUBST([XKB_BASE])
AC_SUBST([X11_KEYSYMDEF_H])
+# Check for Sun RPC headers and library.
+AC_CHECK_HEADER([rpc/types.h], [HAVE_SUN_RPC=yes], [HAVE_SUN_RPC=no])
+AC_SEARCH_LIBS([clnt_create], [], [:], [HAVE_SUN_RPC=no])
+AC_SUBST([HAVE_SUN_RPC])
+
if test -f ./$ac_unique_file; then
# Configuring in source directory; don't create any Makefiles.
makefiles=
diff --git a/console-client/bdf.c b/console-client/bdf.c
index 30501f4a..f62a2473 100644
--- a/console-client/bdf.c
+++ b/console-client/bdf.c
@@ -154,7 +154,7 @@ next_line (char **line, int *size, FILE *file, int *count)
}
-/* Isolate the next white-space seperated argument from the current
+/* Isolate the next white-space separated argument from the current
line, and set ARGP to the beginning of the next argument. It is an
error if there is no further argument. */
static bdf_error_t
@@ -178,7 +178,7 @@ find_arg (char **argp)
/* Read the font from stream FILE, and return it in FONT. If
LINECOUNT is not zero, it will contain the number of lines in the
- file at success, and the line an error occured at failure. */
+ file at success, and the line an error occurred at failure. */
bdf_error_t
bdf_read (FILE *filep, bdf_font_t *font, int *linecount)
{
diff --git a/console-client/bdf.h b/console-client/bdf.h
index 1f0bce41..17cd0235 100644
--- a/console-client/bdf.h
+++ b/console-client/bdf.h
@@ -32,17 +32,17 @@
types of the arguments, so we treat a string as an 8-bit string
which must not contain a binary null, and a number like an integer
as an int. Leading and trailing white space are removed, multiple
- spaces that seperate arguments are replaced by a single white
+ spaces that separate arguments are replaced by a single white
space, and empty lines are ignored. */
/* Possible error values returned by the BDF functions. */
typedef enum
{
- /* No error occured. This is guaranteed to be zero. */
+ /* No error occurred. This is guaranteed to be zero. */
BDF_NO_ERROR = 0,
- /* A system error occured. The caller should consult errno. */
+ /* A system error occurred. The caller should consult errno. */
BDF_SYSTEM_ERROR,
/* All following errors indicate that the file is not a valid BDF
@@ -200,7 +200,7 @@ typedef struct bdf_font *bdf_font_t;
/* Read the font from stream FILE, and return it in FONT. If
LINECOUNT is not zero, it will contain the number of lines in the
- file at success, and the current line an error occured at
+ file at success, and the current line an error occurred at
failure. */
bdf_error_t bdf_read (FILE *file, bdf_font_t *font, int *linecount);
diff --git a/console-client/driver.c b/console-client/driver.c
index 2a56729d..7f799f0a 100644
--- a/console-client/driver.c
+++ b/console-client/driver.c
@@ -83,7 +83,7 @@ driver_fini (void)
/* Load, intialize and (if START is non-zero) start the driver DRIVER
under the given NAME (which must be unique among all loaded
- drivers) with arguments ARGZ with length ARGZ_LEN. This funtion
+ drivers) with arguments ARGZ with length ARGZ_LEN. This function
will grab the driver list lock. The driver itself might try to
grab the display, input source and bell list locks as well. */
error_t driver_add (const char *const name, const char *const driver,
diff --git a/console-client/ncursesw.c b/console-client/ncursesw.c
index 8b559016..a34026a2 100644
--- a/console-client/ncursesw.c
+++ b/console-client/ncursesw.c
@@ -47,7 +47,7 @@ static WINDOW *conspad;
static unsigned int padx;
static unsigned int pady;
-/* Autoscroll is on or off. Autoscroll makes scrolling dependant on
+/* Autoscroll is on or off. Autoscroll makes scrolling dependent on
the cursor position. */
static int autoscroll;
diff --git a/console-client/pc-kbd.c b/console-client/pc-kbd.c
index 9999654f..95109e52 100644
--- a/console-client/pc-kbd.c
+++ b/console-client/pc-kbd.c
@@ -602,7 +602,7 @@ gnumach_v1_input_next ()
error_t err = device_read_inband (kbd_dev, 0, -1, sizeof (kd_event),
(void *) &data_buf, &data_cnt);
- /* XXX The error occured likely because KBD_DEV was closed, so
+ /* XXX The error occurred likely because KBD_DEV was closed, so
terminate. */
if (err)
return 0;
@@ -685,7 +685,7 @@ input_next ()
error_t err = device_read_inband (kbd_dev, 0, -1, 1,
(void *) &next, &data_cnt);
- /* XXX The error occured likely because KBD_DEV was closed, so
+ /* XXX The error occurred likely because KBD_DEV was closed, so
terminate. */
if (err)
return 0;
@@ -913,7 +913,7 @@ input_loop (any_t unused)
/* The virtual console to switch to. */
int vc = 0;
- /* Check if a funtion key was pressed.
+ /* Check if a function key was pressed.
Choose the virtual console corresponding to that key. */
switch (sc)
{
diff --git a/console-client/vga-dynacolor.c b/console-client/vga-dynacolor.c
index 7b81e2f9..9289e1eb 100644
--- a/console-client/vga-dynacolor.c
+++ b/console-client/vga-dynacolor.c
@@ -177,7 +177,7 @@ dynacolor_replace_colors (dynacolor_t *dc,
based on pairs, but that increases the number of cases a
lot. */
/* Note that no color must occur twice in one replacement list,
- and that the color to be replaced must not occure either. */
+ and that the color to be replaced must not occur either. */
static signed char pref[16][9] =
{
/* Replacements for CONS_COLOR_BLACK. */
diff --git a/console-client/vga-dynafont.c b/console-client/vga-dynafont.c
index 3e0ec3ff..834d0aca 100644
--- a/console-client/vga-dynafont.c
+++ b/console-client/vga-dynafont.c
@@ -529,6 +529,31 @@ dynafont_new (bdf_font_t font, bdf_font_t font_italic, bdf_font_t font_bold,
df->vga_font_last_free_index_lgc = 0;
}
+ /* Ensure that ASCII is always available 1-to-1, for kernel messages. */
+ for (int c = ' '; c <= '~'; c++)
+ {
+ glyph = bdf_find_glyph (df->font, c, 0);
+ if (!glyph)
+ glyph = bdf_find_glyph (df->font, -1, c);
+ if (glyph)
+ {
+ struct mapped_character *chr = &df->charmap_data[c];
+ df->vga_font_free_indices--;
+ chr->refs = 1;
+
+ for (int i = 0; i < ((glyph->bbox.height > 32)
+ ? 32 : glyph->bbox.height); i++)
+ df->vga_font[c][i]
+ = glyph->bitmap[i * ((glyph->bbox.width + 7) / 8)];
+ if (glyph->bbox.height < 32)
+ memset (((char *) df->vga_font[c])
+ + glyph->bbox.height, 0, 32 - glyph->bbox.height);
+
+ /* Update the hash table. */
+ hurd_ihash_add (&df->charmap, c, chr);
+ }
+ }
+
/* Ensure that we always have the replacement character
available. */
{
@@ -846,7 +871,7 @@ dynafont_lookup_internal (dynafont_t df, bdf_font_t font,
chr->refs = 1;
chr->character = (wide_chr | attr);
- /* Copy the glyph bitmap, taking into account double-width charcters. */
+ /* Copy the glyph bitmap, taking into account double-width characters. */
{
int height = (glyph->bbox.height > 32) ? 32 : glyph->bbox.height;
int bwidth = (glyph->bbox.width + 7) / 8;
diff --git a/console-client/vga-hw.h b/console-client/vga-hw.h
index 6be87d31..7275b03e 100644
--- a/console-client/vga-hw.h
+++ b/console-client/vga-hw.h
@@ -21,7 +21,7 @@
#ifndef _VGA_HW_H_
#define _VGA_HW_H_ 1
-#define VGA_VIDEO_MEM_BASE_ADDR 0x0a0000
+#define VGA_VIDEO_MEM_BASE_ADDR 0x0b8000
#define VGA_VIDEO_MEM_LENGTH 0x004000
#define VGA_FONT_BUFFER 8
diff --git a/console-client/vga-support.c b/console-client/vga-support.c
index bce6f8e9..2837a6e0 100644
--- a/console-client/vga-support.c
+++ b/console-client/vga-support.c
@@ -59,19 +59,6 @@ struct vga_state
static struct vga_state *vga_state;
-#if OSKIT_MACH
-#else
-
-#include <device/device.h>
-#include <hurd.h>
-
-/* Constants from Mach. */
-#define VIDMMAP_BEGIN 0xA0000
-#define VIDMMAP_SIZE (0xC0000 - 0xA0000)
-#define VIDMMAP_KDOFS 0xA0000 /* == kd_bitmap_start in mach/i386/i386at/kd.c */
-
-#endif
-
error_t
vga_init (void)
{
@@ -101,43 +88,6 @@ vga_init (void)
if (vga_videomem == (void *) -1)
return err;
}
- else if (errno == ENXIO)
- {
- /* GNU Mach v1 does not provide /dev/mem, but allows direct
- memory access to the video memory through the special "kd"
- kernel device. */
- device_t device_master = MACH_PORT_NULL;
- memory_object_t kd_mem = MACH_PORT_NULL;
- static device_t kd_device = MACH_PORT_NULL;
- vm_address_t mapped;
-
- err = get_privileged_ports (0, &device_master);
- if (err)
- return err;
-
- err = device_open (device_master, D_WRITE, "kd", &kd_device);
- if (err)
- return err;
-
- err = device_map (kd_device, VM_PROT_READ | VM_PROT_WRITE,
- VIDMMAP_BEGIN - VIDMMAP_KDOFS, VIDMMAP_SIZE,
- &kd_mem, 0);
- if (err)
- return err;
-
- err = vm_map (mach_task_self (), &mapped, VIDMMAP_SIZE,
- 0, 1, kd_mem, VIDMMAP_BEGIN - VIDMMAP_KDOFS, 0,
- VM_PROT_READ | VM_PROT_WRITE, VM_PROT_READ | VM_PROT_WRITE,
- VM_INHERIT_NONE);
- if (err)
- return err;
-
- vga_videomem = (char *) mapped;
- assert (vga_videomem != NULL);
-
- mach_port_deallocate (mach_task_self (), device_master);
- mach_port_deallocate (mach_task_self (), kd_mem);
- }
else
return errno;
@@ -175,7 +125,7 @@ vga_init (void)
/* Read/write in interleaved mode. */
outb (VGA_GFX_MISC_ADDR, VGA_GFX_ADDR_REG);
- outb (VGA_GFX_MISC_CHAINOE | VGA_GFX_MISC_A0TOAF, VGA_GFX_DATA_REG);
+ outb (VGA_GFX_MISC_CHAINOE | VGA_GFX_MISC_B8TOBF, VGA_GFX_DATA_REG);
outb (VGA_GFX_MODE_ADDR, VGA_GFX_ADDR_REG);
outb (VGA_GFX_MODE_HOSTOE, VGA_GFX_DATA_REG);
@@ -269,7 +219,7 @@ vga_read_write_font_buffer (int write, int buffer, int index,
outb (VGA_GFX_MODE_READ0, VGA_GFX_DATA_REG);
outb (VGA_GFX_MISC_ADDR, VGA_GFX_ADDR_REG);
saved_gfx_misc = inb (VGA_GFX_DATA_REG);
- outb (VGA_GFX_MISC_A0TOBF, VGA_GFX_DATA_REG);
+ outb (VGA_GFX_MISC_B8TOBF, VGA_GFX_DATA_REG);
if (write)
memcpy (vga_videomem + offset, data, datalen);
diff --git a/console-client/vga.c b/console-client/vga.c
index 4693c664..9e8abb3a 100644
--- a/console-client/vga.c
+++ b/console-client/vga.c
@@ -394,7 +394,7 @@ vga_display_restore_status (void *handle)
/* Read/write in interleaved mode. This is not preserved by the
XFree VESA driver. */
outb (VGA_GFX_MISC_ADDR, VGA_GFX_ADDR_REG);
- outb (VGA_GFX_MISC_CHAINOE | VGA_GFX_MISC_A0TOAF, VGA_GFX_DATA_REG);
+ outb (VGA_GFX_MISC_CHAINOE | VGA_GFX_MISC_B8TOBF, VGA_GFX_DATA_REG);
}
diff --git a/console/Makefile b/console/Makefile
index 71f7f1e4..3eb4252e 100644
--- a/console/Makefile
+++ b/console/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2002 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2012 Free Software Foundation, Inc.
# Written by Marcus Brinkmann.
#
# This file is part of the GNU Hurd.
@@ -25,7 +25,7 @@ target = console
SRCS = console.c display.c pager.c input.c
LCLHDRS = display.h pager.h input.h priv.h mutations.h
-DIST_FILES = hurd.ti
+DIST_FILES = hurd.ti motd.UTF8
MIGSTUBS = notifyServer.o tioctlServer.o fs_notifyUser.o
diff --git a/console/console.c b/console/console.c
index 0b1f42c4..cf208cff 100644
--- a/console/console.c
+++ b/console/console.c
@@ -59,7 +59,7 @@ int netfs_maxsymlinks = 16; /* Arbitrary. */
/* Handy source of time. */
volatile struct mapped_time_value *console_maptime;
-#define DEFAULT_ENCODING "ISO-8859-1"
+#define DEFAULT_ENCODING "UTF-8"
#define DEFAULT_INTENSITY CONS_ATTR_INTENSITY_NORMAL
#define DEFAULT_UNDERLINED 0
#define DEFAULT_BLINKING 0
diff --git a/console/display.c b/console/display.c
index 26786c11..e807c50f 100644
--- a/console/display.c
+++ b/console/display.c
@@ -454,7 +454,7 @@ do_mach_notify_msg_accepted (mach_port_t notify, mach_port_t send)
mutex_unlock (&display->lock);
return 0;
}
- /* The message was succesfully queued, fall through. */
+ /* The message was successfully queued, fall through. */
}
/* Remove request from pending queue. */
*preq = req->next;
diff --git a/console/hurd.ti b/console/hurd.ti
index 504192b5..2508482a 100644
--- a/console/hurd.ti
+++ b/console/hurd.ti
@@ -116,7 +116,7 @@ hurd|The GNU Hurd console server,
kpp=\E[5~, knp=\E[6~,
# Keycode for center of keypad area.
kb2=\E[G,
-# Mouse event has occured.
+# Mouse event has occurred.
kmous=\E[M,
# Text attribute capabilities.
diff --git a/daemons/console-run.c b/daemons/console-run.c
index 3ab2629a..aaa1159b 100644
--- a/daemons/console-run.c
+++ b/daemons/console-run.c
@@ -72,17 +72,17 @@ main (int argc, char **argv)
}
/* Open /dev/console. If it isn't there, or it isn't a terminal, then
- create /tmp/console and put the terminal on it. If we get EROFS,
- in trying to create /tmp/console then as a last resort, put the
- console on /tmp itself. If all fail, we exit.
+ create /dev/console and put the terminal on it. If we get EROFS,
+ in trying to create /dev/console then as a last resort, create
+ /tmp/console. If all fail, we exit.
Return nonzero if the vanilla open of /dev/console didn't work.
In any case, after the console has been opened, put it on fds 0, 1, 2. */
static int
open_console (char **namep)
{
-#define TERMINAL_FIRST_TRY "/hurd/term\0/tmp/console\0device\0console"
-#define TERMINAL_SECOND_TRY "/hurd/term\0/tmp\0device\0console"
+#define TERMINAL_FIRST_TRY "/hurd/term\0/dev/console\0device\0console"
+#define TERMINAL_SECOND_TRY "/hurd/term\0/tmp/console\0device\0console"
mach_port_t term, proc;
static char *termname;
struct stat st;
@@ -183,7 +183,13 @@ open_console (char **namep)
if (term != MACH_PORT_NULL)
{
- error (0, 0, "Using temporary console %s", termname);
+ if (try == 1)
+ /* We created /dev/console, started, and installed the
+ translator on it, so it really isn't a fallback
+ console. */
+ fallback = 0;
+ else
+ error (0, 0, "Using temporary console %s", termname);
break;
}
}
diff --git a/daemons/lmail.c b/daemons/lmail.c
index ef616862..23c7b497 100644
--- a/daemons/lmail.c
+++ b/daemons/lmail.c
@@ -60,7 +60,7 @@ static const char doc[] = "Deliver mail to the local mailboxes of USER...";
#define HDR_PFX "From " /* Header, at the beginning of a line,
starting each msg in a mailbox. */
-#define ESC_PFX ">" /* Used to escape occurances of HDR_PFX in
+#define ESC_PFX ">" /* Used to escape occurrences of HDR_PFX in
the msg body. */
#define BMAX (64*1024) /* Chunk size for I/O. */
@@ -71,7 +71,7 @@ struct params
char *mail_dir; /* Mailbox directory. */
};
-/* Convert the system error code ERR to an appropiate exit value. This
+/* Convert the system error code ERR to an appropriate exit value. This
function currently only returns three sorts: success, temporary failure,
or error, with exit codes 0, EX_TEMPFAIL, or EX_UNAVAILABLE. The table of
temporary failures is from the bsd original of this program. */
@@ -116,7 +116,7 @@ err_to_ex (error_t err)
}
/* Print and syslog the given error message, with the system error string for
- ERRNO appended. Return an appropiate exit code for ERRNO. */
+ ERRNO appended. Return an appropriate exit code for ERRNO. */
#define SYSERR(fmt, args...) \
({ syslog (LOG_ERR, fmt ": %m" , ##args); err_to_ex (errno); })
@@ -126,7 +126,7 @@ err_to_ex (error_t err)
({ syslog (LOG_ERR, fmt , ##args); EX_UNAVAILABLE; })
/* Print and syslog the given error message, with the system error string for
- CODE appended. Return an appropiate exit code for CODE. */
+ CODE appended. Return an appropriate exit code for CODE. */
#define SYSERRX(code, fmt, args...) \
({ error_t _code = (code); \
syslog (LOG_ERR, fmt ": %s" , ##args , strerror (_code)); \
@@ -225,7 +225,7 @@ write_header (int out, char *out_name, struct params *params)
/* Copy from file descriptor IN to OUT, making any changes needed to make the
contents a valid mailbox entry. These include:
(1) Prepending a `From ...' line, and appending a blank line.
- (2) Replacing any occurances of `From ' at the beginning of lines with
+ (2) Replacing any occurrences of `From ' at the beginning of lines with
`>From '.
An exit status is returned. */
static int
@@ -326,7 +326,7 @@ process (int in, char *in_name, int out, char *out_name, struct params *params)
#define D_REWIND 0x2 /* Rewind MSG before using it. */
/* Deliver the text from the file descriptor MSG to the mailbox of the user
- RCPT in MAIL_DIR. FLAGS is from the set D_* above. An exit appropiate
+ RCPT in MAIL_DIR. FLAGS is from the set D_* above. An exit appropriate
exit code is returned. */
static int
deliver (int msg, char *msg_name, char *rcpt, int flags, struct params *params)
@@ -437,7 +437,7 @@ cache (int in, char *in_name, struct params *params, int *cached)
int
main (int argc, char **argv)
{
- int rcpt = 0; /* Index in ARGV of next recepient. */
+ int rcpt = 0; /* Index in ARGV of next recipient. */
char *file = 0; /* File containing message. */
int remove = 0; /* Remove file after successful delivery. */
int in = 0; /* Raw input file descriptor. */
diff --git a/daemons/runsystem.sh b/daemons/runsystem.sh
index c653807f..c3cb2d62 100644
--- a/daemons/runsystem.sh
+++ b/daemons/runsystem.sh
@@ -14,6 +14,8 @@
PATH=/bin:/sbin
export PATH
+umask 022
+
# If we lose badly, try to exec each of these in turn.
fallback_shells='/bin/sh /bin/bash /bin/csh /bin/ash /bin/shd'
diff --git a/daemons/runttys.c b/daemons/runttys.c
index 1afd558d..7efb7b7a 100644
--- a/daemons/runttys.c
+++ b/daemons/runttys.c
@@ -190,7 +190,7 @@ init_ttys (void)
return 0;
}
-/* Free everyting in the terminal array */
+/* Free everything in the terminal array */
void
free_ttys (void)
{
diff --git a/doc/Makefile b/doc/Makefile
index 707f3304..0c00976c 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -18,8 +18,7 @@
dir := doc
makemode := misc
-DIST_FILES := navigating gpl.texinfo hurd.texi version.texi \
- hurd.info $(wildcard hurd.info-*)
+DIST_FILES := navigating gpl.texinfo hurd.texi version.texi
targets = hurd.info $(wildcard hurd.info-*)
installationdir = $(infodir)
@@ -56,3 +55,10 @@ stamp-version: $(top_srcdir)/Makeconf
echo '@set VERSION $(hurd-version)' > version.texi.new
$(move-if-change) version.texi.new version.texi
touch $@
+
+# XXX: the default lndist target will try to look for target files
+# in the source directory. Special case them.
+lndist: lndist-info-targets
+lndist-info-targets: hurd.info $(wildcard hurd.info-*)
+ ln $? $(top_srcdir)/hurd-snap/$(dir)
+
diff --git a/doc/hurd.texi b/doc/hurd.texi
index 098bebf2..ea73a4c6 100644
--- a/doc/hurd.texi
+++ b/doc/hurd.texi
@@ -1759,7 +1759,7 @@ new reference port. (FIXME: xref the C library manual for information
on how to send sig_post messages.)
The server then sends one @code{SIGIO} signal to each registered async
-user everytime I/O becomes possible. I/O is possible if at least one
+user every time I/O becomes possible. I/O is possible if at least one
byte can be read or written immediately. The definition of
``immediately'' must be the same as for the implementation of the
@code{O_NONBLOCK} flag (@pxref{Open Modes}). In addition, every time a
diff --git a/exec/do-bunzip2.c b/exec/do-bunzip2.c
index 17bbf911..716a0cde 100644
--- a/exec/do-bunzip2.c
+++ b/exec/do-bunzip2.c
@@ -150,7 +150,7 @@ bz2_fclose (void *stream)
with *all* the algorithms contained herein, and with the
consequences of modifying them, you should NOT meddle with the
compression or decompression machinery. Incorrect changes can
- and very likely *will* lead to disasterous loss of data.
+ and very likely *will* lead to disastrous loss of data.
DISCLAIMER:
I TAKE NO RESPONSIBILITY FOR ANY LOSS OF DATA ARISING FROM THE
diff --git a/exec/exec.c b/exec/exec.c
index 01d22e70..4c2fcec1 100644
--- a/exec/exec.c
+++ b/exec/exec.c
@@ -1061,7 +1061,7 @@ load (task_t usertask, struct execdata *e)
if (e->info.elf.phdr[i].p_type == PT_LOAD)
load_section (&e->info.elf.phdr[i], e);
- /* The entry point address is relative to whereever we loaded the
+ /* The entry point address is relative to wherever we loaded the
program text. */
e->entry += e->info.elf.loadbase;
}
diff --git a/ext2fs/Makefile b/ext2fs/Makefile
index e0419d46..e83aab26 100644
--- a/ext2fs/Makefile
+++ b/ext2fs/Makefile
@@ -21,7 +21,7 @@ makemode := server
target = ext2fs
SRCS = balloc.c dir.c ext2fs.c getblk.c hyper.c ialloc.c \
- inode.c pager.c pokel.c truncate.c storeinfo.c msg.c
+ inode.c pager.c pokel.c truncate.c storeinfo.c msg.c xinl.c
OBJS = $(SRCS:.c=.o)
LCLHDRS = ext2fs.h ext2_fs.h ext2_fs_i.h bitmap.c
HURDLIBS = diskfs pager iohelp fshelp store threads ports ihash shouldbeinlibc
diff --git a/ext2fs/balloc.c b/ext2fs/balloc.c
index a53e1116..7333123c 100644
--- a/ext2fs/balloc.c
+++ b/ext2fs/balloc.c
@@ -44,7 +44,7 @@
#include "ext2fs.h"
#include "bitmap.c"
-/* Returns a pointer to the first occurence of CH in the buffer BUF of len
+/* Returns a pointer to the first occurrence of CH in the buffer BUF of len
LEN, or BUF + LEN if CH doesn't occur. */
static inline void *
memscan (void *buf, unsigned char ch, size_t len)
diff --git a/ext2fs/dir.c b/ext2fs/dir.c
index 66d8c8a6..d70dbf32 100644
--- a/ext2fs/dir.c
+++ b/ext2fs/dir.c
@@ -698,7 +698,7 @@ diskfs_direnter_hard (struct node *dp, const char *name, struct node *np,
/* Following a lookup call for REMOVE, this removes the link from the
directory. DP is the directory being changed and DS is the cached
information returned from lookup. This call is only valid if the
- directory has been locked continously since the call to lookup, and
+ directory has been locked continuously since the call to lookup, and
only if that call succeeded. */
error_t
diskfs_dirremove_hard (struct node *dp, struct dirstat *ds)
diff --git a/ext2fs/ext2_fs.h b/ext2fs/ext2_fs.h
index a8f922e1..b1caeefa 100644
--- a/ext2fs/ext2_fs.h
+++ b/ext2fs/ext2_fs.h
@@ -203,6 +203,29 @@ struct ext2_group_desc
#define EXT2_FL_USER_VISIBLE 0x00001FFF /* User visible flags */
#define EXT2_FL_USER_MODIFIABLE 0x000000FF /* User modifiable flags */
+/* Flags that should be inherited by new inodes from their parent. */
+#define EXT2_FL_INHERITED (EXT2_SECRM_FL | EXT2_UNRM_FL | EXT2_COMPR_FL |\
+ EXT2_SYNC_FL | EXT2_NODUMP_FL |\
+ EXT2_NOATIME_FL | EXT2_COMPRBLK_FL |\
+ EXT2_NOCOMP_FL)
+
+/* Flags that are appropriate for regular files (all but dir-specific ones). */
+#define EXT2_REG_FLMASK (~(0))
+
+/* Flags that are appropriate for non-directories/regular files. */
+#define EXT2_OTHER_FLMASK (EXT2_NODUMP_FL | EXT2_NOATIME_FL)
+
+/* Mask out flags that are inappropriate for the given type of inode. */
+static __inline__ __u32 ext2_mask_flags(mode_t mode, __u32 flags)
+{
+ if (S_ISDIR(mode))
+ return flags;
+ else if (S_ISREG(mode))
+ return flags & EXT2_REG_FLMASK;
+ else
+ return flags & EXT2_OTHER_FLMASK;
+}
+
/*
* ioctl commands
*/
diff --git a/ext2fs/ext2fs.h b/ext2fs/ext2fs.h
index 1d490861..2ad4a9df 100644
--- a/ext2fs/ext2fs.h
+++ b/ext2fs/ext2fs.h
@@ -101,8 +101,11 @@ void pokel_flush (struct pokel *pokel);
/* Transfer all regions from FROM to POKEL, which must have the same pager. */
void pokel_inherit (struct pokel *pokel, struct pokel *from);
-#ifndef EXT2FS_EI
-#define EXT2FS_EI extern inline
+#include <features.h>
+#ifdef EXT2FS_DEFINE_EI
+#define EXT2FS_EI
+#else
+#define EXT2FS_EI __extern_inline
#endif
/* ---------------------------------------------------------------- */
@@ -110,6 +113,11 @@ void pokel_inherit (struct pokel *pokel, struct pokel *from);
#include <stdint.h>
+extern int test_bit (unsigned num, char *bitmap);
+
+extern int set_bit (unsigned num, char *bitmap);
+
+#if defined(__USE_EXTERN_INLINES) || defined(EXT2FS_DEFINE_EI)
/* Returns TRUE if bit NUM is set in BITMAP. */
EXT2FS_EI int
test_bit (unsigned num, char *bitmap)
@@ -138,6 +146,7 @@ clear_bit (unsigned num, char *bitmap)
const uint_fast32_t mask = 1 << (num & 31);
return (*bw & mask) ? (*bw &= ~mask, mask) : 0;
}
+#endif /* Use extern inlines. */
/* ---------------------------------------------------------------- */
@@ -294,6 +303,9 @@ struct ext2_group_desc *group_desc_image;
#define inode_group_num(inum) (((inum) - 1) / sblock->s_inodes_per_group)
+extern struct ext2_inode *dino (ino_t inum);
+
+#if defined(__USE_EXTERN_INLINES) || defined(EXT2FS_DEFINE_EI)
/* Convert an inode number to the dinode on disk. */
EXT2FS_EI struct ext2_inode *
dino (ino_t inum)
@@ -305,6 +317,7 @@ dino (ino_t inum)
block_t block = bg->bg_inode_table + (group_inum / inodes_per_block);
return ((struct ext2_inode *)bptr(block)) + group_inum % inodes_per_block;
}
+#endif /* Use extern inlines. */
/* ---------------------------------------------------------------- */
/* inode.c */
@@ -333,6 +346,14 @@ struct pokel global_pokel;
char *modified_global_blocks;
spin_lock_t modified_global_blocks_lock;
+extern int global_block_modified (block_t block);
+extern void record_global_poke (void *ptr);
+extern void sync_global_ptr (void *bptr, int wait);
+extern void record_indir_poke (struct node *node, void *ptr);
+extern void sync_global (int wait);
+extern void alloc_sync (struct node *np);
+
+#if defined(__USE_EXTERN_INLINES) || defined(EXT2FS_DEFINE_EI)
/* Marks the global block BLOCK as being modified, and returns true if we
think it may have been clean before (but we may not be sure). Note that
this isn't enough to cause the block to be synced; you must call
@@ -401,6 +422,7 @@ alloc_sync (struct node *np)
diskfs_set_hypermetadata (1, 0);
}
}
+#endif /* Use extern inlines. */
/* ---------------------------------------------------------------- */
/* getblk.c */
diff --git a/ext2fs/ialloc.c b/ext2fs/ialloc.c
index 22d911b5..15c17a4e 100644
--- a/ext2fs/ialloc.c
+++ b/ext2fs/ialloc.c
@@ -315,9 +315,8 @@ diskfs_alloc_node (struct node *dir, mode_t mode, struct node **node)
}
/* Propagate initial inode flags from the directory, as Linux does. */
- np->dn->info.i_flags = dir->dn->info.i_flags;
- if (S_ISLNK (mode))
- np->dn->info.i_flags &= ~(EXT2_IMMUTABLE_FL | EXT2_APPEND_FL);
+ np->dn->info.i_flags =
+ ext2_mask_flags(mode, dir->dn->info.i_flags & EXT2_FL_INHERITED);
st->st_flags = 0;
diff --git a/ext2fs/pager.c b/ext2fs/pager.c
index 3f4674b4..0136f9b1 100644
--- a/ext2fs/pager.c
+++ b/ext2fs/pager.c
@@ -119,7 +119,7 @@ free_page_buf (void *buf)
/* Find the location on disk of page OFFSET in NODE. Return the disk block
in BLOCK (if unallocated, then return 0). If *LOCK is 0, then a reader
- lock is aquired on NODE's ALLOC_LOCK before doing anything, and left
+ lock is acquired on NODE's ALLOC_LOCK before doing anything, and left
locked after the return -- even if an error is returned. 0 is returned
on success otherwise an error code. */
static error_t
@@ -851,7 +851,10 @@ drop_pager_softrefs (struct node *node)
spin_unlock (&node_to_page_lock);
if (MAY_CACHE && pager)
- pager_change_attributes (pager, 0, MEMORY_OBJECT_COPY_DELAY, 0);
+ {
+ pager_sync (pager, 0);
+ pager_change_attributes (pager, 0, MEMORY_OBJECT_COPY_DELAY, 0);
+ }
if (pager)
ports_port_deref (pager);
}
diff --git a/ext2fs/xinl.c b/ext2fs/xinl.c
new file mode 100644
index 00000000..9f37e166
--- /dev/null
+++ b/ext2fs/xinl.c
@@ -0,0 +1,2 @@
+#define EXT2FS_DEFINE_EI
+#include "ext2fs.h"
diff --git a/fatfs/Makefile b/fatfs/Makefile
index 7a24840b..06ed8778 100644
--- a/fatfs/Makefile
+++ b/fatfs/Makefile
@@ -21,7 +21,6 @@ makemode := server
target = fatfs
SRCS = inode.c main.c dir.c pager.c fat.c virt-inode.c node-create.c
LCLHDRS = fat.h fatfs.h virt-inode.h
-DIST_FILES = EXTENSIONS
OBJS = $(SRCS:.c=.o)
HURDLIBS = diskfs iohelp fshelp store pager threads ports ihash shouldbeinlibc
diff --git a/fatfs/dir.c b/fatfs/dir.c
index aa389993..762320f8 100644
--- a/fatfs/dir.c
+++ b/fatfs/dir.c
@@ -681,7 +681,7 @@ diskfs_direnter_hard (struct node *dp, const char *name, struct node *np,
/* Following a lookup call for REMOVE, this removes the link from the
directory. DP is the directory being changed and DS is the cached
information returned from lookup. This call is only valid if the
- directory has been locked continously since the call to lookup, and
+ directory has been locked continuously since the call to lookup, and
only if that call succeeded. */
error_t
diskfs_dirremove_hard (struct node *dp, struct dirstat *ds)
diff --git a/fatfs/fat.h b/fatfs/fat.h
index 87af27db..58b45c63 100644
--- a/fatfs/fat.h
+++ b/fatfs/fat.h
@@ -72,7 +72,7 @@
Data
The data region occupies the rest of the filesystem and stores
- the actual file and directory data. It is seperated in clusters,
+ the actual file and directory data. It is separated in clusters,
which are indexed in the FAT.
The size of the data region is stored in the word at offset 19
diff --git a/fatfs/pager.c b/fatfs/pager.c
index 22adb089..e617af03 100644
--- a/fatfs/pager.c
+++ b/fatfs/pager.c
@@ -91,7 +91,7 @@ free_page_buf (void *buf)
/* Find the location on disk of page OFFSET in NODE. Return the disk
cluster in CLUSTER. If *LOCK is 0, then it a reader
- lock is aquired on NODE's ALLOC_LOCK before doing anything, and left
+ lock is acquired on NODE's ALLOC_LOCK before doing anything, and left
locked after return -- even if an error is returned. 0 on success or an
error code otherwise is returned. */
static error_t
diff --git a/ftpfs/dir.c b/ftpfs/dir.c
index fb35a451..8ef719d8 100644
--- a/ftpfs/dir.c
+++ b/ftpfs/dir.c
@@ -485,7 +485,7 @@ ftpfs_refresh_node (struct node *node)
}
else if (*(entry->name))
{
- /* The root node is treated seperately below. */
+ /* The root node is treated separately below. */
struct ftp_conn *conn;
err = ftpfs_get_ftp_conn (dir->fs, &conn);
@@ -775,7 +775,7 @@ ftpfs_dir_lookup (struct ftpfs_dir *dir, const char *name,
}
/* Lookup the null name in DIR, and return a node for it in NODE. Unlike
- ftpfs_dir_lookup, this won't attempt to validate the existance of the
+ ftpfs_dir_lookup, this won't attempt to validate the existence of the
entry (to avoid opening a new connection if possible) -- that will happen
the first time the entry is refreshed. Also unlink ftpfs_dir_lookup, this
function doesn't expect DIR to be locked, and won't return *NODE locked.
diff --git a/ftpfs/ftpfs.h b/ftpfs/ftpfs.h
index d1d816d7..0eef5bde 100644
--- a/ftpfs/ftpfs.h
+++ b/ftpfs/ftpfs.h
@@ -138,7 +138,7 @@ struct netnode
/* Various parameters that can be used to change the behavior of an ftpfs. */
struct ftpfs_params
{
- /* Amount of time name existance is cached. */
+ /* Amount of time name existence is cached. */
time_t name_timeout;
/* Amount of time stat information is cached. */
@@ -240,7 +240,7 @@ error_t ftpfs_dir_lookup (struct ftpfs_dir *dir, const char *name,
struct node **node);
/* Lookup the null name in DIR, and return a node for it in NODE. Unlike
- ftpfs_dir_lookup, this won't attempt to validate the existance of the
+ ftpfs_dir_lookup, this won't attempt to validate the existence of the
entry (to avoid opening a new connection if possible) -- that will happen
the first time the entry is refreshed. Also unlink ftpfs_dir_lookup, this
function doesn't expect DIR to be locked, and won't return *NODE locked.
diff --git a/hostmux/hostmux-xinl.c b/hostmux/hostmux-xinl.c
index e8ab1493..4e11968e 100644
--- a/hostmux/hostmux-xinl.c
+++ b/hostmux/hostmux-xinl.c
@@ -18,7 +18,5 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
-#define HOSTMUX_EI
-#undef __OPTIMIZE__
-#define __OPTIMIZE__ 1
+#define HOSTMUX_DEFINE_EI
#include "hostmux.h"
diff --git a/hostmux/hostmux.h b/hostmux/hostmux.h
index 10170002..98ef04ac 100644
--- a/hostmux/hostmux.h
+++ b/hostmux/hostmux.h
@@ -24,6 +24,13 @@
#include <hurd/netfs.h>
#include <rwlock.h>
#include <maptime.h>
+#include <features.h>
+
+#ifdef HOSTMUX_DEFINE_EI
+#define HOSTMUX_EI
+#else
+#define HOSTMUX_EI __extern_inline
+#endif
/* Handy source of time. */
volatile struct mapped_time_value *hostmux_maptime;
@@ -85,8 +92,4 @@ struct netnode
struct hostmux_name *name;
};
-#ifndef HOSTMUX_EI
-# define HOSTMUX_EI extern inline
-#endif
-
#endif /* __HOSTMUX_H__ */
diff --git a/hostmux/leaf.c b/hostmux/leaf.c
index aba32b84..fb53622f 100644
--- a/hostmux/leaf.c
+++ b/hostmux/leaf.c
@@ -53,7 +53,7 @@ netfs_get_translator (struct node *node, char **argz, size_t *argz_len)
*argz = 0; /* Initialize return value. */
*argz_len = 0;
- /* Return a copy of MUX's translator template, with occurances of
+ /* Return a copy of MUX's translator template, with occurrences of
HOST_PAT replaced by the canonical hostname. */
err = argz_append (argz, argz_len,
mux->trans_template, mux->trans_template_len);
diff --git a/hurd/console.h b/hurd/console.h
index 4634cc28..baf03942 100644
--- a/hurd/console.h
+++ b/hurd/console.h
@@ -122,7 +122,7 @@ struct cons_display
ever increased by the server, so clients
can optimize scrolling. */
uint32_t scr_lines; /* Number of lines in scrollback buffer
- preceeding CUR_LINE. */
+ preceding CUR_LINE. */
uint32_t height; /* Number of lines in visible area following
(and including) CUR_LINE. */
uint32_t matrix; /* Index (in uint32_t) of the beginning of
diff --git a/hurd/default_pager.defs b/hurd/default_pager.defs
index 7b1549a0..8ad82dcc 100644
--- a/hurd/default_pager.defs
+++ b/hurd/default_pager.defs
@@ -91,6 +91,5 @@ routine default_pager_paging_storage(
will fail. */
routine default_pager_object_set_size(
memory_object : mach_port_t;
- sreplyport reply_port : mach_port_send_once_t;
msgseqno seqno : mach_port_seqno_t;
object_size_limit : vm_size_t);
diff --git a/hurd/hurd_types.h b/hurd/hurd_types.h
index 86b9bcbe..e1a644f1 100644
--- a/hurd/hurd_types.h
+++ b/hurd/hurd_types.h
@@ -201,7 +201,7 @@ enum term_bottom_type
remap - TY, FL, NR NR * (OFFS, LEN) - 1
(BS and SIZE are that of the child)
copy - TY, FL, SIZE - DATA -
- (DATA is preceeded by padding to the next page boundary, and is
+ (DATA is preceded by padding to the next page boundary, and is
SIZE bytes long itself)
For ileave, concat, and layer, the children are encoded following the parent.
diff --git a/hurd/io.defs b/hurd/io.defs
index d30233e6..9119b05b 100644
--- a/hurd/io.defs
+++ b/hurd/io.defs
@@ -101,7 +101,7 @@ routine io_clear_some_openmodes (
when appropriate, to the designated port using sig_post. A
port is also returned which will be used as the reference port in
sending such signals (this is the "async IO ID" port). The async
- call is cancelled by deleting all refernces to the async_id_port.
+ call is cancelled by deleting all references to the async_id_port.
Each call to io_async generates a new ASYNC_ID_PORT.
*/
routine io_async (
diff --git a/include/Makefile b/include/Makefile
index de876802..3dc9ba75 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -34,4 +34,4 @@ $(includedir)/%: $(srcdir)/%
$(INSTALL_DATA) $< $@
lndist: $(top_srcdir)/hurd-snap/$(dir)
- cp -r --parent Makefile $(installhdrs) $<
+ cp -r --parent $(addprefix $(srcdir)/, Makefile $(installhdrs)) $<
diff --git a/isofs/lookup.c b/isofs/lookup.c
index f3e7581f..8daa5464 100644
--- a/isofs/lookup.c
+++ b/isofs/lookup.c
@@ -50,11 +50,11 @@ isonamematch (const char *dirname, size_t dnamelen,
if (dnamelen == unamelen)
return 1;
- /* User has ommitted the version number */
+ /* User has omitted the version number */
if (dirname[unamelen] == ';')
return 1;
- /* User has ommitted an empty extension */
+ /* User has omitted an empty extension */
if (dirname[unamelen] == '.'
&& (dirname[unamelen+1] == '\0' || dirname[unamelen+1] == ';'))
return 1;
diff --git a/isofs/rr.c b/isofs/rr.c
index f26d9e42..be4395d6 100644
--- a/isofs/rr.c
+++ b/isofs/rr.c
@@ -505,7 +505,7 @@ rrip_work (struct dirrect *dr, struct rrip_lookup *rr,
we got here from the exit point of the function, then
VALID_NM is actually clear. */
- /* Save these, becuase rrip_work will clear them. */
+ /* Save these, because rrip_work will clear them. */
savename = (rr->valid & VALID_NM) ? rr->name : 0;
realdir = rr->realdirent;
diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c
index e73e4d37..15563bdb 100644
--- a/libdiskfs/boot-start.c
+++ b/libdiskfs/boot-start.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1993,94,95,96,97,98,99,2000,01,02,10
+ Copyright (C) 1993,94,95,96,97,98,99,2000,01,02,10,11
Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -104,6 +104,7 @@ diskfs_start_bootstrap ()
struct protid *rootpi;
struct peropen *rootpo;
mach_port_t diskfs_exec;
+ unsigned int init_lookups = 0;
/* Create the port for current and root directory. */
err = diskfs_make_peropen (diskfs_root_node, O_READ | O_EXEC, 0,
@@ -222,8 +223,10 @@ diskfs_start_bootstrap ()
initname = exec_argv + 1;
}
+ lookup_init:
err = dir_lookup (root_pt, initname, O_READ, 0,
&retry, pathbuf, &startup_pt);
+ init_lookups++;
if (err)
{
printf ("\nCannot find startup program `%s': %s\n",
@@ -232,6 +235,15 @@ diskfs_start_bootstrap ()
free (exec_argv);
assert_perror (err); /* XXX this won't reboot properly */
}
+ else if (retry == FS_RETRY_MAGICAL && pathbuf[0] == '/')
+ {
+ assert (init_lookups < SYMLOOP_MAX);
+
+ /* INITNAME is a symlink with an absolute target, so try again. */
+ initname = strdupa (pathbuf);
+ goto lookup_init;
+ }
+
assert (retry == FS_RETRY_NORMAL);
assert (pathbuf[0] == '\0');
diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h
index 9a61964c..2051e41d 100644
--- a/libdiskfs/diskfs.h
+++ b/libdiskfs/diskfs.h
@@ -27,9 +27,12 @@
#include <hurd/fshelp.h>
#include <hurd/iohelp.h>
#include <idvec.h>
+#include <features.h>
-#ifndef DISKFS_EXTERN_INLINE
-#define DISKFS_EXTERN_INLINE extern inline
+#ifdef DISKFS_DEFINE_EXTERN_INLINE
+#define DISKFS_EXTERN_INLINE
+#else
+#define DISKFS_EXTERN_INLINE __extern_inline
#endif
/* Each user port referring to a file points to one of these
@@ -781,6 +784,12 @@ error_t diskfs_start_protid (struct peropen *po, struct protid **cred);
the user to install is USER. */
void diskfs_finish_protid (struct protid *cred, struct iouser *user);
+extern struct protid * diskfs_begin_using_protid_port (file_t port);
+
+extern void diskfs_end_using_protid_port (struct protid *cred);
+
+#if defined(__USE_EXTERN_INLINES) || defined(DISKFS_DEFINE_EXTERN_INLINE)
+
/* Called by MiG to translate ports into struct protid *.
fsmutations.h arranges for this to happen for the io and
fs interfaces. */
@@ -800,6 +809,8 @@ diskfs_end_using_protid_port (struct protid *cred)
ports_port_deref (cred);
}
+#endif /* Use extern inlines. */
+
/* Called when a protid CRED has no more references. (Because references\
to protids are maintained by the port management library, this is
installed in the clean routines list.) The ports library will
diff --git a/libdiskfs/extern-inline.c b/libdiskfs/extern-inline.c
index 0abcc4cc..43de88d6 100644
--- a/libdiskfs/extern-inline.c
+++ b/libdiskfs/extern-inline.c
@@ -15,6 +15,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-#define DISKFS_EXTERN_INLINE
+#define DISKFS_DEFINE_EXTERN_INLINE
#include "diskfs.h"
diff --git a/libdiskfs/io-pathconf.c b/libdiskfs/io-pathconf.c
index b851f9b1..38e277c3 100644
--- a/libdiskfs/io-pathconf.c
+++ b/libdiskfs/io-pathconf.c
@@ -41,6 +41,7 @@ diskfs_S_io_pathconf (struct protid *cred,
case _PC_PIPE_BUF:
case _PC_VDISABLE:
case _PC_SOCK_MAXBUF:
+ case _PC_PATH_MAX:
*value = -1;
break;
diff --git a/libfshelp/fshelp.h b/libfshelp/fshelp.h
index 5c43c54c..9f4fa677 100644
--- a/libfshelp/fshelp.h
+++ b/libfshelp/fshelp.h
@@ -38,7 +38,7 @@
or the ports library. */
/* A callback used by the translator starting functions, which should be a
- function that given some open flags, opens the appropiate file, and
+ function that given some open flags, opens the appropriate file, and
returns the node port. */
typedef error_t (*fshelp_open_fn_t) (int flags,
file_t *node,
@@ -253,7 +253,7 @@ error_t fshelp_access (io_statbuf_t *st, int op, struct iouser *user);
/* Check to see whether USER is allowed to modify DIR with respect to
existing file ST. (If there is no existing file, pass 0 for ST.)
- If the access is permissable return 0; otherwise return an
+ If the access is permissible return 0; otherwise return an
appropriate error code. */
error_t fshelp_checkdirmod (io_statbuf_t *dir, io_statbuf_t *st,
struct iouser *user);
diff --git a/libfshelp/perms-checkdirmod.c b/libfshelp/perms-checkdirmod.c
index db4b2e43..823c9f63 100644
--- a/libfshelp/perms-checkdirmod.c
+++ b/libfshelp/perms-checkdirmod.c
@@ -23,7 +23,7 @@
/* Check to see whether USER is allowed to modify DIR with respect to
existing file ST. (If there is no existing file, pass 0 for ST.)
- If the access is permissable return 0; otherwise return an
+ If the access is permissible return 0; otherwise return an
appropriate error code. */
error_t
fshelp_checkdirmod (struct stat *dir, struct stat *st, struct iouser *user)
diff --git a/libftpconn/fname.c b/libftpconn/fname.c
index afa0852b..3be6eeec 100644
--- a/libftpconn/fname.c
+++ b/libftpconn/fname.c
@@ -23,7 +23,7 @@
#include "ftpconn.h"
/* Give a name which refers to a directory file, and a name in that
- directory, this should return in COMPOSITE the composite name refering to
+ directory, this should return in COMPOSITE the composite name referring to
that name in that directory, in malloced storage. */
error_t
ftp_conn_append_name (struct ftp_conn *conn,
diff --git a/libftpconn/ftpconn.h b/libftpconn/ftpconn.h
index e445130e..6bff5918 100644
--- a/libftpconn/ftpconn.h
+++ b/libftpconn/ftpconn.h
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
+#include <features.h>
#define __need_error_t
#include <errno.h>
@@ -35,8 +36,10 @@ typedef int error_t;
#define __error_t_defined
#endif
-#ifndef FTP_CONN_EI
-# define FTP_CONN_EI extern inline
+#ifdef FTP_CONN_DEFINE_EI
+#define FTP_CONN_EI
+#else
+#define FTP_CONN_EI __extern_inline
#endif
struct ftp_conn;
@@ -91,7 +94,7 @@ struct ftp_conn_syshooks
ftp_conn_add_stat_fun_t add_stat, void *hook);
/* Give a name which refers to a directory file, and a name in that
- directory, this should return in COMPOSITE the composite name refering
+ directory, this should return in COMPOSITE the composite name referring
to that name in that directory, in malloced storage. */
error_t (*append_name) (struct ftp_conn *conn,
const char *dir, const char *name,
@@ -242,6 +245,9 @@ error_t ftp_conn_open (struct ftp_conn *conn);
void ftp_conn_close (struct ftp_conn *conn);
+extern error_t ftp_conn_validate_syshooks (struct ftp_conn *conn);
+
+#if defined(__USE_EXTERN_INLINES) || defined(FTP_CONN_DEFINE_EI)
/* Makes sure that CONN's syshooks are set according to the remote system
type. */
FTP_CONN_EI error_t
@@ -253,6 +259,7 @@ ftp_conn_validate_syshooks (struct ftp_conn *conn)
/* Opening the connection should set the syshooks. */
return ftp_conn_open (conn);
}
+#endif /* Use extern inlines. */
/* Create a new ftp connection as specified by PARAMS, and return it in CONN;
HOOKS contains customization hooks used by the connection. Neither PARAMS
@@ -371,7 +378,7 @@ error_t ftp_conn_get_names (struct ftp_conn *conn, const char *name,
ftp_conn_add_name_fun_t add_name, void *hook);
/* Give a name which refers to a directory file, and a name in that
- directory, this should return in COMPOSITE the composite name refering to
+ directory, this should return in COMPOSITE the composite name referring to
that name in that directory, in malloced storage. */
error_t ftp_conn_append_name (struct ftp_conn *conn,
const char *dir, const char *name,
diff --git a/libftpconn/priv.h b/libftpconn/priv.h
index fb4dae50..570ea290 100644
--- a/libftpconn/priv.h
+++ b/libftpconn/priv.h
@@ -21,8 +21,12 @@
#ifndef __FTPCONN_PRIV_H__
#define __FTPCONN_PRIV_H__
-#ifndef FTP_CONN_EI
-# define FTP_CONN_EI extern inline
+#include <features.h>
+
+#ifdef FTP_CONN_DEFINE_EI
+#define FTP_CONN_EI
+#else
+#define FTP_CONN_EI __extern_inline
#endif
/* Ftp reply codes. */
@@ -61,6 +65,9 @@
#define REPLY_IS_TRANSIENT(rep) ((rep) >= 400 && (rep) < 500)
#define REPLY_IS_FAILURE(rep) ((rep) >= 500 && (rep) < 600)
+extern error_t unexpected_reply (struct ftp_conn *conn, int reply, const char *reply_txt,
+ const error_t *poss_errs);
+#if defined(__USE_EXTERN_INLINES) || defined(FTP_CONN_DEFINE_EI)
FTP_CONN_EI error_t
unexpected_reply (struct ftp_conn *conn, int reply, const char *reply_txt,
const error_t *poss_errs)
@@ -79,6 +86,7 @@ unexpected_reply (struct ftp_conn *conn, int reply, const char *reply_txt,
else
return EGRATUITOUS;
}
+#endif /* Use extern inlines. */
/* Error codes we think may result from file operations we do. */
extern const error_t ftp_conn_poss_file_errs[];
diff --git a/libftpconn/reply.c b/libftpconn/reply.c
index 4f30f751..d39cdb02 100644
--- a/libftpconn/reply.c
+++ b/libftpconn/reply.c
@@ -78,7 +78,7 @@ ftp_conn_getline (struct ftp_conn *conn, const char **line, size_t *line_len)
offs = nl + 1 - l; /* Consume the line */
/* Null terminate the result by overwriting the newline; if
- there's a CR preceeding it, get rid of that too. */
+ there's a CR preceding it, get rid of that too. */
if (nl > *line && nl[-1] == '\r')
nl--;
*nl = '\0';
diff --git a/libftpconn/unix.c b/libftpconn/unix.c
index d279a7a6..28efefdd 100644
--- a/libftpconn/unix.c
+++ b/libftpconn/unix.c
@@ -732,7 +732,7 @@ finished:
}
/* Give a name which refers to a directory file, and a name in that
- directory, this should return in COMPOSITE the composite name refering to
+ directory, this should return in COMPOSITE the composite name referring to
that name in that directory, in malloced storage. */
error_t
ftp_conn_unix_append_name (struct ftp_conn *conn,
diff --git a/libftpconn/xinl.c b/libftpconn/xinl.c
index a975b80d..72b7fdcf 100644
--- a/libftpconn/xinl.c
+++ b/libftpconn/xinl.c
@@ -19,6 +19,6 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#define FTP_CONN_EI
+#define FTP_CONN_DEFINE_EI
#include <ftpconn.h>
#include "priv.h"
diff --git a/libnetfs/io-pathconf.c b/libnetfs/io-pathconf.c
index 78244bcd..2fd3f5bc 100644
--- a/libnetfs/io-pathconf.c
+++ b/libnetfs/io-pathconf.c
@@ -39,6 +39,7 @@ netfs_S_io_pathconf (struct protid *user,
case _PC_PIPE_BUF:
case _PC_VDISABLE:
case _PC_SOCK_MAXBUF:
+ case _PC_PATH_MAX:
*value = -1;
break;
diff --git a/libpager/demuxer.c b/libpager/demuxer.c
index d6b99fc2..79c0ddc5 100644
--- a/libpager/demuxer.c
+++ b/libpager/demuxer.c
@@ -1,5 +1,5 @@
/* Demuxer for pager library
- Copyright (C) 1994, 1995, 2002 Free Software Foundation
+ Copyright (C) 1994, 1995, 2002, 2011 Free Software Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -33,20 +33,8 @@ pager_demuxer (mach_msg_header_t *inp,
int result = _pager_seqnos_memory_object_server (inp, outp)
|| _pager_seqnos_notify_server (inp, outp);
if (!result)
- {
- struct pager *p;
-
- p = ports_lookup_port (0, inp->msgh_local_port, _pager_class);
- if (p)
- {
- /* Synchronize our bookkeeping of the port's seqno with
- the one consumed by this bogus message. */
- mutex_lock (&p->interlock);
- _pager_wait_for_seqno (p, inp->msgh_seqno);
- _pager_release_seqno (p, inp->msgh_seqno);
- mutex_unlock (&p->interlock);
- ports_port_deref (p);
- }
- }
+ /* Synchronize our bookkeeping of the port's seqno with the one consumed by
+ this bogus message. */
+ _pager_update_seqno (inp->msgh_local_port, inp->msgh_seqno);
return result;
}
diff --git a/libpager/notify-stubs.c b/libpager/notify-stubs.c
index 728163e4..2d791aac 100644
--- a/libpager/notify-stubs.c
+++ b/libpager/notify-stubs.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1995 Free Software Foundation, Inc.
+ Copyright (C) 1995, 2011 Free Software Foundation, Inc.
Written by Michael I. Bushnell.
This file is part of the GNU Hurd.
@@ -18,58 +18,59 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+#include "priv.h"
#include "notify_S.h"
#include <errno.h>
error_t
-_pager_do_seqnos_mach_notify_port_deleted (mach_port_t notify
- __attribute__ ((unused)),
- mach_port_seqno_t seqno
- __attribute__ ((unused)),
+_pager_do_seqnos_mach_notify_port_deleted (mach_port_t notify,
+ mach_port_seqno_t seqno,
mach_port_t name
__attribute__ ((unused)))
{
+ _pager_update_seqno (notify, seqno);
+
return 0;
}
error_t
-_pager_do_seqnos_mach_notify_msg_accepted (mach_port_t notify
- __attribute__ ((unused)),
- mach_port_seqno_t seqno
- __attribute__ ((unused)),
+_pager_do_seqnos_mach_notify_msg_accepted (mach_port_t notify,
+ mach_port_seqno_t seqno,
mach_port_t name
__attribute__ ((unused)))
{
+ _pager_update_seqno (notify, seqno);
+
return 0;
}
error_t
-_pager_do_seqnos_mach_notify_port_destroyed (mach_port_t notify
- __attribute__ ((unused)),
- mach_port_seqno_t seqno
- __attribute__ ((unused)),
+_pager_do_seqnos_mach_notify_port_destroyed (mach_port_t notify,
+ mach_port_seqno_t seqno,
mach_port_t name
__attribute__ ((unused)))
{
+ _pager_update_seqno (notify, seqno);
+
return 0;
}
error_t
-_pager_do_seqnos_mach_notify_send_once (mach_port_t notify
- __attribute__ ((unused)),
- mach_port_seqno_t seqno
- __attribute__ ((unused)))
+_pager_do_seqnos_mach_notify_send_once (mach_port_t notify,
+ mach_port_seqno_t seqno)
{
+ _pager_update_seqno (notify, seqno);
+
return 0;
}
error_t
-_pager_do_seqnos_mach_notify_dead_name (mach_port_t notify
- __attribute__ ((unused)),
- mach_port_seqno_t seqno
- __attribute__ ((unused)),
+_pager_do_seqnos_mach_notify_dead_name (mach_port_t notify,
+ mach_port_seqno_t seqno,
mach_port_t name
__attribute__ ((unused)))
{
+ _pager_update_seqno (notify, seqno);
+
return 0;
}
diff --git a/libpager/pager-memcpy.c b/libpager/pager-memcpy.c
index e5f4cdac..f2be5585 100644
--- a/libpager/pager-memcpy.c
+++ b/libpager/pager-memcpy.c
@@ -23,9 +23,10 @@
#include <assert.h>
#include <string.h>
-/* Start using vm_copy over memcpy when we have at a page. (This
- value *cannot* be less than vm_page_size.) */
-#define VMCOPY_BETTER_THAN_MEMCPY (vm_page_size)
+/* Start using vm_copy over memcpy when we have that many page. This is
+ roughly the L1 cache size. (This value *cannot* be less than
+ vm_page_size.) */
+#define VMCOPY_BETTER_THAN_MEMCPY (8*vm_page_size)
/* Try to copy *SIZE bytes between the region OTHER points to
and the region at OFFSET in the pager indicated by PAGER and MEMOBJ.
@@ -42,8 +43,8 @@ pager_memcpy (struct pager *pager, memory_object_t memobj,
error_t err;
size_t n = *size;
-#define VMCOPY_WINDOW_DEFAULT_SIZE (16 * vm_page_size)
-#define MEMCPY_WINDOW_DEFAULT_SIZE (8 * vm_page_size)
+#define VMCOPY_WINDOW_DEFAULT_SIZE (32 * vm_page_size)
+#define MEMCPY_WINDOW_DEFAULT_SIZE (32 * vm_page_size)
vm_address_t window;
vm_size_t window_size;
diff --git a/libpager/pager.h b/libpager/pager.h
index d3f1162c..99fb3845 100644
--- a/libpager/pager.h
+++ b/libpager/pager.h
@@ -151,7 +151,7 @@ pager_memcpy (struct pager *pager, memory_object_t memobj,
/* The user must define this function. For pager PAGER, read one
page from offset PAGE. Set *BUF to be the address of the page,
and set *WRITE_LOCK if the page must be provided read-only.
- The only permissable error returns are EIO, EDQUOT, and ENOSPC. */
+ The only permissible error returns are EIO, EDQUOT, and ENOSPC. */
error_t
pager_read_page (struct user_pager_info *pager,
vm_offset_t page,
@@ -160,7 +160,7 @@ pager_read_page (struct user_pager_info *pager,
/* The user must define this function. For pager PAGER, synchronously
write one page from BUF to offset PAGE. In addition, mfree
- (or equivalent) BUF. The only permissable error returns are EIO,
+ (or equivalent) BUF. The only permissible error returns are EIO,
EDQUOT, and ENOSPC. */
error_t
pager_write_page (struct user_pager_info *pager,
diff --git a/libpager/priv.h b/libpager/priv.h
index 80afff1b..586bccbf 100644
--- a/libpager/priv.h
+++ b/libpager/priv.h
@@ -1,5 +1,5 @@
/* Private data for pager library.
- Copyright (C) 1994,95,96,97,99, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1994-1997, 1999, 2000, 2011 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -50,7 +50,7 @@ struct pager
memory_object_control_t memobjcntl;
memory_object_name_t memobjname;
- int seqno;
+ mach_port_seqno_t seqno;
int noterm; /* number of threads blocking termination */
@@ -131,8 +131,9 @@ extern int _pager_page_errors[];
struct port_class *_pager_class;
-void _pager_wait_for_seqno (struct pager *, int);
-void _pager_release_seqno (struct pager *, int);
+void _pager_wait_for_seqno (struct pager *, mach_port_seqno_t);
+void _pager_release_seqno (struct pager *, mach_port_seqno_t);
+void _pager_update_seqno (mach_port_t, mach_port_seqno_t);
void _pager_block_termination (struct pager *);
void _pager_allow_termination (struct pager *);
error_t _pager_pagemap_resize (struct pager *, vm_address_t);
diff --git a/libpager/seqnos.c b/libpager/seqnos.c
index 94cce93b..7d8bcba7 100644
--- a/libpager/seqnos.c
+++ b/libpager/seqnos.c
@@ -1,5 +1,5 @@
/* Sequence number synchronization routines for pager library
- Copyright (C) 1994 Free Software Foundation
+ Copyright (C) 1994, 2011 Free Software Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -23,7 +23,7 @@
return. */
void
_pager_wait_for_seqno (struct pager *p,
- int seqno)
+ mach_port_seqno_t seqno)
{
while (seqno != p->seqno + 1)
{
@@ -37,7 +37,7 @@ _pager_wait_for_seqno (struct pager *p,
_pager_wait_for_seqno) to be handled. */
void
_pager_release_seqno (struct pager *p,
- int seqno)
+ mach_port_seqno_t seqno)
{
assert (seqno == p->seqno + 1);
p->seqno = seqno;
@@ -47,3 +47,23 @@ _pager_release_seqno (struct pager *p,
condition_broadcast (&p->wakeup);
}
}
+
+
+/* Just update the seqno. */
+void
+_pager_update_seqno (mach_port_t object,
+ mach_port_seqno_t seqno)
+{
+ struct pager *p;
+
+ p = ports_lookup_port (0, object, _pager_class);
+ if (p)
+ {
+ mutex_lock (&p->interlock);
+ _pager_wait_for_seqno (p, seqno);
+ _pager_release_seqno (p, seqno);
+ mutex_unlock (&p->interlock);
+
+ ports_port_deref (p);
+ }
+}
diff --git a/libpager/stubs.c b/libpager/stubs.c
index b455699e..84782120 100644
--- a/libpager/stubs.c
+++ b/libpager/stubs.c
@@ -1,5 +1,5 @@
/* Unused memory object interface stubs
- Copyright (C) 1994 Free Software Foundation
+ Copyright (C) 1994, 2011 Free Software Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -21,19 +21,22 @@
#include <stdio.h>
kern_return_t
-_pager_seqnos_memory_object_copy (mach_port_t old,
+_pager_seqnos_memory_object_copy (mach_port_t obj,
mach_port_seqno_t seq,
- memory_object_control_t old_ctl,
+ memory_object_control_t obj_ctl,
vm_offset_t off,
vm_size_t len,
mach_port_t new)
{
printf ("m_o_copy called\n");
+
+ _pager_update_seqno (obj, seq);
+
return EOPNOTSUPP;
}
kern_return_t
-_pager_seqnos_memory_object_data_write (mach_port_t old,
+_pager_seqnos_memory_object_data_write (mach_port_t obj,
mach_port_seqno_t seq,
mach_port_t ctl,
vm_offset_t off,
@@ -41,6 +44,9 @@ _pager_seqnos_memory_object_data_write (mach_port_t old,
vm_size_t data_cnt)
{
printf ("m_o_data_write called\n");
+
+ _pager_update_seqno (obj, seq);
+
return EOPNOTSUPP;
}
@@ -54,6 +60,8 @@ _pager_seqnos_memory_object_supply_completed (mach_port_t obj,
vm_offset_t err_off)
{
printf ("m_o_supply_completed called\n");
+
+ _pager_update_seqno (obj, seq);
+
return EOPNOTSUPP;
}
-
diff --git a/libpipe/pipe-funcs.c b/libpipe/pipe-funcs.c
index 450180ee..79cda2a4 100644
--- a/libpipe/pipe-funcs.c
+++ b/libpipe/pipe-funcs.c
@@ -1,2 +1,2 @@
-#define PIPE_EI
+#define PIPE_DEFINE_EI
#include "pipe.h"
diff --git a/libpipe/pipe.h b/libpipe/pipe.h
index d6c5ae8f..96432990 100644
--- a/libpipe/pipe.h
+++ b/libpipe/pipe.h
@@ -24,13 +24,16 @@
#define EWOULDBLOCK EAGAIN /* XXX */
#include <cthreads.h> /* For conditions & mutexes */
+#include <features.h>
-#include "pq.h"
-
-#ifndef PIPE_EI
-#define PIPE_EI extern inline
+#ifdef PIPE_DEFINE_EI
+#define PIPE_EI
+#else
+#define PIPE_EI __extern_inline
#endif
+#include "pq.h"
+
/* A description of a class of pipes and how to operate on them. */
struct pipe_class
@@ -98,7 +101,7 @@ struct pipe
PACKET_TYPE_CONTROL. Each data packet represents one datagram for
protocols that maintain record boundaries. Control packets always
represent the control information to be returned from one read
- operation, and will be returned in conjuction with the following data
+ operation, and will be returned in conjunction with the following data
packet (if any). Reads interested only in data just skip control
packets until they find a data packet. */
struct pq *queue;
@@ -107,6 +110,21 @@ struct pipe
/* Pipe flags. */
#define PIPE_BROKEN 0x1 /* This pipe isn't connected. */
+
+extern size_t pipe_readable (struct pipe *pipe, int data_only);
+
+extern int pipe_is_readable (struct pipe *pipe, int data_only);
+
+extern error_t pipe_wait_readable (struct pipe *pipe, int noblock, int data_only);
+
+extern error_t pipe_select_readable (struct pipe *pipe, int data_only);
+
+extern error_t pipe_wait_writable (struct pipe *pipe, int noblock);
+
+extern error_t pipe_select_writable (struct pipe *pipe);
+
+#if defined(__USE_EXTERN_INLINES) || defined(PIPE_DEFINE_EI)
+
/* Returns the number of characters quickly readable from PIPE. If DATA_ONLY
is true, then `control' packets are ignored. */
PIPE_EI size_t
@@ -139,7 +157,7 @@ pipe_is_readable (struct pipe *pipe, int data_only)
return (packet != NULL);
}
-/* Waits for PIPE to be readable, or an error to occurr. If NOBLOCK is true,
+/* Waits for PIPE to be readable, or an error to occur. If NOBLOCK is true,
this operation will return EWOULDBLOCK instead of blocking when no data is
immediately available. If DATA_ONLY is true, then `control' packets are
ignored. */
@@ -156,7 +174,7 @@ pipe_wait_readable (struct pipe *pipe, int noblock, int data_only)
return 0;
}
-/* Waits for PIPE to be readable, or an error to occurr. This call only
+/* Waits for PIPE to be readable, or an error to occur. This call only
returns once threads waiting using pipe_wait_readable have been woken and
given a chance to read, and if there is still data available thereafter.
If DATA_ONLY is true, then `control' packets are ignored. */
@@ -203,6 +221,8 @@ pipe_select_writable (struct pipe *pipe)
return 0;
}
+#endif /* Use extern inlines. */
+
/* Creates a new pipe of class CLASS and returns it in RESULT. */
error_t pipe_create (struct pipe_class *class, struct pipe **pipe);
@@ -223,6 +243,26 @@ void _pipe_no_readers (struct pipe *pipe);
should be locked. */
void _pipe_no_writers (struct pipe *pipe);
+extern void pipe_acquire_reader (struct pipe *pipe);
+
+extern void pipe_acquire_writer (struct pipe *pipe);
+
+extern void pipe_release_reader (struct pipe *pipe);
+
+extern void pipe_release_writer (struct pipe *pipe);
+
+extern void pipe_add_reader (struct pipe *pipe);
+
+extern void pipe_add_writer (struct pipe *pipe);
+
+extern void pipe_remove_reader (struct pipe *pipe);
+
+extern void pipe_remove_writer (struct pipe *pipe);
+
+extern void pipe_drain (struct pipe *pipe);
+
+#if defined(__USE_EXTERN_INLINES) || defined(PIPE_DEFINE_EI)
+
/* Lock PIPE and increment its readers count. */
PIPE_EI void
pipe_acquire_reader (struct pipe *pipe)
@@ -304,6 +344,8 @@ pipe_drain (struct pipe *pipe)
pq_drain (pipe->queue);
}
+#endif /* Use extern inlines. */
+
/* Writes up to LEN bytes of DATA, to PIPE, which should be locked, and
returns the amount written in AMOUNT. If present, the information in
CONTROL & PORTS is written in a preceding control packet. If an error is
diff --git a/libpipe/pq-funcs.c b/libpipe/pq-funcs.c
index 2acecd08..57061419 100644
--- a/libpipe/pq-funcs.c
+++ b/libpipe/pq-funcs.c
@@ -1,2 +1,2 @@
-#define PQ_EI
+#define PQ_DEFINE_EI
#include "pq.h"
diff --git a/libpipe/pq.h b/libpipe/pq.h
index 3a26aa80..0fffe254 100644
--- a/libpipe/pq.h
+++ b/libpipe/pq.h
@@ -25,9 +25,12 @@
#include <stddef.h> /* for size_t */
#include <string.h>
#include <mach/mach.h>
+#include <features.h>
-#ifndef PQ_EI
-#define PQ_EI extern inline
+#ifdef PQ_DEFINE_EI
+#define PQ_EI
+#else
+#define PQ_EI __extern_inline
#endif
@@ -70,6 +73,10 @@ error_t packet_set_ports (struct packet *packet,
/* If PACKET has any ports, deallocates them. */
void packet_dealloc_ports (struct packet *packet);
+extern size_t packet_readable (struct packet *packet);
+
+#if defined(__USE_EXTERN_INLINES) || defined(PQ_DEFINE_EI)
+
/* Returns the number of bytes of data in PACKET. */
PQ_EI size_t
packet_readable (struct packet *packet)
@@ -77,6 +84,8 @@ packet_readable (struct packet *packet)
return packet->buf_end - packet->buf_start;
}
+#endif /* Use extern inlines. */
+
/* Append the bytes in DATA, of length DATA_LEN, to what's already in PACKET,
and return the amount appended in AMOUNT if that's not the null pointer. */
error_t packet_write (struct packet *packet,
@@ -94,6 +103,10 @@ error_t packet_read (struct packet *packet,
error_t packet_read_ports (struct packet *packet,
mach_port_t **ports, size_t *num_ports);
+extern void packet_read_source (struct packet *packet, void **source);
+
+#if defined(__USE_EXTERN_INLINES) || defined(PQ_DEFINE_EI)
+
/* Return the source addressd in PACKET in SOURCE, deallocating it from
PACKET. */
PQ_EI void
@@ -102,6 +115,8 @@ packet_read_source (struct packet *packet, void **source)
*source = packet->source;
packet->source = 0;
}
+
+#endif /* Use extern inlines. */
/* The packet size above which we start to do things differently to avoid
copying around data. */
@@ -125,6 +140,14 @@ int packet_extend (struct packet *packet, size_t new_len);
returned. */
error_t packet_realloc (struct packet *packet, size_t new_len);
+extern int packet_fit (struct packet *packet, size_t amount);
+
+extern error_t packet_ensure (struct packet *packet, size_t amount);
+
+extern int packet_ensure_efficiently (struct packet *packet, size_t amount);
+
+#if defined(__USE_EXTERN_INLINES) || defined(PQ_DEFINE_EI)
+
/* Try to make space in PACKET for AMOUNT more bytes without growing the
buffer, returning true if we could do it. */
PQ_EI int
@@ -189,6 +212,8 @@ packet_ensure_efficiently (struct packet *packet, size_t amount)
}
return 0;
}
+
+#endif /* Use extern inlines. */
struct pq
{
@@ -201,6 +226,10 @@ struct pq
the packet, or deallocated by calling pipe_dealloc_addr. */
struct packet *pq_queue (struct pq *pq, unsigned type, void *source);
+extern struct packet * pq_tail (struct pq *pq, unsigned type, void *source);
+
+#if defined(__USE_EXTERN_INLINES) || defined(PQ_DEFINE_EI)
+
/* Returns the tail of the packet queue PQ, which may mean pushing a new
packet if TYPE and SOURCE do not match the current tail, or this is the
first packet. */
@@ -214,13 +243,21 @@ pq_tail (struct pq *pq, unsigned type, void *source)
return tail;
}
+#endif /* Use extern inlines. */
+
/* Remove the first packet (if any) in PQ, deallocating any resources it
holds. True is returned if a packet was found, false otherwise. */
int pq_dequeue (struct pq *pq);
+extern struct packet * pq_head (struct pq *pq, unsigned type, void *source);
+
+extern struct packet * pq_next (struct pq *pq, unsigned type, void *source);
+
+#if defined(__USE_EXTERN_INLINES) || defined(PQ_DEFINE_EI)
+
/* Returns the next available packet in PQ, without removing it from the
- queue, or NULL if there is none, or the next packet isn't appropiate.
- A packet is inappropiate if SOURCE is non-NULL its source field doesn't
+ queue, or NULL if there is none, or the next packet isn't appropriate.
+ A packet is inappropriate if SOURCE is non-NULL its source field doesn't
match it, or TYPE is non-NULL and the packet's type field doesn't match
it. */
PQ_EI struct packet *
@@ -246,6 +283,8 @@ pq_next (struct pq *pq, unsigned type, void *source)
return pq_head (pq, type, source);
}
+#endif /* Use extern inlines. */
+
/* Dequeues all packets in PQ. */
void pq_drain (struct pq *pq);
diff --git a/libports/bucket-iterate.c b/libports/bucket-iterate.c
index d376e6f8..e439cb19 100644
--- a/libports/bucket-iterate.c
+++ b/libports/bucket-iterate.c
@@ -31,7 +31,7 @@ _ports_bucket_class_iterate (struct port_bucket *bucket,
error_t (*fun)(void *))
{
/* This is obscenely ineffecient. ihash and ports need to cooperate
- more closely to do it effeciently. */
+ more closely to do it efficiently. */
struct item
{
struct item *next;
diff --git a/libports/manage-multithread.c b/libports/manage-multithread.c
index 6ec1e49f..82fa2ac6 100644
--- a/libports/manage-multithread.c
+++ b/libports/manage-multithread.c
@@ -60,6 +60,7 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket,
assert (nreqthreads);
nreqthreads--;
if (nreqthreads == 0)
+ /* No thread would be listening for requests, spawn one. */
spawn = 1;
spin_unlock (&lock);
@@ -150,6 +151,12 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket,
else
{
spin_lock (&lock);
+ if (nreqthreads == 1)
+ {
+ /* No other thread is listening for requests, continue. */
+ spin_unlock (&lock);
+ goto startover;
+ }
nreqthreads--;
totalthreads--;
spin_unlock (&lock);
diff --git a/libports/manage-one-thread.c b/libports/manage-one-thread.c
index 57b8a9a9..4ea740b2 100644
--- a/libports/manage-one-thread.c
+++ b/libports/manage-one-thread.c
@@ -69,7 +69,7 @@ ports_manage_port_operations_one_thread (struct port_bucket *bucket,
}
else
{
- /* No need to check cancel threshhold here, because
+ /* No need to check cancel threshold here, because
in a single threaded server the cancel is always
handled in order. */
status = demuxer (inp, outheadp);
diff --git a/libps/fmt.c b/libps/fmt.c
index 3a47338a..0465555d 100644
--- a/libps/fmt.c
+++ b/libps/fmt.c
@@ -370,8 +370,8 @@ ps_fmt_clone (struct ps_fmt *fmt, struct ps_fmt **copy)
return 0;
}
-/* Write an appropiate header line for FMT, containing the titles of all its
- fields appropiately aligned with where the values would be printed, to
+/* Write an appropriate header line for FMT, containing the titles of all its
+ fields appropriately aligned with where the values would be printed, to
STREAM (without a trailing newline). If count is non-NULL, the total
number number of characters output is added to the integer it points to.
If any fatal error occurs, the error code is returned, otherwise 0. */
@@ -461,9 +461,9 @@ ps_fmt_write_proc_stat (struct ps_fmt *fmt, struct proc_stat *ps, struct ps_stre
}
/* Remove those fields from FMT for which the function FN, when called on the
- field, returns true. Appropiate inter-field characters are also removed:
+ field, returns true. Appropriate inter-field characters are also removed:
those *following* deleted fields at the beginning of the fmt, and those
- *preceeding* deleted fields *not* at the beginning. */
+ *preceding* deleted fields *not* at the beginning. */
void
ps_fmt_squash (struct ps_fmt *fmt, int (*fn)(struct ps_fmt_field *field))
{
@@ -540,8 +540,8 @@ ps_fmt_squash (struct ps_fmt *fmt, int (*fn)(struct ps_fmt_field *field))
}
/* Remove those fields from FMT which would need the proc_stat flags FLAGS.
- Appropiate inter-field characters are also removed: those *following*
- deleted fields at the beginning of the fmt, and those *preceeding* deleted
+ Appropriate inter-field characters are also removed: those *following*
+ deleted fields at the beginning of the fmt, and those *preceding* deleted
fields *not* at the beginning. */
void
ps_fmt_squash_flags (struct ps_fmt *fmt, ps_flags_t flags)
diff --git a/libps/procstat.c b/libps/procstat.c
index eac4ae42..ba923780 100644
--- a/libps/procstat.c
+++ b/libps/procstat.c
@@ -288,7 +288,7 @@ add_preconditions (ps_flags_t flags, struct ps_context *context)
flags |= PSTAT_PROC_INFO;
if (flags & PSTAT_SUSPEND_COUNT)
/* We just request the resources require for both the thread and task
- versions, as the extraneous info won't be possible to aquire anyway. */
+ versions, as the extraneous info won't be possible to acquire anyway. */
flags |= PSTAT_TASK_BASIC | PSTAT_THREAD_BASIC;
if (flags & (PSTAT_CTTYID | PSTAT_CWDIR | PSTAT_AUTH | PSTAT_UMASK)
&& !(flags & PSTAT_NO_MSGPORT))
@@ -774,7 +774,7 @@ proc_stat_set_flags (struct proc_stat *ps, ps_flags_t flags)
/* Returns true if (1) FLAGS is in NEED, and (2) the appropriate
preconditions PRECOND are available; if only (1) is true, FLAG is added
- to the INAPP set if appropiate (to distinguish it from an error), and
+ to the INAPP set if appropriate (to distinguish it from an error), and
returns false. */
#define NEED(flag, precond) \
({ \
@@ -1090,7 +1090,7 @@ _proc_stat_create (pid_t pid, struct ps_context *context, struct proc_stat **ps)
resulting proc_stat isn't fully functional -- most flags can't be set in
it. It also contains a pointer to PS, so PS shouldn't be freed without
also freeing THREAD_PS. If N was out of range, EINVAL is returned. If a
- memory allocation error occured, ENOMEM is returned. Otherwise, 0 is
+ memory allocation error occurred, ENOMEM is returned. Otherwise, 0 is
returned. */
error_t
proc_stat_thread_create (struct proc_stat *ps, unsigned index, struct proc_stat **thread_ps)
diff --git a/libps/ps.h b/libps/ps.h
index b85ede46..91fdc70b 100644
--- a/libps/ps.h
+++ b/libps/ps.h
@@ -475,7 +475,7 @@ error_t proc_stat_set_flags (struct proc_stat *ps, ps_flags_t flags);
PS (N should be between 0 and the number of threads in the process). The
resulting proc_stat isn't fully functional -- most flags can't be set in
it. If N was out of range, EINVAL is returned. If a memory allocation
- error occured, ENOMEM is returned. Otherwise, 0 is returned. */
+ error occurred, ENOMEM is returned. Otherwise, 0 is returned. */
error_t proc_stat_thread_create (struct proc_stat *ps, unsigned n,
struct proc_stat **thread_ps);
@@ -769,7 +769,7 @@ struct ps_fmt
this procstat. */
char *inapp;
- /* The string displayed by default for fields which are appropiate, but
+ /* The string displayed by default for fields which are appropriate, but
couldn't be fetched due to some error. */
char *error;
};
@@ -822,7 +822,7 @@ void ps_fmt_free (struct ps_fmt *fmt);
instance, you would like squash a format without destroying the original. */
error_t ps_fmt_clone (struct ps_fmt *fmt, struct ps_fmt **copy);
-/* Write an appropiate header line for FMT, containing the titles of all its
+/* Write an appropriate header line for FMT, containing the titles of all its
fields appropiately aligned with where the values would be printed, to
STREAM (without a trailing newline). If count is non-NULL, the total
number number of characters output is added to the integer it points to.
@@ -837,14 +837,14 @@ error_t ps_fmt_write_proc_stat (struct ps_fmt *fmt, struct proc_stat *ps,
struct ps_stream *stream);
/* Remove those fields from FMT for which the function FN, when called on the
- field, returns true. Appropiate inter-field characters are also removed:
+ field, returns true. Appropriate inter-field characters are also removed:
those *following* deleted fields at the beginning of the fmt, and those
- *preceeding* deleted fields *not* at the beginning. */
+ *preceding* deleted fields *not* at the beginning. */
void ps_fmt_squash (struct ps_fmt *fmt, int (*fn)(struct ps_fmt_field *field));
/* Remove those fields from FMT which would need the proc_stat flags FLAGS.
- Appropiate inter-field characters are also removed: those *following*
- deleted fields at the beginning of the fmt, and those *preceeding* deleted
+ Appropriate inter-field characters are also removed: those *following*
+ deleted fields at the beginning of the fmt, and those *preceding* deleted
fields *not* at the beginning. */
void ps_fmt_squash_flags (struct ps_fmt *fmt, ps_flags_t flags);
diff --git a/libshouldbeinlibc/cacheq.c b/libshouldbeinlibc/cacheq.c
index eb41c6e9..5649903a 100644
--- a/libshouldbeinlibc/cacheq.c
+++ b/libshouldbeinlibc/cacheq.c
@@ -106,7 +106,7 @@ cacheq_set_length (struct cacheq *cq, int length)
th->next = next_th;
}
- /* Call user hooks as appropiate. */
+ /* Call user hooks as appropriate. */
if (fh && th)
{
if (cq->move_entry)
diff --git a/libshouldbeinlibc/idvec-funcs.c b/libshouldbeinlibc/idvec-funcs.c
index 1bc6d85f..3bb0318d 100644
--- a/libshouldbeinlibc/idvec-funcs.c
+++ b/libshouldbeinlibc/idvec-funcs.c
@@ -1,2 +1,2 @@
-#define IDVEC_EI
+#define IDVEC_DEFINE_EI
#include "idvec.h"
diff --git a/libshouldbeinlibc/idvec.c b/libshouldbeinlibc/idvec.c
index 692c4788..24adeb8f 100644
--- a/libshouldbeinlibc/idvec.c
+++ b/libshouldbeinlibc/idvec.c
@@ -202,7 +202,7 @@ idvec_merge (struct idvec *idvec, const struct idvec *new)
return idvec_merge_ids (idvec, new->ids, new->num);
}
-/* Remove any occurances of ID in IDVEC after position POS.
+/* Remove any occurrences of ID in IDVEC after position POS.
Returns true if anything was done. */
int
idvec_remove (struct idvec *idvec, unsigned pos, uid_t id)
diff --git a/libshouldbeinlibc/idvec.h b/libshouldbeinlibc/idvec.h
index 41441259..abbc273e 100644
--- a/libshouldbeinlibc/idvec.h
+++ b/libshouldbeinlibc/idvec.h
@@ -24,9 +24,12 @@
#include <hurd/hurd_types.h>
#include <errno.h>
#include <string.h>
+#include <features.h>
-#ifndef IDVEC_EI
-#define IDVEC_EI extern inline
+#ifdef IDVEC_DEFINE_EI
+#define IDVEC_EI
+#else
+#define IDVEC_EI __extern_inline
#endif
struct idvec
@@ -50,6 +53,14 @@ void idvec_free_wrapper (struct idvec *idvec);
/* Free IDVEC and any storage associated with it. */
void idvec_free (struct idvec *idvec);
+extern void idvec_clear (struct idvec *idvec);
+
+extern int idvec_is_empty (const struct idvec *idvec);
+
+extern int idvec_equal (const struct idvec *idvec1, const struct idvec *idvec2);
+
+#if defined(__USE_EXTERN_INLINES) || defined(IDVEC_DEFINE_EI)
+
/* Mark IDVEC as not containing any ids. */
IDVEC_EI void
idvec_clear (struct idvec *idvec)
@@ -74,6 +85,8 @@ idvec_equal (const struct idvec *idvec1, const struct idvec *idvec2)
|| memcmp (idvec1->ids, idvec2->ids, num * sizeof *idvec1->ids) == 0);
}
+#endif /* Use extern inlines. */
+
/* Ensure that IDVEC has enough spaced allocated to hold NUM ids, thus
ensuring that any subsequent ids added won't return a memory allocation
error unless it would result in more ids that NUM. ENOMEM is returned if
@@ -87,6 +100,10 @@ error_t idvec_grow (struct idvec *idvec, unsigned inc);
/* Returns true if IDVEC contains ID, at or after position POS. */
int idvec_tail_contains (const struct idvec *idvec, unsigned pos, uid_t id);
+extern int idvec_contains (const struct idvec *idvec, uid_t id);
+
+#if defined(__USE_EXTERN_INLINES) || defined(IDVEC_DEFINE_EI)
+
/* Returns true if IDVEC contains ID. */
IDVEC_EI int
idvec_contains (const struct idvec *idvec, uid_t id)
@@ -94,6 +111,8 @@ idvec_contains (const struct idvec *idvec, uid_t id)
return idvec_tail_contains (idvec, 0, id);
}
+#endif /* Use extern inlines. */
+
/* Insert ID into IDVEC at position POS, returning ENOMEM if there wasn't
enough memory, or 0. */
error_t idvec_insert (struct idvec *idvec, unsigned pos, uid_t id);
@@ -131,7 +150,7 @@ int idvec_subtract (struct idvec *idvec, const struct idvec *sub);
anything was changed. */
int idvec_keep (struct idvec *idvec, const struct idvec *keep);
-/* Remove any occurances of ID in IDVEC after position POS> Returns true if
+/* Remove any occurrences of ID in IDVEC after position POS> Returns true if
anything was done. */
int idvec_remove (struct idvec *idvec, unsigned pos, uid_t id);
diff --git a/libshouldbeinlibc/localhost.c b/libshouldbeinlibc/localhost.c
index f0c67541..f0225116 100644
--- a/libshouldbeinlibc/localhost.c
+++ b/libshouldbeinlibc/localhost.c
@@ -39,18 +39,27 @@ localhost ()
errno = 0;
if (buf) {
+ char *new;
buf_len += buf_len;
- buf = realloc (buf, buf_len);
+ new = realloc (buf, buf_len);
+ if (! new)
+ {
+ free (buf);
+ buf = 0;
+ errno = ENOMEM;
+ return 0;
+ }
+ else
+ buf = new;
} else {
buf_len = 128; /* Initial guess */
buf = malloc (buf_len);
+ if (! buf)
+ {
+ errno = ENOMEM;
+ return 0;
+ }
}
-
- if (! buf)
- {
- errno = ENOMEM;
- return 0;
- }
} while ((gethostname(buf, buf_len) == 0 && !memchr (buf, '\0', buf_len))
|| errno == ENAMETOOLONG);
diff --git a/libshouldbeinlibc/maptime-funcs.c b/libshouldbeinlibc/maptime-funcs.c
index eeac3b3e..080e3ae6 100644
--- a/libshouldbeinlibc/maptime-funcs.c
+++ b/libshouldbeinlibc/maptime-funcs.c
@@ -1,4 +1,4 @@
-#define MAPTIME_EI
+#define MAPTIME_DEFINE_EI
#include <errno.h>
#include <sys/types.h>
#include <sys/time.h>
diff --git a/libshouldbeinlibc/maptime.h b/libshouldbeinlibc/maptime.h
index ac97b411..947ad640 100644
--- a/libshouldbeinlibc/maptime.h
+++ b/libshouldbeinlibc/maptime.h
@@ -21,13 +21,16 @@
#ifndef __MAPTIME_H__
#define __MAPTIME_H__
-#ifndef MAPTIME_EI
-#define MAPTIME_EI extern inline
-#endif
-
#include <mach/time_value.h>
#include <sys/time.h>
#include <errno.h>
+#include <features.h>
+
+#ifdef MAPTIME_DEFINE_EI
+#define MAPTIME_EI
+#else
+#define MAPTIME_EI __extern_inline
+#endif
/* Return the mach mapped time page in MTIME. If USE_MACH_DEV is false, then
the hurd time device DEV_NAME, or "/dev/time" if DEV_NAME is 0, is
@@ -37,6 +40,10 @@
error_t maptime_map (int use_mach_dev, char *dev_name,
volatile struct mapped_time_value **mtime);
+extern void maptime_read (volatile struct mapped_time_value *mtime, struct timeval *tv);
+
+#if defined(__USE_EXTERN_INLINES) || defined(MAPTIME_DEFINE_EI)
+
/* Read the current time from MTIME into TV. This should be very fast. */
MAPTIME_EI void
maptime_read (volatile struct mapped_time_value *mtime, struct timeval *tv)
@@ -49,4 +56,6 @@ maptime_read (volatile struct mapped_time_value *mtime, struct timeval *tv)
while (tv->tv_sec != mtime->check_seconds);
}
+#endif /* Use extern inlines. */
+
#endif /* __MAPTIME_H__ */
diff --git a/libshouldbeinlibc/ugids-xinl.c b/libshouldbeinlibc/ugids-xinl.c
index 26df93cc..107de8b9 100644
--- a/libshouldbeinlibc/ugids-xinl.c
+++ b/libshouldbeinlibc/ugids-xinl.c
@@ -19,7 +19,5 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#define UGIDS_EI
-#undef __OPTIMIZE__
-#define __OPTIMIZE__ 1
+#define UGIDS_DEFINE_EI
#include "ugids.h"
diff --git a/libshouldbeinlibc/ugids.c b/libshouldbeinlibc/ugids.c
index 057dcf81..2b9b6b71 100644
--- a/libshouldbeinlibc/ugids.c
+++ b/libshouldbeinlibc/ugids.c
@@ -49,7 +49,7 @@ ugids_add_gid (struct ugids *ugids, gid_t gid, int avail)
error_t err =
idvec_add_new (avail ? &ugids->avail_gids : &ugids->eff_gids, gid);
if (! err)
- /* Since this gid is now explicit, remove it from the appropiate implied
+ /* Since this gid is now explicit, remove it from the appropriate implied
set. */
idvec_remove (avail ? &ugids->imp_avail_gids : &ugids->imp_eff_gids,
0, gid);
@@ -70,7 +70,7 @@ ugids_add_user (struct ugids *ugids, uid_t uid, int avail)
idvec_merge_implied_gids (&imp_gids, &uids);
/* Now remove any gids we already know about from IMP_GIDS. For gids
- that weren't in the appropiate implied set before, this will
+ that weren't in the appropriate implied set before, this will
ensure that they remain out after we merge IMP_GIDS into it, and
ones that *were*, they will remain so. */
idvec_subtract (&imp_gids, gids);
diff --git a/libshouldbeinlibc/ugids.h b/libshouldbeinlibc/ugids.h
index 8440b608..10e7a242 100644
--- a/libshouldbeinlibc/ugids.h
+++ b/libshouldbeinlibc/ugids.h
@@ -23,9 +23,12 @@
#include <stdlib.h> /* For inline function stuff. */
#include <idvec.h>
+#include <features.h>
-#ifndef UGIDS_EI
-#define UGIDS_EI extern inline
+#ifdef UGIDS_DEFINE_EI
+#define UGIDS_EI
+#else
+#define UGIDS_EI __extern_inline
#endif
/* A structure holding a set of the common various types of ids. */
@@ -47,6 +50,16 @@ struct ugids
/* Return a new ugids structure, or 0 if an allocation error occurs. */
struct ugids *make_ugids ();
+extern void ugids_fini (struct ugids *ugids);
+
+extern void ugids_free (struct ugids *ugids);
+
+extern int ugids_is_empty (const struct ugids *ugids);
+
+extern int ugids_equal (const struct ugids *ugids1, const struct ugids *ugids2);
+
+#if defined(__USE_EXTERN_INLINES) || defined(UGIDS_DEFINE_EI)
+
/* Free all resources used by UGIDS except UGIDS itself. */
UGIDS_EI void
ugids_fini (struct ugids *ugids)
@@ -93,6 +106,8 @@ ugids_equal (const struct ugids *ugids1, const struct ugids *ugids2)
&& idvec_equal (&ugids1->imp_avail_gids, &ugids2->imp_avail_gids);
}
+#endif /* Use extern inlines. */
+
/* Add all ids in NEW to UGIDS. */
error_t ugids_merge (struct ugids *ugids, const struct ugids *new);
diff --git a/libstore/argp.c b/libstore/argp.c
index 9af7ae57..6ed79964 100644
--- a/libstore/argp.c
+++ b/libstore/argp.c
@@ -365,7 +365,7 @@ parse_opt (int opt, char *arg, struct argp_state *state)
break;
case ARGP_KEY_ERROR:
- /* Parsing error occured, free everything. */
+ /* Parsing error occurred, free everything. */
store_parsed_free (parsed); break;
case ARGP_KEY_SUCCESS:
diff --git a/libstore/kids.c b/libstore/kids.c
index f254bcd3..901a7f85 100644
--- a/libstore/kids.c
+++ b/libstore/kids.c
@@ -103,7 +103,7 @@ store_decode_children (struct store_enc *enc, int num_children,
return err;
}
-/* Set FLAGS in all children of STORE, and if successfull, add FLAGS to
+/* Set FLAGS in all children of STORE, and if successful, add FLAGS to
STORE's flags. */
error_t
store_set_child_flags (struct store *store, int flags)
@@ -127,7 +127,7 @@ store_set_child_flags (struct store *store, int flags)
return err;
}
-/* Clear FLAGS in all children of STORE, and if successfull, remove FLAGS from
+/* Clear FLAGS in all children of STORE, and if successful, remove FLAGS from
STORE's flags. */
error_t
store_clear_child_flags (struct store *store, int flags)
diff --git a/libstore/store.h b/libstore/store.h
index 5b48504c..ae334a1d 100644
--- a/libstore/store.h
+++ b/libstore/store.h
@@ -33,11 +33,13 @@
#include <mach.h>
#include <device/device.h>
#include <hurd/hurd_types.h>
+#include <features.h>
-#ifndef STORE_EI
-#define STORE_EI extern inline
+#ifdef STORE_DEFINE_EI
+#define STORE_EI
+#else
+#define STORE_EI __extern_inline
#endif
-
/* Type for addresses inside the store. */
typedef off64_t store_offset_t;
@@ -262,14 +264,18 @@ error_t store_set_flags (struct store *store, int flags);
/* Remove FLAGS from STORE's currently set flags. */
error_t store_clear_flags (struct store *store, int flags);
-/* Set FLAGS in all children of STORE, and if successfull, add FLAGS to
+/* Set FLAGS in all children of STORE, and if successful, add FLAGS to
STORE's flags. */
error_t store_set_child_flags (struct store *store, int flags);
-/* Clear FLAGS in all children of STORE, and if successfull, remove FLAGS from
+/* Clear FLAGS in all children of STORE, and if successful, remove FLAGS from
STORE's flags. */
error_t store_clear_child_flags (struct store *store, int flags);
+extern int store_is_securely_returnable (struct store *store, int open_flags);
+
+#if defined(__USE_EXTERN_INLINES) || defined(STORE_DEFINE_EI)
+
/* Returns true if STORE can safely be returned to a user who has accessed it
via a node using OPEN_FLAGS, without compromising security. */
STORE_EI int
@@ -283,6 +289,8 @@ store_is_securely_returnable (struct store *store, int open_flags)
|| (flags & STORE_HARD_READONLY)));
}
+#endif /* Use extern inlines. */
+
/* Fills in the values of the various fields in STORE that are derivable from
the set of runs & the block size. */
void _store_derive (struct store *store);
diff --git a/libstore/xinl.c b/libstore/xinl.c
index a603d621..90242212 100644
--- a/libstore/xinl.c
+++ b/libstore/xinl.c
@@ -1,2 +1,2 @@
-#define STORE_EI
+#define STORE_DEFINE_EI
#include "store.h"
diff --git a/libthreads/alpha/thread.c b/libthreads/alpha/thread.c
index 2bf5ff64..db2cb0c8 100644
--- a/libthreads/alpha/thread.c
+++ b/libthreads/alpha/thread.c
@@ -65,10 +65,12 @@ extern bzero();
* so that it will invoke routine(child)
* when it is resumed.
*/
+#warning TLS support not implemented
void
cproc_setup(
register cproc_t child,
thread_t thread,
+ tcbhead_t *tcb,
void (*routine)(cproc_t))
{
register integer_t *top;
diff --git a/libthreads/cprocs.c b/libthreads/cprocs.c
index 2195039c..7f63fc0d 100644
--- a/libthreads/cprocs.c
+++ b/libthreads/cprocs.c
@@ -725,10 +725,11 @@ cproc_create(void)
spin_lock(&n_kern_lock);
if (cthread_max_kernel_threads == 0 ||
cthread_kernel_threads < cthread_max_kernel_threads) {
+ tcbhead_t *tcb = _dl_allocate_tls(NULL);
cthread_kernel_threads++;
spin_unlock(&n_kern_lock);
MACH_CALL(thread_create(mach_task_self(), &n), r);
- cproc_setup(child, n, cthread_body); /* machine dependent */
+ cproc_setup(child, n, tcb, cthread_body); /* machine dependent */
MACH_CALL(thread_resume(n), r);
#ifdef STATISTICS
spin_lock(&ready_lock);
diff --git a/libthreads/cthread_internals.h b/libthreads/cthread_internals.h
index eec336cf..81e3b91c 100644
--- a/libthreads/cthread_internals.h
+++ b/libthreads/cthread_internals.h
@@ -161,6 +161,14 @@
# endif
#endif
+/* Type of the TCB. */
+typedef struct
+{
+ void *tcb; /* Points to this structure. */
+ void *dtv; /* Vector of pointers to TLS data. */
+ thread_t self; /* This thread's control port. */
+} tcbhead_t;
+
/*
* Low-level thread implementation.
* This structure must agree with struct ur_cthread in cthreads.h
@@ -307,4 +315,10 @@ extern void cproc_prepare(cproc_t _child,
void (*cthread_body_pc)());
extern void cproc_setup(cproc_t _child, thread_t _mach_thread,
- void (*_routine)(cproc_t));
+ tcbhead_t *tcb, void (*_routine)(cproc_t));
+
+
+/* From glibc. */
+
+/* Dynamic linker TLS allocation. */
+extern void *_dl_allocate_tls(void *);
diff --git a/libthreads/i386/thread.c b/libthreads/i386/thread.c
index c0195a8b..00537be5 100644
--- a/libthreads/i386/thread.c
+++ b/libthreads/i386/thread.c
@@ -61,6 +61,21 @@ char rcs_id[] = "$Header: cvs-sans-libpthread/hurd/libthreads/i386/thread.c,v 1.
#include <cthreads.h>
#include "cthread_internals.h"
#include <mach.h>
+#include <mach/i386/mach_i386.h>
+#include <mach/mig_errors.h>
+
+#define HURD_TLS_DESC_DECL(desc, tcb) \
+ struct descriptor desc = \
+ { /* low word: */ \
+ 0xffff /* limit 0..15 */ \
+ | (((unsigned int) (tcb)) << 16) /* base 0..15 */ \
+ , /* high word: */ \
+ ((((unsigned int) (tcb)) >> 16) & 0xff) /* base 16..23 */ \
+ | ((0x12 | 0x60 | 0x80) << 8) /* access = ACC_DATA_W|ACC_PL_U|ACC_P */ \
+ | (0xf << 16) /* limit 16..19 */ \
+ | ((4 | 8) << 20) /* granularity = SZ_32|SZ_G */ \
+ | (((unsigned int) (tcb)) & 0xff000000) /* base 24..31 */ \
+ }
/*
* Set up the initial state of a MACH thread
@@ -68,7 +83,7 @@ char rcs_id[] = "$Header: cvs-sans-libpthread/hurd/libthreads/i386/thread.c,v 1.
* when it is resumed.
*/
void
-cproc_setup(register cproc_t child, thread_t thread, void (*routine)(cproc_t))
+cproc_setup(register cproc_t child, thread_t thread, tcbhead_t *tcb, void (*routine)(cproc_t))
{
extern unsigned int __hurd_threadvar_max; /* GNU */
register int *top = (int *)
@@ -81,13 +96,15 @@ cproc_setup(register cproc_t child, thread_t thread, void (*routine)(cproc_t))
register struct i386_thread_state *ts = &state;
kern_return_t r;
unsigned int count;
+ HURD_TLS_DESC_DECL(desc, tcb);
+ int sel;
/*
* Set up i386 call frame and registers.
* Read registers first to get correct segment values.
*/
count = i386_THREAD_STATE_COUNT;
- MACH_CALL(thread_get_state(thread,i386_THREAD_STATE,(thread_state_t) &state,&count),r);
+ MACH_CALL(thread_get_state(thread,i386_REGS_SEGS_STATE,(thread_state_t) &state,&count),r);
ts->eip = (int) routine;
*--top = (int) child; /* argument to function */
@@ -95,7 +112,16 @@ cproc_setup(register cproc_t child, thread_t thread, void (*routine)(cproc_t))
ts->uesp = (int) top; /* set stack pointer */
ts->ebp = 0; /* clear frame pointer */
- MACH_CALL(thread_set_state(thread,i386_THREAD_STATE,(thread_state_t) &state,i386_THREAD_STATE_COUNT),r);
+ asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0));
+ tcb->tcb = tcb;
+ tcb->self = thread;
+ if (__builtin_expect (sel, 0x48) & 4) /* LDT selector */
+ __i386_set_ldt (thread, sel, &desc, 1);
+ else
+ __i386_set_gdt (thread, &sel, desc);
+ ts->gs = sel;
+
+ MACH_CALL(thread_set_state(thread,i386_REGS_SEGS_STATE,(thread_state_t) &state,i386_THREAD_STATE_COUNT),r);
}
#if defined(cthread_sp)
diff --git a/libthreads/mig_support.c b/libthreads/mig_support.c
index 01e5deb0..cd0d4124 100644
--- a/libthreads/mig_support.c
+++ b/libthreads/mig_support.c
@@ -53,7 +53,7 @@
* Revision 2.3 90/08/07 14:27:48 rpd
* When we recycle the global reply port by giving it to the first
* cthread, clear the global reply port. This will take care of
- * someone accidently calling this twice.
+ * someone accidentally calling this twice.
* [90/08/07 rwd]
*
* Revision 2.2 90/06/02 15:14:04 rpd
diff --git a/libthreads/rwlock.c b/libthreads/rwlock.c
index 93533a97..ae6a7c48 100644
--- a/libthreads/rwlock.c
+++ b/libthreads/rwlock.c
@@ -1,2 +1,2 @@
-#define RWLOCK_EI
+#define RWLOCK_DEFINE_EI
#include "rwlock.h"
diff --git a/libthreads/rwlock.h b/libthreads/rwlock.h
index 1a61eeea..44d9a35d 100644
--- a/libthreads/rwlock.h
+++ b/libthreads/rwlock.h
@@ -21,6 +21,13 @@
#include <cthreads.h>
#include <assert.h>
+#include <features.h>
+
+#ifdef RWLOCK_DEFINE_EI
+#define RWLOCK_EI
+#else
+#define RWLOCK_EI __extern_inline
+#endif
struct rwlock
{
@@ -31,9 +38,17 @@ struct rwlock
int readers_waiting;
};
-#ifndef RWLOCK_EI
-#define RWLOCK_EI extern inline
-#endif
+extern void rwlock_reader_lock (struct rwlock *lock);
+
+extern void rwlock_writer_lock (struct rwlock *lock);
+
+extern void rwlock_reader_unlock (struct rwlock *lock);
+
+extern void rwlock_writer_unlock (struct rwlock *lock);
+
+extern void rwlock_init (struct rwlock *lock);
+
+#if defined(__USE_EXTERN_INLINES) || defined(RWLOCK_DEFINE_EI)
/* Get a reader lock on reader-writer lock LOCK for disknode DN */
RWLOCK_EI void
@@ -104,6 +119,8 @@ rwlock_init (struct rwlock *lock)
lock->writers_waiting = 0;
}
+#endif /* Use extern inlines. */
+
#define RWLOCK_INITIALIZER \
{ MUTEX_INITIALIZER, CONDITION_INITIALIZER, 0, 0, 0 }
diff --git a/libtreefs/Makefile b/libtreefs/Makefile
index 89d95e9b..3cdc30c9 100644
--- a/libtreefs/Makefile
+++ b/libtreefs/Makefile
@@ -25,12 +25,12 @@ installhdrs = treefs.h
S_SRCS = s-file.c s-dir.c s-io.c s-fsys.c
OTHERSRCS = defhooks.c dir-hooks.c dir-lookup.c fsys-getroot.c fsys-hooks.c \
fsys-startup.c hooks.c mdir.c nlist.c node-hooks.c rights.c \
- trans-help.c trans-start.c
+ trans-help.c trans-start.c xinl.c
SRCS = $(OTHERSRCS) $(S_SRCS)
LCLHDRS = treefs.h fs-mutate.h
MIGSTUBS = fsServer.o ioServer.o fsysServer.o
-OBJS = $(sort $(subst .c,.o,$(SRCS)) $(MIGSTUBS)
+OBJS = $(sort $(SRCS:.c=.o)) $(MIGSTUBS)
MIGSFLAGS = -imacros fs-mutate.h
MIGCOMSFLAGS = -prefix treefs_
diff --git a/libtreefs/mig-decls.h b/libtreefs/mig-decls.h
index 0d051e9c..e17f6196 100644
--- a/libtreefs/mig-decls.h
+++ b/libtreefs/mig-decls.h
@@ -25,7 +25,11 @@
/* For mig */
typedef struct treefs_handle *treefs_handle_t;
-extern inline
+extern treefs_handle_t treefs_begin_using_handle_port(mach_port_t port);
+extern void treefs_end_using_handle_port (treefs_handle_t handle);
+
+#if defined(__USE_EXTERN_INLINES) || defined(TREEFS_DEFINE_EI)
+TREEFS_EI
treefs_handle_t treefs_begin_using_handle_port(mach_port_t port)
{
return
@@ -33,9 +37,10 @@ treefs_handle_t treefs_begin_using_handle_port(mach_port_t port)
ports_lookup_port (0, port, treefs_fsys_port_class);
}
-extern inline void
+TREEFS_EI void
treefs_end_using_handle_port (treefs_handle_t handle)
{
if (handle != NULL)
ports_port_deref (&handle->pi);
}
+#endif /* Use extern inlines. */
diff --git a/libtreefs/treefs.h b/libtreefs/treefs.h
index 0ad528d8..d8f30e4e 100644
--- a/libtreefs/treefs.h
+++ b/libtreefs/treefs.h
@@ -26,6 +26,7 @@
#include <errno.h>
#include <cthreads.h>
#include <assert.h>
+#include <features.h>
#include <sys/stat.h>
@@ -36,6 +37,12 @@
/* Include the hook calling macros and non-rpc hook definitions (to get
those, include "trees-s-hooks.h"). */
#include "treefs-hooks.h"
+
+#ifdef TREEFS_DEFINE_EI
+#define TREEFS_EI
+#else
+#define TREEFS_EI __extern_inline
+#endif
/* ---------------------------------------------------------------- */
@@ -237,10 +244,18 @@ void treefs_hooks_set (treefs_hook_vector_t hooks,
extern spin_lock_t treefs_node_refcnt_lock;
+extern void treefs_node_ref (struct treefs_node *node);
+extern void treefs_node_release (struct treefs_node *node);
+extern void treefs_node_unref (struct treefs_node *node);
+extern void treefs_node_ref_weak (struct treefs_node *node);
+extern void treefs_node_release_weak (struct treefs_node *node);
+extern void treefs_node_unref_weak (struct treefs_node *node);
+
+#if defined(__USE_EXTERN_INLINES) || defined(TREEFS_DEFINE_EI)
/* Add a hard reference to a node. If there were no hard
references previously, then the node cannot be locked
(because you must hold a hard reference to hold the lock). */
-extern inline void
+TREEFS_EI void
treefs_node_ref (struct treefs_node *node)
{
int new_ref;
@@ -259,7 +274,7 @@ treefs_node_ref (struct treefs_node *node)
/* Unlock node NODE and release a hard reference; if this is the last
hard reference and there are no links to the file then request
weak references to be dropped. */
-extern inline void
+TREEFS_EI void
treefs_node_release (struct treefs_node *node)
{
int tried_drop_weak_refs = 0;
@@ -306,7 +321,7 @@ treefs_node_release (struct treefs_node *node)
hard reference in order to hold the lock). If this is the last
hard reference and there are no links, then request weak references
to be dropped. */
-extern inline void
+TREEFS_EI void
treefs_node_unref (struct treefs_node *node)
{
int tried_drop_weak_refs = 0;
@@ -346,7 +361,7 @@ treefs_node_unref (struct treefs_node *node)
}
/* Add a weak reference to a node. */
-extern inline void
+TREEFS_EI void
treefs_node_ref_weak (struct treefs_node *node)
{
spin_lock (&treefs_node_refcnt_lock);
@@ -355,7 +370,7 @@ treefs_node_ref_weak (struct treefs_node *node)
}
/* Unlock node NODE and release a weak reference */
-extern inline void
+TREEFS_EI void
treefs_node_release_weak (struct treefs_node *node)
{
spin_lock (&treefs_node_refcnt_lock);
@@ -373,7 +388,7 @@ treefs_node_release_weak (struct treefs_node *node)
/* Release a weak reference on NODE. If NODE is locked by anyone, then
this cannot be the last reference (because you must hold a
hard reference in order to hold the lock). */
-extern inline void
+TREEFS_EI void
treefs_node_unref_weak (struct treefs_node *node)
{
spin_lock (&treefs_node_refcnt_lock);
@@ -387,6 +402,7 @@ treefs_node_unref_weak (struct treefs_node *node)
else
spin_unlock (&treefs_node_refcnt_lock);
}
+#endif /* Use extern inlines. */
/* ---------------------------------------------------------------- */
@@ -408,8 +424,12 @@ treefs_node_create_right (struct treefs_node *node, int flags,
/* ---------------------------------------------------------------- */
/* Auth functions; copied from diskfs. */
+extern int treefs_auth_has_uid (struct treefs_auth *auth, uid_t uid);
+extern int treefs_auth_in_group (struct treefs_auth *auth, gid_t gid);
+
+#if defined(__USE_EXTERN_INLINES) || defined(TREEFS_DEFINE_EI)
/* Return nonzero iff the user identified by AUTH has uid UID. */
-extern inline int
+TREEFS_EI int
treefs_auth_has_uid (struct treefs_auth *auth, uid_t uid)
{
int i;
@@ -420,7 +440,7 @@ treefs_auth_has_uid (struct treefs_auth *auth, uid_t uid)
}
/* Return nonzero iff the user identified by AUTH has group GID. */
-extern inline int
+TREEFS_EI int
treefs_auth_in_group (struct treefs_auth *auth, gid_t gid)
{
int i;
@@ -429,6 +449,7 @@ treefs_auth_in_group (struct treefs_auth *auth, gid_t gid)
return 1;
return 0;
}
+#endif /* Use extern inlines. */
/* ---------------------------------------------------------------- */
/* Helper routines for dealing with translators. */
diff --git a/libtreefs/xinl.c b/libtreefs/xinl.c
new file mode 100644
index 00000000..fe83e5a3
--- /dev/null
+++ b/libtreefs/xinl.c
@@ -0,0 +1,3 @@
+#define TREEFS_DEFINE_EI
+#include "treefs.h"
+#include "mig-decls.h"
diff --git a/libtrivfs/file-reparent.c b/libtrivfs/file-reparent.c
index c07fbccb..0682a912 100644
--- a/libtrivfs/file-reparent.c
+++ b/libtrivfs/file-reparent.c
@@ -27,5 +27,8 @@ trivfs_S_file_reparent (struct trivfs_protid *cred,
mach_port_t *new, mach_msg_type_name_t *new_type)
{
/* This is not a directory, so we just duplicate it */
- return trivfs_S_io_duplicate (cred, reply, reply_type, new, new_type);
+ error_t ret = trivfs_S_io_duplicate (cred, reply, reply_type, new, new_type);
+ if (!ret)
+ mach_port_deallocate (mach_task_self (), parent);
+ return ret;
}
diff --git a/libtrivfs/trivfs.h b/libtrivfs/trivfs.h
index 6e087f31..798e0b38 100644
--- a/libtrivfs/trivfs.h
+++ b/libtrivfs/trivfs.h
@@ -96,7 +96,7 @@ extern int trivfs_cntl_nportclasses;
/* The user must define this function. This should modify a struct
stat (as returned from the underlying node) for presentation to
- callers of io_stat. It is permissable for this function to do
+ callers of io_stat. It is permissible for this function to do
nothing. */
void trivfs_modify_stat (struct trivfs_protid *cred, io_statbuf_t *);
diff --git a/login/utmp.c b/login/utmp.c
index e56f2c53..c7c1ac04 100644
--- a/login/utmp.c
+++ b/login/utmp.c
@@ -134,7 +134,7 @@ next_device(char *dev)
/* ---------------------------------------------------------------- */
-/* Try and start the translator for CTL_PORT on NODE. If succesful, this
+/* Try and start the translator for CTL_PORT on NODE. If successful, this
call will not return until the translator is stopped; otherwise it returns
an error code describing the reason why it couldn't start. */
static error_t
@@ -163,7 +163,7 @@ start_translator(file_t node, fsys_t ctl_port)
}
/* Find an unoccupied (one with no active translator) filename starting with
- NAME_PFX, and start the translator for CTL_PORT on it. If succesful, this
+ NAME_PFX, and start the translator for CTL_PORT on it. If successful, this
call will not return until the translator is stopped; otherwise it returns
an error code describing the reason why it couldn't start. When
successful, this function sets UTMP_NODE_NAME to the name of the file we
diff --git a/mach-defpager/Makefile b/mach-defpager/Makefile
index 5ed8f11f..9a4b7edf 100644
--- a/mach-defpager/Makefile
+++ b/mach-defpager/Makefile
@@ -1,6 +1,6 @@
# Makefile for mach-defpager subdirectory of hurd sources
#
-# Copyright (C) 1999, 2000, 2002, 2007 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2002, 2007, 2010 Free Software Foundation, Inc.
#
# This file is part of the GNU Hurd.
#
@@ -27,15 +27,13 @@ OBJS := $(SRCS:.c=.o) \
$(addsuffix Server.o,\
memory_object default_pager memory_object_default exc) \
default_pager_replyUser.o
+LCLHDRS := file_io.h queue.h wiring.h kalloc.h default_pager.h
HURDLIBS:= threads
LDFLAGS += -static
include ../Makeconf
-vpath %.c $(srcdir)/../serverboot
-CPPFLAGS += -I$(srcdir)/../serverboot
-
MIGSFLAGS = -DSEQNOS
# Don't even bother.
diff --git a/serverboot/default_pager.c b/mach-defpager/default_pager.c
index 41c2768d..b467cbce 100644
--- a/serverboot/default_pager.c
+++ b/mach-defpager/default_pager.c
@@ -44,9 +44,12 @@
#include <queue.h>
#include <wiring.h>
+#include <kalloc.h>
+#include <default_pager.h>
#include <assert.h>
#include <stdio.h>
+#include <string.h>
#include <file_io.h>
@@ -54,15 +57,23 @@
#define debug 0
-extern void *kalloc();
-
static char my_name[] = "(default pager):";
static struct mutex printf_lock = MUTEX_INITIALIZER;
+#if 0
#define dprintf(f, x...) \
({ mutex_lock (&printf_lock); printf (f , ##x); fflush (stdout); mutex_unlock (&printf_lock); })
-#define ddprintf(f, x...) ((void)0)
+#else
+#define dprintf(f, x...)
+#endif
+
+#if 0
+#define ddprintf(f, x...) \
+ ({ mutex_lock (&printf_lock); printf (f , ##x); fflush (stdout); mutex_unlock (&printf_lock); })
+#else
+#define ddprintf(f, x...)
+#endif
/*
* parallel vs serial switch
@@ -144,9 +155,10 @@ void set_partition_of(x, p)
* Saves space, filenames can be long.
*/
unsigned int
-part_id(const unsigned char *name)
+part_id(const char *name)
{
- register unsigned int len, id, xorid;
+ register unsigned int id, xorid;
+ size_t len;
len = strlen(name);
id = xorid = 0;
@@ -157,6 +169,7 @@ part_id(const unsigned char *name)
return (id << 8) | xorid;
}
+void
partition_init()
{
mutex_init(&all_partitions.lock);
@@ -476,7 +489,7 @@ choose_partition(size, cur_part)
mutex_lock(&all_partitions.lock);
for (i = 0; i < all_partitions.n_partitions; i++) {
- /* the undesireable one ? */
+ /* the undesirable one ? */
if (i == cur_part)
continue;
@@ -513,6 +526,7 @@ ddprintf ("choose_partition(%x,%d,%d)\n",size,cur_part,i);
vm_offset_t
pager_alloc_page(pindex, lock_it)
p_index_t pindex;
+ boolean_t lock_it;
{
register int bm_e;
register int bit;
@@ -577,6 +591,7 @@ void
pager_dealloc_page(pindex, page, lock_it)
p_index_t pindex;
register vm_offset_t page;
+ boolean_t lock_it;
{
register partition_t part;
register int bit, bm_e;
@@ -653,6 +668,8 @@ struct dpager {
dp_map_t map; /* block map */
vm_size_t size; /* size of paging object, in pages */
vm_size_t limit; /* limit (bytes) allowed to grow to */
+ vm_size_t byte_limit; /* limit, which wasn't
+ rounded to page boundary */
p_index_t cur_partition;
#ifdef CHECKSUM
vm_offset_t *checksum; /* checksum - parallel to block map */
@@ -686,6 +703,43 @@ typedef struct dpager *dpager_t;
vm_size_t max_doubled_size = 4 * 1024 * 1024; /* 4 meg */
/*
+ * Return first level map for pager.
+ * If there is no such map, than allocate it.
+ */
+dp_map_t pager_get_direct_map(pager)
+ register dpager_t pager;
+{
+ register dp_map_t mapptr, emapptr;
+ register vm_size_t size = pager->size;
+
+ if (pager->map)
+ return pager->map;
+ /*
+ * Allocate and initialize the block map
+ */
+ {
+ register vm_size_t alloc_size;
+ dp_map_t init_value;
+
+ if (INDIRECT_PAGEMAP(size)) {
+ alloc_size = INDIRECT_PAGEMAP_SIZE(size);
+ init_value = (dp_map_t)0;
+ } else {
+ alloc_size = PAGEMAP_SIZE(size);
+ init_value = (dp_map_t)NO_BLOCK;
+ }
+
+ mapptr = (dp_map_t) kalloc(alloc_size);
+ for (emapptr = &mapptr[(alloc_size-1) / sizeof(vm_offset_t)];
+ emapptr >= mapptr;
+ emapptr--)
+ emapptr->indirect = init_value;
+ }
+ pager->map = mapptr;
+ return mapptr;
+}
+
+/*
* Attach a new paging object to a paging partition
*/
void
@@ -717,29 +771,7 @@ pager_alloc(pager, part, size)
} else
size = ROUNDUP_TO_PAGEMAP(size);
- /*
- * Allocate and initialize the block map
- */
- {
- register vm_size_t alloc_size;
- dp_map_t init_value;
-
- if (INDIRECT_PAGEMAP(size)) {
- alloc_size = INDIRECT_PAGEMAP_SIZE(size);
- init_value = (dp_map_t)0;
- } else {
- alloc_size = PAGEMAP_SIZE(size);
- init_value = (dp_map_t)NO_BLOCK;
- }
-
- mapptr = (dp_map_t) kalloc(alloc_size);
- for (emapptr = &mapptr[(alloc_size-1) / sizeof(vm_offset_t)];
- emapptr >= mapptr;
- emapptr--)
- emapptr->indirect = init_value;
-
- }
- pager->map = mapptr;
+ pager->map = NULL;
pager->size = size;
pager->limit = (vm_size_t)-1;
@@ -773,7 +805,7 @@ pager_allocated(pager)
size = pager->size; /* in pages */
asize = 0; /* allocated, in pages */
- map = pager->map;
+ map = pager_get_direct_map(pager);
if (INDIRECT_PAGEMAP(size)) {
for (emap = &map[INDIRECT_PAGEMAP_ENTRIES(size)];
@@ -817,7 +849,7 @@ pager_pages(pager, pages, numpages)
vm_offset_t offset;
size = pager->size; /* in pages */
- map = pager->map;
+ map = pager_get_direct_map(pager);
actual = 0;
offset = 0;
@@ -879,7 +911,8 @@ pager_extend(pager, new_size)
old_size = pager->size;
if (new_size <= atop(max_doubled_size)) {
- i = old_size;
+ /* New size cannot be less than 1 */
+ i = old_size ? old_size : 1;
while (i < new_size)
i <<= 1;
new_size = i;
@@ -893,7 +926,7 @@ pager_extend(pager, new_size)
*/
new_mapptr = (dp_map_t)
kalloc(INDIRECT_PAGEMAP_SIZE(new_size));
- old_mapptr = pager->map;
+ old_mapptr = pager_get_direct_map(pager);
for (i = 0; i < INDIRECT_PAGEMAP_ENTRIES(old_size); i++)
new_mapptr[i] = old_mapptr[i];
for (; i < INDIRECT_PAGEMAP_ENTRIES(new_size); i++)
@@ -938,7 +971,7 @@ pager_extend(pager, new_size)
* Allocate new second-level map first.
*/
new_mapptr = (dp_map_t) kalloc(PAGEMAP_SIZE(PAGEMAP_ENTRIES));
- old_mapptr = pager->map;
+ old_mapptr = pager_get_direct_map(pager);
for (i = 0; i < old_size; i++)
new_mapptr[i] = old_mapptr[i];
for (; i < PAGEMAP_ENTRIES; i++)
@@ -997,7 +1030,7 @@ pager_extend(pager, new_size)
* Enlarging a direct block.
*/
new_mapptr = (dp_map_t) kalloc(PAGEMAP_SIZE(new_size));
- old_mapptr = pager->map;
+ old_mapptr = pager_get_direct_map(pager);
for (i = 0; i < old_size; i++)
new_mapptr[i] = old_mapptr[i];
for (; i < new_size; i++)
@@ -1042,15 +1075,27 @@ pager_truncate(dpager_t pager, vm_size_t new_size) /* in pages */
vm_size_t old_size, vm_size_t new_size)
{
vm_size_t i;
+
+ if (!mapptr)
+ return;
+
for (i = new_size; i < old_size; ++i)
{
const union dp_map entry = mapptr[i];
- pager_dealloc_page(entry.block.p_index, entry.block.p_offset,
- TRUE);
- invalidate_block(mapptr[i]);
+ if (!no_block(entry))
+ {
+ pager_dealloc_page(entry.block.p_index, entry.block.p_offset,
+ TRUE);
+ invalidate_block(mapptr[i]);
+ }
}
}
+ mutex_lock(&pager->lock); /* XXX lock_write */
+
+ if (!pager->map)
+ goto done;
+
old_size = pager->size;
if (INDIRECT_PAGEMAP(old_size))
@@ -1073,19 +1118,10 @@ pager_truncate(dpager_t pager, vm_size_t new_size) /* in pages */
if (INDIRECT_PAGEMAP (new_size))
{
- if (INDIRECT_PAGEMAP_SIZE (new_size) >= vm_page_size)
- /* XXX we know how kalloc.c works; avoid copying. */
- kfree ((char *) round_page ((vm_address_t) pager->map
- + INDIRECT_PAGEMAP_SIZE (new_size)),
- round_page (INDIRECT_PAGEMAP_SIZE (old_size))
- - round_page (INDIRECT_PAGEMAP_SIZE (new_size)));
- else
- {
- const dp_map_t old_mapptr = pager->map;
- pager->map = (dp_map_t) kalloc (INDIRECT_PAGEMAP_SIZE(new_size));
- memcpy (pager->map, old_mapptr, INDIRECT_PAGEMAP_SIZE(old_size));
- kfree ((char *) old_mapptr, INDIRECT_PAGEMAP_SIZE (old_size));
- }
+ const dp_map_t old_mapptr = pager->map;
+ pager->map = (dp_map_t) kalloc (INDIRECT_PAGEMAP_SIZE(new_size));
+ memcpy (pager->map, old_mapptr, INDIRECT_PAGEMAP_SIZE(new_size));
+ kfree ((char *) old_mapptr, INDIRECT_PAGEMAP_SIZE (old_size));
}
else
{
@@ -1095,13 +1131,9 @@ pager_truncate(dpager_t pager, vm_size_t new_size) /* in pages */
const dp_map_t mapptr = pager->map[0].indirect;
kfree((char *)pager->map, INDIRECT_PAGEMAP_SIZE(old_size));
pager->map = mapptr;
- old_size = PAGEMAP_ENTRIES;
}
}
- if (new_size == 0)
- new_size = 1;
-
if (! INDIRECT_PAGEMAP(old_size))
{
/* First deallocate pages in the truncated region. */
@@ -1113,12 +1145,14 @@ pager_truncate(dpager_t pager, vm_size_t new_size) /* in pages */
{
const dp_map_t old_mapptr = pager->map;
pager->map = (dp_map_t) kalloc (PAGEMAP_SIZE (new_size));
- memcpy (pager->map, old_mapptr, PAGEMAP_SIZE (old_size));
+ memcpy (pager->map, old_mapptr, PAGEMAP_SIZE (new_size));
kfree ((char *) old_mapptr, PAGEMAP_SIZE (old_size));
}
}
+ done:
pager->size = new_size;
+ mutex_unlock(&pager->lock);
#ifdef CHECKSUM
#error write me
@@ -1161,17 +1195,19 @@ pager_read_offset(pager, offset)
#endif
}
+ invalidate_block(pager_offset);
if (INDIRECT_PAGEMAP(pager->size)) {
register dp_map_t mapptr;
- mapptr = pager->map[f_page/PAGEMAP_ENTRIES].indirect;
- if (mapptr == 0)
- invalidate_block(pager_offset);
- else
- pager_offset = mapptr[f_page%PAGEMAP_ENTRIES];
+ if (pager->map) {
+ mapptr = pager->map[f_page/PAGEMAP_ENTRIES].indirect;
+ if (mapptr)
+ pager_offset = mapptr[f_page%PAGEMAP_ENTRIES];
+ }
}
else {
- pager_offset = pager->map[f_page];
+ if (pager->map)
+ pager_offset = pager->map[f_page];
}
#if DEBUG_READER_CONFLICTS
@@ -1185,7 +1221,7 @@ pager_read_offset(pager, offset)
/*
* Release a single disk block.
*/
-pager_release_offset(pager, offset)
+void pager_release_offset(pager, offset)
register dpager_t pager;
vm_offset_t offset;
{
@@ -1195,6 +1231,7 @@ pager_release_offset(pager, offset)
mutex_lock(&pager->lock); /* XXX lock_read */
+ assert (pager->map);
if (INDIRECT_PAGEMAP(pager->size)) {
register dp_map_t mapptr;
@@ -1442,7 +1479,8 @@ pager_write_offset(pager, offset)
if (INDIRECT_PAGEMAP(pager->size)) {
ddprintf ("pager_write_offset: indirect\n");
- mapptr = pager->map[f_page/PAGEMAP_ENTRIES].indirect;
+ mapptr = pager_get_direct_map(pager);
+ mapptr = mapptr[f_page/PAGEMAP_ENTRIES].indirect;
if (mapptr == 0) {
/*
* Allocate the indirect block
@@ -1481,7 +1519,7 @@ pager_write_offset(pager, offset)
f_page %= PAGEMAP_ENTRIES;
}
else {
- mapptr = pager->map;
+ mapptr = pager_get_direct_map(pager);
}
block = mapptr[f_page];
@@ -1528,9 +1566,6 @@ dprintf("extending object %x (size %x) to %x.\n",
block.block.p_offset = off;
block.block.p_index = pager->cur_partition;
mapptr[f_page] = block;
- ddprintf ("pager_write_offset: mapptr %x [3b] = %x\n", mapptr,
- mapptr[0x3b]);
- ddprintf ("pager_write_offset: block is finally %x\n", block);
}
out:
@@ -1554,6 +1589,9 @@ pager_dealloc(pager)
register dp_map_t mapptr;
register union dp_map block;
+ if (!pager->map)
+ return;
+
if (INDIRECT_PAGEMAP(pager->size)) {
for (i = INDIRECT_PAGEMAP_ENTRIES(pager->size); --i >= 0; ) {
mapptr = pager->map[i].indirect;
@@ -1565,9 +1603,11 @@ pager_dealloc(pager)
block.block.p_offset, TRUE);
}
kfree((char *)mapptr, PAGEMAP_SIZE(PAGEMAP_ENTRIES));
+ pager->map[i].indirect = (dp_map_t) 0;
}
}
kfree((char *)pager->map, INDIRECT_PAGEMAP_SIZE(pager->size));
+ pager->map = (dp_map_t) 0;
#ifdef CHECKSUM
for (i = INDIRECT_PAGEMAP_ENTRIES(pager->size); --i >= 0; ) {
mapptr = (vm_offset_t *)pager->checksum[i];
@@ -1588,6 +1628,7 @@ pager_dealloc(pager)
block.block.p_offset, TRUE);
}
kfree((char *)pager->map, PAGEMAP_SIZE(pager->size));
+ pager->map = (dp_map_t) 0;
#ifdef CHECKSUM
kfree((char *)pager->checksum, PAGEMAP_SIZE(pager->size));
#endif /* CHECKSUM */
@@ -1610,6 +1651,9 @@ pager_realloc(pager, pindex)
vm_size_t size;
union dp_map block;
+ if (!pager->map)
+ return TRUE;
+
size = pager->size; /* in pages */
map = pager->map;
@@ -2051,14 +2095,10 @@ void pager_port_lock(ds, seqno)
mach_port_seqno_t seqno;
{
default_pager_total++;
-ddprintf ("pager_port_lock <%p>: <%p>: %d: 1\n", &ds, ds, seqno);
dstruct_lock(ds);
-ddprintf ("pager_port_lock <%p>: <%p>: %d: 2\n", &ds, ds, seqno);
while (ds->seqno != seqno) {
-ddprintf ("pager_port_lock <%p>: <%p>: %d: 3\n", &ds, ds, seqno);
default_pager_wait_seqno++;
condition_wait(&ds->waiting_seqno, &ds->lock);
-ddprintf ("pager_port_lock <%p>: <%p>: %d: 4\n", &ds, ds, seqno);
}
}
@@ -2069,11 +2109,8 @@ void pager_port_unlock(ds)
default_pager_t ds;
{
ds->seqno++;
-ddprintf ("pager_port_unlock <%p>: <%p>: seqno => %d\n", &ds, ds, ds->seqno);
dstruct_unlock(ds);
-ddprintf ("pager_port_unlock <%p>: <%p>: 2\n", &ds, ds);
condition_broadcast(&ds->waiting_seqno);
-ddprintf ("pager_port_unlock <%p>: <%p>: 3\n", &ds, ds);
}
/*
@@ -2444,10 +2481,9 @@ seqnos_memory_object_init(pager, seqno, pager_request, pager_name,
* until we unlock the object.
*/
- kr = memory_object_set_attributes(pager_request,
- TRUE,
- FALSE, /* do not cache */
- default_pager_copy_strategy);
+ kr = memory_object_ready(pager_request,
+ FALSE, /* Do not cache */
+ default_pager_copy_strategy);
if (kr != KERN_SUCCESS)
panic(here, my_name);
@@ -2500,6 +2536,8 @@ ddprintf ("seqnos_memory_object_terminate <%p>: pager_port_lock: <%p>[s:%d,r:%d,
pager_port_wait_for_refs(ds);
+ if (ds->external)
+ pager_request = ds->pager_request;
ds->pager_request = MACH_PORT_NULL;
request_refs = ds->request_refs;
ds->request_refs = 0;
@@ -2512,28 +2550,11 @@ ddprintf ("seqnos_memory_object_terminate <%p>: pager_port_unlock: <%p>[s:%d,r:%
pager_port_unlock(ds);
/*
- * Now we deallocate our various port rights.
+ * Now we destroy our port rights.
*/
- kr = mach_port_mod_refs(default_pager_self, pager_request,
- MACH_PORT_RIGHT_SEND, -request_refs);
- if (kr != KERN_SUCCESS)
- panic(here,my_name);
-
- kr = mach_port_mod_refs(default_pager_self, pager_request,
- MACH_PORT_RIGHT_RECEIVE, -1);
- if (kr != KERN_SUCCESS)
- panic(here,my_name);
-
- kr = mach_port_mod_refs(default_pager_self, pager_name,
- MACH_PORT_RIGHT_SEND, -name_refs);
- if (kr != KERN_SUCCESS)
- panic(here,my_name);
-
- kr = mach_port_mod_refs(default_pager_self, pager_name,
- MACH_PORT_RIGHT_RECEIVE, -1);
- if (kr != KERN_SUCCESS)
- panic(here,my_name);
+ mach_port_destroy(mach_task_self(), pager_request);
+ mach_port_destroy(mach_task_self(), pager_name);
return (KERN_SUCCESS);
}
@@ -2684,10 +2705,11 @@ ddprintf ("seqnos_memory_object_data_request <%p>: pager_port_unlock: <%p>[s:%d,
VM_PROT_NONE,
FALSE, MACH_PORT_NULL);
} else {
- (void) memory_object_data_provided(
+ (void) memory_object_data_supply(
reply_to, offset,
- addr, vm_page_size,
- VM_PROT_NONE);
+ addr, vm_page_size, FALSE,
+ VM_PROT_NONE,
+ FALSE, MACH_PORT_NULL);
}
break;
@@ -2803,56 +2825,49 @@ seqnos_memory_object_data_write(pager, seqno, pager_request,
pager_request++;
#endif /* lint */
-ddprintf ("seqnos_memory_object_data_write <%p>: 1\n", &err);
if ((data_cnt % vm_page_size) != 0)
- {
- ddprintf ("fail 1: %d %d\n", data_cnt, vm_page_size);
panic(here,my_name);
- }
-
-ddprintf ("seqnos_memory_object_data_write <%p>: 2\n", &err);
ds = pager_port_lookup(pager);
-ddprintf ("seqnos_memory_object_data_write <%p>: 3\n", &err);
if (ds == DEFAULT_PAGER_NULL)
- {
- ddprintf ("fail 2: %d %d\n", pager, ds);
panic(here,my_name);
- }
-ddprintf ("seqnos_memory_object_data_write <%p>: 4\n", &err);
-ddprintf ("seqnos_memory_object_data_write <%p>: pager_port_lock: <%p>[s:%d,r:%d,w:%d,l:%d], %d\n",
- &err, ds, ds->seqno, ds->readers, ds->writers, ds->lock.held, seqno);
pager_port_lock(ds, seqno);
-ddprintf ("seqnos_memory_object_data_write <%p>: 5\n", &err);
- pager_port_check_request(ds, pager_request);
-ddprintf ("seqnos_memory_object_data_write <%p>: 6\n", &err);
pager_port_start_write(ds);
-ddprintf ("seqnos_memory_object_data_write <%p>: 7\n", &err);
-ddprintf ("seqnos_memory_object_data_write <%p>: pager_port_unlock: <%p>[s:%d,r:%d,w:%d,l:%d]\n",
- &err, ds, ds->seqno, ds->readers, ds->writers, ds->lock.held);
+
+ vm_size_t limit = ds->dpager.byte_limit;
pager_port_unlock(ds);
+ if ((limit != round_page(limit)) && (trunc_page(limit) == offset)) {
+ assert(trunc_page(limit) == offset);
+ assert(data_cnt == vm_page_size);
+
+ vm_offset_t tail = addr + limit - trunc_page(limit);
+ vm_size_t tail_size = round_page(limit) - limit;
+ memset((void *) tail, 0, tail_size);
+
+ unsigned *arr = (unsigned *)addr;
+ memory_object_data_supply(pager_request, trunc_page(limit), addr,
+ vm_page_size, TRUE, VM_PROT_NONE,
+ TRUE, MACH_PORT_NULL);
+ dstruct_lock(ds);
+ ds->dpager.byte_limit = round_page(limit);
+ dstruct_unlock(ds);
+ pager_port_finish_write(ds);
+
+ return(KERN_SUCCESS);
+ }
-ddprintf ("seqnos_memory_object_data_write <%p>: 8\n", &err);
for (amount_sent = 0;
amount_sent < data_cnt;
amount_sent += vm_page_size) {
register int result;
-ddprintf ("seqnos_memory_object_data_write <%p>: 9\n", &err);
result = default_write(&ds->dpager,
addr + amount_sent,
vm_page_size,
offset + amount_sent);
-ddprintf ("seqnos_memory_object_data_write <%p>: 10\n", &err);
if (result != KERN_SUCCESS) {
-ddprintf ("seqnos_memory_object_data_write <%p>: 11\n", &err);
-#if debug
- dprintf("%s WRITE ERROR on default_pageout:", my_name);
- dprintf(" pager=%x, offset=0x%x, length=0x%x, result=%d\n",
- pager, offset+amount_sent, vm_page_size, result);
-#endif
dstruct_lock(ds);
ds->errors++;
dstruct_unlock(ds);
@@ -2860,20 +2875,13 @@ ddprintf ("seqnos_memory_object_data_write <%p>: 11\n", &err);
default_pager_pageout_count++;
}
-ddprintf ("seqnos_memory_object_data_write <%p>: 12\n", &err);
pager_port_finish_write(ds);
-ddprintf ("seqnos_memory_object_data_write <%p>: 13\n", &err);
err = vm_deallocate(default_pager_self, addr, data_cnt);
-ddprintf ("seqnos_memory_object_data_write <%p>: 14\n", &err);
if (err != KERN_SUCCESS)
{
- ddprintf ("fail 3: %s %s %s %s\n", default_pager_self, addr, data_cnt, &err);
-
panic(here,my_name);
}
-
-ddprintf ("seqnos_memory_object_data_write <%p>: 15\n", &err);
return(KERN_SUCCESS);
}
@@ -2902,30 +2910,8 @@ seqnos_memory_object_lock_completed (memory_object_t pager,
vm_offset_t offset,
vm_size_t length)
{
- default_pager_t ds;
-
- ds = pager_port_lookup(pager);
- assert(ds != DEFAULT_PAGER_NULL);
-
- pager_port_lock(ds, seqno);
- pager_port_wait_for_readers(ds);
- pager_port_wait_for_writers(ds);
-
- /* Now that any in-core pages have been flushed, we can apply
- the limit to prevent any new page-ins. */
- assert (page_aligned (offset));
- ds->dpager.limit = offset;
-
- default_pager_object_set_size_reply (ds->lock_request, KERN_SUCCESS);
- ds->lock_request = MACH_PORT_NULL;
-
- if (ds->dpager.size > ds->dpager.limit / vm_page_size)
- /* Deallocate the old backing store pages and shrink the page map. */
- pager_truncate (&ds->dpager, ds->dpager.limit / vm_page_size);
-
- pager_port_unlock(ds, seqno);
-
- return KERN_SUCCESS;
+ panic("%slock_completed",my_name);
+ return KERN_FAILURE;
}
kern_return_t
@@ -2958,6 +2944,11 @@ seqnos_memory_object_supply_completed(pager, seqno, pager_request,
return(KERN_FAILURE);
}
+/*
+ * memory_object_data_return: split up the stuff coming in from
+ * a memory_object_data_write call
+ * into individual pages and pass them off to default_write.
+ */
kern_return_t
seqnos_memory_object_data_return(pager, seqno, pager_request,
offset, addr, data_cnt,
@@ -2971,8 +2962,9 @@ seqnos_memory_object_data_return(pager, seqno, pager_request,
boolean_t dirty;
boolean_t kernel_copy;
{
- panic("%sdata_return",my_name);
- return(KERN_FAILURE);
+
+ return seqnos_memory_object_data_write (pager, seqno, pager_request,
+ offset, addr, data_cnt);
}
kern_return_t
@@ -3356,6 +3348,7 @@ rename_it:
*/
ds->pager = port;
+ ds->dpager.limit = size;
pager_port_list_insert(port, ds);
default_pager_add(ds, FALSE);
@@ -3724,7 +3717,6 @@ S_default_pager_object_pages (mach_port_t pager,
kern_return_t
S_default_pager_object_set_size (mach_port_t pager,
- mach_port_t reply_to,
mach_port_seqno_t seqno,
vm_size_t limit)
{
@@ -3736,38 +3728,63 @@ S_default_pager_object_set_size (mach_port_t pager,
return KERN_INVALID_ARGUMENT;
pager_port_lock(ds, seqno);
- pager_port_check_request(ds, reply_to);
pager_port_wait_for_readers(ds);
pager_port_wait_for_writers(ds);
- limit = round_page (limit);
- if (ds->dpager.size <= limit / vm_page_size)
+ vm_size_t rounded_limit = round_page (limit);
+ vm_size_t trunc_limit = trunc_page (limit);
+
+
+ if (ds->dpager.limit < rounded_limit)
{
/* The limit has not been exceeded heretofore. Just change it. */
- ds->dpager.limit = limit;
- kr = KERN_SUCCESS;
- }
- else if (ds->lock_request == MACH_PORT_NULL)
- {
- /* Tell the kernel to flush from core all the pages being removed.
- We will get the memory_object_lock_completed callback when they
- have been flushed. We handle that by completing the limit update
- and posting the reply to the pending truncation. */
- kr = memory_object_lock_request (ds->pager_request,
- limit,
- ds->dpager.size * vm_page_size - limit,
- MEMORY_OBJECT_RETURN_NONE, TRUE,
- VM_PROT_ALL, ds->pager);
+ ds->dpager.limit = rounded_limit;
+
+ /* Byte limit is used for truncation of file, which aren't rounded to
+ page boundary. But by enlarging of file we are free to increase this value*/
+ ds->dpager.byte_limit = rounded_limit;
+ kr = memory_object_lock_request(ds->pager_request, 0,
+ rounded_limit,
+ MEMORY_OBJECT_RETURN_NONE, FALSE,
+ VM_PROT_NONE, MACH_PORT_NULL);
if (kr != KERN_SUCCESS)
- panic ("memory_object_lock_request: %d", kr);
- ds->lock_request = reply_to;
- kr = MIG_NO_REPLY;
+ panic ("memory_object_lock_request: %d", kr);
}
else
- /* There is already another call in progress. Tough titties. */
- kr = KERN_FAILURE;
+ {
+ union dp_map block;
+
+ if (ds->dpager.limit != rounded_limit)
+ {
+ kr = memory_object_lock_request(ds->pager_request, rounded_limit,
+ ds->dpager.limit - rounded_limit,
+ MEMORY_OBJECT_RETURN_NONE, TRUE,
+ VM_PROT_ALL, MACH_PORT_NULL);
+ if (kr != KERN_SUCCESS)
+ panic ("memory_object_lock_request: %d", kr);
- pager_port_unlock(ds, seqno);
+ ds->dpager.limit = rounded_limit;
+ }
+
+ /* Deallocate the old backing store pages and shrink the page map. */
+ if (ds->dpager.size > ds->dpager.limit / vm_page_size)
+ pager_truncate (&ds->dpager, ds->dpager.limit / vm_page_size);
+
+ /* If memory object size isn't page aligned, fill the tail
+ of last page with zeroes */
+ if ((limit != rounded_limit) && (ds->dpager.limit > limit))
+ {
+ /* Clean part of last page which isn't part of file.
+ For file sizes that aren't multiple of vm_page_size */
+ ds->dpager.byte_limit = limit;
+ kr = memory_object_lock_request(ds->pager_request, trunc_limit,
+ vm_page_size,
+ MEMORY_OBJECT_RETURN_ALL, TRUE,
+ VM_PROT_NONE, MACH_PORT_NULL);
+ }
+ }
+
+ pager_port_unlock(ds);
return kr;
}
@@ -3808,6 +3825,7 @@ dprintf("bmd %x md %x\n", bootstrap_master_device_port, mdport);
return kr;
}
+kern_return_t
default_pager_register_fileserver(pager, fileserver)
mach_port_t pager;
mach_port_t fileserver;
@@ -3824,7 +3842,7 @@ default_pager_register_fileserver(pager, fileserver)
/*
* When things do not quite workout...
*/
-no_paging_space(out_of_memory)
+void no_paging_space(out_of_memory)
boolean_t out_of_memory;
{
static char here[] = "%s *** NOT ENOUGH PAGING SPACE ***";
@@ -3834,7 +3852,7 @@ no_paging_space(out_of_memory)
panic(here, my_name);
}
-overcommitted(got_more_space, space)
+void overcommitted(got_more_space, space)
boolean_t got_more_space;
vm_size_t space; /* in pages */
{
@@ -3875,7 +3893,7 @@ overcommitted(got_more_space, space)
#endif
}
-paging_space_info(totp, freep)
+void paging_space_info(totp, freep)
vm_size_t *totp, *freep;
{
register vm_size_t total, free;
diff --git a/mach-defpager/default_pager.h b/mach-defpager/default_pager.h
new file mode 100644
index 00000000..f4cdda64
--- /dev/null
+++ b/mach-defpager/default_pager.h
@@ -0,0 +1,43 @@
+/* Backing store access callbacks for Hurd version of Mach default pager.
+ Copyright (C) 2012 Free Software Foundation, Inc.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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, or (at
+ your option) any later version.
+
+ The GNU Hurd 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. */
+
+/* Prototypes for working with paging partitions and files */
+
+#ifndef _DEFAULT_PAGER_H_
+#define _DEFAULT_PAGER_H_
+
+#include <file_io.h>
+
+void partition_init();
+
+void create_paging_partition(const char *name, struct file_direct *fdp,
+ int isa_file, int linux_signature);
+kern_return_t destroy_paging_partition(char *name, void **pp_private);
+
+kern_return_t add_paging_file(mach_port_t master_device_port,
+ char *file_name, int linux_signature);
+kern_return_t remove_paging_file (char *file_name);
+
+void paging_space_info(vm_size_t *totp, vm_size_t *freep);
+void no_paging_space(boolean_t out_of_memory);
+void overcommitted(boolean_t got_more_space, vm_size_t space);
+
+void panic (const char *fmt, ...);
+
+#endif /* _DEFAULT_PAGER_H_ */
diff --git a/serverboot/kalloc.c b/mach-defpager/kalloc.c
index 28c0b55e..d9b18c02 100644
--- a/serverboot/kalloc.c
+++ b/mach-defpager/kalloc.c
@@ -36,11 +36,19 @@
#include <cthreads.h> /* for spin locks */
#include <malloc.h> /* for malloc_hook/free_hook */
+#include "wiring.h"
+
static void init_hook (void);
static void *malloc_hook (size_t size, const void *caller);
static void free_hook (void *ptr, const void *caller);
-void (*__malloc_initialize_hook) (void) = init_hook;
+/* GNU libc 2.14 defines this macro to declare hook variables as volatile.
+ Define it as empty for older libc versions. */
+#ifndef __MALLOC_HOOK_VOLATILE
+# define __MALLOC_HOOK_VOLATILE
+#endif
+
+void (*__MALLOC_HOOK_VOLATILE __malloc_initialize_hook) (void) = init_hook;
#define DEBUG
diff --git a/mach-defpager/kalloc.h b/mach-defpager/kalloc.h
new file mode 100644
index 00000000..8f52f1a5
--- /dev/null
+++ b/mach-defpager/kalloc.h
@@ -0,0 +1,30 @@
+/* Backing store access callbacks for Hurd version of Mach default pager.
+ Copyright (C) 2012 Free Software Foundation, Inc.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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, or (at
+ your option) any later version.
+
+ The GNU Hurd 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. */
+
+/*
+ * General kernel memory allocator.
+ */
+
+#ifndef _KALLOC_H_
+#define _KALLOC_H_
+
+void *kalloc (vm_size_t size);
+void kfree (void *data, vm_size_t size);
+
+#endif /* _KALLOC_H_ */
diff --git a/mach-defpager/main.c b/mach-defpager/main.c
index 0be9dee1..c44c86cb 100644
--- a/mach-defpager/main.c
+++ b/mach-defpager/main.c
@@ -31,6 +31,7 @@
#include <stdarg.h>
#include <error.h>
#include <signal.h>
+#include <string.h>
/* XXX */
#include <fcntl.h>
@@ -42,6 +43,7 @@
#include <hurd/fd.h>
/* XXX */
+#include <default_pager.h>
extern
vm_size_t cthread_wait_stack_size;
diff --git a/serverboot/queue.h b/mach-defpager/queue.h
index 00619174..00619174 100644
--- a/serverboot/queue.h
+++ b/mach-defpager/queue.h
diff --git a/mach-defpager/setup.c b/mach-defpager/setup.c
index e7e89299..080b0fa6 100644
--- a/mach-defpager/setup.c
+++ b/mach-defpager/setup.c
@@ -22,19 +22,21 @@
#include <stddef.h>
#include <assert.h>
#include <mach.h>
+#include <string.h>
+#include <strings.h>
+
+#include <default_pager.h>
+#include <kalloc.h>
#include "file_io.h"
#include "default_pager_S.h"
/* This should be in some system header... XXX */
-static inline int page_aligned (vm_offset_t num)
+int page_aligned (vm_offset_t num)
{
return trunc_page (num) == num;
}
-/* From serverboot/kalloc.c. */
-extern void *kalloc (vm_size_t);
-
extern mach_port_t default_pager_default_port; /* default_pager.c */
kern_return_t
@@ -87,7 +89,7 @@ S_default_pager_paging_storage (mach_port_t pager,
fdp->runs[i].length = runs[i + 1];
if (fdp->runs[i].start + fdp->runs[i].length > devsize)
{
- kfree (fdp);
+ kfree (fdp, offsetof (struct file_direct, runs[nrun]));
return EINVAL;
}
fdp->fd_size += fdp->runs[i].length;
@@ -295,7 +297,7 @@ remove_paging_file (char *file_name)
struct file_direct *fdp = 0;
kern_return_t kr;
- kr = destroy_paging_partition(file_name, &fdp);
+ kr = destroy_paging_partition(file_name, (void **)&fdp);
if (kr == KERN_SUCCESS && fdp != 0)
{
mach_port_deallocate (mach_task_self (), fdp->device);
diff --git a/serverboot/wiring.c b/mach-defpager/wiring.c
index 585a3075..8bf49934 100644
--- a/serverboot/wiring.c
+++ b/mach-defpager/wiring.c
@@ -29,6 +29,7 @@
#include <mach.h>
#include <mach_init.h>
#include <mach/machine/vm_param.h>
+#include "default_pager.h"
mach_port_t this_task; /* our task */
mach_port_t priv_host_port = MACH_PORT_NULL;
diff --git a/serverboot/wiring.h b/mach-defpager/wiring.h
index b5f8e53f..b5f8e53f 100644
--- a/serverboot/wiring.h
+++ b/mach-defpager/wiring.h
diff --git a/nfs/Makefile b/nfs/Makefile
index d6b8c9c0..10ca2587 100644
--- a/nfs/Makefile
+++ b/nfs/Makefile
@@ -1,6 +1,6 @@
#
-# Copyright (C) 1995, 1996, 1997, 2000, 2001, 2008 Free Software Foundation,
-# Inc.
+# Copyright (C) 1995, 1996, 1997, 2000, 2001, 2008, 2011 Free Software
+# Foundation, Inc.
#
# Written by Michael I. Bushnell.
#
@@ -28,6 +28,6 @@ LCLHDRS = nfs.h mount.h nfs-spec.h
SRCS = ops.c rpc.c mount.c nfs.c cache.c consts.c main.c name-cache.c \
storage-info.c
OBJS = $(SRCS:.c=.o)
-HURDLIBS = netfs fshelp iohelp threads ports shouldbeinlibc
+HURDLIBS = netfs fshelp iohelp threads ports ihash shouldbeinlibc
include ../Makeconf
diff --git a/nfs/mount.c b/nfs/mount.c
index 07dbb19b..6120f87a 100644
--- a/nfs/mount.c
+++ b/nfs/mount.c
@@ -199,7 +199,7 @@ mount_root (char *name, char *host)
err = conduct_rpc (&rpcbuf, &p);
if (err)
{
- error (0, err, name);
+ error (0, err, "%s", name);
goto error_with_rpcbuf;
}
/* XXX Protocol spec says this should be a "unix error code"; we'll
@@ -209,7 +209,7 @@ mount_root (char *name, char *host)
p++;
if (err)
{
- error (0, err, name);
+ error (0, err, "%s", name);
goto error_with_rpcbuf;
}
diff --git a/nfs/ops.c b/nfs/ops.c
index 96190d2e..05cfbe9a 100644
--- a/nfs/ops.c
+++ b/nfs/ops.c
@@ -1,5 +1,5 @@
/* ops.c - Libnetfs callbacks for node operations in NFS client.
- Copyright (C) 1994,95,96,97,99,2002 Free Software Foundation, Inc.
+ Copyright (C) 1994,95,96,97,99,2002,2011 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -1881,17 +1881,6 @@ netfs_get_dirents (struct iouser *cred, struct node *np,
}
-/* Implement the netfs_set_translator callback as described in
- <hurd/netfs.h>. */
-error_t
-netfs_set_translator (struct iouser *cred,
- struct node *np,
- char *argz,
- size_t argzlen)
-{
- return EOPNOTSUPP;
-}
-
/* Implement the netfs_attempt_mksymlink callback as described in
<hurd/netfs.h>. */
error_t
diff --git a/nfs/rpc.c b/nfs/rpc.c
index f5e19066..0b0444d0 100644
--- a/nfs/rpc.c
+++ b/nfs/rpc.c
@@ -75,7 +75,7 @@ generate_xid ()
credential structure with UID, GID, and SECOND_GID; any of these
may be -1 to indicate that it does not apply, however, exactly zero
or two of UID and GID must be -1. The returned address is a pointer
- to the start of the payload. If NULL is returned, an error occured
+ to the start of the payload. If NULL is returned, an error occurred
and the code is set in errno. */
int *
initialize_rpc (int program, int version, int rpc_proc,
diff --git a/pfinet/Makefile b/pfinet/Makefile
index 9bc97e80..0874eee3 100644
--- a/pfinet/Makefile
+++ b/pfinet/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 1995, 1996, 1997, 2000, 2007 Free Software Foundation, Inc.
+# Copyright (C) 1995, 1996, 1997, 2000, 2007, 2011 Free Software Foundation, Inc.
#
# This file is part of the GNU Hurd.
#
@@ -76,8 +76,10 @@ ipv6-srcs := addrconf.c \
route_ipv6.c \
tcp_ipv6.c \
udp_ipv6.c
-LINUXSRCS = $(core-srcs) $(ethernet-srcs) $(ipv4-srcs) $(ipv6-srcs) \
- $(notdir $(wildcard $(addprefix \
+ARCHS = alpha arm i386 m68k ppc s390 sparc sparc64
+
+LINUXSRCS = $(core-srcs) $(ethernet-srcs) $(ipv4-srcs) $(ipv6-srcs)
+ARCHSRCS = $(notdir $(wildcard $(addprefix \
$(srcdir)/linux-src/arch/$(asm_syntax)/lib/,\
$(arch-lib-srcs) $(arch-lib-srcs:.c=.S))))
SRCS = sched.c timer-emul.c socket.c main.c ethernet.c \
@@ -87,17 +89,31 @@ SRCS = sched.c timer-emul.c socket.c main.c ethernet.c \
MIGSRCS = ioServer.c socketServer.c startup_notifyServer.c \
pfinetServer.c iioctlServer.c
OBJS = $(patsubst %.S,%.o,$(patsubst %.c,%.o,\
- $(LINUXSRCS) $(SRCS) $(MIGSRCS)))
+ $(LINUXSRCS) $(ARCHSRCS) $(SRCS) $(MIGSRCS)))
LCLHDRS = config.h mapped-time.h mutations.h pfinet.h
-LINUXHDRS = arp.h datalink.h eth.h icmp.h ip.h ipx.h ipxcall.h p8022.h \
- p8022call.h protocol.h psnap.h psnapcall.h \
- rarp.h raw.h route.h snmp.h sock.h tcp.h udp.h
-FROBBEDLINUXHEADERS = autoconf.h config.h errno.h etherdevice.h fcntl.h \
- icmp.h if.h if_arp.h if_ether.h igmp.h in.h inet.h interrupt.h \
- ip.h ip_fw.h ipx.h kernel.h major.h malloc.h mm.h net.h netdevice.h \
- notifier.h param.h route.h sched.h skbuff.h socket.h sockios.h stat.h \
- string.h tcp.h termios.h time.h timer.h types.h udp.h un.h wait.h
-ASMHEADERS=bitops.h segment.h system.h
+LINUXHDRS = bitops.h capability.h delay.h errqueue.h etherdevice.h \
+ fddidevice.h firewall.h icmp.h icmpv6.h if_arp.h if_ether.h \
+ if_fddi.h if_packet.h if_ppp.h if_tunnel.h if_tr.h \
+ igmp.h in.h in_route.h inet.h inetdevice.h init.h ip.h \
+ ip_fw.h ipsec.h ipv6_route.h ipx.h kmod.h linkage.h lists.h \
+ module.h mroute.h net.h netdevice.h netlink.h notifier.h \
+ pkt_cls.h pkt_sched.h ppp_defs.h random.h route.h \
+ rtnetlink.h skbuff.h stddef.h sysctl.h tasks.h tcp.h times.h \
+ trdevice.h udp.h
+LINUXNETHDRS = addrconf.h arp.h br.h checksum.h datalink.h dst.h flow.h \
+ icmp.h if_inet6.h inet_common.h ip.h ip_fib.h ip6_fib.h \
+ ip6_route.h ipip.h ipv6.h ipx.h ipxcall.h ndisc.h \
+ neighbour.h p8022.h p8022call.h pkt_cls.h pkt_sched.h \
+ profile.h protocol.h psnap.h psnapcall.h rarp.h raw.h \
+ rawv6.h route.h slhc.h snmp.h sock.h tcp.h transp_v6.h udp.h
+ARCHHDRS = checksum.h
+FROBBEDLINUXHEADERS = autoconf.h binfmts.h config.h errno.h fcntl.h fs.h \
+ if.h in.h in6.h interrupt.h ioctl.h ipv6.h \
+ kernel.h limits.h major.h malloc.h mm.h param.h personality.h \
+ poll.h proc_fs.h sched.h slab.h socket.h sockios.h stat.h \
+ string.h termios.h time.h timer.h timex.h types.h un.h version.h wait.h
+ASMHEADERS = atomic.h bitops.h byteorder.h delay.h errno.h hardirq.h init.h \
+ segment.h spinlock.h system.h types.h uaccess.h
HURDLIBS=trivfs fshelp threads ports ihash shouldbeinlibc iohelp
@@ -130,20 +146,62 @@ socket-MIGSFLAGS = -imacros $(srcdir)/mutations.h
io_S.h ioServer.c socket_S.h socketServer.c: mutations.h
$(OBJS): config.h
-lndist: lndist-linux-inet-files lndist-linux-files lndist-asm-files
+lndist: lndist-linux-src-net-core-files lndist-linux-src-net-ethernet-files lndist-linux-src-net-ipv4-files lndist-linux-src-net-ipv6-files lndist-linux-src-asm-files lndist-linux-src-include-asm-files lndist-linux-src-include-linux-files lndist-linux-src-include-net-files lndist-glue-include-linux-files lndist-glue-include-asm-files
+
+lndist-linux-src-net-core-files: $(top_srcdir)/hurd-snap/$(dir)/linux-src/net/core
+ ln $(addprefix $(srcdir)/linux-src/net/core/,$(core-srcs)) $<
+
+lndist-linux-src-net-ethernet-files: $(top_srcdir)/hurd-snap/$(dir)/linux-src/net/ethernet
+ ln $(addprefix $(srcdir)/linux-src/net/ethernet/,$(ethernet-srcs)) $<
+
+lndist-linux-src-net-ipv4-files: $(top_srcdir)/hurd-snap/$(dir)/linux-src/net/ipv4
+ ln $(addprefix $(srcdir)/linux-src/net/ipv4/,$(ipv4-srcs)) $<
+
+lndist-linux-src-net-ipv6-files: $(top_srcdir)/hurd-snap/$(dir)/linux-src/net/ipv6
+ ln $(addprefix $(srcdir)/linux-src/net/ipv6/,$(ipv6-srcs)) $<
-lndist-linux-inet-files: $(top_srcdir)/hurd-snap/$(dir)/linux-inet
- ln $(addprefix $(srcdir)/linux-inet/,$(LINUXSRCS) $(UNUSEDSRC) $(LINUXHDRS)) $<
+# FIXME !i386
+lndist-linux-src-asm-files: $(top_srcdir)/hurd-snap/$(dir)/linux-src/arch/i386/lib
+ ln $(addprefix $(srcdir)/linux-src/arch/i386/lib/,$(ARCHSRCS)) $<
-lndist-linux-files: $(top_srcdir)/hurd-snap/$(dir)/linux
- ln $(addprefix $(srcdir)/linux/,$(FROBBEDLINUXHEADERS)) $<
+lndist-linux-src-include-linux-files: $(top_srcdir)/hurd-snap/$(dir)/linux-src/include/linux
+ ln $(addprefix $(srcdir)/linux-src/include/linux/,$(LINUXHDRS)) $<
-lndist-asm-files: $(top_srcdir)/hurd-snap/$(dir)/asm
- ln $(addprefix $(srcdir)/asm/,$(ASMHEADERS)) $<
+lndist-linux-src-include-net-files: $(top_srcdir)/hurd-snap/$(dir)/linux-src/include/net
+ ln $(addprefix $(srcdir)/linux-src/include/net/,$(LINUXNETHDRS)) $<
-$(top_srcdir)/hurd-snap/$(dir)/linux-inet:
+lndist-linux-src-include-asm-files: $(top_srcdir)/hurd-snap/$(dir)/linux-src/include/asm-i386
+ ln $(addprefix $(srcdir)/linux-src/include/asm-$(asm_syntax)/,$(ARCHHDRS)) $<
+
+lndist-glue-include-linux-files: $(top_srcdir)/hurd-snap/$(dir)/glue-include/linux
+ ln $(addprefix $(srcdir)/glue-include/linux/,$(FROBBEDLINUXHEADERS)) $<
+
+lndist-glue-include-asm-files: $(top_srcdir)/hurd-snap/$(dir)/glue-include/asm
+ ln $(addprefix $(srcdir)/glue-include/asm/,$(ASMHEADERS)) $<
+
+$(top_srcdir)/hurd-snap/$(dir)/linux-src:
+ mkdir $@
+$(top_srcdir)/hurd-snap/$(dir)/linux-src/arch: $(top_srcdir)/hurd-snap/$(dir)/linux-src
+ mkdir $@
+$(top_srcdir)/hurd-snap/$(dir)/linux-src/arch/%/lib: $(top_srcdir)/hurd-snap/$(dir)/linux-src/arch
+ mkdir -p $@
+$(top_srcdir)/hurd-snap/$(dir)/linux-src/include: $(top_srcdir)/hurd-snap/$(dir)/linux-src
+ mkdir $@
+$(top_srcdir)/hurd-snap/$(dir)/linux-src/include/%: $(top_srcdir)/hurd-snap/$(dir)/linux-src/include
+ mkdir $@
+$(top_srcdir)/hurd-snap/$(dir)/linux-src/net: $(top_srcdir)/hurd-snap/$(dir)/linux-src
+ mkdir $@
+$(top_srcdir)/hurd-snap/$(dir)/linux-src/net/core: $(top_srcdir)/hurd-snap/$(dir)/linux-src/net
+ mkdir $@
+$(top_srcdir)/hurd-snap/$(dir)/linux-src/net/ethernet: $(top_srcdir)/hurd-snap/$(dir)/linux-src/net
+ mkdir $@
+$(top_srcdir)/hurd-snap/$(dir)/linux-src/net/ipv4: $(top_srcdir)/hurd-snap/$(dir)/linux-src/net
+ mkdir $@
+$(top_srcdir)/hurd-snap/$(dir)/linux-src/net/ipv6: $(top_srcdir)/hurd-snap/$(dir)/linux-src/net
+ mkdir $@
+$(top_srcdir)/hurd-snap/$(dir)/glue-include:
mkdir $@
-$(top_srcdir)/hurd-snap/$(dir)/linux:
+$(top_srcdir)/hurd-snap/$(dir)/glue-include/asm: $(top_srcdir)/hurd-snap/$(dir)/glue-include
mkdir $@
-$(top_srcdir)/hurd-snap/$(dir)/asm:
+$(top_srcdir)/hurd-snap/$(dir)/glue-include/linux: $(top_srcdir)/hurd-snap/$(dir)/glue-include
mkdir $@
diff --git a/pfinet/ethernet.c b/pfinet/ethernet.c
index dab5c56f..0fd76706 100644
--- a/pfinet/ethernet.c
+++ b/pfinet/ethernet.c
@@ -20,6 +20,8 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+/* Do not include glue-include/linux/errno.h */
+#define _HACK_ERRNO_H
#include "pfinet.h"
#include <device/device.h>
@@ -27,6 +29,7 @@
#include <netinet/in.h>
#include <string.h>
#include <error.h>
+#include <fcntl.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
@@ -80,6 +83,18 @@ static short ether_filter[] =
};
static int ether_filter_len = sizeof (ether_filter) / sizeof (short);
+/* The BPF instruction allows IP and ARP packets */
+static struct bpf_insn bpf_ether_filter[] =
+{
+ {NETF_IN|NETF_BPF, /* Header. */ 0, 0, 0},
+ {40, 0, 0, 12},
+ {21, 1, 0, 2054},
+ {21, 0, 1, 2048},
+ {6, 0, 0, 1500},
+ {6, 0, 0, 0},
+};
+static int bpf_ether_filter_len = sizeof (bpf_ether_filter) / sizeof (short);
+
static struct port_bucket *etherport_bucket;
@@ -166,20 +181,46 @@ ethernet_open (struct device *dev)
mach_port_set_qlimit (mach_task_self (), edev->readptname, MACH_PORT_QLIMIT_MAX);
- err = get_privileged_ports (0, &master_device);
- if (err)
- error (2, err, "cannot get device master port");
-
- err = device_open (master_device, D_WRITE | D_READ, dev->name, &edev->ether_port);
- mach_port_deallocate (mach_task_self (), master_device);
- if (err)
- error (2, err, "%s", dev->name);
+ master_device = file_name_lookup (dev->name, O_READ | O_WRITE, 0);
+ if (master_device != MACH_PORT_NULL)
+ {
+ /* The device name here is the path of a device file. */
+ err = device_open (master_device, D_WRITE | D_READ, "eth", &edev->ether_port);
+ mach_port_deallocate (mach_task_self (), master_device);
+ if (err)
+ error (2, err, "device_open on %s", dev->name);
+
+ err = device_set_filter (edev->ether_port, ports_get_right (edev->readpt),
+ MACH_MSG_TYPE_MAKE_SEND, 0,
+ bpf_ether_filter, bpf_ether_filter_len);
+ if (err)
+ error (2, err, "device_set_filter on %s", dev->name);
+ }
+ else
+ {
+ /* No, perhaps a Mach device? */
+ int file_errno = errno;
+ err = get_privileged_ports (0, &master_device);
+ if (err)
+ {
+ error (0, file_errno, "file_name_lookup %s", dev->name);
+ error (2, err, "and cannot get device master port");
+ }
+ err = device_open (master_device, D_WRITE | D_READ, dev->name, &edev->ether_port);
+ mach_port_deallocate (mach_task_self (), master_device);
+ if (err)
+ {
+ error (0, file_errno, "file_name_lookup %s", dev->name);
+ error (2, err, "device_open(%s)", dev->name);
+ }
+
+ err = device_set_filter (edev->ether_port, ports_get_right (edev->readpt),
+ MACH_MSG_TYPE_MAKE_SEND, 0,
+ ether_filter, ether_filter_len);
+ if (err)
+ error (2, err, "device_set_filter on %s", dev->name);
+ }
- err = device_set_filter (edev->ether_port, ports_get_right (edev->readpt),
- MACH_MSG_TYPE_MAKE_SEND, 0,
- ether_filter, ether_filter_len);
- if (err)
- error (2, err, "%s", dev->name);
return 0;
}
diff --git a/pfinet/linux-src/arch/sparc/lib/checksum.S b/pfinet/linux-src/arch/sparc/lib/checksum.S
index d02b6dfb..3dc58259 100644
--- a/pfinet/linux-src/arch/sparc/lib/checksum.S
+++ b/pfinet/linux-src/arch/sparc/lib/checksum.S
@@ -336,7 +336,7 @@ C_LABEL(__csum_partial_copy_sparc_generic):
bne cc_dword_align ! yes, we check for short lengths there
andcc %g1, 0xffffff80, %g0 ! can we use unrolled loop?
3: be 3f ! nope, less than one loop remains
- andcc %o1, 4, %g0 ! dest aligned on 4 or 8 byte boundry?
+ andcc %o1, 4, %g0 ! dest aligned on 4 or 8 byte boundary?
be ccdbl + 4 ! 8 byte aligned, kick ass
5: CSUMCOPY_BIGCHUNK(%o0,%o1,%g7,0x00,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
CSUMCOPY_BIGCHUNK(%o0,%o1,%g7,0x20,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
diff --git a/pfinet/linux-src/include/linux/b1lli.h b/pfinet/linux-src/include/linux/b1lli.h
index 72cae4d2..388ff80c 100644
--- a/pfinet/linux-src/include/linux/b1lli.h
+++ b/pfinet/linux-src/include/linux/b1lli.h
@@ -129,7 +129,7 @@ typedef struct avmb1_extcarddef {
#define AVMB1_LOAD_AND_CONFIG 3 /* load image and config to card */
#define AVMB1_ADDCARD_WITH_TYPE 4 /* add a new card, with cardtype */
#define AVMB1_GET_CARDINFO 5 /* get cardtype */
-#define AVMB1_REMOVECARD 6 /* remove a card (usefull for T1) */
+#define AVMB1_REMOVECARD 6 /* remove a card (useful for T1) */
#define AVMB1_REGISTERCARD_IS_OBSOLETE
diff --git a/pfinet/linux-src/include/linux/cdk.h b/pfinet/linux-src/include/linux/cdk.h
index 2180e433..2fab8949 100644
--- a/pfinet/linux-src/include/linux/cdk.h
+++ b/pfinet/linux-src/include/linux/cdk.h
@@ -149,7 +149,7 @@ typedef struct cdkhdr {
/*
* Define the memory mapping structure. This structure is pointed to by
* the memp field in the stlcdkhdr struct. As many as these structures
- * as required are layed out in shared memory to define how the rest of
+ * as required are laid out in shared memory to define how the rest of
* shared memory is divided up. There will be one for each port.
*/
typedef struct cdkmem {
diff --git a/pfinet/linux-src/include/linux/cdrom.h b/pfinet/linux-src/include/linux/cdrom.h
index a8c028fb..4bbdbd44 100644
--- a/pfinet/linux-src/include/linux/cdrom.h
+++ b/pfinet/linux-src/include/linux/cdrom.h
@@ -75,7 +75,7 @@
#define CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code"
if available (struct cdrom_mcn) */
#define CDROM_GET_UPC CDROM_GET_MCN /* This one is depricated,
- but here anyway for compatability */
+ but here anyway for compatibility */
#define CDROMRESET 0x5312 /* hard-reset the drive */
#define CDROMVOLREAD 0x5313 /* Get the drive's volume setting
(struct cdrom_volctrl) */
diff --git a/pfinet/linux-src/include/linux/coda_opstats.h b/pfinet/linux-src/include/linux/coda_opstats.h
index fdf3fac4..167490d8 100644
--- a/pfinet/linux-src/include/linux/coda_opstats.h
+++ b/pfinet/linux-src/include/linux/coda_opstats.h
@@ -85,7 +85,7 @@ struct cfs_op_stats {
/*
- * With each call to the minicache, we'll bump the counters whenver
+ * With each call to the minicache, we'll bump the counters whenever
* a call is satisfied internally (through the cache or through a
* redirect), and whenever an operation is caused internally.
* Then, we can add the total operations caught by the minicache
diff --git a/pfinet/linux-src/include/linux/cyclades.h b/pfinet/linux-src/include/linux/cyclades.h
index 008254e6..4e8333c1 100644
--- a/pfinet/linux-src/include/linux/cyclades.h
+++ b/pfinet/linux-src/include/linux/cyclades.h
@@ -134,7 +134,7 @@ struct CYZ_BOOT_CTRL {
/****************** ****************** *******************/
/*
* The data types defined below are used in all ZFIRM interface
- * data structures. They accomodate differences between HW
+ * data structures. They accommodate differences between HW
* architectures and compilers.
*/
@@ -167,7 +167,7 @@ struct CUSTOM_REG {
uclong fpga_version; /* FPGA Version Number Register */
uclong cpu_start; /* CPU start Register (write) */
uclong cpu_stop; /* CPU stop Register (write) */
- uclong misc_reg; /* Miscelaneous Register */
+ uclong misc_reg; /* Miscellaneous Register */
uclong idt_mode; /* IDT mode Register */
uclong uart_irq_status; /* UART IRQ status Register */
uclong clear_timer0_irq; /* Clear timer interrupt Register */
diff --git a/pfinet/linux-src/include/linux/isdn.h b/pfinet/linux-src/include/linux/isdn.h
index a0a0b0fa..742fe14b 100644
--- a/pfinet/linux-src/include/linux/isdn.h
+++ b/pfinet/linux-src/include/linux/isdn.h
@@ -23,7 +23,7 @@
* $Log: isdn.h,v $
* Revision 1.81 1999/10/27 21:21:18 detabc
* Added support for building logically-bind-group's per interface.
- * usefull for outgoing call's with more then one isdn-card.
+ * useful for outgoing call's with more then one isdn-card.
*
* Switchable support to dont reset the hangup-timeout for
* receive frames. Most part's of the timru-rules for receiving frames
@@ -192,7 +192,7 @@
* Added changes for recent 2.1.x kernels:
* changed return type of isdn_close
* queue_task_* -> queue_task
- * clear/set_bit -> test_and_... where apropriate.
+ * clear/set_bit -> test_and_... where appropriate.
* changed type of hard_header_cache parameter.
*
* Revision 1.28 1997/03/07 01:33:01 fritz
diff --git a/pfinet/linux-src/include/linux/isdn_ppp.h b/pfinet/linux-src/include/linux/isdn_ppp.h
index 06d71797..e7682fb3 100644
--- a/pfinet/linux-src/include/linux/isdn_ppp.h
+++ b/pfinet/linux-src/include/linux/isdn_ppp.h
@@ -77,7 +77,7 @@ struct isdn_ppp_comp_data {
*
* We use this same struct for the reset entry of the compressor to commu-
* nicate to its caller how to deal with sending of a Reset Ack. In this
- * case, expra is not used, but other options still apply (supressing
+ * case, expra is not used, but other options still apply (suppressing
* sending with rsend, appending arbitrary data, etc).
*/
diff --git a/pfinet/linux-src/include/linux/isdnif.h b/pfinet/linux-src/include/linux/isdnif.h
index 07e3b826..7380b326 100644
--- a/pfinet/linux-src/include/linux/isdnif.h
+++ b/pfinet/linux-src/include/linux/isdnif.h
@@ -73,7 +73,7 @@
* Added changes for recent 2.1.x kernels:
* changed return type of isdn_close
* queue_task_* -> queue_task
- * clear/set_bit -> test_and_... where apropriate.
+ * clear/set_bit -> test_and_... where appropriate.
* changed type of hard_header_cache parameter.
*
* Revision 1.19 1997/03/25 23:13:56 keil
@@ -189,7 +189,7 @@
/* */
/* The proceed command holds a incoming call in a state to leave processes */
/* enough time to check whether ist should be accepted. */
-/* The PROT_IO Command extends the interface to make protocol dependant */
+/* The PROT_IO Command extends the interface to make protocol dependent */
/* features available (call diversion, call waiting...). */
/* */
/* The PROT_IO Command is executed with the desired driver id and the arg */
diff --git a/pfinet/linux-src/include/linux/ixjuser.h b/pfinet/linux-src/include/linux/ixjuser.h
index a7019533..1ee0ee91 100644
--- a/pfinet/linux-src/include/linux/ixjuser.h
+++ b/pfinet/linux-src/include/linux/ixjuser.h
@@ -31,7 +31,7 @@ static char ixjuser_h_rcsid[] = "$Id: ixjuser.h,v 3.4 1999/12/16 22:18:36 root E
/***************************************************************************
If you use the IXJCTL_TESTRAM command, the card must be power
- cycled to reset the SRAM values before futher use.
+ cycled to reset the SRAM values before further use.
***************************************************************************/
#define IXJCTL_DSP_RESET _IO ('q', 0xC0)
@@ -332,7 +332,7 @@ typedef struct {
* This group of IOCTLs deal with the Acoustic Echo Cancellation settings
* of the DSP
*
-* Issueing the IXJCTL_AEC_START command with a value of AEC_OFF has the
+* Issuing the IXJCTL_AEC_START command with a value of AEC_OFF has the
* same effect as IXJCTL_AEC_STOP. This is to simplify slider bar
* controls. IXJCTL_AEC_GET_LEVEL returns the current setting of the AEC.
******************************************************************************/
diff --git a/pfinet/linux-src/include/linux/loop.h b/pfinet/linux-src/include/linux/loop.h
index d276911c..43b3bd69 100644
--- a/pfinet/linux-src/include/linux/loop.h
+++ b/pfinet/linux-src/include/linux/loop.h
@@ -63,7 +63,7 @@ typedef int (* transfer_proc_t)(struct loop_device *, int cmd,
#endif
/*
- * This uses kdev_t because glibc currently has no appropiate
+ * This uses kdev_t because glibc currently has no appropriate
* conversion version for the loop ioctls.
* The situation is very unpleasant
*/
diff --git a/pfinet/linux-src/include/linux/module.h b/pfinet/linux-src/include/linux/module.h
index 94cce874..585a8d1d 100644
--- a/pfinet/linux-src/include/linux/module.h
+++ b/pfinet/linux-src/include/linux/module.h
@@ -230,7 +230,7 @@ extern struct module *module_list;
In the kernel, the symbol is added to the kernel's global symbol table.
In a module, it controls which variables are exported. If no
- variables are explicitly exported, the action is controled by the
+ variables are explicitly exported, the action is controlled by the
insmod -[xX] flags. Otherwise, only the variables listed are exported.
This obviates the need for the old register_symtab() function. */
diff --git a/pfinet/linux-src/include/linux/notifier.h b/pfinet/linux-src/include/linux/notifier.h
index 42faceaa..1e8bf707 100644
--- a/pfinet/linux-src/include/linux/notifier.h
+++ b/pfinet/linux-src/include/linux/notifier.h
@@ -106,7 +106,7 @@ extern __inline__ int notifier_call_chain(struct notifier_block **n, unsigned lo
#define SYS_POWER_OFF 0x0003 /* Notify of system power off */
/*
- * Publically visible notifier objects
+ * Publicly visible notifier objects
*/
extern struct notifier_block *boot_notifier_list;
diff --git a/pfinet/linux-src/include/linux/poll.h b/pfinet/linux-src/include/linux/poll.h
index 7eb57334..991204f1 100644
--- a/pfinet/linux-src/include/linux/poll.h
+++ b/pfinet/linux-src/include/linux/poll.h
@@ -51,7 +51,7 @@ extern inline void poll_wait(struct file * filp, struct wait_queue ** wait_addre
typedef unsigned long kernel_fd_set[KFDS_NR/__NFDBITS];
/*
- * Scaleable version of the fd_set.
+ * Scalable version of the fd_set.
*/
typedef struct {
diff --git a/pfinet/linux-src/include/linux/rtnetlink.h b/pfinet/linux-src/include/linux/rtnetlink.h
index 4fda960d..548a9b14 100644
--- a/pfinet/linux-src/include/linux/rtnetlink.h
+++ b/pfinet/linux-src/include/linux/rtnetlink.h
@@ -138,7 +138,7 @@ enum
*/
#define RTPROT_GATED 8 /* Apparently, GateD */
-#define RTPROT_RA 9 /* RDISC/ND router advertisments */
+#define RTPROT_RA 9 /* RDISC/ND router advertisements */
#define RTPROT_MRT 10 /* Merit MRT */
#define RTPROT_ZEBRA 11 /* Zebra */
#define RTPROT_BIRD 12 /* BIRD */
diff --git a/pfinet/linux-src/include/linux/socket.h b/pfinet/linux-src/include/linux/socket.h
index 837a3e46..b427f992 100644
--- a/pfinet/linux-src/include/linux/socket.h
+++ b/pfinet/linux-src/include/linux/socket.h
@@ -53,7 +53,7 @@ struct cmsghdr {
};
/*
- * Ancilliary data object information MACROS
+ * Ancillary data object information MACROS
* Table 5-14 of POSIX 1003.1g
*/
diff --git a/pfinet/linux-src/include/linux/soundcard.h b/pfinet/linux-src/include/linux/soundcard.h
index 2d5128dc..2041b4d4 100644
--- a/pfinet/linux-src/include/linux/soundcard.h
+++ b/pfinet/linux-src/include/linux/soundcard.h
@@ -1204,7 +1204,7 @@ extern int OSS_write_patch2(int fd, unsigned char *buf, int len);
#define SEQ_PANNING(dev, voice, pos) SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2)
/*
- * Timing and syncronization macros
+ * Timing and synchronization macros
*/
#define _TIMER_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\
diff --git a/pfinet/linux-src/include/linux/telephony.h b/pfinet/linux-src/include/linux/telephony.h
index 082b885f..0e4a95a4 100644
--- a/pfinet/linux-src/include/linux/telephony.h
+++ b/pfinet/linux-src/include/linux/telephony.h
@@ -168,8 +168,8 @@ typedef enum {
* indicate the current state of the hookswitch. The pstn_ring bit
* indicates that the DAA on a LineJACK card has detected ring voltage on
* the PSTN port. The caller_id bit indicates that caller_id data has been
-* recieved and is available. The pstn_wink bit indicates that the DAA on
-* the LineJACK has recieved a wink from the telco switch. The f0, f1, f2
+* received and is available. The pstn_wink bit indicates that the DAA on
+* the LineJACK has received a wink from the telco switch. The f0, f1, f2
* and f3 bits indicate that the filter has been triggered by detecting the
* frequency programmed into that filter.
*
diff --git a/pfinet/linux-src/include/linux/tpqic02.h b/pfinet/linux-src/include/linux/tpqic02.h
index fe13ad6e..790e0e5a 100644
--- a/pfinet/linux-src/include/linux/tpqic02.h
+++ b/pfinet/linux-src/include/linux/tpqic02.h
@@ -588,7 +588,7 @@
*/
#define TP_REWCLOSE(d) ((MINOR(d)&0x01) == 1) /* rewind bit */
- /* rewind is only done if data has been transfered */
+ /* rewind is only done if data has been transferred */
#define TP_DENS(dev) ((MINOR(dev) >> 1) & 0x07) /* tape density */
#define TP_UNIT(dev) ((MINOR(dev) >> 4) & 0x07) /* unit number */
@@ -633,8 +633,8 @@ struct tpstatus { /* sizeof(short)==2), LSB first */
#define EXC_WP 3 /* Write protected */
#define EXC_EOM 4 /* EOM */
#define EXC_RWA 5 /* read/write abort */
-#define EXC_XBAD 6 /* read error, bad block transfered */
-#define EXC_XFILLER 7 /* read error, filler block transfered */
+#define EXC_XBAD 6 /* read error, bad block transferred */
+#define EXC_XFILLER 7 /* read error, filler block transferred */
#define EXC_NDT 8 /* read error, no data */
#define EXC_NDTEOM 9 /* read error, no data & EOM */
#define EXC_NDTBOM 10 /* read error, no data & BOM */
diff --git a/pfinet/linux-src/include/linux/tty_ldisc.h b/pfinet/linux-src/include/linux/tty_ldisc.h
index 501ea076..4e904f83 100644
--- a/pfinet/linux-src/include/linux/tty_ldisc.h
+++ b/pfinet/linux-src/include/linux/tty_ldisc.h
@@ -62,7 +62,7 @@
* void (*set_termios)(struct tty_struct *tty, struct termios * old);
*
* This function notifies the line discpline that a change has
- * been made to the termios stucture.
+ * been made to the termios structure.
*
* int (*poll)(struct tty_struct * tty, struct file * file,
* poll_table *wait);
diff --git a/pfinet/linux-src/include/linux/wavefront.h b/pfinet/linux-src/include/linux/wavefront.h
index f96c52d0..f816f940 100644
--- a/pfinet/linux-src/include/linux/wavefront.h
+++ b/pfinet/linux-src/include/linux/wavefront.h
@@ -667,7 +667,7 @@ typedef struct wf_fx_info {
/* Allow direct user-space control over FX memory/coefficient data.
In theory this could be used to download the FX microprogram,
- but it would be a little slower, and involve some wierd code.
+ but it would be a little slower, and involve some weird code.
*/
#define WFFX_MEMSET 69
diff --git a/pfinet/linux-src/include/linux/wireless.h b/pfinet/linux-src/include/linux/wireless.h
index 868f812a..61f85152 100644
--- a/pfinet/linux-src/include/linux/wireless.h
+++ b/pfinet/linux-src/include/linux/wireless.h
@@ -146,7 +146,7 @@
* The "flags" member indicate if the ESSID is active or not (promiscuous).
*/
-/* Other parameters usefull in 802.11 and some other devices */
+/* Other parameters useful in 802.11 and some other devices */
#define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
#define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
#define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
diff --git a/pfinet/linux-src/include/net/pkt_sched.h b/pfinet/linux-src/include/net/pkt_sched.h
index 9911464f..c2ef8656 100644
--- a/pfinet/linux-src/include/net/pkt_sched.h
+++ b/pfinet/linux-src/include/net/pkt_sched.h
@@ -119,7 +119,7 @@ struct qdisc_rate_table
The result: [34]86 is not good choice for QoS router :-(
- The things are not so bad, because we may use artifical
+ The things are not so bad, because we may use artificial
clock evaluated by integration of network data flow
in the most critical places.
diff --git a/pfinet/linux-src/include/net/tcp.h b/pfinet/linux-src/include/net/tcp.h
index 0e7e4bb6..abb4b210 100644
--- a/pfinet/linux-src/include/net/tcp.h
+++ b/pfinet/linux-src/include/net/tcp.h
@@ -713,7 +713,7 @@ extern __inline__ __u32 tcp_recalc_ssthresh(struct tcp_opt *tp)
/* TCP timestamps are only 32-bits, this causes a slight
* complication on 64-bit systems since we store a snapshot
- * of jiffies in the buffer control blocks below. We decidely
+ * of jiffies in the buffer control blocks below. We decidedly
* only use of the low 32-bits of jiffies and hide the ugly
* casts with the following macro.
*/
@@ -1066,7 +1066,7 @@ static inline void tcp_clear_xmit_timer(struct sock *sk, int what)
timer = &tp->probe_timer;
break;
default:
- printk(timer_bug_msg);
+ printk("%s", timer_bug_msg);
return;
};
if(timer->prev != NULL)
@@ -1088,7 +1088,7 @@ static inline int tcp_timer_is_set(struct sock *sk, int what)
return tp->probe_timer.prev != NULL;
break;
default:
- printk(timer_bug_msg);
+ printk("%s", timer_bug_msg);
};
return 0;
}
diff --git a/pfinet/linux-src/net/core/dev.c b/pfinet/linux-src/net/core/dev.c
index 5b4c6255..92e105a1 100644
--- a/pfinet/linux-src/net/core/dev.c
+++ b/pfinet/linux-src/net/core/dev.c
@@ -187,7 +187,7 @@ int netdev_nit=0;
*
* BEWARE!!! Protocol handlers, mangling input packets,
* MUST BE last in hash buckets and checking protocol handlers
- * MUST start from promiscous ptype_all chain in net_bh.
+ * MUST start from promiscuous ptype_all chain in net_bh.
* It is true now, do not change it.
* Explantion follows: if protocol handler, mangling packet, will
* be the first on list, it is not able to sense, that packet
diff --git a/pfinet/linux-src/net/core/sock.c b/pfinet/linux-src/net/core/sock.c
index e0eb41a0..c47c935b 100644
--- a/pfinet/linux-src/net/core/sock.c
+++ b/pfinet/linux-src/net/core/sock.c
@@ -138,7 +138,7 @@ __u32 sysctl_rmem_max = SK_RMEM_MAX;
__u32 sysctl_wmem_default = SK_WMEM_MAX;
__u32 sysctl_rmem_default = SK_RMEM_MAX;
-/* Maximal space eaten by iovec or ancilliary data plus some space */
+/* Maximal space eaten by iovec or ancillary data plus some space */
int sysctl_optmem_max = sizeof(unsigned long)*(2*UIO_MAXIOV + 512);
/*
@@ -693,7 +693,7 @@ struct sk_buff *sock_alloc_send_skb(struct sock *sk, unsigned long size,
* 1003.1g draft 6.4. If we (the user) did a shutdown()
* call however we should not.
*
- * Note: This routine isnt just used for datagrams and
+ * Note: This routine isn't just used for datagrams and
* anyway some datagram protocols have a notion of
* close down.
*/
diff --git a/pfinet/linux-src/net/ipv4/fib_semantics.c b/pfinet/linux-src/net/ipv4/fib_semantics.c
index b78f7eba..b7edb29b 100644
--- a/pfinet/linux-src/net/ipv4/fib_semantics.c
+++ b/pfinet/linux-src/net/ipv4/fib_semantics.c
@@ -291,7 +291,7 @@ int fib_nh_match(struct rtmsg *r, struct nlmsghdr *nlh, struct kern_rta *rta,
Attempt to reconcile all of these (alas, self-contradictory) conditions
results in pretty ugly and hairy code with obscure logic.
- I choosed to generalized it instead, so that the size
+ I chose to generalize it instead, so that the size
of code does not increase practically, but it becomes
much more general.
Every prefix is assigned a "scope" value: "host" is local address,
diff --git a/pfinet/linux-src/net/ipv4/icmp.c b/pfinet/linux-src/net/ipv4/icmp.c
index 6c1edfd7..7fad4783 100644
--- a/pfinet/linux-src/net/ipv4/icmp.c
+++ b/pfinet/linux-src/net/ipv4/icmp.c
@@ -730,7 +730,7 @@ static void icmp_unreach(struct icmphdr *icmph, struct sk_buff *skb, int len)
*/
/*
- * Check the other end isnt violating RFC 1122. Some routers send
+ * Check the other end isn't violating RFC 1122. Some routers send
* bogus responses to broadcast frames. If you see this message
* first check your netmask matches at both ends, if it does then
* get the other vendor to fix their kit.
diff --git a/pfinet/linux-src/net/ipv4/ip_fw.c b/pfinet/linux-src/net/ipv4/ip_fw.c
index 400f46c0..73af70ae 100644
--- a/pfinet/linux-src/net/ipv4/ip_fw.c
+++ b/pfinet/linux-src/net/ipv4/ip_fw.c
@@ -239,7 +239,7 @@ struct ip_chain
ip_chainlabel label; /* Defines the label for each block */
struct ip_chain *next; /* Pointer to next block */
struct ip_fwkernel *chain; /* Pointer to first rule in block */
- __u32 refcount; /* Number of refernces to block */
+ __u32 refcount; /* Number of references to block */
int policy; /* Default rule for chain. Only *
* used in built in chains */
struct ip_reent reent[0]; /* Actually several of these */
diff --git a/pfinet/linux-src/net/ipv4/ip_gre.c b/pfinet/linux-src/net/ipv4/ip_gre.c
index 6a7546fd..4b03c226 100644
--- a/pfinet/linux-src/net/ipv4/ip_gre.c
+++ b/pfinet/linux-src/net/ipv4/ip_gre.c
@@ -436,7 +436,7 @@ void ipgre_err(struct sk_buff *skb, unsigned char *dp, int len)
/* Impossible event. */
return;
case ICMP_FRAG_NEEDED:
- /* And it is the only really necesary thing :-) */
+ /* And it is the only really necessary thing :-) */
rel_info = ntohs(skb->h.icmph->un.frag.mtu);
if (rel_info < grehlen+68)
return;
diff --git a/pfinet/linux-src/net/ipv4/ip_masq_quake.c b/pfinet/linux-src/net/ipv4/ip_masq_quake.c
index 995c3a0a..646348d1 100644
--- a/pfinet/linux-src/net/ipv4/ip_masq_quake.c
+++ b/pfinet/linux-src/net/ipv4/ip_masq_quake.c
@@ -92,7 +92,7 @@ masq_quake_in (struct ip_masq_app *mapp, struct ip_masq *ms, struct sk_buff **sk
iph = skb->nh.iph;
uh = (struct udphdr *)&(((char *)iph)[iph->ihl*4]);
- /* Check for lenght */
+ /* Check for length */
if(ntohs(uh->len) < 5)
return 0;
@@ -178,7 +178,7 @@ masq_quake_out (struct ip_masq_app *mapp, struct ip_masq *ms, struct sk_buff **s
iph = skb->nh.iph;
uh = (struct udphdr *)&(((char *)iph)[iph->ihl*4]);
- /* Check for lenght */
+ /* Check for length */
if(ntohs(uh->len) < 5)
return 0;
diff --git a/pfinet/linux-src/net/ipv4/ip_options.c b/pfinet/linux-src/net/ipv4/ip_options.c
index a3d1f0aa..ec21054d 100644
--- a/pfinet/linux-src/net/ipv4/ip_options.c
+++ b/pfinet/linux-src/net/ipv4/ip_options.c
@@ -491,15 +491,18 @@ void ip_options_undo(struct ip_options * opt)
int ip_options_get(struct ip_options **optp, unsigned char *data, int optlen, int user)
{
struct ip_options *opt;
+ size_t opt_size = sizeof(struct ip_options)+((optlen+3)&~3);
- opt = kmalloc(sizeof(struct ip_options)+((optlen+3)&~3), GFP_KERNEL);
+ opt = kmalloc(opt_size, GFP_KERNEL);
if (!opt)
return -ENOMEM;
memset(opt, 0, sizeof(struct ip_options));
if (optlen) {
if (user) {
- if (copy_from_user(opt->__data, data, optlen))
+ if (copy_from_user(opt->__data, data, optlen)) {
+ kfree_s(opt, opt_size);
return -EFAULT;
+ }
} else
memcpy(opt->__data, data, optlen);
}
@@ -509,7 +512,7 @@ int ip_options_get(struct ip_options **optp, unsigned char *data, int optlen, in
opt->is_data = 1;
opt->is_setbyuser = 1;
if (optlen && ip_options_compile(opt, NULL)) {
- kfree_s(opt, sizeof(struct ip_options) + optlen);
+ kfree_s(opt, opt_size);
return -EINVAL;
}
*optp = opt;
diff --git a/pfinet/linux-src/net/ipv4/ip_output.c b/pfinet/linux-src/net/ipv4/ip_output.c
index c8f416ee..d85ba6b5 100644
--- a/pfinet/linux-src/net/ipv4/ip_output.c
+++ b/pfinet/linux-src/net/ipv4/ip_output.c
@@ -782,7 +782,7 @@ void ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
/* IF: it doesn't fit, use 'mtu' - the data space left */
if (len > mtu)
len = mtu;
- /* IF: we are not sending upto and including the packet end
+ /* IF: we are not sending up to and including the packet end
then align the next start on an eight byte boundary */
if (len < left) {
len &= ~7;
diff --git a/pfinet/linux-src/net/ipv4/ipconfig.c b/pfinet/linux-src/net/ipv4/ipconfig.c
index 0770bad1..bb95824c 100644
--- a/pfinet/linux-src/net/ipv4/ipconfig.c
+++ b/pfinet/linux-src/net/ipv4/ipconfig.c
@@ -844,7 +844,7 @@ int __init ip_auto_config(void)
}
/*
- * Use defaults whereever applicable.
+ * Use defaults wherever applicable.
*/
if (ic_defaults() < 0)
return -1;
diff --git a/pfinet/linux-src/net/ipv4/ipip.c b/pfinet/linux-src/net/ipv4/ipip.c
index 0aeef4a3..119d7567 100644
--- a/pfinet/linux-src/net/ipv4/ipip.c
+++ b/pfinet/linux-src/net/ipv4/ipip.c
@@ -365,7 +365,7 @@ void ipip_err(struct sk_buff *skb, unsigned char *dp, int len)
/* Impossible event. */
return;
case ICMP_FRAG_NEEDED:
- /* And it is the only really necesary thing :-) */
+ /* And it is the only really necessary thing :-) */
rel_info = ntohs(skb->h.icmph->un.frag.mtu);
if (rel_info < hlen+68)
return;
diff --git a/pfinet/linux-src/net/ipv4/raw.c b/pfinet/linux-src/net/ipv4/raw.c
index 5e7910dd..a0aaa82e 100644
--- a/pfinet/linux-src/net/ipv4/raw.c
+++ b/pfinet/linux-src/net/ipv4/raw.c
@@ -379,7 +379,7 @@ static void raw_close(struct sock *sk, long timeout)
sk->state = TCP_CLOSE;
raw_v4_unhash(sk);
/*
- B. Raw sockets may have direct kernel refereneces. Kill them.
+ B. Raw sockets may have direct kernel references. Kill them.
*/
ip_ra_control(sk, 0, NULL);
diff --git a/pfinet/linux-src/net/ipv4/tcp.c b/pfinet/linux-src/net/ipv4/tcp.c
index cf8cee22..8cde3854 100644
--- a/pfinet/linux-src/net/ipv4/tcp.c
+++ b/pfinet/linux-src/net/ipv4/tcp.c
@@ -1218,7 +1218,7 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg,
break;
/* We need to check signals first, to get correct SIGURG
- * handling. FIXME: Need to check this doesnt impact 1003.1g
+ * handling. FIXME: Need to check this doesn't impact 1003.1g
* and move it down to the bottom of the loop
*/
if (signal_pending(current)) {
diff --git a/pfinet/linux-src/net/ipv4/tcp_input.c b/pfinet/linux-src/net/ipv4/tcp_input.c
index 7f5cc4e7..e84eaf43 100644
--- a/pfinet/linux-src/net/ipv4/tcp_input.c
+++ b/pfinet/linux-src/net/ipv4/tcp_input.c
@@ -130,7 +130,7 @@ static __inline__ void tcp_remember_ack(struct tcp_opt *tp, struct tcphdr *th,
{
tp->delayed_acks++;
- /* Tiny-grams with PSH set artifically deflate our
+ /* Tiny-grams with PSH set artificially deflate our
* ato measurement, but with a lower bound.
*/
if(th->psh && (skb->len < (tp->mss_cache >> 1))) {
@@ -989,7 +989,7 @@ tcp_timewait_state_process(struct tcp_tw_bucket *tw, struct sk_buff *skb,
/* Check RST or SYN */
if(th->rst || th->syn) {
- /* This is TIME_WAIT assasination, in two flavors.
+ /* This is TIME_WAIT assassination, in two flavors.
* Oh well... nobody has a sufficient solution to this
* protocol bug yet.
*/
@@ -1931,7 +1931,7 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
* Dave!!! Phrase above (and all about rcv_mss) has
* nothing to do with reality. rcv_mss must measure TOTAL
* size, including sacks, IP options etc. Hence, measure_rcv_mss
- * must occure before pulling etc, otherwise it will flap
+ * must occur before pulling etc, otherwise it will flap
* like hell. Even putting it before tcp_data is wrong,
* it should use skb->tail - skb->nh.raw instead.
* --ANK (980805)
@@ -1939,7 +1939,7 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
* BTW I broke it. Now all TCP options are handled equally
* in mss_clamp calculations (i.e. ignored, rfc1122),
* and mss_cache does include all of them (i.e. tstamps)
- * except for sacks, to calulate effective mss faster.
+ * except for sacks, to calculate effective mss faster.
* --ANK (980805)
*/
tcp_measure_rcv_mss(sk, skb);
diff --git a/pfinet/linux-src/net/ipv4/tcp_ipv4.c b/pfinet/linux-src/net/ipv4/tcp_ipv4.c
index ab6db9bb..99194238 100644
--- a/pfinet/linux-src/net/ipv4/tcp_ipv4.c
+++ b/pfinet/linux-src/net/ipv4/tcp_ipv4.c
@@ -1516,7 +1516,7 @@ struct sock * tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
#ifdef CONFIG_IP_TRANSPARENT_PROXY
/* The new socket created for transparent proxy may fall
* into a non-existed bind bucket because sk->num != newsk->num.
- * Ensure existance of the bucket now. The placement of the check
+ * Ensure existence of the bucket now. The placement of the check
* later will require to destroy just created newsk in the case of fail.
* 1998/04/22 Andrey V. Savochkin <saw@msu.ru>
*/
diff --git a/pfinet/linux-src/net/ipv4/tcp_output.c b/pfinet/linux-src/net/ipv4/tcp_output.c
index 2ac5e8a2..9ea4b7ad 100644
--- a/pfinet/linux-src/net/ipv4/tcp_output.c
+++ b/pfinet/linux-src/net/ipv4/tcp_output.c
@@ -257,7 +257,7 @@ static int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len)
for TCP options, but includes only bare TCP header.
tp->mss_clamp is mss negotiated at connection setup.
- It is minumum of user_mss and mss received with SYN.
+ It is minimum of user_mss and mss received with SYN.
It also does not include TCP options.
tp->pmtu_cookie is last pmtu, seen by this function.
diff --git a/pfinet/linux-src/net/ipv6/addrconf.c b/pfinet/linux-src/net/ipv6/addrconf.c
index e3ca6d72..d392b3fd 100644
--- a/pfinet/linux-src/net/ipv6/addrconf.c
+++ b/pfinet/linux-src/net/ipv6/addrconf.c
@@ -373,9 +373,9 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
}
/*
- * Choose an apropriate source address
+ * Choose an appropriate source address
* should do:
- * i) get an address with an apropriate scope
+ * i) get an address with an appropriate scope
* ii) see if there is a specific route for the destination and use
* an address of the attached interface
* iii) don't use deprecated addresses
diff --git a/pfinet/linux-src/net/ipv6/af_inet6.c b/pfinet/linux-src/net/ipv6/af_inet6.c
index fb5d3957..ca428188 100644
--- a/pfinet/linux-src/net/ipv6/af_inet6.c
+++ b/pfinet/linux-src/net/ipv6/af_inet6.c
@@ -551,7 +551,7 @@ __initfunc(void inet6_proto_init(struct net_proto *pro))
/*
* ipngwg API draft makes clear that the correct semantics
* for TCP and UDP is to consider one TCP and UDP instance
- * in a host availiable by both INET and INET6 APIs and
+ * in a host available by both INET and INET6 APIs and
* able to communicate via both network protocols.
*/
diff --git a/pfinet/linux-src/net/ipv6/icmpv6.c b/pfinet/linux-src/net/ipv6/icmpv6.c
index f7bebe0a..9d701764 100644
--- a/pfinet/linux-src/net/ipv6/icmpv6.c
+++ b/pfinet/linux-src/net/ipv6/icmpv6.c
@@ -567,15 +567,15 @@ int icmpv6_rcv(struct sk_buff *skb, unsigned long len)
default:
if (net_ratelimit())
- printk(KERN_DEBUG "icmpv6: msg of unkown type\n");
+ printk(KERN_DEBUG "icmpv6: msg of unknown type\n");
/* informational */
if (type & 0x80)
break;
- /*
- * error of unkown type.
- * must pass to upper level
+ /*
+ * error of unknown type.
+ * must pass to upper level
*/
icmpv6_notify(skb, type, hdr->icmp6_code, hdr->icmp6_mtu,
diff --git a/pfinet/linux-src/net/ipv6/ip6_fib.c b/pfinet/linux-src/net/ipv6/ip6_fib.c
index d1908348..9468c023 100644
--- a/pfinet/linux-src/net/ipv6/ip6_fib.c
+++ b/pfinet/linux-src/net/ipv6/ip6_fib.c
@@ -234,7 +234,7 @@ static __inline__ void rt6_release(struct rt6_info *rt)
/*
* Routing Table
*
- * return the apropriate node for a routing tree "add" operation
+ * return the appropriate node for a routing tree "add" operation
* by either creating and inserting or by returning an existing
* node.
*/
diff --git a/pfinet/linux-src/net/ipv6/ip6_input.c b/pfinet/linux-src/net/ipv6/ip6_input.c
index 54a3f455..c4a51831 100644
--- a/pfinet/linux-src/net/ipv6/ip6_input.c
+++ b/pfinet/linux-src/net/ipv6/ip6_input.c
@@ -246,7 +246,7 @@ int ip6_mc_input(struct sk_buff *skb)
deliver = 1;
/*
- * IPv6 multicast router mode isnt currently supported.
+ * IPv6 multicast router mode isn't currently supported.
*/
#if 0
if (ipv6_config.multicast_route) {
diff --git a/pfinet/linux-src/net/ipv6/ip6_output.c b/pfinet/linux-src/net/ipv6/ip6_output.c
index f67e3e9e..e06ad59a 100644
--- a/pfinet/linux-src/net/ipv6/ip6_output.c
+++ b/pfinet/linux-src/net/ipv6/ip6_output.c
@@ -481,7 +481,7 @@ int ip6_build_xmit(struct sock *sk, inet_getfrag_t getfrag, const void *data,
if (err) {
#if IP6_DEBUG >= 2
printk(KERN_DEBUG "ip6_build_xmit: "
- "no availiable source address\n");
+ "no available source address\n");
#endif
goto out;
}
diff --git a/pfinet/linux-src/net/ipv6/ndisc.c b/pfinet/linux-src/net/ipv6/ndisc.c
index 3b3d3f4e..61f950d2 100644
--- a/pfinet/linux-src/net/ipv6/ndisc.c
+++ b/pfinet/linux-src/net/ipv6/ndisc.c
@@ -554,7 +554,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (skb->nh.ipv6h->hop_limit != 255) {
printk(KERN_INFO
- "NDISC: fake router advertisment received\n");
+ "NDISC: fake router advertisement received\n");
return;
}
@@ -694,7 +694,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
ND_PRINTK0("got illegal option with RA");
break;
default:
- ND_PRINTK0("unkown option in RA\n");
+ ND_PRINTK0("unknown option in RA\n");
};
optlen -= len;
opt += len;
diff --git a/pfinet/linux-src/net/ipv6/udp_ipv6.c b/pfinet/linux-src/net/ipv6/udp_ipv6.c
index 1886e8ac..f6968ae4 100644
--- a/pfinet/linux-src/net/ipv6/udp_ipv6.c
+++ b/pfinet/linux-src/net/ipv6/udp_ipv6.c
@@ -335,7 +335,7 @@ ipv4_connected:
ip6_dst_store(sk, dst, fl.fl6_dst);
- /* get the source adddress used in the apropriate device */
+ /* get the source adddress used in the appropriate device */
err = ipv6_get_saddr(dst, daddr, &saddr);
diff --git a/pfinet/main.c b/pfinet/main.c
index c1e080a6..1357b037 100644
--- a/pfinet/main.c
+++ b/pfinet/main.c
@@ -288,7 +288,7 @@ main (int argc,
/* Parse options. When successful, this configures the interfaces
before returning; to do so, it will acquire the global_lock.
- (And when not sucessful, it never returns.) */
+ (And when not successful, it never returns.) */
argp_parse (&pfinet_argp, argc, argv, 0,0,0);
task_get_bootstrap_port (mach_task_self (), &bootstrap);
@@ -415,7 +415,7 @@ pfinet_bind (int portclass, const char *name)
}
if (err)
- error (1, err, name);
+ error (1, err, "%s", name);
ports_port_deref (cntl);
diff --git a/pfinet/options.c b/pfinet/options.c
index d0a1ff2b..21a35c61 100644
--- a/pfinet/options.c
+++ b/pfinet/options.c
@@ -479,7 +479,7 @@ parse_opt (int opt, char *arg, struct argp_state *state)
/* Fall through to free hook. */
case ARGP_KEY_ERROR:
- /* Parsing error occured, free everything. */
+ /* Parsing error occurred, free everything. */
free_hook:
free (h->interfaces);
free (h);
diff --git a/pfinet/socket-ops.c b/pfinet/socket-ops.c
index 02675425..b4172dc4 100644
--- a/pfinet/socket-ops.c
+++ b/pfinet/socket-ops.c
@@ -51,12 +51,14 @@ S_socket_create (struct trivfs_protid *master,
/* Don't allow bogus SOCK_PACKET here. */
- if ((sock_type != SOCK_STREAM
- && sock_type != SOCK_DGRAM
- && sock_type != SOCK_SEQPACKET
- && sock_type != SOCK_RAW)
- || protocol < 0)
- return EINVAL;
+ if (sock_type != SOCK_STREAM
+ && sock_type != SOCK_DGRAM
+ && sock_type != SOCK_SEQPACKET
+ && sock_type != SOCK_RAW)
+ return EPROTOTYPE;
+
+ if (protocol < 0)
+ return EPROTONOSUPPORT;
__mutex_lock (&global_lock);
diff --git a/pfinet/tunnel.c b/pfinet/tunnel.c
index c4f95804..ec96861a 100644
--- a/pfinet/tunnel.c
+++ b/pfinet/tunnel.c
@@ -469,8 +469,7 @@ trivfs_S_io_select (struct trivfs_protid *cred,
tdev = (struct tunnel_device *) cred->po->cntl->hook;
/* We only deal with SELECT_READ here. */
- if (*type & ~SELECT_READ)
- return EINVAL;
+ *type &= SELECT_READ;
if (*type == 0)
return 0;
diff --git a/pflocal/Makefile b/pflocal/Makefile
index a7e664fa..7258e587 100644
--- a/pflocal/Makefile
+++ b/pflocal/Makefile
@@ -26,7 +26,7 @@ LCLHDRS = connq.h sock.h mig-decls.h mig-mutate.h sserver.h
MIGSTUBS = ioServer.o socketServer.o
OBJS = $(SRCS:.c=.o) $(MIGSTUBS)
-HURDLIBS = pipe trivfs fshelp threads ports ihash shouldbeinlibc
+HURDLIBS = pipe trivfs iohelp fshelp threads ports ihash shouldbeinlibc
MIGSFLAGS = -imacros $(srcdir)/mig-mutate.h
diff --git a/pflocal/io.c b/pflocal/io.c
index 74c2f970..36221a66 100644
--- a/pflocal/io.c
+++ b/pflocal/io.c
@@ -106,7 +106,7 @@ S_io_write (struct sock_user *user,
{
err = pipe_write (pipe, user->sock->flags & SOCK_NONBLOCK,
source_addr, data, data_len, amount);
- if (source_addr)
+ if (err && source_addr)
ports_port_deref (source_addr);
}
diff --git a/pflocal/pf.c b/pflocal/pf.c
index 852aabbb..55824d41 100644
--- a/pflocal/pf.c
+++ b/pflocal/pf.c
@@ -65,7 +65,7 @@ S_socket_create (mach_port_t pf,
case SOCK_SEQPACKET:
pipe_class = seqpack_pipe_class; break;
default:
- return ESOCKTNOSUPPORT;
+ return EPROTOTYPE;
}
err = sock_create (pipe_class, mode, &sock);
@@ -114,7 +114,7 @@ S_socket_fabricate_address (mach_port_t pf,
}
/* Implement socket_whatis_address as described in <hurd/socket.defs>.
- Since we cannot tell what our adress is, return an empty string as
+ Since we cannot tell what our address is, return an empty string as
the file name. This is primarily for the implementation of accept
and recvfrom. The functions getsockname and getpeername remain
unsupported for the local namespace. */
diff --git a/pflocal/socket.c b/pflocal/socket.c
index c5c4e1df..2684a723 100644
--- a/pflocal/socket.c
+++ b/pflocal/socket.c
@@ -37,6 +37,8 @@ S_socket_connect2 (struct sock_user *user1, struct sock_user *user2)
return EOPNOTSUPP;
err = sock_connect (user1->sock, user2->sock);
+ if (!err && user1->sock->pipe_class->flags & PIPE_CLASS_CONNECTIONLESS)
+ err = sock_connect (user2->sock, user1->sock);
/* Since USER2 isn't in the receiver position in the rpc, we get a send
right for it (although we only use the receive right with the same
@@ -309,7 +311,7 @@ S_socket_send (struct sock_user *user, struct addr *dest_addr, int flags,
if (dest_sock)
/* Grab the destination socket's read pipe directly, and stuff data
into it. This is not quite the usage sock_acquire_read_pipe was
- intended for, but it will work, as the only inappropiate errors
+ intended for, but it will work, as the only inappropriate errors
occur on a broken pipe, which shouldn't be possible with the sort of
sockets with which we can use socket_send... XXXX */
err = sock_acquire_read_pipe (dest_sock, &pipe);
diff --git a/proc/info.c b/proc/info.c
index 11625442..f35ad166 100644
--- a/proc/info.c
+++ b/proc/info.c
@@ -228,8 +228,6 @@ get_vector (task_t task,
if (err)
return err;
- /* XXX fault bad here */
-
/* Scan for a null. */
for (t = (vm_address_t *) (data + (scanned - readaddr));
t < (vm_address_t *) (data + readlen);
@@ -248,7 +246,7 @@ get_vector (task_t task,
/* If we didn't find the null terminator, then we will loop
to read an additional page. */
- scanned = data + readlen;
+ scanned = readaddr + readlen;
munmap ((caddr_t) data, readlen);
} while (!err && *vec == NULL);
diff --git a/proc/mgt.c b/proc/mgt.c
index 5373d101..1180c700 100644
--- a/proc/mgt.c
+++ b/proc/mgt.c
@@ -499,7 +499,7 @@ S_proc_exception_raise (mach_port_t excport,
mach_port_destroy (mach_task_self (), thread);
- return 0;
+ return MIG_NO_REPLY;
}
}
diff --git a/release/SOURCES.0.0 b/release/SOURCES.0.0
index 1f561ad6..673f8dd1 100644
--- a/release/SOURCES.0.0
+++ b/release/SOURCES.0.0
@@ -107,5 +107,5 @@ sh-utils (1.12m from alpha.gnu.ai.mit.edu)
[ copy libc's time/strftime.c into lib/strftime.c to fix a date bug. ]
make (3.74.5 from alpha.gnu.ai.mit.edu; unmodified)
gdb (Modified from Cygnus snapshot of 960526)
-mach4 (UK22, slighly hacked) [already includes `serverboot' program.]
+mach4 (UK22, slightly hacked) [already includes `serverboot' program.]
libc (1.93, with modifications)
diff --git a/release/mkfsimage.sh b/release/mkfsimage.sh
index 181928f8..07b142f0 100644
--- a/release/mkfsimage.sh
+++ b/release/mkfsimage.sh
@@ -75,7 +75,7 @@ while :; do
--help Display this help and exit
--version Output version information and exit
-If multiple SRCs are specified, then each occurance of --files pertains only to
+If multiple SRCs are specified, then each occurrence of --files pertains only to
the corresponding SRC.
Each FILE named in a --copy-rules option contains lines of the form:
@@ -83,8 +83,8 @@ Each FILE named in a --copy-rules option contains lines of the form:
[gzip] [rename TARGET] COPY-OP NAME
and says to copy NAME from the source tree to the destination, using the
-method specified by COPY-OP. A preceeding "\`"rename TARGET"\'" says to give
-NAME a different name in the target tree, and a preceeding "\`"gzip"\'" says
+method specified by COPY-OP. A preceding "\`"rename TARGET"\'" says to give
+NAME a different name in the target tree, and a preceding "\`"gzip"\'" says
to compress the result (appending .gz to the name). COPY-OP may be one of the
following:
diff --git a/serverboot/Makefile b/serverboot/Makefile
deleted file mode 100644
index 653d5963..00000000
--- a/serverboot/Makefile
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright (C) 1997,99,2001,02 Free Software Foundation, Inc.
-# This file is part of the GNU Hurd.
-#
-# The GNU Hurd 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, or (at your option)
-# any later version.
-#
-# The GNU Hurd 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 the GNU Hurd; see the file COPYING. If not, write to
-# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-dir := serverboot
-makemode := utility
-
-SRCS = bootstrap.c ffs_compat.c load.c wiring.c \
- ffs_file_io.c minix_ffs_compat.c file_io.c \
- minix_file_io.c ext2_file_io.c strfcns.c exec.c \
- panic.c elf-load.c gunzip.c bunzip2.c
-LCLHDRS = assert.h disk_inode_ffs.h fs.h queue.h defs.h \
- minix_ffs_compat.h wiring.h dir.h ffs_compat.h minix_fs.h \
- disk_inode.h file_io.h minix_super.h mach-exec.h
-EXTRA_DIST = def_pager_setup.c default_pager.c kalloc.c
-target = serverboot
-HURDLIBS = threads
-installationdir = $(bootdir)
-
-UNZIP_OBJS = unzip.o inflate.o util.o do-bunzip2.o
-OBJS = $(subst .c,.o,$(SRCS)) \
- boot_script.o userland-boot.o \
- $(UNZIP_OBJS)
-
-include ../Makeconf
-
-vpath boot_script.c $(srcdir)/../boot
-vpath userland-boot.c $(srcdir)/../boot
-
-# Look for zip stuff
-vpath %.c $(srcdir) $(srcdir)/../exec
-
-# If SMALL_BZIP2 is defined, use relatively small memory.
-# It's crucial for serverboot, because swap is not enabled yet.
-CPPFLAGS += -I$(srcdir)/../exec -DGZIP -DBZIP2 -DSMALL_BZIP2
-
-LDFLAGS += -static
-
-# Don't even bother.
-CFLAGS := $(filter-out -Wall,$(CFLAGS))
diff --git a/serverboot/assert.h b/serverboot/assert.h
deleted file mode 100644
index 9f70aec3..00000000
--- a/serverboot/assert.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-
-#ifndef _ASSERT_H_
-#define _ASSERT_H_
-
-#ifdef ASSERTIONS
-extern void Assert();
-
-#define assert(ex) \
- do { \
- if (!(ex)) \
- Assert(__FILE__, __LINE__); \
- } while (0)
-
-#ifdef lint
-#define assert_static(x)
-#else /* lint */
-#define assert_static(x) assert(x)
-#endif /* lint */
-
-#else /* ASSERTIONS */
-#define assert(ex)
-#define assert_static(ex)
-#endif /* ASSERTIONS */
-
-#endif /* _ASSERT_H_ */
diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c
deleted file mode 100644
index 64f7c5eb..00000000
--- a/serverboot/bootstrap.c
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1992,1991,1990,1989 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the
- * rights to redistribute these changes.
- */
-/*
- * Bootstrap the various built-in servers.
- */
-
-#include <mach.h>
-#include <mach/message.h>
-#include <sys/reboot.h>
-
-#include <file_io.h>
-
-#include <stdio.h>
-#include <string.h>
-
-#include "../boot/boot_script.h"
-
-#if 0
-/*
- * Use 8 Kbyte stacks instead of the default 64K.
- * Use 4 Kbyte waiting stacks instead of the default 8K.
- */
-#if defined(alpha)
-vm_size_t cthread_stack_size = 16 * 1024;
-#else
-vm_size_t cthread_stack_size = 8 * 1024;
-#endif
-#endif
-
-extern
-vm_size_t cthread_wait_stack_size;
-
-mach_port_t bootstrap_master_device_port; /* local name */
-mach_port_t bootstrap_master_host_port; /* local name */
-
-int boot_load_program();
-
-char *root_name;
-char boot_script_name[MAXPATHLEN];
-
-extern void default_pager();
-extern void default_pager_initialize();
-extern void default_pager_setup();
-
-/*
- * Convert ASCII to integer.
- */
-int atoi(str)
- register const char *str;
-{
- register int n;
- register int c;
- int is_negative = 0;
-
- n = 0;
- while (*str == ' ')
- str++;
- if (*str == '-') {
- is_negative = 1;
- str++;
- }
- while ((c = *str++) >= '0' && c <= '9') {
- n = n * 10 + (c - '0');
- }
- if (is_negative)
- n = -n;
- return (n);
-}
-
-__main ()
-{
-}
-
-static void
-boot_panic (kern_return_t err)
-{
-#define PFX "bootstrap: "
- char *err_string = boot_script_error_string (err);
- char panic_string[strlen (err_string) + sizeof (PFX)];
- strcpy (panic_string, PFX);
- strcat (panic_string, err_string);
- panic (panic_string);
-#undef PFX
-}
-
-void
-safe_gets (char *str, int maxlen)
-{
- char *c = fgets (str, maxlen, stdin);
- if (c == 0) {
- perror ("fgets");
- panic ("cannot read from console");
- }
- c = strchr (c, '\n');
- if (c)
- *c = '\0';
- printf ("\r\n");
-}
-
-printf_init (device_t master)
-{
- mach_port_t cons;
- kern_return_t rc;
- rc = device_open (master, D_READ|D_WRITE, "console", &cons);
- if (rc)
- while (1) {
- volatile int x = 0;
- (void) host_reboot(bootstrap_master_host_port, RB_DEBUGGER);
- x = x / x;
- }
- stdin = mach_open_devstream (cons, "r");
- stdout = stderr = mach_open_devstream (cons, "w");
- mach_port_deallocate (mach_task_self (), cons);
- setbuf (stdout, 0);
-}
-
-/*
- * Bootstrap task.
- * Runs in user spacep.
- *
- * Called as 'boot -switches host_port device_port root_name'
- *
- */
-main(argc, argv)
- int argc;
- char **argv;
-{
- int die = 0;
- int script_paging_file (const struct cmd *cmd, integer_t *val)
- {
- printf ("*** paging files no longer supported in boot scripts ***\n\a"
- "*** use swapon %s and/or /etc/fstab instead ***\n",
- cmd->path);
- return 0;
- }
- int script_serverboot_ctl (const struct cmd *cmd, integer_t *val)
- {
- const char *const ctl = cmd->path;
- if (!strcmp (ctl, "die"))
- die = 1;
- else
- printf ("(serverboot): Unknown control word `%s' ignored\n", ctl);
- return 0;
- }
-
- void prompt_for_root ()
- {
- static char new_root[MAXPATHLEN/2];
-
- if (!root_name)
- root_name = "UNKNOWN";
- printf ("Root device name? [%s] ", root_name);
- safe_gets(new_root, sizeof(new_root));
-
- if (new_root[0] != '\0') {
- root_name = new_root;
- (void) strbuild(boot_script_name,
- "/dev/",
- root_name,
- "/boot/servers.boot",
- (char *)0);
- }
- }
-
- register kern_return_t result;
- struct file scriptf;
-
- task_t my_task = mach_task_self();
-
- char *flag_string;
-
- boolean_t ask_boot_script = 0;
- boolean_t ask_root_name = 0;
-
- /*
- * Use 4Kbyte cthread wait stacks.
- */
- cthread_wait_stack_size = 4 * 1024;
-
- /*
- * Arg 1 is flags
- */
- if (argv[1][0] != '-')
- panic("bootstrap: no flags");
-
- flag_string = argv[1];
-
- /*
- * Parse the arguments.
- */
- if (argc >= 5)
- {
- /*
- * Arg 0 is program name
- */
-
- /*
- * Arg 2 is host port number
- */
- bootstrap_master_host_port = atoi(argv[2]);
-
- /*
- * Arg 3 is device port number
- */
- bootstrap_master_device_port = atoi(argv[3]);
-
- /*
- * Arg 4 is root name
- */
- root_name = argv[4];
- }
- else if (argc == 3)
- {
- root_name = argv[2];
-
- get_privileged_ports (&bootstrap_master_host_port,
- &bootstrap_master_device_port);
- }
-
- printf_init(bootstrap_master_device_port);
-#ifdef pleasenoXXX
- panic_init(bootstrap_master_host_port);
-#endif
-
-
- /*
- * If the '-a' (ask) switch was specified, or if no
- * root device was specificed, ask for the root device.
- */
-
- if (!root_name || root_name [0] == '\0' || index(flag_string, 'a'))
- prompt_for_root ();
-
- (void) strbuild(boot_script_name,
- "/dev/",
- root_name,
- "/boot/servers.boot",
- (char *)0);
- /*
- * If the '-q' (query) switch was specified, ask for the
- * server boot script.
- */
-
- if (index(flag_string, 'q'))
- ask_boot_script = TRUE;
-
- while (TRUE) {
- if (ask_root_name)
- prompt_for_root ();
-
- if (ask_boot_script) {
- char new_boot_script[MAXPATHLEN];
-
- printf("Server boot script? [%s] ", boot_script_name);
- safe_gets(new_boot_script, sizeof(new_boot_script));
- if (new_boot_script[0] != '\0')
- strcpy(boot_script_name, new_boot_script);
- }
-
- result = open_file(bootstrap_master_device_port,
- boot_script_name,
- &scriptf);
- if (result == D_NO_SUCH_DEVICE)
- {
- printf ("Root device `%s' does not exist!\n", root_name);
- ask_root_name = ask_boot_script = TRUE;
- continue;
- }
- else
- ask_root_name = FALSE;
- if (result != 0) {
- printf("Can't open server boot script %s: %s\n",
- boot_script_name,
- strerror (result));
- ask_boot_script = TRUE;
- continue;
- }
- break;
- }
-
- /*
- * If the server boot script name was changed,
- * then use the new device name as the root device.
- */
- {
- char *dev, *end;
- int len;
-
- dev = boot_script_name;
- if (strncmp(dev, "/dev/", 5) == 0)
- dev += 5;
- end = strchr(dev, '/');
- len = end ? end-dev : strlen(dev);
- memcpy(root_name, dev, len);
- root_name[len] = 0;
- }
-
- {
- char *cmdline;
-
- /* Initialize boot script variables. */
- if (boot_script_set_variable ("host-port", VAL_PORT,
- (integer_t) bootstrap_master_host_port)
- || boot_script_set_variable ("device-port", VAL_PORT,
- (integer_t) bootstrap_master_device_port)
- || boot_script_set_variable ("root-device", VAL_STR,
- (integer_t) root_name)
- || boot_script_set_variable ("boot-args", VAL_STR,
- (integer_t) flag_string)
- || boot_script_define_function ("add-paging-file", VAL_NONE,
- &script_paging_file)
- || boot_script_define_function ("add-raw-paging-file", VAL_NONE,
- &script_paging_file)
- || boot_script_define_function ("add-linux-paging-file",
- VAL_NONE,
- &script_paging_file)
- || boot_script_define_function ("serverboot",
- VAL_NONE,
- &script_serverboot_ctl)
- )
- panic ("bootstrap: error setting boot script variables");
-
- cmdline = getenv ("MULTIBOOT_CMDLINE");
- if (cmdline != NULL
- && boot_script_set_variable ("kernel-command-line",
- VAL_STR,
- (integer_t) cmdline))
- panic ("bootstrap: error setting boot script variables");
-
- parse_script (&scriptf);
- close_file (&scriptf);
- }
-
- if (index (flag_string, 'd'))
- {
- char xx[5];
- printf ("Hit return to boot...");
- safe_gets (xx, sizeof xx);
- }
-
- result = boot_script_exec ();
-
- if (result)
- boot_panic (result);
-
-#if 0
- {
- /*
- * Delete the old stack (containing only the arguments).
- */
- vm_offset_t addr = (vm_offset_t) argv;
-
- vm_offset_t r_addr;
- vm_size_t r_size;
- vm_prot_t r_protection, r_max_protection;
- vm_inherit_t r_inheritance;
- boolean_t r_is_shared;
- memory_object_name_t r_object_name;
- vm_offset_t r_offset;
- kern_return_t kr;
-
- r_addr = addr;
-
- kr = vm_region(my_task,
- &r_addr,
- &r_size,
- &r_protection,
- &r_max_protection,
- &r_inheritance,
- &r_is_shared,
- &r_object_name,
- &r_offset);
- if ((kr == KERN_SUCCESS) && MACH_PORT_VALID(r_object_name))
- (void) mach_port_deallocate(my_task, r_object_name);
- if ((kr == KERN_SUCCESS) &&
- (r_addr <= addr) &&
- ((r_protection & (VM_PROT_READ|VM_PROT_WRITE)) ==
- (VM_PROT_READ|VM_PROT_WRITE)))
- (void) vm_deallocate(my_task, r_addr, r_size);
- }
-#endif
-
- printf ("(serverboot): terminating\n");
- while (1)
- task_terminate (mach_task_self ());
- /*NOTREACHED*/
-}
-
-/* Parse the boot script. */
-parse_script (struct file *f)
-{
- char *p, *line, *buf;
- int amt, fd, err;
- int n = 0;
-
- buf = malloc (f->f_size + 1); /* add one for null terminator we will write */
- err = read_file (f, 0, buf, f->f_size, 0);
- if (err)
- panic ("bootstrap: error reading boot script file: %s", strerror (err));
-
- line = p = buf;
- while (1)
- {
- while (p < buf + f->f_size && *p != '\n')
- p++;
- *p = '\0';
- err = boot_script_parse_line (0, line);
- if (err)
- boot_panic (err);
- if (p == buf + f->f_size)
- break;
- line = ++p;
- }
- free (buf);
-}
diff --git a/serverboot/bunzip2.c b/serverboot/bunzip2.c
deleted file mode 100644
index 9f79ade5..00000000
--- a/serverboot/bunzip2.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/* Modified by okuji@kuicr.kyoto-u.ac.jp for use in serverboot. */
-/* Decompressing store backend
-
- Copyright (C) 1997 Free Software Foundation, Inc.
- Written by Miles Bader <miles@gnu.ai.mit.edu>
- This file is part of the GNU Hurd.
-
- The GNU Hurd 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, or (at
- your option) any later version.
-
- The GNU Hurd 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
-
-#include <stdio.h>
-#include <string.h>
-#include <setjmp.h>
-#include <cthreads.h>
-#include <errno.h>
-
-#include <file_io.h>
-
-#define IN_BUFFERING (256*1024)
-#define OUT_BUFFERING (512*1024)
-
-static struct mutex bunzip2_lock = MUTEX_INITIALIZER;
-
-/* Uncompress the contents of FROM, which should contain a valid bzip2 file,
- into memory, returning the result buffer in BUF & BUF_LEN. */
-int
-serverboot_bunzip2 (struct file *from, void **buf, size_t *buf_len)
-{
- /* Callbacks from do_bunzip2 for I/O and error interface. */
- extern int (*unzip_read) (char *buf, size_t maxread);
- extern void (*unzip_write) (const char *buf, size_t nwrite);
- extern void (*unzip_read_error) (void);
- extern void (*unzip_error) (const char *msg);
-
- /* How we return errors from our hook functions. */
- jmp_buf zerr_jmp_buf;
- int zerr;
-
- size_t offset = 0; /* Offset of read point in FROM. */
-
- /* Read at most MAXREAD (or 0 if eof) bytes into BUF from our current
- position in FROM. */
- int zread (char *buf, size_t maxread)
- {
- vm_size_t resid;
- size_t did_read;
-
- if (from->f_size - offset < maxread)
- did_read = from->f_size - offset;
- else
- did_read = maxread;
-
- zerr = read_file (from, offset, buf, did_read, &resid);
- if (zerr)
- longjmp (zerr_jmp_buf, 1);
-
- did_read -= resid;
- offset += did_read;
-
- return did_read;
- }
-
- size_t out_buf_offs = 0; /* Position in the output buffer. */
-
- /* Write uncompress data to our output buffer. */
- void zwrite (const char *wbuf, size_t nwrite)
- {
- size_t old_buf_len = *buf_len;
-
- if (out_buf_offs + nwrite > old_buf_len)
- /* Have to grow the output buffer. */
- {
- void *old_buf = *buf;
- void *new_buf = old_buf + old_buf_len; /* First try. */
- size_t new_buf_len = round_page (old_buf_len + old_buf_len + nwrite);
-
- /* Try to grow the buffer. */
- zerr =
- vm_allocate (mach_task_self (),
- (vm_address_t *)&new_buf, new_buf_len - old_buf_len,
- 0);
- if (zerr)
- /* Can't do that, try to make a bigger buffer elsewhere. */
- {
- new_buf = old_buf;
- zerr =
- vm_allocate (mach_task_self (),
- (vm_address_t *)&new_buf, new_buf_len, 1);
- if (zerr)
- longjmp (zerr_jmp_buf, 1);
-
- if (out_buf_offs > 0)
- /* Copy the old buffer into the start of the new & free it. */
- bcopy (old_buf, new_buf, out_buf_offs);
-
- vm_deallocate (mach_task_self (),
- (vm_address_t)old_buf, old_buf_len);
-
- *buf = new_buf;
- }
-
- *buf_len = new_buf_len;
- }
-
- bcopy (wbuf, *buf + out_buf_offs, nwrite);
- out_buf_offs += nwrite;
- }
-
- void zreaderr (void)
- {
- zerr = EIO;
- longjmp (zerr_jmp_buf, 1);
- }
- void zerror (const char *msg)
- {
- zerr = EINVAL;
- longjmp (zerr_jmp_buf, 2);
- }
-
- /* Try to guess a reasonable output buffer size. */
- *buf_len = round_page (from->f_size * 2);
- zerr = vm_allocate (mach_task_self (), (vm_address_t *)buf, *buf_len, 1);
- if (zerr)
- return zerr;
-
- mutex_lock (&bunzip2_lock);
-
- unzip_read = zread;
- unzip_write = zwrite;
- unzip_read_error = zreaderr;
- unzip_error = zerror;
-
- if (! setjmp (zerr_jmp_buf))
- {
- /* Call the bunzip2 engine. */
- do_bunzip2 ();
- zerr = 0;
- }
-
- mutex_unlock (&bunzip2_lock);
-
- if (zerr)
- {
- if (*buf_len > 0)
- vm_deallocate (mach_task_self (), (vm_address_t)*buf, *buf_len);
- }
- else if (out_buf_offs < *buf_len)
- /* Trim the output buffer to be the right length. */
- {
- size_t end = round_page (out_buf_offs);
- if (end < *buf_len)
- vm_deallocate (mach_task_self (),
- (vm_address_t)(*buf + end), *buf_len - end);
- *buf_len = out_buf_offs;
- }
-
- return zerr;
-}
diff --git a/serverboot/def_pager_setup.c b/serverboot/def_pager_setup.c
deleted file mode 100644
index 5e2073ec..00000000
--- a/serverboot/def_pager_setup.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1992-1989 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-#include <mach.h>
-#include <mach/mig_errors.h>
-#include <mach/default_pager_types.h>
-
-#include <file_io.h>
-
-extern void *kalloc();
-
-/*
- * Create a paging partition given a file name
- */
-extern void create_paging_partition();
-
-kern_return_t
-add_paging_file(master_device_port, file_name, linux_signature)
- mach_port_t master_device_port;
- char *file_name;
- int linux_signature;
-{
- register struct file_direct *fdp;
- register kern_return_t result;
- struct file pfile;
- boolean_t isa_file;
-
- bzero((char *) &pfile, sizeof(struct file));
-
- result = open_file(master_device_port, file_name, &pfile);
- if (result != KERN_SUCCESS)
- return result;
-
- fdp = (struct file_direct *) kalloc(sizeof *fdp);
- bzero((char *) fdp, sizeof *fdp);
-
- isa_file = file_is_structured(&pfile);
-
- result = open_file_direct(pfile.f_dev, fdp, isa_file);
- if (result)
- panic("Can't open paging file %s: %s\n",
- file_name, strerror (result));
-
- result = add_file_direct(fdp, &pfile);
- if (result)
- panic("Can't read disk addresses: %s\n", strerror (result));
-
- close_file(&pfile);
-
- /*
- * Set up the default paging partition
- */
- create_paging_partition(file_name, fdp, isa_file, linux_signature);
-
- return result;
-}
-
-/*
- * Destroy a paging_partition given a file name
- */
-kern_return_t
-remove_paging_file(file_name)
- char *file_name;
-{
- struct file_direct *fdp = 0;
- kern_return_t kr;
-
- kr = destroy_paging_partition(file_name, &fdp);
- if (kr == KERN_SUCCESS) {
- remove_file_direct(fdp);
- kfree(fdp, sizeof(*fdp));
- }
- return kr;
-}
-
-kern_return_t
-default_pager_paging_storage (mach_port_t pager,
- mach_port_t device,
- recnum_t *runs, mach_msg_type_number_t nrun,
- default_pager_filename_t name,
- boolean_t add)
-{
- return MIG_BAD_ID;
-}
-
-#if 0 /* no longer used */
-/*
- * Set up default pager
- */
-extern char *strbuild();
-
-boolean_t
-default_pager_setup(master_device_port, server_dir_name)
- mach_port_t master_device_port;
- char *server_dir_name;
-{
- register kern_return_t result;
-
- char paging_file_name[MAXPATHLEN+1];
-
- (void) strbuild(paging_file_name,
- server_dir_name,
- "/paging_file",
- (char *)0);
-
- while (TRUE) {
- result = add_paging_file(master_device_port, paging_file_name);
- if (result == KERN_SUCCESS)
- break;
- printf("Can't open paging file %s: %d\n",
- paging_file_name,
- result);
-
- bzero(paging_file_name, sizeof(paging_file_name));
- printf("Paging file name ? ");
- safe_gets(paging_file_name, sizeof(paging_file_name));
-
- if (paging_file_name[0] == 0) {
- printf("*** WARNING: running without paging area!\n");
- return FALSE;
- }
- }
-
- /*
- * Our caller will become the default pager - later
- */
-
- return TRUE;
-}
-#endif
diff --git a/serverboot/defs.h b/serverboot/defs.h
deleted file mode 100644
index 7b872fd6..00000000
--- a/serverboot/defs.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * Common definitions for Berkeley Fast File System.
- */
-
-/*
- * Compatibility definitions for disk IO.
- */
-
-/*
- * Disk devices do all IO in 512-byte blocks.
- */
-#define DEV_BSIZE 512
-
-/*
- * Conversion between bytes and disk blocks.
- */
-#define btodb(byte_offset) ((byte_offset) >> 9)
-#define dbtob(block_number) ((block_number) << 9)
-
-/*
- * Compatibility definitions for old type names.
- */
-
-typedef struct _quad_ {
- unsigned int val[2]; /* 2 int values make... */
-} quad; /* an 8-byte item */
-
-#if 0
-typedef unsigned char u_char; /* unsigned char */
-typedef unsigned short u_short; /* unsigned short */
-typedef unsigned int u_int; /* unsigned int */
-
-typedef unsigned int time_t; /* an unsigned int */
-typedef unsigned int daddr_t; /* an unsigned int */
-typedef unsigned int off_t; /* another unsigned int */
-
-typedef unsigned short uid_t;
-typedef unsigned short gid_t;
-typedef unsigned int ino_t;
-#endif
-
-#define NBBY 8
-
-/*
- * The file system is made out of blocks of at most MAXBSIZE units,
- * with smaller units (fragments) only in the last direct block.
- * MAXBSIZE primarily determines the size of buffers in the buffer
- * pool. It may be made larger without any effect on existing
- * file systems; however, making it smaller may make some file
- * systems unmountable.
- *
- * Note that the disk devices are assumed to have DEV_BSIZE "sectors"
- * and that fragments must be some multiple of this size.
- */
-#define MAXBSIZE 8192
-#define MAXFRAG 8
-
-/*
- * MAXPATHLEN defines the longest permissible path length
- * after expanding symbolic links.
- *
- * MAXSYMLINKS defines the maximum number of symbolic links
- * that may be expanded in a path name. It should be set
- * high enough to allow all legitimate uses, but halt infinite
- * loops reasonably quickly.
- */
-
-#define MAXPATHLEN 1024
-#define MAXSYMLINKS 8
-
diff --git a/serverboot/dir.h b/serverboot/dir.h
deleted file mode 100644
index 208df5ce..00000000
--- a/serverboot/dir.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * Copyright (c) 1982, 1986, 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#)dir.h 7.6 (Berkeley) 5/9/89
- */
-
-#ifndef _BOOT_UFS_DIR_H_
-#define _BOOT_UFS_DIR_H_
-
-/*
- * A directory consists of some number of blocks of DIRBLKSIZ
- * bytes, where DIRBLKSIZ is chosen such that it can be transferred
- * to disk in a single atomic operation (e.g. 512 bytes on most machines).
- *
- * Each DIRBLKSIZ byte block contains some number of directory entry
- * structures, which are of variable length. Each directory entry has
- * a struct direct at the front of it, containing its inode number,
- * the length of the entry, and the length of the name contained in
- * the entry. These are followed by the name padded to a 4 byte boundary
- * with null bytes. All names are guaranteed null terminated.
- * The maximum length of a name in a directory is MAXNAMLEN.
- *
- * The macro DIRSIZ(dp) gives the amount of space required to represent
- * a directory entry. Free space in a directory is represented by
- * entries which have dp->d_reclen > DIRSIZ(dp). All DIRBLKSIZ bytes
- * in a directory block are claimed by the directory entries. This
- * usually results in the last entry in a directory having a large
- * dp->d_reclen. When entries are deleted from a directory, the
- * space is returned to the previous entry in the same directory
- * block by increasing its dp->d_reclen. If the first entry of
- * a directory block is free, then its dp->d_ino is set to 0.
- * Entries other than the first in a directory do not normally have
- * dp->d_ino set to 0.
- */
-#define DIRBLKSIZ DEV_BSIZE
-#define MAXNAMLEN 255
-
-struct direct {
- u_int d_ino; /* inode number of entry */
- u_short d_reclen; /* length of this record */
- u_short d_namlen; /* length of string in d_name */
- char d_name[MAXNAMLEN + 1]; /* name with length <= MAXNAMLEN */
-};
-
-/*
- * The DIRSIZ macro gives the minimum record length which will hold
- * the directory entry. This requires the amount of space in struct direct
- * without the d_name field, plus enough space for the name with a terminating
- * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
- */
-#undef DIRSIZ
-#define DIRSIZ(dp) \
- ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
-
-#ifdef KERNEL
-/*
- * Template for manipulating directories.
- * Should use struct direct's, but the name field
- * is MAXNAMLEN - 1, and this just won't do.
- */
-struct dirtemplate {
- u_int dot_ino;
- short dot_reclen;
- short dot_namlen;
- char dot_name[4]; /* must be multiple of 4 */
- u_int dotdot_ino;
- short dotdot_reclen;
- short dotdot_namlen;
- char dotdot_name[4]; /* ditto */
-};
-#endif
-
-/*
- * The following information should be obtained from <dirent.h>
- * and is provided solely (and temporarily) for backward compatibility.
- */
-#ifndef KERNEL
-#define d_fileno d_ino /* compatibility with POSIX */
-#ifndef DEV_BSIZE
-#define DEV_BSIZE 512
-#endif
-/*
- * Definitions for library routines operating on directories.
- */
-typedef struct _dirdesc {
- int dd_fd;
- int dd_loc;
- int dd_size;
- char dd_buf[DIRBLKSIZ];
-} DIR;
-
-#define dirfd(dirp) ((dirp)->dd_fd)
-
-#ifndef NULL
-#define NULL 0
-#endif
-extern DIR *opendir();
-extern struct direct *readdir();
-extern int telldir();
-extern void seekdir();
-#define rewinddir(dirp) seekdir((dirp), (long)0)
-extern void closedir();
-#endif /* not KERNEL */
-#endif /* _BOOT_UFS_DIR_H_ */
diff --git a/serverboot/disk_inode.h b/serverboot/disk_inode.h
deleted file mode 100644
index 6eed9104..00000000
--- a/serverboot/disk_inode.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * Copyright (c) 1982, 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#)inode.h 7.5 (Berkeley) 7/3/89
- */
-
-#ifndef _BOOT_UFS_DISK_INODE_H_
-#define _BOOT_UFS_DISK_INODE_H_
-
-/*
- * The I node is the focus of all file activity in the BSD Fast File System.
- * There is a unique inode allocated for each active file,
- * each current directory, each mounted-on file, text file, and the root.
- * An inode is 'named' by its dev/inumber pair. (iget/iget.c)
- * Data in icommon is read in from permanent inode on volume.
- */
-
-#define FFS_NDADDR 12 /* direct addresses in inode */
-#define FFS_NIADDR 3 /* indirect addresses in inode */
-
-#define FFS_MAX_FASTLINK_SIZE ((FFS_NDADDR + FFS_NIADDR) * sizeof(daddr_t))
-
-struct icommon {
- u_short ic_mode; /* 0: mode and type of file */
- short ic_nlink; /* 2: number of links to file */
- short ic_uid; /* 4: owner's user id */
- short ic_gid; /* 6: owner's group id */
- quad ic_size; /* 8: number of bytes in file */
- time_t ic_atime; /* 16: time last accessed */
- int ic_atspare;
- time_t ic_mtime; /* 24: time last modified */
- int ic_mtspare;
- time_t ic_ctime; /* 32: last time inode changed */
- int ic_ctspare;
- union {
- struct {
- daddr_t Mb_db[FFS_NDADDR]; /* 40: disk block addresses */
- daddr_t Mb_ib[FFS_NIADDR]; /* 88: indirect blocks */
- } ic_Mb;
- char ic_Msymlink[FFS_MAX_FASTLINK_SIZE];
- /* 40: symbolic link name */
- } ic_Mun;
-#define ic_db ic_Mun.ic_Mb.Mb_db
-#define ic_ib ic_Mun.ic_Mb.Mb_ib
-#define ic_symlink ic_Mun.ic_Msymlink
- int ic_flags; /* 100: status, currently unused */
- int ic_blocks; /* 104: blocks actually held */
- int ic_gen; /* 108: generation number */
- int ic_spare[4]; /* 112: reserved, currently unused */
-} i_ic;
-
-/*
- * Same structure, but on disk.
- */
-struct dinode {
- union {
- struct icommon di_com;
- char di_char[128];
- } di_un;
-};
-#define di_ic di_un.di_com
-
-#endif /* _BOOT_UFS_DISK_INODE_H_ */
diff --git a/serverboot/disk_inode_ffs.h b/serverboot/disk_inode_ffs.h
deleted file mode 100644
index ab352f84..00000000
--- a/serverboot/disk_inode_ffs.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * Copyright (c) 1982, 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#)inode.h 7.5 (Berkeley) 7/3/89
- */
-
-#ifndef _BOOT_UFS_DISK_INODE_FFS_H_
-#define _BOOT_UFS_DISK_INODE_FFS_H_
-
-#define NDADDR FFS_NDADDR
-#define NIADDR FFS_NIADDR
-
-#define MAX_FASTLINK_SIZE FFS_MAX_FASTLINK_SIZE
-
-#define IC_FASTLINK 0x0001 /* Symbolic link in inode */
-
-#define i_mode i_ic.ic_mode
-#define i_nlink i_ic.ic_nlink
-#define i_uid i_ic.ic_uid
-#define i_gid i_ic.ic_gid
-#if BYTE_MSF
-#define i_size i_ic.ic_size.val[1]
-#else /* BYTE_LSF */
-#define i_size i_ic.ic_size.val[0]
-#endif
-#define i_db i_ic.ic_db
-#define i_ib i_ic.ic_ib
-#define i_atime i_ic.ic_atime
-#define i_mtime i_ic.ic_mtime
-#define i_ctime i_ic.ic_ctime
-#define i_blocks i_ic.ic_blocks
-#define i_rdev i_ic.ic_db[0]
-#define i_symlink i_ic.ic_symlink
-#define i_flags i_ic.ic_flags
-#define i_gen i_ic.ic_gen
-
-/* modes */
-#define IFMT 0xf000 /* type of file */
-#define IFCHR 0x2000 /* character special */
-#define IFDIR 0x4000 /* directory */
-#define IFBLK 0x6000 /* block special */
-#define IFREG 0x8000 /* regular */
-#define IFLNK 0xa000 /* symbolic link */
-#define IFSOCK 0xc000 /* socket */
-
-
-#define ISUID 0x0800 /* set user id on execution */
-#define ISGID 0x0400 /* set group id on execution */
-#define ISVTX 0x0200 /* save swapped text even after use */
-#define IREAD 0x0100 /* read, write, execute permissions */
-#define IWRITE 0x0080
-#define IEXEC 0x0040
-
-#define f_fs u.ffs.ffs_fs
-#define i_ic u.ffs.ffs_ic
-#define f_nindir u.ffs.ffs_nindir
-#define f_blk u.ffs.ffs_blk
-#define f_blksize u.ffs.ffs_blksize
-#define f_blkno u.ffs.ffs_blkno
-
-#endif /* _BOOT_UFS_DISK_INODE_FFS_H_ */
diff --git a/serverboot/elf-load.c b/serverboot/elf-load.c
deleted file mode 100644
index 603eadf0..00000000
--- a/serverboot/elf-load.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (c) 1995, 1994, 1993, 1992, 1991, 1990
- * Open Software Foundation, Inc.
- *
- * Permission to use, copy, modify, and distribute this software and
- * its documentation for any purpose and without fee is hereby granted,
- * provided that the above copyright notice appears in all copies and
- * that both the copyright notice and this permission notice appear in
- * supporting documentation, and that the name of ("OSF") or Open Software
- * Foundation not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- *
- * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL OSF BE LIABLE FOR ANY
- * SPECIAL, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
- * ACTION OF CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE
- */
-/*
- * OSF Research Institute MK6.1 (unencumbered) 1/31/1995
- */
-
-#include <alloca.h>
-#include <mach/machine/vm_types.h>
-#include <elf.h>
-#include "mach-exec.h"
-
-int exec_load(exec_read_func_t *read, exec_read_exec_func_t *read_exec,
- void *handle, exec_info_t *out_info)
-{
- vm_size_t actual;
- union { Elf32_Ehdr h; Elf64_Ehdr h64; } x;
- int i;
- int result;
-
- /* Read the ELF header. */
- if ((result = (*read)(handle, 0, &x, sizeof(x), &actual)) != 0)
- return result;
- if (actual < sizeof(x))
- return EX_NOT_EXECUTABLE;
-
- if ((x.h.e_ident[EI_MAG0] != ELFMAG0) ||
- (x.h.e_ident[EI_MAG1] != ELFMAG1) ||
- (x.h.e_ident[EI_MAG2] != ELFMAG2) ||
- (x.h.e_ident[EI_MAG3] != ELFMAG3))
- return EX_NOT_EXECUTABLE;
-
- /* Make sure the file is of the right architecture. */
-#ifdef i386
-# define MY_CLASS ELFCLASS32
-# define MY_DATA ELFDATA2LSB
-# define MY_MACHINE EM_386
-#elif defined __alpha__
-# define MY_CLASS ELFCLASS64
-# define MY_DATA ELFDATA2LSB
-# define MY_MACHINE EM_ALPHA
-#else
-#error Not ported to this architecture!
-#endif
-
- if ((x.h.e_ident[EI_CLASS] != MY_CLASS) ||
- (x.h.e_ident[EI_DATA] != MY_DATA))
- return EX_WRONG_ARCH;
-
- if (MY_CLASS == ELFCLASS64)
- {
- Elf64_Phdr *phdr, *ph;
- vm_size_t phsize;
-
- if (x.h64.e_machine != MY_MACHINE)
- return EX_WRONG_ARCH;
-
- /* XXX others */
- out_info->entry = (vm_offset_t) x.h64.e_entry;
- out_info->init_dp = 0; /* ? */
-
- phsize = x.h64.e_phnum * x.h64.e_phentsize;
- phdr = (Elf64_Phdr *)alloca(phsize);
-
- result = (*read)(handle, x.h64.e_phoff, phdr, phsize, &actual);
- if (result)
- return result;
- if (actual < phsize)
- return EX_CORRUPT;
-
- for (i = 0; i < x.h64.e_phnum; i++)
- {
- ph = (Elf64_Phdr *)((vm_offset_t)phdr + i * x.h64.e_phentsize);
- if (ph->p_type == PT_LOAD)
- {
- exec_sectype_t type = EXEC_SECTYPE_ALLOC |
- EXEC_SECTYPE_LOAD;
- if (ph->p_flags & PF_R) type |= EXEC_SECTYPE_READ;
- if (ph->p_flags & PF_W) type |= EXEC_SECTYPE_WRITE;
- if (ph->p_flags & PF_X) type |= EXEC_SECTYPE_EXECUTE;
- result = (*read_exec)(handle,
- ph->p_offset, ph->p_filesz,
- ph->p_vaddr, ph->p_memsz, type);
- }
- }
- }
- else
- {
- Elf32_Phdr *phdr, *ph;
- vm_size_t phsize;
-
- if (x.h.e_machine != MY_MACHINE)
- return EX_WRONG_ARCH;
-
- /* XXX others */
- out_info->entry = (vm_offset_t) x.h.e_entry;
- out_info->init_dp = 0; /* ? */
-
- phsize = x.h.e_phnum * x.h.e_phentsize;
- phdr = (Elf32_Phdr *)alloca(phsize);
-
- result = (*read)(handle, x.h.e_phoff, phdr, phsize, &actual);
- if (result)
- return result;
- if (actual < phsize)
- return EX_CORRUPT;
-
- for (i = 0; i < x.h.e_phnum; i++)
- {
- ph = (Elf32_Phdr *)((vm_offset_t)phdr + i * x.h.e_phentsize);
- if (ph->p_type == PT_LOAD)
- {
- exec_sectype_t type = EXEC_SECTYPE_ALLOC |
- EXEC_SECTYPE_LOAD;
- if (ph->p_flags & PF_R) type |= EXEC_SECTYPE_READ;
- if (ph->p_flags & PF_W) type |= EXEC_SECTYPE_WRITE;
- if (ph->p_flags & PF_X) type |= EXEC_SECTYPE_EXECUTE;
- result = (*read_exec)(handle,
- ph->p_offset, ph->p_filesz,
- ph->p_vaddr, ph->p_memsz, type);
- }
- }
- }
-
- return 0;
-}
diff --git a/serverboot/exec.c b/serverboot/exec.c
deleted file mode 100644
index a487fb5d..00000000
--- a/serverboot/exec.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1993-1989 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * i386-specific routines for loading a.out files.
- */
-
-#include <mach.h>
-#include <mach/machine/vm_param.h>
-#include "mach-exec.h"
-
-#include <file_io.h>
-
-#ifdef i386
-
-#include <mach/machine/eflags.h>
-
-/*
- * Machine-dependent portions of execve() for the i386.
- */
-
-#define STACK_SIZE (64*1024)
-
-char *set_regs(
- mach_port_t user_task,
- mach_port_t user_thread,
- struct exec_info *info,
- int arg_size)
-{
- vm_offset_t stack_start;
- vm_offset_t stack_end;
- struct i386_thread_state regs;
- unsigned int reg_size;
-
- /*
- * Add space for 5 ints to arguments, for
- * PS program. XXX
- */
- arg_size += 5 * sizeof(int);
-
- /*
- * Allocate stack.
- */
- stack_end = VM_MAX_ADDRESS;
- stack_start = VM_MAX_ADDRESS - STACK_SIZE;
- (void)vm_allocate(user_task,
- &stack_start,
- (vm_size_t)(stack_end - stack_start),
- FALSE);
-
- reg_size = i386_THREAD_STATE_COUNT;
- (void)thread_get_state(user_thread,
- i386_THREAD_STATE,
- (thread_state_t)&regs,
- &reg_size);
-
- regs.eip = info->entry;
- regs.uesp = (int)((stack_end - arg_size) & ~(sizeof(int)-1));
-
- /* regs.efl |= EFL_TF; trace flag*/
-
- (void)thread_set_state(user_thread,
- i386_THREAD_STATE,
- (thread_state_t)&regs,
- reg_size);
-
- return (char *)regs.uesp;
-}
-
-#elif defined __alpha__
-
-
-/*
- * Object:
- * set_regs EXPORTED function
- *
- * Initialize enough state for a thread to run, including
- * stack memory and stack pointer, and program counter.
- *
- */
-#define STACK_SIZE (vm_size_t)(128*1024)
-
-char *set_regs(
- mach_port_t user_task,
- mach_port_t user_thread,
- struct exec_info *info,
- int arg_size)
-{
- vm_offset_t stack_start;
- vm_offset_t stack_end;
- struct alpha_thread_state regs;
-
- natural_t reg_size;
-
- /*
- * Allocate stack.
- */
- stack_end = VM_MAX_ADDRESS;
- stack_start = stack_end - STACK_SIZE;
- (void)vm_allocate(user_task,
- &stack_start,
- (vm_size_t)(STACK_SIZE),
- FALSE);
-
- reg_size = ALPHA_THREAD_STATE_COUNT;
- (void)thread_get_state(user_thread,
- ALPHA_THREAD_STATE,
- (thread_state_t)&regs,
- &reg_size);
-
- regs.pc = info->entry;
- regs.r29 = info->init_dp;
- regs.r30 = (integer_t)((stack_end - arg_size) & ~(sizeof(integer_t)-1));
-
- (void)thread_set_state(user_thread,
- ALPHA_THREAD_STATE,
- (thread_state_t)&regs,
- reg_size);
-
- return (char *)regs.r30;
-}
-
-#else
-# error "Not ported to this architecture!"
-#endif
diff --git a/serverboot/ext2_file_io.c b/serverboot/ext2_file_io.c
deleted file mode 100644
index cb915c4a..00000000
--- a/serverboot/ext2_file_io.c
+++ /dev/null
@@ -1,983 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * Stand-alone file reading package.
- */
-
-#include <device/device_types.h>
-#include <device/device.h>
-
-#include <mach/mach_traps.h>
-#include <mach/mach_interface.h>
-
-#include "file_io.h"
-#include "ffs_compat.h"
-
-void ext2_close_file(); /* forward */
-
-/*
- * Free file buffers, but don't close file.
- */
-static void
-free_file_buffers(fp)
- register struct file *fp;
-{
- register int level;
-
- /*
- * Free the indirect blocks
- */
- for (level = 0; level < NIADDR; level++) {
- if (fp->f_blk[level] != 0) {
- (void) vm_deallocate(mach_task_self(),
- fp->f_blk[level],
- fp->f_blksize[level]);
- fp->f_blk[level] = 0;
- }
- fp->f_blkno[level] = -1;
- }
-
- /*
- * Free the data block
- */
- if (fp->f_buf != 0) {
- (void) vm_deallocate(mach_task_self(),
- fp->f_buf,
- fp->f_buf_size);
- fp->f_buf = 0;
- }
- fp->f_buf_blkno = -1;
-}
-
-/*
- * Read a new inode into a file structure.
- */
-static int
-read_inode(inumber, fp)
- ino_t inumber;
- register struct file *fp;
-{
- vm_offset_t buf;
- mach_msg_type_number_t buf_size;
- register
- struct ext2_super_block *fs;
- daddr_t disk_block;
- kern_return_t rc;
-
- fs = fp->f_fs;
- disk_block = ino2blk(fs, fp->f_gd, inumber);
-
- rc = device_read(fp->f_dev,
- 0,
- (recnum_t) fsbtodb(fp->f_fs, disk_block),
- (int) EXT2_BLOCK_SIZE(fs),
- (char **)&buf,
- &buf_size);
- if (rc != KERN_SUCCESS)
- return (rc);
-
- {
- register struct ext2_inode *dp;
-
- dp = (struct ext2_inode *)buf;
- dp += itoo(fs, inumber);
- fp->i_ic = *dp;
- fp->f_size = dp->i_size;
- }
-
- (void) vm_deallocate(mach_task_self(), buf, buf_size);
-
- /*
- * Clear out the old buffers
- */
- free_file_buffers(fp);
-
- return (0);
-}
-
-/*
- * Given an offset in a file, find the disk block number that
- * contains that block.
- */
-static int
-block_map(fp, file_block, disk_block_p)
- struct file *fp;
- daddr_t file_block;
- daddr_t *disk_block_p; /* out */
-{
- int level;
- int idx;
- daddr_t ind_block_num;
- kern_return_t rc;
-
- vm_offset_t olddata[NIADDR+1];
- vm_size_t oldsize[NIADDR+1];
-
- /*
- * Index structure of an inode:
- *
- * i_db[0..NDADDR-1] hold block numbers for blocks
- * 0..NDADDR-1
- *
- * i_ib[0] index block 0 is the single indirect
- * block
- * holds block numbers for blocks
- * NDADDR .. NDADDR + NINDIR(fs)-1
- *
- * i_ib[1] index block 1 is the double indirect
- * block
- * holds block numbers for INDEX blocks
- * for blocks
- * NDADDR + NINDIR(fs) ..
- * NDADDR + NINDIR(fs) + NINDIR(fs)**2 - 1
- *
- * i_ib[2] index block 2 is the triple indirect
- * block
- * holds block numbers for double-indirect
- * blocks for blocks
- * NDADDR + NINDIR(fs) + NINDIR(fs)**2 ..
- * NDADDR + NINDIR(fs) + NINDIR(fs)**2
- * + NINDIR(fs)**3 - 1
- */
-
- mutex_lock(&fp->f_lock);
-
- if (file_block < NDADDR) {
- /* Direct block. */
- *disk_block_p = fp->i_ic.i_block[file_block];
- mutex_unlock(&fp->f_lock);
- return (0);
- }
-
- file_block -= NDADDR;
-
- /*
- * nindir[0] = NINDIR
- * nindir[1] = NINDIR**2
- * nindir[2] = NINDIR**3
- * etc
- */
- for (level = 0; level < NIADDR; level++) {
- if (file_block < fp->f_nindir[level])
- break;
- file_block -= fp->f_nindir[level];
- }
- if (level == NIADDR) {
- /* Block number too high */
- mutex_unlock(&fp->f_lock);
- return (FS_NOT_IN_FILE);
- }
-
- ind_block_num = fp->i_ic.i_block[level + NDADDR];
-
- /*
- * Initialize array of blocks to free.
- */
- for (idx = 0; idx < NIADDR; idx++)
- oldsize[idx] = 0;
-
- for (; level >= 0; level--) {
-
- vm_offset_t data;
- mach_msg_type_number_t size;
-
- if (ind_block_num == 0)
- break;
-
- if (fp->f_blkno[level] == ind_block_num) {
- /*
- * Cache hit. Just pick up the data.
- */
-
- data = fp->f_blk[level];
- }
- else {
- /*
- * Drop our lock while doing the read.
- * (The f_dev and f_fs fields don`t change.)
- */
- mutex_unlock(&fp->f_lock);
-
- rc = device_read(fp->f_dev,
- 0,
- (recnum_t) fsbtodb(fp->f_fs, ind_block_num),
- EXT2_BLOCK_SIZE(fp->f_fs),
- (char **)&data,
- &size);
- if (rc != KERN_SUCCESS)
- return (rc);
-
- /*
- * See if we can cache the data. Need a write lock to
- * do this. While we hold the write lock, we can`t do
- * *anything* which might block for memory. Otherwise
- * a non-privileged thread might deadlock with the
- * privileged threads. We can`t block while taking the
- * write lock. Otherwise a non-privileged thread
- * blocked in the vm_deallocate (while holding a read
- * lock) will block a privileged thread. For the same
- * reason, we can`t take a read lock and then use
- * lock_read_to_write.
- */
-
- mutex_lock(&fp->f_lock);
-
- olddata[level] = fp->f_blk[level];
- oldsize[level] = fp->f_blksize[level];
-
- fp->f_blkno[level] = ind_block_num;
- fp->f_blk[level] = data;
- fp->f_blksize[level] = size;
-
- /*
- * Return to holding a read lock, and
- * dispose of old data.
- */
-
- }
-
- if (level > 0) {
- idx = file_block / fp->f_nindir[level-1];
- file_block %= fp->f_nindir[level-1];
- }
- else
- idx = file_block;
-
- ind_block_num = ((daddr_t *)data)[idx];
- }
-
- mutex_unlock(&fp->f_lock);
-
- /*
- * After unlocking the file, free any blocks that
- * we need to free.
- */
- for (idx = 0; idx < NIADDR; idx++)
- if (oldsize[idx] != 0)
- (void) vm_deallocate(mach_task_self(),
- olddata[idx],
- oldsize[idx]);
-
- *disk_block_p = ind_block_num;
- return (0);
-}
-
-/*
- * Read a portion of a file into an internal buffer. Return
- * the location in the buffer and the amount in the buffer.
- */
-static int
-buf_read_file(fp, offset, buf_p, size_p)
- register struct file *fp;
- vm_offset_t offset;
- vm_offset_t *buf_p; /* out */
- vm_size_t *size_p; /* out */
-{
- register
- struct ext2_super_block *fs;
- vm_offset_t off;
- register daddr_t file_block;
- daddr_t disk_block;
- int rc;
- vm_offset_t block_size;
-
- if (offset >= fp->i_ic.i_size)
- return (FS_NOT_IN_FILE);
-
- fs = fp->f_fs;
-
- off = blkoff(fs, offset);
- file_block = lblkno(fs, offset);
- block_size = blksize(fs, fp, file_block);
-
- if (file_block != fp->f_buf_blkno) {
- rc = block_map(fp, file_block, &disk_block);
- if (rc != 0)
- return (rc);
-
- if (fp->f_buf)
- (void)vm_deallocate(mach_task_self(),
- fp->f_buf,
- fp->f_buf_size);
-
- if (disk_block == 0) {
- (void)vm_allocate(mach_task_self(),
- &fp->f_buf,
- block_size,
- TRUE);
- fp->f_buf_size = block_size;
- }
- else {
- rc = device_read(fp->f_dev,
- 0,
- (recnum_t) fsbtodb(fs, disk_block),
- (int) block_size,
- (char **) &fp->f_buf,
- (mach_msg_type_number_t *)&fp->f_buf_size);
- }
- if (rc)
- return (rc);
-
- fp->f_buf_blkno = file_block;
- }
-
- /*
- * Return address of byte in buffer corresponding to
- * offset, and size of remainder of buffer after that
- * byte.
- */
- *buf_p = fp->f_buf + off;
- *size_p = block_size - off;
-
- /*
- * But truncate buffer at end of file.
- */
- if (*size_p > fp->i_ic.i_size - offset)
- *size_p = fp->i_ic.i_size - offset;
-
- return (0);
-}
-
-/*
- * Search a directory for a name and return its
- * i_number.
- */
-static int
-search_directory(name, fp, inumber_p)
- char * name;
- register struct file *fp;
- ino_t *inumber_p; /* out */
-{
- vm_offset_t buf;
- vm_size_t buf_size;
- vm_offset_t offset;
- struct ext2_dir_entry_2 *dp;
- int length;
- kern_return_t rc;
- char tmp_name[256];
-
- length = strlen(name);
-
- offset = 0;
- while (offset < fp->i_ic.i_size) {
- rc = buf_read_file(fp, offset, &buf, &buf_size);
- if (rc != KERN_SUCCESS)
- return (rc);
-
- dp = (struct ext2_dir_entry_2 *)buf;
- if (dp->inode != 0) {
- strncpy (tmp_name, dp->name, dp->name_len);
- tmp_name[dp->name_len] = '\0';
- if (dp->name_len == length &&
- !strcmp(name, tmp_name))
- {
- /* found entry */
- *inumber_p = dp->inode;
- return (0);
- }
- }
- offset += dp->rec_len;
- }
- return (FS_NO_ENTRY);
-}
-
-static int
-read_fs(dev, fsp, gdp, gd_size_p)
- mach_port_t dev;
- struct ext2_super_block **fsp;
- struct ext2_group_desc **gdp;
- vm_size_t *gd_size_p;
-{
- register
- struct ext2_super_block *fs;
- vm_offset_t buf;
- vm_offset_t buf2;
- mach_msg_type_number_t buf_size;
- mach_msg_type_number_t buf2_size;
- int error;
- int gd_count;
- int gd_blocks;
- int gd_size;
- int gd_location;
- int gd_sector;
-
- /*
- * Read the super block
- */
- error = device_read(dev, 0, (recnum_t) SBLOCK, SBSIZE,
- (char **) &buf, &buf_size);
- if (error)
- return (error);
-
- /*
- * Check the superblock
- */
- fs = (struct ext2_super_block *)buf;
- if (fs->s_magic != EXT2_SUPER_MAGIC) {
- (void) vm_deallocate(mach_task_self(), buf, buf_size);
- return (FS_INVALID_FS);
- }
-
- *fsp = fs;
-
- /*
- * Compute the groups informations
- */
- gd_count = (fs->s_blocks_count - fs->s_first_data_block +
- fs->s_blocks_per_group - 1) / fs->s_blocks_per_group;
- gd_blocks = (gd_count + EXT2_DESC_PER_BLOCK(fs) - 1) /
- EXT2_DESC_PER_BLOCK(fs);
- gd_size = gd_blocks * EXT2_BLOCK_SIZE(fs);
- gd_location = fs->s_first_data_block + 1;
- gd_sector = (gd_location * EXT2_BLOCK_SIZE(fs)) / DEV_BSIZE;
-
- /*
- * Read the groups descriptors
- */
- error = device_read(dev, 0, (recnum_t) gd_sector, gd_size,
- (char **) &buf2, &buf2_size);
- if (error) {
- (void) vm_deallocate(mach_task_self(), buf, buf_size);
- return error;
- }
-
- *gdp = (struct ext2_group_desc *) buf2;
- *gd_size_p = gd_size;
-
- return 0;
-}
-
-static int
-mount_fs(fp)
- register struct file *fp;
-{
- register struct ext2_super_block *fs;
- int error;
-
- error = read_fs(fp->f_dev, &fp->f_fs, &fp->f_gd, &fp->f_gd_size);
- if (error)
- return (error);
-
- fs = fp->f_fs;
-
- /*
- * Calculate indirect block levels.
- */
- {
- register int mult;
- register int level;
-
- mult = 1;
- for (level = 0; level < NIADDR; level++) {
- mult *= NINDIR(fs);
- fp->f_nindir[level] = mult;
- }
- }
-
- return (0);
-}
-
-static void
-unmount_fs(fp)
- register struct file *fp;
-{
- if (file_is_structured(fp)) {
- (void) vm_deallocate(mach_task_self(),
- (vm_offset_t) fp->f_fs,
- SBSIZE);
- (void) vm_deallocate(mach_task_self(),
- (vm_offset_t) fp->f_gd,
- fp->f_gd_size);
- fp->f_fs = 0;
- }
-}
-
-/*
- * Open a file.
- */
-int
-ext2_open_file(master_device_port, path, fp)
- mach_port_t master_device_port;
- char * path;
- struct file *fp;
-{
-#define RETURN(code) { rc = (code); goto exit; }
-
- register char *cp, *component;
- register int c; /* char */
- register int rc;
- ino_t inumber, parent_inumber;
- int nlinks = 0;
-
- char namebuf[MAXPATHLEN+1];
-
- if (path == 0 || *path == '\0') {
- return FS_NO_ENTRY;
- }
-
- /*
- * Copy name into buffer to allow modifying it.
- */
- strcpy(namebuf, path);
-
- /*
- * Look for '/dev/xxx' at start of path, for
- * root device.
- */
- if (!strprefix(namebuf, "/dev/")) {
- printf("no device name\n");
- return FS_NO_ENTRY;
- }
-
- cp = namebuf + 5; /* device */
- component = cp;
- while ((c = *cp) != '\0' && c != '/') {
- cp++;
- }
- *cp = '\0';
-
- bzero (fp, sizeof (struct file));
-
- rc = device_open(master_device_port,
- D_READ|D_WRITE,
- component,
- &fp->f_dev);
- if (rc)
- return rc;
-
- if (c == 0) {
- fp->f_fs = 0;
- goto out_ok;
- }
-
- *cp = c;
-
- rc = mount_fs(fp);
- if (rc)
- return rc;
-
- inumber = (ino_t) ROOTINO;
- if ((rc = read_inode(inumber, fp)) != 0) {
- printf("can't read root inode\n");
- goto exit;
- }
-
- while (*cp) {
-
- /*
- * Check that current node is a directory.
- */
- if ((fp->i_ic.i_mode & IFMT) != IFDIR)
- RETURN (FS_NOT_DIRECTORY);
-
- /*
- * Remove extra separators
- */
- while (*cp == '/')
- cp++;
-
- /*
- * Get next component of path name.
- */
- component = cp;
- {
- register int len = 0;
-
- while ((c = *cp) != '\0' && c != '/') {
- if (len++ > MAXNAMLEN)
- RETURN (FS_NAME_TOO_LONG);
- if (c & 0200)
- RETURN (FS_INVALID_PARAMETER);
- cp++;
- }
- *cp = 0;
- }
-
- /*
- * Look up component in current directory.
- * Save directory inumber in case we find a
- * symbolic link.
- */
- parent_inumber = inumber;
- rc = search_directory(component, fp, &inumber);
- if (rc) {
- printf("%s: not found\n", path);
- goto exit;
- }
- *cp = c;
-
- /*
- * Open next component.
- */
- if ((rc = read_inode(inumber, fp)) != 0)
- goto exit;
-
- /*
- * Check for symbolic link.
- */
- if ((fp->i_ic.i_mode & IFMT) == IFLNK) {
-
- int link_len = fp->i_ic.i_size;
- int len;
-
- len = strlen(cp) + 1;
-
- if (link_len + len >= MAXPATHLEN - 1)
- RETURN (FS_NAME_TOO_LONG);
-
- if (++nlinks > MAXSYMLINKS)
- RETURN (FS_SYMLINK_LOOP);
-
- memmove(&namebuf[link_len], cp, len);
-
-#ifdef IC_FASTLINK
- if (fp->i_ic.i_blocks == 0) {
- bcopy(fp->i_ic.i_block, namebuf, (unsigned) link_len);
- }
- else
-#endif /* IC_FASTLINK */
- {
- /*
- * Read file for symbolic link
- */
- vm_offset_t buf;
- mach_msg_type_number_t buf_size;
- daddr_t disk_block;
- register struct ext2_super_block *fs = fp->f_fs;
-
- (void) block_map(fp, (daddr_t)0, &disk_block);
- rc = device_read(fp->f_dev,
- 0,
- (recnum_t) fsbtodb(fs, disk_block),
- (int) blksize(fs, fp, 0),
- (char **) &buf,
- &buf_size);
- if (rc)
- goto exit;
-
- bcopy((char *)buf, namebuf, (unsigned)link_len);
- (void) vm_deallocate(mach_task_self(), buf, buf_size);
- }
-
- /*
- * If relative pathname, restart at parent directory.
- * If absolute pathname, restart at root.
- * If pathname begins '/dev/<device>/',
- * restart at root of that device.
- */
- cp = namebuf;
- if (*cp != '/') {
- inumber = parent_inumber;
- }
- else if (!strprefix(cp, "/dev/")) {
- inumber = (ino_t)ROOTINO;
- }
- else {
- cp += 5;
- component = cp;
- while ((c = *cp) != '\0' && c != '/') {
- cp++;
- }
- *cp = '\0';
-
- /*
- * Unmount current file system and free buffers.
- */
- ext2_close_file(fp);
-
- /*
- * Open new root device.
- */
- rc = device_open(master_device_port,
- D_READ,
- component,
- &fp->f_dev);
- if (rc)
- return (rc);
-
- if (c == 0) {
- fp->f_fs = 0;
- goto out_ok;
- }
-
- *cp = c;
-
- rc = mount_fs(fp);
- if (rc)
- return (rc);
-
- inumber = (ino_t)ROOTINO;
- }
- if ((rc = read_inode(inumber, fp)) != 0)
- goto exit;
- }
- }
-
- /*
- * Found terminal component.
- */
- out_ok:
- mutex_init(&fp->f_lock);
- return 0;
-
- /*
- * At error exit, close file to free storage.
- */
- exit:
- ext2_close_file(fp);
- return rc;
-}
-
-/*
- * Close file - free all storage used.
- */
-void
-ext2_close_file(fp)
- register struct file *fp;
-{
- register int i;
-
- /*
- * Free the disk super-block.
- */
- unmount_fs(fp);
-
- /*
- * Free the inode and data buffers.
- */
- free_file_buffers(fp);
-}
-
-int
-ext2_file_is_directory(struct file *fp)
-{
- return (fp->i_ic.i_mode & IFMT) == IFDIR;
-}
-
-int
-ext2_file_is_regular(struct file *fp)
-{
- return (fp->i_ic.i_mode & IFMT) == IFREG;
-}
-
-/*
- * Copy a portion of a file into kernel memory.
- * Cross block boundaries when necessary.
- */
-int
-ext2_read_file(fp, offset, start, size, resid)
- register struct file *fp;
- vm_offset_t offset;
- vm_offset_t start;
- vm_size_t size;
- vm_size_t *resid; /* out */
-{
- int rc;
- register vm_size_t csize;
- vm_offset_t buf;
- vm_size_t buf_size;
-
- while (size != 0) {
- rc = buf_read_file(fp, offset, &buf, &buf_size);
- if (rc)
- return (rc);
-
- csize = size;
- if (csize > buf_size)
- csize = buf_size;
- if (csize == 0)
- break;
-
- bcopy((char *)buf, (char *)start, csize);
-
- offset += csize;
- start += csize;
- size -= csize;
- }
- if (resid)
- *resid = size;
-
- return (0);
-}
-
-/* simple utility: only works for 2^n */
-static int
-log2(n)
- register unsigned int n;
-{
- register int i = 0;
-
- while ((n & 1) == 0) {
- i++;
- n >>= 1;
- }
- return i;
-}
-
-/*
- * Make an empty file_direct for a device.
- */
-int
-ext2_open_file_direct(dev, fdp, is_structured)
- mach_port_t dev;
- register struct file_direct *fdp;
- boolean_t is_structured;
-{
- struct ext2_super_block *fs;
- struct ext2_group_desc *gd;
- vm_size_t gd_size;
- int rc;
-
- if (!is_structured) {
- fdp->fd_dev = dev;
- fdp->fd_blocks = (daddr_t *) 0;
- fdp->fd_bsize = vm_page_size;
- fdp->fd_bshift = log2(vm_page_size);
- fdp->fd_fsbtodb = 0; /* later */
- fdp->fd_size = 0; /* later */
- return 0;
- }
-
- rc = read_fs(dev, &fs, &gd, &gd_size);
- if (rc)
- return rc;
-
- fdp->fd_dev = dev;
- fdp->fd_blocks = (daddr_t *) 0;
- fdp->fd_size = 0;
- fdp->fd_bsize = EXT2_BLOCK_SIZE(fs);
- fdp->fd_bshift = log2(fdp->fd_bsize);
- fdp->fd_fsbtodb = log2(fdp->fd_bsize / DEV_BSIZE);
-
- (void) vm_deallocate(mach_task_self(),
- (vm_offset_t) fs,
- SBSIZE);
- (void) vm_deallocate(mach_task_self(),
- (vm_offset_t) gd,
- gd_size);
-
- return 0;
-}
-
-/*
- * Add blocks from a file to a file_direct.
- */
-int
-ext2_add_file_direct(fdp, fp)
- register struct file_direct *fdp;
- register struct file *fp;
-{
- register struct ext2_super_block *fs;
- long num_blocks, i;
- vm_offset_t buffer;
- vm_size_t size;
- int rc;
-
- /* the file must be on the same device */
-
- if (fdp->fd_dev != fp->f_dev)
- return FS_INVALID_FS;
-
- if (!file_is_structured(fp)) {
- int result[DEV_GET_SIZE_COUNT];
- natural_t count;
-
- count = DEV_GET_SIZE_COUNT;
- rc = device_get_status( fdp->fd_dev, DEV_GET_SIZE,
- result, &count);
- if (rc)
- return rc;
- fdp->fd_size = result[DEV_GET_SIZE_DEVICE_SIZE] >> fdp->fd_bshift;
- fdp->fd_fsbtodb = log2(fdp->fd_bsize/result[DEV_GET_SIZE_RECORD_SIZE]);
- return 0;
- }
-
- /* it must hold a file system */
-
- fs = fp->f_fs;
-/*
- if (fdp->fd_bsize != fs->fs_bsize ||
- fdp->fd_fsbtodb != fs->fs_fsbtodb)
-*/
- if (fdp->fd_bsize != EXT2_BLOCK_SIZE(fs))
- return FS_INVALID_FS;
-
- /* calculate number of blocks in the file, ignoring fragments */
-
- num_blocks = lblkno(fs, fp->i_ic.i_size);
-
- /* allocate memory for a bigger array */
-
- size = (num_blocks + fdp->fd_size) * sizeof(daddr_t);
- rc = vm_allocate(mach_task_self(), &buffer, size, TRUE);
- if (rc != KERN_SUCCESS)
- return rc;
-
- /* lookup new block addresses */
-
- for (i = 0; i < num_blocks; i++) {
- daddr_t disk_block;
-
- rc = block_map(fp, (daddr_t) i, &disk_block);
- if (rc != 0) {
- (void) vm_deallocate(mach_task_self(), buffer, size);
- return rc;
- }
-
- ((daddr_t *) buffer)[fdp->fd_size + i] = disk_block;
- }
-
- /* copy old addresses and install the new array */
-
- if (fdp->fd_blocks != 0) {
- bcopy((char *) fdp->fd_blocks, (char *) buffer,
- fdp->fd_size * sizeof(daddr_t));
-
- (void) vm_deallocate(mach_task_self(),
- (vm_offset_t) fdp->fd_blocks,
- (vm_size_t) (fdp->fd_size * sizeof(daddr_t)));
- }
- fdp->fd_blocks = (daddr_t *) buffer;
- fdp->fd_size += num_blocks;
-
- /* deallocate cached blocks */
-
- free_file_buffers(fp);
-
- return 0;
-}
-
-int
-ext2_remove_file_direct(fdp)
- struct file_direct *fdp;
-{
- if (fdp->fd_blocks)
- (void) vm_deallocate(mach_task_self(),
- (vm_offset_t) fdp->fd_blocks,
- (vm_size_t) (fdp->fd_size * sizeof(daddr_t)));
- fdp->fd_blocks = 0; /* sanity */
- /* xxx should lose a ref to fdp->fd_dev here (and elsewhere) xxx */
-}
diff --git a/serverboot/ffs_compat.c b/serverboot/ffs_compat.c
deleted file mode 100644
index 6e322b63..00000000
--- a/serverboot/ffs_compat.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * BSD FFS like functions used to ease porting bootstrap to Linux ext2 fs
- * Copyright (C) 1994 Remy Card
- *
- * This file 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.
- */
-
-#include <device/device_types.h>
-#include <device/device.h>
-
-#include <mach/mach_traps.h>
-#include <mach/mach_interface.h>
-
-#include <file_io.h>
-
-#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_inode))
-
-int ino2blk (struct ext2_super_block *fs, struct ext2_group_desc *gd, int ino)
-{
- int group;
- int blk;
-
- group = (ino - 1) / EXT2_INODES_PER_GROUP(fs);
- blk = gd[group].bg_inode_table +
- (((ino - 1) % EXT2_INODES_PER_GROUP(fs)) /
- EXT2_INODES_PER_BLOCK(fs));
- return blk;
-}
-
-int fsbtodb (struct ext2_super_block *fs, int b)
-{
- return (b * EXT2_BLOCK_SIZE(fs)) / DEV_BSIZE;
-}
-
-int itoo (struct ext2_super_block *fs, int ino)
-{
- return (ino - 1) % EXT2_INODES_PER_BLOCK(fs);
-}
-
-int blkoff (struct ext2_super_block * fs, vm_offset_t offset)
-{
- return offset % EXT2_BLOCK_SIZE(fs);
-}
-
-int lblkno (struct ext2_super_block * fs, vm_offset_t offset)
-{
- return offset / EXT2_BLOCK_SIZE(fs);
-}
-
-int blksize (struct ext2_super_block *fs, struct file *fp, daddr_t file_block)
-{
- return EXT2_BLOCK_SIZE(fs); /* XXX - fix for fragments */
-}
diff --git a/serverboot/ffs_compat.h b/serverboot/ffs_compat.h
deleted file mode 100644
index d78840f5..00000000
--- a/serverboot/ffs_compat.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * BSD FFS like declarations used to ease porting bootstrap to Linux ext2 fs
- * Copyright (C) 1994 Remy Card
- *
- * This file 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.
- */
-
-#define SBSIZE EXT2_MIN_BLOCK_SIZE /* Size of superblock */
-#define SBLOCK ((daddr_t) 2) /* Location of superblock */
-
-#define NDADDR EXT2_NDIR_BLOCKS
-#define NIADDR (EXT2_N_BLOCKS - EXT2_NDIR_BLOCKS)
-
-#define MAXNAMLEN 255
-
-#define ROOTINO EXT2_ROOT_INO
-
-#define NINDIR(fs) EXT2_ADDR_PER_BLOCK(fs)
-
-#define IC_FASTLINK
-
-#define IFMT 00170000
-#define IFSOCK 0140000
-#define IFLNK 0120000
-#define IFREG 0100000
-#define IFBLK 0060000
-#define IFDIR 0040000
-#define IFCHR 0020000
-#define IFIFO 0010000
-#define ISUID 0004000
-#define ISGID 0002000
-#define ISVTX 0001000
-
-#define f_fs u.ext2.ext2_fs
-#define f_gd u.ext2.ext2_gd
-#define f_gd_size u.ext2.ext2_gd_size
-#define i_ic u.ext2.ext2_ic
-#define f_nindir u.ext2.ext2_nindir
-#define f_blk u.ext2.ext2_blk
-#define f_blksize u.ext2.ext2_blksize
-#define f_blkno u.ext2.ext2_blkno
-
diff --git a/serverboot/ffs_file_io.c b/serverboot/ffs_file_io.c
deleted file mode 100644
index 1105eacc..00000000
--- a/serverboot/ffs_file_io.c
+++ /dev/null
@@ -1,969 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * Stand-alone file reading package.
- */
-
-#include <device/device_types.h>
-#include <device/device.h>
-
-#include <mach/mach_traps.h>
-#include <mach/mach_interface.h>
-
-#include "file_io.h"
-#include "fs.h"
-#include "dir.h"
-#include "disk_inode_ffs.h"
-
-void close_file(); /* forward */
-
-/*
- * Free file buffers, but don't close file.
- */
-static void
-free_file_buffers(fp)
- register struct file *fp;
-{
- register int level;
-
- /*
- * Free the indirect blocks
- */
- for (level = 0; level < NIADDR; level++) {
- if (fp->f_blk[level] != 0) {
- (void) vm_deallocate(mach_task_self(),
- fp->f_blk[level],
- fp->f_blksize[level]);
- fp->f_blk[level] = 0;
- }
- fp->f_blkno[level] = -1;
- }
-
- /*
- * Free the data block
- */
- if (fp->f_buf != 0) {
- (void) vm_deallocate(mach_task_self(),
- fp->f_buf,
- fp->f_buf_size);
- fp->f_buf = 0;
- }
- fp->f_buf_blkno = -1;
-}
-
-/*
- * Read a new inode into a file structure.
- */
-static int
-read_inode(inumber, fp)
- ino_t inumber;
- register struct file *fp;
-{
- vm_offset_t buf;
- mach_msg_type_number_t buf_size;
- register struct fs *fs;
- daddr_t disk_block;
- kern_return_t rc;
-
- fs = fp->f_fs;
- disk_block = itod(fs, inumber);
-
- rc = device_read(fp->f_dev,
- 0,
- (recnum_t) fsbtodb(fp->f_fs, disk_block),
- (int) fs->fs_bsize,
- (char **)&buf,
- &buf_size);
- if (rc != KERN_SUCCESS)
- return (rc);
-
- {
- register struct dinode *dp;
-
- dp = (struct dinode *)buf;
- dp += itoo(fs, inumber);
- fp->i_ic = dp->di_ic;
- fp->f_size = fp->i_size;
- }
-
- (void) vm_deallocate(mach_task_self(), buf, buf_size);
-
- /*
- * Clear out the old buffers
- */
- free_file_buffers(fp);
-
- return (0);
-}
-
-/*
- * Given an offset in a file, find the disk block number that
- * contains that block.
- */
-static int
-block_map(fp, file_block, disk_block_p)
- struct file *fp;
- daddr_t file_block;
- daddr_t *disk_block_p; /* out */
-{
- int level;
- int idx;
- daddr_t ind_block_num;
- kern_return_t rc;
-
- vm_offset_t olddata[NIADDR+1];
- vm_size_t oldsize[NIADDR+1];
-
- /*
- * Index structure of an inode:
- *
- * i_db[0..NDADDR-1] hold block numbers for blocks
- * 0..NDADDR-1
- *
- * i_ib[0] index block 0 is the single indirect
- * block
- * holds block numbers for blocks
- * NDADDR .. NDADDR + NINDIR(fs)-1
- *
- * i_ib[1] index block 1 is the double indirect
- * block
- * holds block numbers for INDEX blocks
- * for blocks
- * NDADDR + NINDIR(fs) ..
- * NDADDR + NINDIR(fs) + NINDIR(fs)**2 - 1
- *
- * i_ib[2] index block 2 is the triple indirect
- * block
- * holds block numbers for double-indirect
- * blocks for blocks
- * NDADDR + NINDIR(fs) + NINDIR(fs)**2 ..
- * NDADDR + NINDIR(fs) + NINDIR(fs)**2
- * + NINDIR(fs)**3 - 1
- */
-
- mutex_lock(&fp->f_lock);
-
- if (file_block < NDADDR) {
- /* Direct block. */
- *disk_block_p = fp->i_db[file_block];
- mutex_unlock(&fp->f_lock);
- return (0);
- }
-
- file_block -= NDADDR;
-
- /*
- * nindir[0] = NINDIR
- * nindir[1] = NINDIR**2
- * nindir[2] = NINDIR**3
- * etc
- */
- for (level = 0; level < NIADDR; level++) {
- if (file_block < fp->f_nindir[level])
- break;
- file_block -= fp->f_nindir[level];
- }
- if (level == NIADDR) {
- /* Block number too high */
- mutex_unlock(&fp->f_lock);
- return (FS_NOT_IN_FILE);
- }
-
- ind_block_num = fp->i_ib[level];
-
- /*
- * Initialize array of blocks to free.
- */
- for (idx = 0; idx < NIADDR; idx++)
- oldsize[idx] = 0;
-
- for (; level >= 0; level--) {
-
- vm_offset_t data;
- mach_msg_type_number_t size;
-
- if (ind_block_num == 0)
- break;
-
- if (fp->f_blkno[level] == ind_block_num) {
- /*
- * Cache hit. Just pick up the data.
- */
-
- data = fp->f_blk[level];
- }
- else {
- /*
- * Drop our lock while doing the read.
- * (The f_dev and f_fs fields don`t change.)
- */
- mutex_unlock(&fp->f_lock);
-
- rc = device_read(fp->f_dev,
- 0,
- (recnum_t) fsbtodb(fp->f_fs, ind_block_num),
- fp->f_fs->fs_bsize,
- (char **)&data,
- &size);
- if (rc != KERN_SUCCESS)
- return (rc);
-
- /*
- * See if we can cache the data. Need a write lock to
- * do this. While we hold the write lock, we can`t do
- * *anything* which might block for memory. Otherwise
- * a non-privileged thread might deadlock with the
- * privileged threads. We can`t block while taking the
- * write lock. Otherwise a non-privileged thread
- * blocked in the vm_deallocate (while holding a read
- * lock) will block a privileged thread. For the same
- * reason, we can`t take a read lock and then use
- * lock_read_to_write.
- */
-
- mutex_lock(&fp->f_lock);
-
- olddata[level] = fp->f_blk[level];
- oldsize[level] = fp->f_blksize[level];
-
- fp->f_blkno[level] = ind_block_num;
- fp->f_blk[level] = data;
- fp->f_blksize[level] = size;
-
- /*
- * Return to holding a read lock, and
- * dispose of old data.
- */
-
- }
-
- if (level > 0) {
- idx = file_block / fp->f_nindir[level-1];
- file_block %= fp->f_nindir[level-1];
- }
- else
- idx = file_block;
-
- ind_block_num = ((daddr_t *)data)[idx];
- }
-
- mutex_unlock(&fp->f_lock);
-
- /*
- * After unlocking the file, free any blocks that
- * we need to free.
- */
- for (idx = 0; idx < NIADDR; idx++)
- if (oldsize[idx] != 0)
- (void) vm_deallocate(mach_task_self(),
- olddata[idx],
- oldsize[idx]);
-
- *disk_block_p = ind_block_num;
- return (0);
-}
-
-/*
- * Read a portion of a file into an internal buffer. Return
- * the location in the buffer and the amount in the buffer.
- */
-static int
-buf_read_file(fp, offset, buf_p, size_p)
- register struct file *fp;
- vm_offset_t offset;
- vm_offset_t *buf_p; /* out */
- vm_size_t *size_p; /* out */
-{
- register struct fs *fs;
- vm_offset_t off;
- register daddr_t file_block;
- daddr_t disk_block;
- int rc;
- vm_offset_t block_size;
-
- if (offset >= fp->i_size)
- return (FS_NOT_IN_FILE);
-
- fs = fp->f_fs;
-
- off = blkoff(fs, offset);
- file_block = lblkno(fs, offset);
- block_size = blksize(fs, fp, file_block);
-
- if (file_block != fp->f_buf_blkno) {
- rc = block_map(fp, file_block, &disk_block);
- if (rc != 0)
- return (rc);
-
- if (fp->f_buf)
- (void)vm_deallocate(mach_task_self(),
- fp->f_buf,
- fp->f_buf_size);
-
- if (disk_block == 0) {
- (void)vm_allocate(mach_task_self(),
- &fp->f_buf,
- block_size,
- TRUE);
- fp->f_buf_size = block_size;
- }
- else {
- rc = device_read(fp->f_dev,
- 0,
- (recnum_t) fsbtodb(fs, disk_block),
- (int) block_size,
- (char **) &fp->f_buf,
- (mach_msg_type_number_t *)&fp->f_buf_size);
- }
- if (rc)
- return (rc);
-
- fp->f_buf_blkno = file_block;
- }
-
- /*
- * Return address of byte in buffer corresponding to
- * offset, and size of remainder of buffer after that
- * byte.
- */
- *buf_p = fp->f_buf + off;
- *size_p = block_size - off;
-
- /*
- * But truncate buffer at end of file.
- */
- if (*size_p > fp->i_size - offset)
- *size_p = fp->i_size - offset;
-
- return (0);
-}
-
-/* In 4.4 d_reclen is split into d_type and d_namlen */
-struct dirent_44 {
- unsigned long d_fileno;
- unsigned short d_reclen;
- unsigned char d_type;
- unsigned char d_namlen;
- char d_name[255 + 1];
-};
-
-/*
- * Search a directory for a name and return its
- * i_number.
- */
-static int
-search_directory(name, fp, inumber_p)
- char * name;
- register struct file *fp;
- ino_t *inumber_p; /* out */
-{
- vm_offset_t buf;
- vm_size_t buf_size;
- vm_offset_t offset;
- register struct dirent_44 *dp;
- int length;
- kern_return_t rc;
-
- length = strlen(name);
-
- offset = 0;
- while (offset < fp->i_size) {
- rc = buf_read_file(fp, offset, &buf, &buf_size);
- if (rc != KERN_SUCCESS)
- return (rc);
-
- dp = (struct dirent_44 *)buf;
- if (dp->d_ino != 0) {
- unsigned short namlen = dp->d_namlen;
- /*
- * If namlen is zero, then either this is a 4.3 file
- * system or the namlen is really zero. In the latter
- * case also the 4.3 d_namlen field is zero
- * interpreted either way.
- */
- if (namlen == 0)
- namlen = ((struct direct *)dp)->d_namlen;
-
- if (namlen == length &&
- !strcmp(name, dp->d_name))
- {
- /* found entry */
- *inumber_p = dp->d_ino;
- return (0);
- }
- }
- offset += dp->d_reclen;
- }
- return (FS_NO_ENTRY);
-}
-
-static int
-read_fs(dev, fsp)
- mach_port_t dev;
- struct fs **fsp;
-{
- register struct fs *fs;
- vm_offset_t buf;
- mach_msg_type_number_t buf_size;
- int error;
-
- error = device_read(dev, 0, (recnum_t) SBLOCK, SBSIZE,
- (char **) &buf, &buf_size);
- if (error)
- return (error);
-
- fs = (struct fs *)buf;
- if (fs->fs_magic != FS_MAGIC ||
- fs->fs_bsize > MAXBSIZE ||
- fs->fs_bsize < sizeof(struct fs)) {
- (void) vm_deallocate(mach_task_self(), buf, buf_size);
- return (FS_INVALID_FS);
- }
- /* don't read cylinder groups - we aren't modifying anything */
-
- *fsp = fs;
- return 0;
-}
-
-static int
-mount_fs(fp)
- register struct file *fp;
-{
- register struct fs *fs;
- int error;
-
- error = read_fs(fp->f_dev, &fp->f_fs);
- if (error)
- return (error);
- fs = fp->f_fs;
-
- /*
- * Calculate indirect block levels.
- */
- {
- register int mult;
- register int level;
-
- mult = 1;
- for (level = 0; level < NIADDR; level++) {
- mult *= NINDIR(fs);
- fp->f_nindir[level] = mult;
- }
- }
-
- return (0);
-}
-
-static void
-unmount_fs(fp)
- register struct file *fp;
-{
- if (file_is_structured(fp)) {
- (void) vm_deallocate(mach_task_self(),
- (vm_offset_t) fp->f_fs,
- SBSIZE);
- fp->f_fs = 0;
- }
-}
-
-/*
- * Open a file.
- */
-int
-ffs_open_file(master_device_port, path, fp)
- mach_port_t master_device_port;
- char * path;
- struct file *fp;
-{
-#define RETURN(code) { rc = (code); goto exit; }
-
- register char *cp, *component;
- register int c; /* char */
- register int rc;
- ino_t inumber, parent_inumber;
- int nlinks = 0;
-
- char namebuf[MAXPATHLEN+1];
-
- if (path == 0 || *path == '\0') {
- return FS_NO_ENTRY;
- }
-
- /*
- * Copy name into buffer to allow modifying it.
- */
- strcpy(namebuf, path);
-
- /*
- * Look for '/dev/xxx' at start of path, for
- * root device.
- */
- if (!strprefix(namebuf, "/dev/")) {
- printf("no device name\n");
- return FS_NO_ENTRY;
- }
-
- cp = namebuf + 5; /* device */
- component = cp;
- while ((c = *cp) != '\0' && c != '/') {
- cp++;
- }
- *cp = '\0';
-
- bzero (fp, sizeof (struct file));
-
- rc = device_open(master_device_port,
- D_READ|D_WRITE,
- component,
- &fp->f_dev);
- if (rc)
- return rc;
-
- if (c == 0) {
- fp->f_fs = 0;
- goto out_ok;
- }
-
- *cp = c;
-
- rc = mount_fs(fp);
- if (rc)
- return rc;
-
- inumber = (ino_t) ROOTINO;
- if ((rc = read_inode(inumber, fp)) != 0) {
- printf("can't read root inode\n");
- goto exit;
- }
-
- while (*cp) {
-
- /*
- * Check that current node is a directory.
- */
- if ((fp->i_mode & IFMT) != IFDIR)
- RETURN (FS_NOT_DIRECTORY);
-
- /*
- * Remove extra separators
- */
- while (*cp == '/')
- cp++;
-
- /*
- * Get next component of path name.
- */
- component = cp;
- {
- register int len = 0;
-
- while ((c = *cp) != '\0' && c != '/') {
- if (len++ > MAXNAMLEN)
- RETURN (FS_NAME_TOO_LONG);
- if (c & 0200)
- RETURN (FS_INVALID_PARAMETER);
- cp++;
- }
- *cp = 0;
- }
-
- /*
- * Look up component in current directory.
- * Save directory inumber in case we find a
- * symbolic link.
- */
- parent_inumber = inumber;
- rc = search_directory(component, fp, &inumber);
- if (rc) {
- printf("%s: not found\n", path);
- goto exit;
- }
- *cp = c;
-
- /*
- * Open next component.
- */
- if ((rc = read_inode(inumber, fp)) != 0)
- goto exit;
-
- /*
- * Check for symbolic link.
- */
- if ((fp->i_mode & IFMT) == IFLNK) {
-
- int link_len = fp->i_size;
- int len;
-
- len = strlen(cp) + 1;
-
- if (link_len + len >= MAXPATHLEN - 1)
- RETURN (FS_NAME_TOO_LONG);
-
- if (++nlinks > MAXSYMLINKS)
- RETURN (FS_SYMLINK_LOOP);
-
- memmove (&namebuf[link_len], cp, len);
-
-#ifdef IC_FASTLINK
- if ((fp->i_flags & IC_FASTLINK) != 0) {
- bcopy(fp->i_symlink, namebuf, (unsigned) link_len);
- }
- else
-#endif /* IC_FASTLINK */
-#if !defined(DISABLE_BSD44_FASTLINKS)
- /*
- * There is no bit for fastlinks in 4.4 but instead
- * all symlinks that fit into the inode are fastlinks.
- * If the second block (ic_db[1]) is zero the symlink
- * can't be a fastlink if its length is at least five.
- * For symlinks of length one to four there is no easy
- * way of knowing whether we are looking at a 4.4
- * fastlink or a 4.3 slowlink. This code always
- * guesses the 4.4 way when in doubt. THIS BREAKS 4.3
- * SLOWLINKS OF LENGTH FOUR OR LESS.
- */
- if ((link_len <= MAX_FASTLINK_SIZE && fp->i_ic.ic_db[1] != 0)
- || (link_len <= 4))
- {
- bcopy(fp->i_symlink, namebuf, (unsigned) link_len);
- }
- else
-#endif /* !DISABLE_BSD44_FASTLINKS */
-
- {
- /*
- * Read file for symbolic link
- */
- vm_offset_t buf;
- mach_msg_type_number_t buf_size;
- daddr_t disk_block;
- register struct fs *fs = fp->f_fs;
-
- (void) block_map(fp, (daddr_t)0, &disk_block);
- rc = device_read(fp->f_dev,
- 0,
- (recnum_t) fsbtodb(fs, disk_block),
- (int) blksize(fs, fp, 0),
- (char **) &buf,
- &buf_size);
- if (rc)
- goto exit;
-
- bcopy((char *)buf, namebuf, (unsigned)link_len);
- (void) vm_deallocate(mach_task_self(), buf, buf_size);
- }
-
- /*
- * If relative pathname, restart at parent directory.
- * If absolute pathname, restart at root.
- * If pathname begins '/dev/<device>/',
- * restart at root of that device.
- */
- cp = namebuf;
- if (*cp != '/') {
- inumber = parent_inumber;
- }
- else if (!strprefix(cp, "/dev/")) {
- inumber = (ino_t)ROOTINO;
- }
- else {
- cp += 5;
- component = cp;
- while ((c = *cp) != '\0' && c != '/') {
- cp++;
- }
- *cp = '\0';
-
- /*
- * Unmount current file system and free buffers.
- */
- close_file(fp);
-
- /*
- * Open new root device.
- */
- rc = device_open(master_device_port,
- D_READ,
- component,
- &fp->f_dev);
- if (rc)
- return (rc);
-
- if (c == 0) {
- fp->f_fs = 0;
- goto out_ok;
- }
-
- *cp = c;
-
- rc = mount_fs(fp);
- if (rc)
- return (rc);
-
- inumber = (ino_t)ROOTINO;
- }
- if ((rc = read_inode(inumber, fp)) != 0)
- goto exit;
- }
- }
-
- /*
- * Found terminal component.
- */
- out_ok:
- mutex_init(&fp->f_lock);
- return 0;
-
- /*
- * At error exit, close file to free storage.
- */
- exit:
- close_file(fp);
- return rc;
-}
-
-/*
- * Close file - free all storage used.
- */
-void
-ffs_close_file(fp)
- register struct file *fp;
-{
- register int i;
-
- /*
- * Free the disk super-block.
- */
- unmount_fs(fp);
-
- /*
- * Free the inode and data buffers.
- */
- free_file_buffers(fp);
-}
-
-int
-ffs_file_is_directory(struct file *fp)
-{
- return (fp->i_mode & IFMT) == IFDIR;
-}
-
-int
-ffs_file_is_regular(struct file *fp)
-{
- return (fp->i_mode & IFMT) == IFREG;
-}
-
-/*
- * Copy a portion of a file into kernel memory.
- * Cross block boundaries when necessary.
- */
-int
-ffs_read_file(fp, offset, start, size, resid)
- register struct file *fp;
- vm_offset_t offset;
- vm_offset_t start;
- vm_size_t size;
- vm_size_t *resid; /* out */
-{
- int rc;
- register vm_size_t csize;
- vm_offset_t buf;
- vm_size_t buf_size;
-
- while (size != 0) {
- rc = buf_read_file(fp, offset, &buf, &buf_size);
- if (rc)
- return (rc);
-
- csize = size;
- if (csize > buf_size)
- csize = buf_size;
- if (csize == 0)
- break;
-
- bcopy((char *)buf, (char *)start, csize);
-
- offset += csize;
- start += csize;
- size -= csize;
- }
- if (resid)
- *resid = size;
-
- return (0);
-}
-
-/* simple utility: only works for 2^n */
-static int
-log2(n)
- register unsigned int n;
-{
- register int i = 0;
-
- while ((n & 1) == 0) {
- i++;
- n >>= 1;
- }
- return i;
-}
-
-/*
- * Make an empty file_direct for a device.
- */
-int
-ffs_open_file_direct(dev, fdp, is_structured)
- mach_port_t dev;
- register struct file_direct *fdp;
- boolean_t is_structured;
-{
- struct fs *fs;
- int rc;
-
- if (!is_structured) {
- fdp->fd_dev = dev;
- fdp->fd_blocks = (daddr_t *) 0;
- fdp->fd_bsize = vm_page_size;
- fdp->fd_bshift = log2(vm_page_size);
- fdp->fd_fsbtodb = 0; /* later */
- fdp->fd_size = 0; /* later */
- return 0;
- }
-
- rc = read_fs(dev, &fs);
- if (rc)
- return rc;
-
- fdp->fd_dev = dev;
- fdp->fd_blocks = (daddr_t *) 0;
- fdp->fd_size = 0;
- fdp->fd_bsize = fs->fs_bsize;
- fdp->fd_bshift = fs->fs_bshift;
- fdp->fd_fsbtodb = fs->fs_fsbtodb;
-
- (void) vm_deallocate(mach_task_self(),
- (vm_offset_t) fs,
- SBSIZE);
-
- return 0;
-}
-
-/*
- * Add blocks from a file to a file_direct.
- */
-int
-ffs_add_file_direct(fdp, fp)
- register struct file_direct *fdp;
- register struct file *fp;
-{
- register struct fs *fs;
- long num_blocks, i;
- vm_offset_t buffer;
- vm_size_t size;
- int rc;
-
- /* the file must be on the same device */
-
- if (fdp->fd_dev != fp->f_dev)
- return FS_INVALID_FS;
-
- if (!file_is_structured(fp)) {
- int result[DEV_GET_SIZE_COUNT];
- natural_t count;
-
- count = DEV_GET_SIZE_COUNT;
- rc = device_get_status( fdp->fd_dev, DEV_GET_SIZE,
- result, &count);
- if (rc)
- return rc;
- fdp->fd_size = result[DEV_GET_SIZE_DEVICE_SIZE] >> fdp->fd_bshift;
- fdp->fd_fsbtodb = log2(fdp->fd_bsize/result[DEV_GET_SIZE_RECORD_SIZE]);
- return 0;
- }
-
- /* it must hold a file system */
-
- fs = fp->f_fs;
- if (fdp->fd_bsize != fs->fs_bsize ||
- fdp->fd_fsbtodb != fs->fs_fsbtodb)
- return FS_INVALID_FS;
-
- /* calculate number of blocks in the file, ignoring fragments */
-
- num_blocks = lblkno(fs, fp->i_size);
-
- /* allocate memory for a bigger array */
-
- size = (num_blocks + fdp->fd_size) * sizeof(daddr_t);
- rc = vm_allocate(mach_task_self(), &buffer, size, TRUE);
- if (rc != KERN_SUCCESS)
- return rc;
-
- /* lookup new block addresses */
-
- for (i = 0; i < num_blocks; i++) {
- daddr_t disk_block;
-
- rc = block_map(fp, (daddr_t) i, &disk_block);
- if (rc != 0) {
- (void) vm_deallocate(mach_task_self(), buffer, size);
- return rc;
- }
-
- ((daddr_t *) buffer)[fdp->fd_size + i] = disk_block;
- }
-
- /* copy old addresses and install the new array */
-
- if (fdp->fd_blocks != 0) {
- bcopy((char *) fdp->fd_blocks, (char *) buffer,
- fdp->fd_size * sizeof(daddr_t));
-
- (void) vm_deallocate(mach_task_self(),
- (vm_offset_t) fdp->fd_blocks,
- (vm_size_t) (fdp->fd_size * sizeof(daddr_t)));
- }
- fdp->fd_blocks = (daddr_t *) buffer;
- fdp->fd_size += num_blocks;
-
- /* deallocate cached blocks */
-
- free_file_buffers(fp);
-
- return 0;
-}
-
-int
-ffs_remove_file_direct(fdp)
- struct file_direct *fdp;
-{
- if (fdp->fd_blocks)
- (void) vm_deallocate(mach_task_self(),
- (vm_offset_t) fdp->fd_blocks,
- (vm_size_t) (fdp->fd_size * sizeof(daddr_t)));
- fdp->fd_blocks = 0; /* sanity */
- /* xxx should lose a ref to fdp->fd_dev here (and elsewhere) xxx */
-}
diff --git a/serverboot/file_io.c b/serverboot/file_io.c
deleted file mode 100644
index 99966f95..00000000
--- a/serverboot/file_io.c
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * Copyright (c) 1994 The University of Utah and
- * the Computer Systems Laboratory at the University of Utah (CSL).
- * All rights reserved.
- *
- * Permission to use, copy, modify and distribute this software is hereby
- * granted provided that (1) source code retains these copyright, permission,
- * and disclaimer notices, and (2) redistributions including binaries
- * reproduce the notices in supporting documentation, and (3) all advertising
- * materials mentioning features or use of this software display the following
- * acknowledgement: ``This product includes software developed by the
- * Computer Systems Laboratory at the University of Utah.''
- *
- * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
- * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
- * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * CSL requests users of this software to return to csl-dist@cs.utah.edu any
- * improvements that they make and grant CSL redistribution rights.
- *
- * Author: Bryan Ford, University of Utah CSL
- * MINIX FS patches: Csizmazia Balazs, University ELTE, Hungary
- */
-/* This is just an icky kludgy "VFS layer" (harhar) for ffs and ext2 and minix. */
-
-#include "file_io.h"
-
-int
-open_file(master_device_port, path, fp)
- mach_port_t master_device_port;
- char * path;
- struct file *fp;
-{
- int rc;
-
- if ((rc = ext2_open_file(master_device_port, path, fp))
- != FS_INVALID_FS)
- {
- if (rc == 0)
- fp->f_fstype = EXT2_FS;
- return rc;
- }
- if ( (rc = minix_open_file(master_device_port, path, fp))
- != FS_INVALID_FS )
- {
- if (rc == 0)
- fp->f_fstype = MINIX_FS;
- return rc;
- }
- fp->f_fstype = BSD_FFS;
- return ffs_open_file(master_device_port, path, fp);
-}
-
-void
-close_file(fp)
- register struct file *fp;
-{
- switch (fp->f_fstype) {
- case EXT2_FS:
- ext2_close_file(fp);
- return;
- case MINIX_FS:
- minix_close_file(fp);
- return;
- default:
- ffs_close_file(fp);
- return;
- }
-}
-
-int
-read_file(fp, offset, start, size, resid)
- register struct file *fp;
- vm_offset_t offset;
- vm_offset_t start;
- vm_size_t size;
- vm_size_t *resid; /* out */
-{
- switch (fp->f_fstype) {
- case EXT2_FS:
- return ext2_read_file(fp, offset, start, size, resid);
- case MINIX_FS:
- return minix_read_file(fp, offset, start, size, resid);
- default:
- return ffs_read_file(fp, offset, start, size, resid);
- }
-
-}
-
-int
-file_is_directory(struct file *f)
-{
- switch (f->f_fstype) {
- case EXT2_FS:
- return ext2_file_is_directory(f);
- case MINIX_FS:
- return minix_file_is_directory(f);
- default:
- return ffs_file_is_directory(f);
- }
-}
-
-int
-file_is_regular(struct file *f)
-{
- switch (f->f_fstype) {
- case EXT2_FS:
- return ext2_file_is_regular(f);
- case MINIX_FS:
- return minix_file_is_regular(f);
- default:
- return ffs_file_is_regular(f);
- }
-
-}
-
-int
-open_file_direct(dev, fdp, is_structured)
- mach_port_t dev;
- register struct file_direct *fdp;
- boolean_t is_structured;
-{
- int rc;
-
-
- if ((rc = ext2_open_file_direct(dev, fdp, is_structured))
- != FS_INVALID_FS)
- {
- if (rc == 0)
- fdp->f_fstype = EXT2_FS;
- return rc;
- }
- if ( (rc = minix_open_file_direct(dev, fdp, is_structured) )
- != FS_INVALID_FS )
- {
- if (rc == 0)
- fdp->f_fstype = MINIX_FS;
- return rc;
- }
- fdp->f_fstype = BSD_FFS;
- return ffs_open_file_direct(dev, fdp, is_structured);
-}
-
-int
-add_file_direct(fdp, fp)
- register struct file_direct *fdp;
- register struct file *fp;
-{
- switch (fp->f_fstype) {
- case EXT2_FS:
- return ext2_add_file_direct(fdp, fp);
- case MINIX_FS:
- return minix_add_file_direct(fdp, fp);
- default:
- return ffs_add_file_direct(fdp, fp);
- }
-}
-
-
-int
-remove_file_direct(fdp)
- struct file_direct *fdp;
-{
- switch (fdp->f_fstype) {
- case EXT2_FS:
- return ext2_remove_file_direct(fdp);
- case MINIX_FS:
- return minix_remove_file_direct(fdp);
- default:
- return ffs_remove_file_direct(fdp);
- }
-}
-
-/*
- * some other stuff, that was previously defined as macro
- */
-
-int
-file_is_structured(fp)
- register struct file *fp;
-{
- switch (fp->f_fstype) {
- case EXT2_FS:
- return (fp)->u.ext2.ext2_fs != 0;
- case MINIX_FS:
- return (fp)->u.minix.minix_fs != 0;
- default:
- return (fp)->u.ffs.ffs_fs != 0;
- }
-}
-
-/*
- * Special read and write routines for default pager.
- * Assume that all offsets and sizes are multiples
- * of DEV_BSIZE.
- */
-
-#define fdir_blkoff(fdp, offset) /* offset % fd_bsize */ \
- ((offset) & ((fdp)->fd_bsize - 1))
-#define fdir_lblkno(fdp, offset) /* offset / fd_bsize */ \
- ((offset) >> (fdp)->fd_bshift)
-
-#define fdir_fsbtodb(fdp, block) /* offset * fd_bsize / DEV_BSIZE */ \
- ((block) << (fdp)->fd_fsbtodb)
-
-/*
- * Read all or part of a data block, and
- * return a pointer to the appropriate part.
- * Caller must deallocate the block when done.
- */
-int
-page_read_file_direct(fdp, offset, size, addr, size_read)
- register struct file_direct *fdp;
- vm_offset_t offset;
- vm_size_t size;
- vm_offset_t *addr; /* out */
- mach_msg_type_number_t *size_read; /* out */
-{
- vm_offset_t off;
- register daddr_t file_block;
- daddr_t disk_block;
-
- if (offset % DEV_BSIZE != 0 ||
- size % DEV_BSIZE != 0)
- panic("page_read_file_direct");
-
- if (offset >= (fdp->fd_size << fdp->fd_bshift))
- return (FS_NOT_IN_FILE);
-
- off = fdir_blkoff(fdp, offset);
- file_block = fdir_lblkno(fdp, offset);
-
- if (file_is_device(fdp)) {
- disk_block = file_block;
- } else {
- disk_block = fdp->fd_blocks[file_block];
- if (disk_block == 0)
- return (FS_NOT_IN_FILE);
-
- if (size > fdp->fd_bsize) {
- /* Read only as much as is contiguous on disk. */
- daddr_t b = file_block + 1;
- while (b < file_block + fdp->fd_size &&
- fdp->fd_blocks[b] == disk_block + fdir_fsbtodb(fdp, 1))
- ++b;
- size = (b - file_block) * fdp->fd_bsize;
- }
- }
-
- return (device_read(fdp->fd_dev,
- 0,
- (recnum_t) (fdir_fsbtodb(fdp, disk_block) + btodb(off)),
- (int) size,
- (char **) addr,
- size_read));
-}
-
-/*
- * Write all or part of a data block, and
- * return the amount written.
- */
-int
-page_write_file_direct(fdp, offset, addr, size, size_written)
- register struct file_direct *fdp;
- vm_offset_t offset;
- vm_offset_t addr;
- vm_size_t size;
- vm_offset_t *size_written; /* out */
-{
- vm_offset_t off;
- register daddr_t file_block;
- daddr_t disk_block;
- int rc, num_written;
- vm_offset_t block_size;
-
- if (offset % DEV_BSIZE != 0 ||
- size % DEV_BSIZE != 0)
- panic("page_write_file");
-
- if (offset >= (fdp->fd_size << fdp->fd_bshift))
- return (FS_NOT_IN_FILE);
-
- off = fdir_blkoff(fdp, offset);
- file_block = fdir_lblkno(fdp, offset);
-
- if (file_is_device(fdp)) {
- disk_block = file_block;
- } else {
- disk_block = fdp->fd_blocks[file_block];
- if (disk_block == 0)
- return (FS_NOT_IN_FILE);
-
- if (size > fdp->fd_bsize) {
- /* Write only as much as is contiguous on disk. */
- daddr_t b = file_block + 1;
- while (b < file_block + fdp->fd_size &&
- fdp->fd_blocks[b] == disk_block + fdir_fsbtodb(fdp, 1))
- ++b;
- size = (b - file_block) * fdp->fd_bsize;
- }
- }
-
- /*
- * Write the data. Wait for completion to keep
- * reads from getting ahead of writes and reading
- * stale data.
- */
- rc = device_write(
- fdp->fd_dev,
- 0,
- (recnum_t) (fdir_fsbtodb(fdp, disk_block) + btodb(off)),
- (char *) addr,
- size,
- &num_written);
- *size_written = num_written;
- return rc;
-}
diff --git a/serverboot/file_io.h b/serverboot/file_io.h
deleted file mode 100644
index 323e4e9a..00000000
--- a/serverboot/file_io.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-
-#ifndef _FILE_IO_H_
-#define _FILE_IO_H_
-
-/*
- * Read-only file IO.
- */
-
-#include <mach.h>
-#include <cthreads.h>
-
-#include <stdint.h>
-#include <device/device_types.h>
-
-/* Types used by the ext2 header files. */
-typedef u_int32_t __u32;
-typedef int32_t __s32;
-typedef u_int16_t __u16;
-typedef int16_t __s16;
-typedef u_int8_t __u8;
-typedef int8_t __s8;
-
-#include <defs.h>
-#include "minix_fs.h"
-#include "../ext2fs/ext2_fs.h" /* snarf stolen linux header from ext2fs */
-#include "disk_inode.h"
-
-#define BSD_FFS 0
-#define EXT2_FS 1
-#define MINIX_FS 2
-
-#define EXT2_NIADDR (EXT2_N_BLOCKS - EXT2_NDIR_BLOCKS)
-
-/*
- * In-core open file.
- */
-struct file {
- struct mutex f_lock; /* lock */
- mach_port_t f_dev; /* port to device */
- vm_offset_t f_buf; /* buffer for data block */
- vm_size_t f_buf_size; /* size of data block */
- daddr_t f_buf_blkno; /* block number of data block */
- vm_size_t f_size; /* size in bytes of the file */
-
- int f_fstype; /* contains fs-id */
-
- union {
- struct {
- struct fs * ffs_fs; /* pointer to super-block */
- struct icommon ffs_ic; /* copy of on-disk inode */
-
- /* number of blocks mapped by
- indirect block at level i */
- int ffs_nindir[FFS_NIADDR+1];
-
- /* buffer for indirect block at level i */
- vm_offset_t ffs_blk[FFS_NIADDR];
-
- /* size of buffer */
- vm_size_t ffs_blksize[FFS_NIADDR];
-
- /* disk address of block in buffer */
- daddr_t ffs_blkno[FFS_NIADDR];
- } ffs;
- struct {
- /* pointer to super-block */
- struct ext2_super_block*ext2_fs;
-
- /* pointer to group descriptors */
- struct ext2_group_desc* ext2_gd;
-
- /* size of group descriptors */
- vm_size_t ext2_gd_size;
-
- /* copy of on-disk inode */
- struct ext2_inode ext2_ic;
-
- /* number of blocks mapped by
- indirect block at level i */
- int ext2_nindir[EXT2_NIADDR+1];
-
- /* buffer for indirect block at level i */
- vm_offset_t ext2_blk[EXT2_NIADDR];
-
- /* size of buffer */
- vm_size_t ext2_blksize[EXT2_NIADDR];
-
- /* disk address of block in buffer */
- daddr_t ext2_blkno[EXT2_NIADDR];
- } ext2;
- struct {
- /* pointer to super-block */
- struct minix_super_block* minix_fs;
-
- /* copy of on-disk inode */
- struct minix_inode minix_ic;
-
- /* number of blocks mapped by
- indirect block at level i */
- int minix_nindir[MINIX_NIADDR+1];
-
- /* buffer for indirect block at level i */
- vm_offset_t minix_blk[MINIX_NIADDR];
-
- /* size of buffer */
- vm_size_t minix_blksize[MINIX_NIADDR];
-
- /* disk address of block in buffer */
- minix_daddr_t minix_blkno[MINIX_NIADDR];
- } minix;
- } u;
-};
-
-/*
- * In-core open file, with in-core block map.
- */
-struct file_direct {
- int f_fstype; /* XXX was: true if ext2, false if ffs */
-
- mach_port_t fd_dev; /* port to device */
- daddr_t * fd_blocks; /* array of disk block addresses */
- long fd_size; /* number of blocks in the array */
- long fd_bsize; /* disk block size */
- long fd_bshift; /* log2(fd_bsize) */
- long fd_fsbtodb; /* log2(fd_bsize / disk sector size) */
-};
-
-#define file_is_device(_fd_) ((_fd_)->fd_blocks == 0)
-
-/*
- * Exported routines.
- */
-
-extern int open_file();
-extern void close_file();
-extern int read_file();
-
-extern int open_file_direct();
-extern int add_file_direct();
-extern int remove_file_direct();
-extern int file_wire_direct();
-extern int page_read_file_direct();
-extern int page_write_file_direct();
-
-/*
- * Error codes for file system errors.
- */
-
-#include <errno.h>
-
-/* Just use the damn Hurd error numbers. This is old CMU/Utah code from
- the days of personality-independent Mach where it made sense for this to
- be a standalone universe. In the Hurd, we compile serverboot against
- the regular C library anyway. */
-
-#define FS_NOT_DIRECTORY ENOTDIR
-#define FS_NO_ENTRY ENOENT
-#define FS_NAME_TOO_LONG ENAMETOOLONG
-#define FS_SYMLINK_LOOP ELOOP
-#define FS_INVALID_FS EFTYPE /* ? */
-#define FS_NOT_IN_FILE EINVAL
-#define FS_INVALID_PARAMETER EINVAL
-
-#if 0
-#define FS_NOT_DIRECTORY 5000 /* not a directory */
-#define FS_NO_ENTRY 5001 /* name not found */
-#define FS_NAME_TOO_LONG 5002 /* name too long */
-#define FS_SYMLINK_LOOP 5003 /* symbolic link loop */
-#define FS_INVALID_FS 5004 /* bad file system */
-#define FS_NOT_IN_FILE 5005 /* offset not in file */
-#define FS_INVALID_PARAMETER 5006 /* bad parameter to routine */
-#endif
-
-
-#endif /* _FILE_IO_H_ */
diff --git a/serverboot/fs.h b/serverboot/fs.h
deleted file mode 100644
index 5809ed93..00000000
--- a/serverboot/fs.h
+++ /dev/null
@@ -1,455 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * Copyright (c) 1982, 1986 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#)fs.h 7.7 (Berkeley) 5/9/89
- */
-
-/*
- * Each disk drive contains some number of file systems.
- * A file system consists of a number of cylinder groups.
- * Each cylinder group has inodes and data.
- *
- * A file system is described by its super-block, which in turn
- * describes the cylinder groups. The super-block is critical
- * data and is replicated in each cylinder group to protect against
- * catastrophic loss. This is done at `newfs' time and the critical
- * super-block data does not change, so the copies need not be
- * referenced further unless disaster strikes.
- *
- * For file system fs, the offsets of the various blocks of interest
- * are given in the super block as:
- * [fs->fs_sblkno] Super-block
- * [fs->fs_cblkno] Cylinder group block
- * [fs->fs_iblkno] Inode blocks
- * [fs->fs_dblkno] Data blocks
- * The beginning of cylinder group cg in fs, is given by
- * the ``cgbase(fs, cg)'' macro.
- *
- * The first boot and super blocks are given in absolute disk addresses.
- * The byte-offset forms are preferred, as they don't imply a sector size.
- */
-#define BBSIZE 8192
-#define SBSIZE 8192
-#define BBOFF ((off_t)(0))
-#define SBOFF ((off_t)(BBOFF + BBSIZE))
-#define BBLOCK ((daddr_t)(0))
-#define SBLOCK ((daddr_t)(BBLOCK + BBSIZE / DEV_BSIZE))
-
-/*
- * Addresses stored in inodes are capable of addressing fragments
- * of `blocks'. File system blocks of at most size MAXBSIZE can
- * be optionally broken into 2, 4, or 8 pieces, each of which is
- * addressible; these pieces may be DEV_BSIZE, or some multiple of
- * a DEV_BSIZE unit.
- *
- * Large files consist of exclusively large data blocks. To avoid
- * undue wasted disk space, the last data block of a small file may be
- * allocated as only as many fragments of a large block as are
- * necessary. The file system format retains only a single pointer
- * to such a fragment, which is a piece of a single large block that
- * has been divided. The size of such a fragment is determinable from
- * information in the inode, using the ``blksize(fs, ip, lbn)'' macro.
- *
- * The file system records space availability at the fragment level;
- * to determine block availability, aligned fragments are examined.
- *
- * The root inode is the root of the file system.
- * Inode 0 can't be used for normal purposes and
- * historically bad blocks were linked to inode 1,
- * thus the root inode is 2. (inode 1 is no longer used for
- * this purpose, however numerous dump tapes make this
- * assumption, so we are stuck with it)
- */
-#define ROOTINO ((ino_t)2) /* i number of all roots */
-
-/*
- * MINBSIZE is the smallest allowable block size.
- * In order to insure that it is possible to create files of size
- * 2^32 with only two levels of indirection, MINBSIZE is set to 4096.
- * MINBSIZE must be big enough to hold a cylinder group block,
- * thus changes to (struct cg) must keep its size within MINBSIZE.
- * Note that super blocks are always of size SBSIZE,
- * and that both SBSIZE and MAXBSIZE must be >= MINBSIZE.
- */
-#define MINBSIZE 4096
-
-/*
- * The path name on which the file system is mounted is maintained
- * in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in
- * the super block for this name.
- * The limit on the amount of summary information per file system
- * is defined by MAXCSBUFS. It is currently parameterized for a
- * maximum of two million cylinders.
- */
-#define MAXMNTLEN 512
-#define MAXCSBUFS 32
-
-/*
- * Per cylinder group information; summarized in blocks allocated
- * from first cylinder group data blocks. These blocks have to be
- * read in from fs_csaddr (size fs_cssize) in addition to the
- * super block.
- *
- * N.B. sizeof(struct csum) must be a power of two in order for
- * the ``fs_cs'' macro to work (see below).
- */
-struct csum {
- int cs_ndir; /* number of directories */
- int cs_nbfree; /* number of free blocks */
- int cs_nifree; /* number of free inodes */
- int cs_nffree; /* number of free frags */
-};
-
-/*
- * Super block for a file system.
- */
-#define FS_MAGIC 0x011954
-struct fs
-{
- int xxx1; /* struct fs *fs_link;*/
- int xxx2; /* struct fs *fs_rlink;*/
- daddr_t fs_sblkno; /* addr of super-block in filesys */
- daddr_t fs_cblkno; /* offset of cyl-block in filesys */
- daddr_t fs_iblkno; /* offset of inode-blocks in filesys */
- daddr_t fs_dblkno; /* offset of first data after cg */
- int fs_cgoffset; /* cylinder group offset in cylinder */
- int fs_cgmask; /* used to calc mod fs_ntrak */
- time_t fs_time; /* last time written */
- int fs_size; /* number of blocks in fs */
- int fs_dsize; /* number of data blocks in fs */
- int fs_ncg; /* number of cylinder groups */
- int fs_bsize; /* size of basic blocks in fs */
- int fs_fsize; /* size of frag blocks in fs */
- int fs_frag; /* number of frags in a block in fs */
-/* these are configuration parameters */
- int fs_minfree; /* minimum percentage of free blocks */
- int fs_rotdelay; /* num of ms for optimal next block */
- int fs_rps; /* disk revolutions per second */
-/* these fields can be computed from the others */
- int fs_bmask; /* ``blkoff'' calc of blk offsets */
- int fs_fmask; /* ``fragoff'' calc of frag offsets */
- int fs_bshift; /* ``lblkno'' calc of logical blkno */
- int fs_fshift; /* ``numfrags'' calc number of frags */
-/* these are configuration parameters */
- int fs_maxcontig; /* max number of contiguous blks */
- int fs_maxbpg; /* max number of blks per cyl group */
-/* these fields can be computed from the others */
- int fs_fragshift; /* block to frag shift */
- int fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */
- int fs_sbsize; /* actual size of super block */
- int fs_csmask; /* csum block offset */
- int fs_csshift; /* csum block number */
- int fs_nindir; /* value of NINDIR */
- int fs_inopb; /* value of INOPB */
- int fs_nspf; /* value of NSPF */
-/* yet another configuration parameter */
- int fs_optim; /* optimization preference, see below */
-/* these fields are derived from the hardware */
- int fs_npsect; /* # sectors/track including spares */
- int fs_interleave; /* hardware sector interleave */
- int fs_trackskew; /* sector 0 skew, per track */
- int fs_headswitch; /* head switch time, usec */
- int fs_trkseek; /* track-to-track seek, usec */
-/* sizes determined by number of cylinder groups and their sizes */
- daddr_t fs_csaddr; /* blk addr of cyl grp summary area */
- int fs_cssize; /* size of cyl grp summary area */
- int fs_cgsize; /* cylinder group size */
-/* these fields are derived from the hardware */
- int fs_ntrak; /* tracks per cylinder */
- int fs_nsect; /* sectors per track */
- int fs_spc; /* sectors per cylinder */
-/* this comes from the disk driver partitioning */
- int fs_ncyl; /* cylinders in file system */
-/* these fields can be computed from the others */
- int fs_cpg; /* cylinders per group */
- int fs_ipg; /* inodes per group */
- int fs_fpg; /* blocks per group * fs_frag */
-/* this data must be re-computed after crashes */
- struct csum fs_cstotal; /* cylinder summary information */
-/* these fields are cleared at mount time */
- char fs_fmod; /* super block modified flag */
- char fs_clean; /* file system is clean flag */
- char fs_ronly; /* mounted read-only flag */
- char fs_flags; /* currently unused flag */
- char fs_fsmnt[MAXMNTLEN]; /* name mounted on */
-/* these fields retain the current block allocation info */
- int fs_cgrotor; /* last cg searched */
-#if 1
- int was_fs_csp[MAXCSBUFS];
-#else
- struct csum *fs_csp[MAXCSBUFS];/* list of fs_cs info buffers */
-#endif
- int fs_cpc; /* cyl per cycle in postbl */
- short fs_opostbl[16][8]; /* old rotation block list head */
- long fs_sparecon[50]; /* reserved for future constants */
- long fs_contigsumsize; /* size of cluster summary array */
- long fs_maxsymlinklen; /* max length of an internal symlink */
- long fs_inodefmt; /* format of on-disk inodes */
- quad fs_maxfilesize; /* maximum representable file size */
- quad fs_qbmask; /* ~fs_bmask - for use with quad size */
- quad fs_qfmask; /* ~fs_fmask - for use with quad size */
- long fs_state; /* validate fs_clean field */
- int fs_postblformat; /* format of positional layout tables */
- int fs_nrpos; /* number of rotaional positions */
- int fs_postbloff; /* (short) rotation block list head */
- int fs_rotbloff; /* (u_char) blocks for each rotation */
- int fs_magic; /* magic number */
- u_char fs_space[1]; /* list of blocks for each rotation */
-/* actually longer */
-};
-/*
- * Preference for optimization.
- */
-#define FS_OPTTIME 0 /* minimize allocation time */
-#define FS_OPTSPACE 1 /* minimize disk fragmentation */
-
-/*
- * Rotational layout table format types
- */
-#define FS_42POSTBLFMT -1 /* 4.2BSD rotational table format */
-#define FS_DYNAMICPOSTBLFMT 1 /* dynamic rotational table format */
-/*
- * Macros for access to superblock array structures
- */
-#define fs_postbl(fs, cylno) \
- (((fs)->fs_postblformat == FS_42POSTBLFMT) \
- ? ((fs)->fs_opostbl[cylno]) \
- : ((short *)((char *)(fs) + (fs)->fs_postbloff) + (cylno) * (fs)->fs_nrpos))
-#define fs_rotbl(fs) \
- (((fs)->fs_postblformat == FS_42POSTBLFMT) \
- ? ((fs)->fs_space) \
- : ((u_char *)((char *)(fs) + (fs)->fs_rotbloff)))
-
-/*
- * Convert cylinder group to base address of its global summary info.
- *
- * N.B. This macro assumes that sizeof(struct csum) is a power of two.
- */
-#define fs_cs(fs, indx) \
- fs_csp[(indx) >> (fs)->fs_csshift][(indx) & ~(fs)->fs_csmask]
-
-/*
- * Cylinder group block for a file system.
- */
-#define CG_MAGIC 0x090255
-struct cg {
- int xxx1; /* struct cg *cg_link;*/
- int cg_magic; /* magic number */
- time_t cg_time; /* time last written */
- int cg_cgx; /* we are the cgx'th cylinder group */
- short cg_ncyl; /* number of cyl's this cg */
- short cg_niblk; /* number of inode blocks this cg */
- int cg_ndblk; /* number of data blocks this cg */
- struct csum cg_cs; /* cylinder summary information */
- int cg_rotor; /* position of last used block */
- int cg_frotor; /* position of last used frag */
- int cg_irotor; /* position of last used inode */
- int cg_frsum[MAXFRAG]; /* counts of available frags */
- int cg_btotoff; /* (long) block totals per cylinder */
- int cg_boff; /* (short) free block positions */
- int cg_iusedoff; /* (char) used inode map */
- int cg_freeoff; /* (u_char) free block map */
- int cg_nextfreeoff; /* (u_char) next available space */
- int cg_sparecon[16]; /* reserved for future use */
- u_char cg_space[1]; /* space for cylinder group maps */
-/* actually longer */
-};
-/*
- * Macros for access to cylinder group array structures
- */
-#define cg_blktot(cgp) \
- (((cgp)->cg_magic != CG_MAGIC) \
- ? (((struct ocg *)(cgp))->cg_btot) \
- : ((int *)((char *)(cgp) + (cgp)->cg_btotoff)))
-#define cg_blks(fs, cgp, cylno) \
- (((cgp)->cg_magic != CG_MAGIC) \
- ? (((struct ocg *)(cgp))->cg_b[cylno]) \
- : ((short *)((char *)(cgp) + (cgp)->cg_boff) + (cylno) * (fs)->fs_nrpos))
-#define cg_inosused(cgp) \
- (((cgp)->cg_magic != CG_MAGIC) \
- ? (((struct ocg *)(cgp))->cg_iused) \
- : ((char *)((char *)(cgp) + (cgp)->cg_iusedoff)))
-#define cg_blksfree(cgp) \
- (((cgp)->cg_magic != CG_MAGIC) \
- ? (((struct ocg *)(cgp))->cg_free) \
- : ((u_char *)((char *)(cgp) + (cgp)->cg_freeoff)))
-#define cg_chkmagic(cgp) \
- ((cgp)->cg_magic == CG_MAGIC || ((struct ocg *)(cgp))->cg_magic == CG_MAGIC)
-
-/*
- * The following structure is defined
- * for compatibility with old file systems.
- */
-struct ocg {
- int xxx1; /* struct ocg *cg_link;*/
- int xxx2; /* struct ocg *cg_rlink;*/
- time_t cg_time; /* time last written */
- int cg_cgx; /* we are the cgx'th cylinder group */
- short cg_ncyl; /* number of cyl's this cg */
- short cg_niblk; /* number of inode blocks this cg */
- int cg_ndblk; /* number of data blocks this cg */
- struct csum cg_cs; /* cylinder summary information */
- int cg_rotor; /* position of last used block */
- int cg_frotor; /* position of last used frag */
- int cg_irotor; /* position of last used inode */
- int cg_frsum[8]; /* counts of available frags */
- int cg_btot[32]; /* block totals per cylinder */
- short cg_b[32][8]; /* positions of free blocks */
- char cg_iused[256]; /* used inode map */
- int cg_magic; /* magic number */
- u_char cg_free[1]; /* free block map */
-/* actually longer */
-};
-
-/*
- * Turn file system block numbers into disk block addresses.
- * This maps file system blocks to device size blocks.
- */
-#define fsbtodb(fs, b) ((b) << (fs)->fs_fsbtodb)
-#define dbtofsb(fs, b) ((b) >> (fs)->fs_fsbtodb)
-
-/*
- * Cylinder group macros to locate things in cylinder groups.
- * They calc file system addresses of cylinder group data structures.
- */
-#define cgbase(fs, c) ((daddr_t)((fs)->fs_fpg * (c)))
-#define cgstart(fs, c) \
- (cgbase(fs, c) + (fs)->fs_cgoffset * ((c) & ~((fs)->fs_cgmask)))
-#define cgsblock(fs, c) (cgstart(fs, c) + (fs)->fs_sblkno) /* super blk */
-#define cgtod(fs, c) (cgstart(fs, c) + (fs)->fs_cblkno) /* cg block */
-#define cgimin(fs, c) (cgstart(fs, c) + (fs)->fs_iblkno) /* inode blk */
-#define cgdmin(fs, c) (cgstart(fs, c) + (fs)->fs_dblkno) /* 1st data */
-
-/*
- * Macros for handling inode numbers:
- * inode number to file system block offset.
- * inode number to cylinder group number.
- * inode number to file system block address.
- */
-#define itoo(fs, x) ((x) % INOPB(fs))
-#define itog(fs, x) ((x) / (fs)->fs_ipg)
-#define itod(fs, x) \
- ((daddr_t)(cgimin(fs, itog(fs, x)) + \
- (blkstofrags((fs), (((x) % (fs)->fs_ipg) / INOPB(fs))))))
-
-/*
- * Give cylinder group number for a file system block.
- * Give cylinder group block number for a file system block.
- */
-#define dtog(fs, d) ((d) / (fs)->fs_fpg)
-#define dtogd(fs, d) ((d) % (fs)->fs_fpg)
-
-/*
- * Extract the bits for a block from a map.
- * Compute the cylinder and rotational position of a cyl block addr.
- */
-#define blkmap(fs, map, loc) \
- (((map)[(loc) / NBBY] >> ((loc) % NBBY)) & (0xff >> (NBBY - (fs)->fs_frag)))
-#define cbtocylno(fs, bno) \
- ((bno) * NSPF(fs) / (fs)->fs_spc)
-#define cbtorpos(fs, bno) \
- (((bno) * NSPF(fs) % (fs)->fs_spc / (fs)->fs_nsect * (fs)->fs_trackskew + \
- (bno) * NSPF(fs) % (fs)->fs_spc % (fs)->fs_nsect * (fs)->fs_interleave) % \
- (fs)->fs_nsect * (fs)->fs_nrpos / (fs)->fs_npsect)
-
-/*
- * The following macros optimize certain frequently calculated
- * quantities by using shifts and masks in place of divisions
- * modulos and multiplications.
- */
-#define blkoff(fs, loc) /* calculates (loc % fs->fs_bsize) */ \
- ((loc) & ~(fs)->fs_bmask)
-#define fragoff(fs, loc) /* calculates (loc % fs->fs_fsize) */ \
- ((loc) & ~(fs)->fs_fmask)
-#define lblkno(fs, loc) /* calculates (loc / fs->fs_bsize) */ \
- ((loc) >> (fs)->fs_bshift)
-#define numfrags(fs, loc) /* calculates (loc / fs->fs_fsize) */ \
- ((loc) >> (fs)->fs_fshift)
-#define blkroundup(fs, size) /* calculates roundup(size, fs->fs_bsize) */ \
- (((size) + (fs)->fs_bsize - 1) & (fs)->fs_bmask)
-#define fragroundup(fs, size) /* calculates roundup(size, fs->fs_fsize) */ \
- (((size) + (fs)->fs_fsize - 1) & (fs)->fs_fmask)
-#define fragstoblks(fs, frags) /* calculates (frags / fs->fs_frag) */ \
- ((frags) >> (fs)->fs_fragshift)
-#define blkstofrags(fs, blks) /* calculates (blks * fs->fs_frag) */ \
- ((blks) << (fs)->fs_fragshift)
-#define fragnum(fs, fsb) /* calculates (fsb % fs->fs_frag) */ \
- ((fsb) & ((fs)->fs_frag - 1))
-#define blknum(fs, fsb) /* calculates rounddown(fsb, fs->fs_frag) */ \
- ((fsb) &~ ((fs)->fs_frag - 1))
-
-/*
- * Determine the number of available frags given a
- * percentage to hold in reserve
- */
-#define freespace(fs, percentreserved) \
- (blkstofrags((fs), (fs)->fs_cstotal.cs_nbfree) + \
- (fs)->fs_cstotal.cs_nffree - ((fs)->fs_dsize * (percentreserved) / 100))
-
-/*
- * Determining the size of a file block in the file system.
- */
-#define blksize(fs, ip, lbn) \
- (((lbn) >= NDADDR || (ip)->i_size >= ((lbn) + 1) << (fs)->fs_bshift) \
- ? (fs)->fs_bsize \
- : (fragroundup(fs, blkoff(fs, (ip)->i_size))))
-#define dblksize(fs, dip, lbn) \
- (((lbn) >= NDADDR || (dip)->di_size >= ((lbn) + 1) << (fs)->fs_bshift) \
- ? (fs)->fs_bsize \
- : (fragroundup(fs, blkoff(fs, (dip)->di_size))))
-
-/*
- * Number of disk sectors per block; assumes DEV_BSIZE byte sector size.
- */
-#define NSPB(fs) ((fs)->fs_nspf << (fs)->fs_fragshift)
-#define NSPF(fs) ((fs)->fs_nspf)
-
-/*
- * INOPB is the number of inodes in a secondary storage block.
- */
-#define INOPB(fs) ((fs)->fs_inopb)
-#define INOPF(fs) ((fs)->fs_inopb >> (fs)->fs_fragshift)
-
-/*
- * NINDIR is the number of indirects in a file system block.
- */
-#define NINDIR(fs) ((fs)->fs_nindir)
-
diff --git a/serverboot/gets.c b/serverboot/gets.c
deleted file mode 100644
index 61d14460..00000000
--- a/serverboot/gets.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1993-1989 Carnegie Mellon University.
- * Copyright (c) 1994 The University of Utah and
- * the Computer Systems Laboratory (CSL).
- * All rights reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF
- * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM ANY LIABILITY
- * OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF
- * THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-
-#include <mach.h>
-#include <device/device.h>
-#include <varargs.h>
-
-extern mach_port_t __libmach_console_port;
-
-safe_gets(str, maxlen)
- char *str;
- int maxlen;
-{
- register char *lp;
- register int c;
-
- char inbuf[IO_INBAND_MAX];
- mach_msg_type_number_t count;
- register char *ip;
- char *strmax = str + maxlen - 1; /* allow space for trailing 0 */
-
- lp = str;
- for (;;) {
- count = IO_INBAND_MAX;
- (void) device_read_inband(__libmach_console_port,
- (dev_mode_t)0, (recnum_t)0,
- sizeof(inbuf), inbuf, &count);
- for (ip = inbuf; ip < &inbuf[count]; ip++) {
- c = *ip;
- switch (c) {
- case '\n':
- case '\r':
- printf("\n");
- *lp++ = 0;
- return;
-
- case '\b':
- case '#':
- case '\177':
- if (lp > str) {
- printf("\b \b");
- lp--;
- }
- continue;
- case '@':
- case 'u'&037:
- lp = str;
- printf("\n\r");
- continue;
- default:
- if (c >= ' ' && c < '\177') {
- if (lp < strmax) {
- *lp++ = c;
- printf("%c", c);
- }
- else {
- printf("%c", '\007'); /* beep */
- }
- }
- }
- }
- }
-}
-
diff --git a/serverboot/gunzip.c b/serverboot/gunzip.c
deleted file mode 100644
index f74da111..00000000
--- a/serverboot/gunzip.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/* Modified by okuji@kuicr.kyoto-u.ac.jp for use in serverboot. */
-/* Decompressing store backend
-
- Copyright (C) 1997 Free Software Foundation, Inc.
- Written by Miles Bader <miles@gnu.ai.mit.edu>
- This file is part of the GNU Hurd.
-
- The GNU Hurd 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, or (at
- your option) any later version.
-
- The GNU Hurd 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
-
-#include <stdio.h>
-#include <string.h>
-#include <setjmp.h>
-#include <cthreads.h>
-#include <errno.h>
-
-#include <file_io.h>
-
-/* gzip.h makes several annoying defines & decls, which we have to work
- around. */
-#define file_t gzip_file_t
-#include "gzip.h"
-#undef file_t
-#undef head
-
-#define IN_BUFFERING (256*1024)
-#define OUT_BUFFERING (512*1024)
-
-static struct mutex unzip_lock = MUTEX_INITIALIZER;
-
-/* Uncompress the contents of FROM, which should contain a valid gzip file,
- into memory, returning the result buffer in BUF & BUF_LEN. */
-int
-serverboot_gunzip (struct file *from, void **buf, size_t *buf_len)
-{
- /* Entry points to unzip engine. */
- int get_method (int);
- extern long int bytes_out;
- /* Callbacks from unzip for I/O and error interface. */
- extern int (*unzip_read) (char *buf, size_t maxread);
- extern void (*unzip_write) (const char *buf, size_t nwrite);
- extern void (*unzip_read_error) (void);
- extern void (*unzip_error) (const char *msg);
-
- /* How we return errors from our hook functions. */
- jmp_buf zerr_jmp_buf;
- int zerr;
-
- size_t offset = 0; /* Offset of read point in FROM. */
-
- /* Read at most MAXREAD (or 0 if eof) bytes into BUF from our current
- position in FROM. */
- int zread (char *buf, size_t maxread)
- {
- vm_size_t resid;
- size_t did_read;
-
- if (from->f_size - offset < maxread)
- did_read = from->f_size - offset;
- else
- did_read = maxread;
-
- zerr = read_file (from, offset, buf, did_read, &resid);
- if (zerr)
- longjmp (zerr_jmp_buf, 1);
-
- did_read -= resid;
- offset += did_read;
-
- return did_read;
- }
-
- size_t out_buf_offs = 0; /* Position in the output buffer. */
-
- /* Write uncompress data to our output buffer. */
- void zwrite (const char *wbuf, size_t nwrite)
- {
- size_t old_buf_len = *buf_len;
-
- if (out_buf_offs + nwrite > old_buf_len)
- /* Have to grow the output buffer. */
- {
- void *old_buf = *buf;
- void *new_buf = old_buf + old_buf_len; /* First try. */
- size_t new_buf_len = round_page (old_buf_len + old_buf_len + nwrite);
-
- /* Try to grow the buffer. */
- zerr =
- vm_allocate (mach_task_self (),
- (vm_address_t *)&new_buf, new_buf_len - old_buf_len,
- 0);
- if (zerr)
- /* Can't do that, try to make a bigger buffer elsewhere. */
- {
- new_buf = old_buf;
- zerr =
- vm_allocate (mach_task_self (),
- (vm_address_t *)&new_buf, new_buf_len, 1);
- if (zerr)
- longjmp (zerr_jmp_buf, 1);
-
- if (out_buf_offs > 0)
- /* Copy the old buffer into the start of the new & free it. */
- bcopy (old_buf, new_buf, out_buf_offs);
-
- vm_deallocate (mach_task_self (),
- (vm_address_t)old_buf, old_buf_len);
-
- *buf = new_buf;
- }
-
- *buf_len = new_buf_len;
- }
-
- bcopy (wbuf, *buf + out_buf_offs, nwrite);
- out_buf_offs += nwrite;
- }
-
- void zreaderr (void)
- {
- zerr = EIO;
- longjmp (zerr_jmp_buf, 1);
- }
- void zerror (const char *msg)
- {
- zerr = EINVAL;
- longjmp (zerr_jmp_buf, 2);
- }
-
- /* Try to guess a reasonable output buffer size. */
- *buf_len = round_page (from->f_size * 2);
- zerr = vm_allocate (mach_task_self (), (vm_address_t *)buf, *buf_len, 1);
- if (zerr)
- return zerr;
-
- mutex_lock (&unzip_lock);
-
- unzip_read = zread;
- unzip_write = zwrite;
- unzip_read_error = zreaderr;
- unzip_error = zerror;
-
- if (! setjmp (zerr_jmp_buf))
- {
- if (get_method (0) != 0)
- /* Not a happy gzip file. */
- zerr = EINVAL;
- else
- /* Matched gzip magic number. Ready to unzip.
- Set up the output stream and let 'er rip. */
- {
- /* Call the gunzip engine. */
- bytes_out = 0;
- unzip (17, 23); /* Arguments ignored. */
- zerr = 0;
- }
- }
-
- mutex_unlock (&unzip_lock);
-
- if (zerr)
- {
- if (*buf_len > 0)
- vm_deallocate (mach_task_self (), (vm_address_t)*buf, *buf_len);
- }
- else if (out_buf_offs < *buf_len)
- /* Trim the output buffer to be the right length. */
- {
- size_t end = round_page (out_buf_offs);
- if (end < *buf_len)
- vm_deallocate (mach_task_self (),
- (vm_address_t)(*buf + end), *buf_len - end);
- *buf_len = out_buf_offs;
- }
-
- return zerr;
-}
diff --git a/serverboot/load.c b/serverboot/load.c
deleted file mode 100644
index aa481943..00000000
--- a/serverboot/load.c
+++ /dev/null
@@ -1,555 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-
-#include <stddef.h>
-#include <assert.h>
-#include <mach/mach_interface.h>
-#include "mach-exec.h"
-#include "../boot/boot_script.h"
-
-#include <file_io.h>
-
-
-boolean_t load_protect_text = TRUE;
-
-
-struct stuff
-{
- struct file *fp;
- task_t user_task;
-
- /* uncompressed image */
- vm_offset_t image_addr;
- vm_size_t image_size;
-
- vm_offset_t aout_symtab_ofs;
- vm_size_t aout_symtab_size;
- vm_offset_t aout_strtab_ofs;
- vm_size_t aout_strtab_size;
-};
-
-char *set_regs(
- mach_port_t user_task,
- mach_port_t user_thread,
- struct exec_info *info,
- int arg_size);
-
-static void read_symtab_from_file(
- struct file *fp,
- mach_port_t host_port,
- task_t task,
- char * symtab_name,
- struct stuff *st);
-
-/* Callback functions for reading the executable file. */
-static int prog_read(void *handle, vm_offset_t file_ofs, void *buf, vm_size_t size,
- vm_size_t *out_actual)
-{
- struct stuff *st = handle;
- vm_size_t resid;
- int result;
-
- result = read_file(st->fp, file_ofs, buf, size, &resid);
- if (result)
- return result;
- *out_actual = size - resid;
- return 0;
-}
-
-static int prog_read_exec(void *handle, vm_offset_t file_ofs, vm_size_t file_size,
- vm_offset_t mem_addr, vm_size_t mem_size,
- exec_sectype_t sec_type)
-{
- struct stuff *st = handle;
- vm_offset_t page_start = trunc_page(mem_addr);
- vm_offset_t page_end = round_page(mem_addr + mem_size);
- vm_prot_t mem_prot = sec_type & EXEC_SECTYPE_PROT_MASK;
- vm_offset_t area_start;
- int result;
-
- if (sec_type & EXEC_SECTYPE_AOUT_SYMTAB)
- {
- st->aout_symtab_ofs = file_ofs;
- st->aout_symtab_size = file_size;
- }
- if (sec_type & EXEC_SECTYPE_AOUT_STRTAB)
- {
- st->aout_strtab_ofs = file_ofs;
- st->aout_strtab_size = file_size;
- }
-
- if (!(sec_type & EXEC_SECTYPE_ALLOC))
- return 0;
-
- assert(mem_size > 0);
- assert(mem_size > file_size);
-
- /*
- printf("section %08x-%08x-%08x prot %08x (%08x-%08x)\n",
- mem_addr, mem_addr+file_size, mem_addr+mem_size, mem_prot, page_start, page_end);
- */
-
- result = vm_allocate(mach_task_self(), &area_start, page_end - page_start, TRUE);
- if (result) return (result);
-
- if (file_size > 0)
- {
- vm_size_t resid;
-
- result = read_file(st->fp, file_ofs, area_start + (mem_addr - page_start),
- file_size, &resid);
- if (result) return result;
- if (resid) return EX_CORRUPT;
- }
-
- if (mem_size > file_size)
- {
- bzero((void*)area_start + (mem_addr + file_size - page_start),
- mem_size - file_size);
- }
-
- result = vm_allocate(st->user_task, &page_start, page_end - page_start, FALSE);
- if (result) return (result);
- assert(page_start == trunc_page(mem_addr));
-
- result = vm_write(st->user_task, page_start, area_start, page_end - page_start);
- if (result) return (result);
-
- result = vm_deallocate(mach_task_self(), area_start, page_end - page_start);
- if (result) return (result);
-
- /*
- * Protect the segment.
- */
- if (load_protect_text && (mem_prot != VM_PROT_ALL)) {
- result = vm_protect(st->user_task, page_start, page_end - page_start,
- FALSE, mem_prot);
- if (result) return (result);
- }
-
- return 0;
-}
-
-/* Callback functions for reading the uncompressed image. */
-static int image_read(void *handle, vm_offset_t file_ofs, void *buf,
- vm_size_t size, vm_size_t *out_actual)
-{
- struct stuff *st = handle;
- bcopy(st->image_addr + file_ofs, buf, size);
- *out_actual = size;
- return 0;
-}
-
-static int image_read_exec(void *handle, vm_offset_t file_ofs,
- vm_size_t file_size, vm_offset_t mem_addr,
- vm_size_t mem_size, exec_sectype_t sec_type)
-{
- struct stuff *st = handle;
- vm_offset_t page_start = trunc_page(mem_addr);
- vm_offset_t page_end = round_page(mem_addr + mem_size);
- vm_prot_t mem_prot = sec_type & EXEC_SECTYPE_PROT_MASK;
- vm_offset_t area_start;
- int result;
-
- if (sec_type & EXEC_SECTYPE_AOUT_SYMTAB)
- {
- st->aout_symtab_ofs = file_ofs;
- st->aout_symtab_size = file_size;
- }
- if (sec_type & EXEC_SECTYPE_AOUT_STRTAB)
- {
- st->aout_strtab_ofs = file_ofs;
- st->aout_strtab_size = file_size;
- }
-
- if (!(sec_type & EXEC_SECTYPE_ALLOC))
- return 0;
-
- assert(mem_size > 0);
- assert(mem_size > file_size);
-
- /*
- printf("section %08x-%08x-%08x prot %08x (%08x-%08x)\n",
- mem_addr, mem_addr+file_size, mem_addr+mem_size, mem_prot, page_start, page_end);
- */
-
- result = vm_allocate(mach_task_self(), &area_start, page_end - page_start, TRUE);
- if (result) return (result);
-
- if (file_size > 0)
- {
- bcopy(st->image_addr + file_ofs, area_start + (mem_addr - page_start),
- file_size);
- }
-
- if (mem_size > file_size)
- {
- bzero((void*)area_start + (mem_addr + file_size - page_start),
- mem_size - file_size);
- }
-
- result = vm_allocate(st->user_task, &page_start, page_end - page_start, FALSE);
- if (result) return (result);
- assert(page_start == trunc_page(mem_addr));
-
- result = vm_write(st->user_task, page_start, area_start, page_end - page_start);
- if (result) return (result);
-
- result = vm_deallocate(mach_task_self(), area_start, page_end - page_start);
- if (result) return (result);
-
- /*
- * Protect the segment.
- */
- if (load_protect_text && (mem_prot != VM_PROT_ALL)) {
- result = vm_protect(st->user_task, page_start, page_end - page_start,
- FALSE, mem_prot);
- if (result) return (result);
- }
-
- return 0;
-}
-
-mach_port_t boot_script_read_file (const char *file)
-{ return MACH_PORT_NULL; } /* XXX */
-
-int
-boot_script_exec_cmd (void *hook,
- task_t user_task,
- char *file_name,
- int arg_count, char **argv,
- char *argstrings, int argslen)
-{
- extern mach_port_t bootstrap_master_device_port, bootstrap_master_host_port;
- extern char *root_name;
- extern char **environ;
- int envc, env_len;
-
- int arg_len = argslen;
- char *arg_pos;
-
- kern_return_t result;
- thread_t user_thread;
- struct file file;
- char namebuf[MAXPATHLEN+1];
-
- struct stuff st;
- struct exec_info info;
-
- extern char * strbuild();
-
- if (strcmp (file_name, "/dev/"))
- (void) strbuild(namebuf, "/dev/", root_name, "/", file_name,
- (char *)0);
- else
- strcpy (namebuf, file_name);
-
- /*
- * Open the file
- */
- bzero((char *)&file, sizeof(file));
-
- result = open_file(bootstrap_master_device_port, namebuf, &file);
- if (result != 0) {
- panic ("%s: %s", namebuf, strerror (result));
- }
-
- env_len = 0;
- for (envc = 0; environ[envc]; ++envc)
- env_len += strlen (environ[envc]) + 1;
-
- /*
- * Add space for:
- * arg_count
- * pointers to arguments
- * trailing 0 pointer
- * environment variables
- * trailing 0 pointer
- * and align to integer boundary
- */
- arg_len += sizeof(integer_t) + (envc + 2 + arg_count) * sizeof(char *);
- arg_len += env_len;
- arg_len = (arg_len + (sizeof(integer_t) - 1)) & ~(sizeof(integer_t)-1);
-
- /*
- * We refrain from checking IEXEC bits to make
- * things a little easier when things went bad.
- * Say you have ftp(1) but chmod(1) is gone.
- */
- if (!file_is_regular(&file))
- panic("boot_load_program: %s is not a regular file", namebuf);
-
- /*
- * Load the executable file.
- */
- st.fp = &file;
- st.user_task = user_task;
- st.aout_symtab_size = 0;
- st.aout_strtab_size = 0;
- result = exec_load(prog_read, prog_read_exec, &st, &info);
-#ifdef GZIP
- if (result)
- {
- /*
- * It might be gzip file.
- */
- int err;
- extern int serverboot_gunzip(struct file *,
- vm_offset_t *, size_t *);
-
- err = serverboot_gunzip(st.fp,
- &(st.image_addr),
- &(st.image_size));
- if (!err)
- {
- result = exec_load(image_read,
- image_read_exec,
- &st,
- &info);
- vm_deallocate(mach_task_self(),
- st.image_addr,
- st.image_size);
- }
- }
-#endif /* GZIP */
-#ifdef BZIP2
- if (result)
- {
- /*
- * It might be bzip2 file.
- */
- int err;
- extern int serverboot_bunzip2(struct file *,
- vm_offset_t *, size_t *);
-
- err = serverboot_bunzip2(st.fp,
- &(st.image_addr),
- &(st.image_size));
- if (!err)
- {
- result = exec_load(image_read,
- image_read_exec,
- &st,
- &info);
- vm_deallocate(mach_task_self(),
- st.image_addr,
- st.image_size);
- }
- }
-#endif /* BZIP2 */
- if (result)
- panic ("cannot load %s: %s", namebuf, strerror (result));
-#if 0
- printf("(serverboot): loaded %s; entrypoint %08x\n", namebuf, info.entry);
-#endif
-
- /*
- * Set up the stack and user registers.
- */
- result = thread_create (user_task, &user_thread);
- if (result)
- panic ("can't create user thread for %s: %s", namebuf,
- strerror (result));
- arg_pos = set_regs(user_task, user_thread, &info, arg_len);
-
- /*
- * Read symbols from the executable file.
- */
-#if 0
- printf("(serverboot): loading symbols from %s\n", namebuf);
- read_symtab_from_file(&file, bootstrap_master_host_port, user_task, namebuf, &st);
-#endif
-
- /*
- * Copy out the arguments.
- */
- {
- vm_offset_t u_arg_start;
- /* user start of argument list block */
- vm_offset_t k_arg_start;
- /* kernel start of argument list block */
- vm_offset_t u_arg_page_start;
- /* user start of args, page-aligned */
- vm_size_t arg_page_size;
- /* page_aligned size of args */
- vm_offset_t k_arg_page_start;
- /* kernel start of args, page-aligned */
-
- register
- char ** k_ap; /* kernel arglist address */
- char * u_cp; /* user argument string address */
- register
- char * k_cp; /* kernel argument string address */
- register
- int i;
-
- /*
- * Get address of argument list in user space
- */
- u_arg_start = (vm_offset_t)arg_pos;
-
- /*
- * Round to page boundaries, and allocate kernel copy
- */
- u_arg_page_start = trunc_page(u_arg_start);
- arg_page_size = (vm_size_t)(round_page(u_arg_start + arg_len)
- - u_arg_page_start);
-
- result = vm_allocate(mach_task_self(),
- &k_arg_page_start,
- (vm_size_t)arg_page_size,
- TRUE);
- if (result)
- panic("boot_load_program: arg size");
-
- /*
- * Set up addresses corresponding to user pointers
- * in the kernel block
- */
- k_arg_start = k_arg_page_start + (u_arg_start - u_arg_page_start);
-
- k_ap = (char **)k_arg_start;
-
- /*
- * Start the strings after the arg-count and pointers
- */
- u_cp = (char *)u_arg_start + arg_count * sizeof(char *)
- + envc * sizeof(char *)
- + 2 * sizeof(char *)
- + sizeof(integer_t);
- k_cp = (char *)k_arg_start + arg_count * sizeof(char *)
- + envc * sizeof(char *)
- + 2 * sizeof(char *)
- + sizeof(integer_t);
-
- /*
- * first the argument count
- */
- *k_ap++ = (char *)(intptr_t)arg_count;
-
- /*
- * Then the strings and string pointers for each argument
- */
- for (i = 0; i < arg_count; i++)
- *k_ap++ = argv[i] - argstrings + u_cp;
- *k_ap++ = (char *)0;
- bcopy (argstrings, k_cp, argslen);
- k_cp += argslen;
- u_cp += argslen;
-
- for (i = 0; i < envc; i++)
- *k_ap++ = environ[i] - environ[0] + u_cp;
- *k_ap = (char *)0;
- bcopy (environ[0], k_cp, env_len);
-
- /*
- * Now write all of this to user space.
- */
- (void) vm_write(user_task,
- u_arg_page_start,
- k_arg_page_start,
- arg_page_size);
-
- (void) vm_deallocate(mach_task_self(),
- k_arg_page_start,
- arg_page_size);
- }
-
- /*
- * Close the file.
- */
- close_file(&file);
-
- /* Resume the thread. */
- thread_resume (user_thread);
- mach_port_deallocate (mach_task_self (), user_thread);
-
- return (0);
-}
-
-/*
- * Load symbols from file into kernel debugger.
- */
-static void read_symtab_from_file(
- struct file *fp,
- mach_port_t host_port,
- task_t task,
- char * symtab_name,
- struct stuff *st)
-{
- vm_size_t resid;
- kern_return_t result;
- vm_size_t table_size;
- vm_offset_t symtab;
-
-#if 0
-
- if (!st->aout_symtab_size || !st->aout_strtab_size)
- return;
-
- /*
- * Allocate space for the symbol table.
- */
- table_size = sizeof(vm_size_t)
- + st->aout_symtab_size
- + st->aout_strtab_size;
- result= vm_allocate(mach_task_self(),
- &symtab,
- table_size,
- TRUE);
- if (result) {
- printf("[ error %d allocating space for %s symbol table ]\n",
- result, symtab_name);
- return;
- }
-
- /*
- * Set the symbol table length word,
- * then read in the symbol table and string table.
- */
- *(vm_size_t*)symtab = st->aout_symtab_size;
- result = read_file(fp, st->aout_symtab_ofs,
- symtab + sizeof(vm_size_t),
- st->aout_symtab_size + st->aout_strtab_size,
- &resid);
- if (result || resid) {
- printf("[ no valid symbol table present for %s ]\n",
- symtab_name);
- }
- else {
- /*
- * Load the symbols into the kernel.
- */
- result = host_load_symbol_table(
- host_port,
- task,
- symtab_name,
- symtab,
- table_size);
- }
- (void) vm_deallocate(mach_task_self(), symtab, table_size);
-#endif
-}
diff --git a/serverboot/mach-exec.h b/serverboot/mach-exec.h
deleted file mode 100644
index 94b234b0..00000000
--- a/serverboot/mach-exec.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the
- * rights to redistribute these changes.
- */
-
-#ifndef _MACH_EXEC_H_
-#define _MACH_EXEC_H_
-
-#include <mach/machine/vm_types.h>
-#include <mach/vm_prot.h>
-
-/* XXX */
-typedef enum
-{
- EXEC_ELF = 1,
- EXEC_AOUT = 2,
-} exec_format_t;
-
-typedef struct exec_info
-{
- /* Format of executable loaded - see above. */
- exec_format_t format;
-
- /* Program entrypoint. */
- vm_offset_t entry;
-
- /* Initial data pointer - only some architectures use this. */
- vm_offset_t init_dp;
-
- /* (ELF) Address of interpreter string for loading shared libraries, null if none. */
- vm_offset_t interp;
-
-} exec_info_t;
-
-typedef int exec_sectype_t;
-#define EXEC_SECTYPE_READ VM_PROT_READ
-#define EXEC_SECTYPE_WRITE VM_PROT_WRITE
-#define EXEC_SECTYPE_EXECUTE VM_PROT_EXECUTE
-#define EXEC_SECTYPE_PROT_MASK VM_PROT_ALL
-#define EXEC_SECTYPE_ALLOC ((exec_sectype_t)0x000100)
-#define EXEC_SECTYPE_LOAD ((exec_sectype_t)0x000200)
-#define EXEC_SECTYPE_DEBUG ((exec_sectype_t)0x010000)
-#define EXEC_SECTYPE_AOUT_SYMTAB ((exec_sectype_t)0x020000)
-#define EXEC_SECTYPE_AOUT_STRTAB ((exec_sectype_t)0x040000)
-
-typedef int exec_read_func_t(void *handle, vm_offset_t file_ofs,
- void *buf, vm_size_t size,
- vm_size_t *out_actual);
-
-typedef int exec_read_exec_func_t(void *handle,
- vm_offset_t file_ofs, vm_size_t file_size,
- vm_offset_t mem_addr, vm_size_t mem_size,
- exec_sectype_t section_type);
-
-/*
- * Routines exported from libmach_exec.a
- */
-
-/* Generic function to interpret an executable "file"
- and "load" it into "memory".
- Doesn't really know about files, loading, or memory;
- all file I/O and destination memory accesses
- go through provided functions.
- Thus, this is a very generic loading mechanism.
-
- The read() function is used to read metadata from the file
- into the local address space.
-
- The read_exec() function is used to load the actual sections.
- It is used for all kinds of sections - code, data, bss, debugging data.
- The 'section_type' parameter specifies what type of section is being loaded.
-
- For code, data, and bss, the EXEC_SECTYPE_ALLOC flag will be set.
- For code and data (i.e. stuff that's actually loaded from the file),
- EXEC_SECTYPE_LOAD will also be set.
- The EXEC_SECTYPE_PROT_MASK contains the intended access permissions
- for the section.
- 'file_size' may be less than 'mem_size';
- the remaining data must be zero-filled.
- 'mem_size' is always greater than zero, but 'file_size' may be zero
- (e.g. in the case of a bss section).
- No two read_exec() calls for one executable
- will load data into the same virtual memory page,
- although they may load from arbitrary (possibly overlapping) file positions.
-
- For sections that aren't normally loaded into the process image
- (e.g. debug sections), EXEC_SECTYPE_ALLOC isn't set,
- but some other appropriate flag is set to indicate the type of section.
-
- The 'handle' is an opaque pointer which is simply passed on
- to the read() and read_exec() functions.
-
- On return, the specified info structure is filled in
- with information about the loaded executable.
-*/
-int exec_load(exec_read_func_t *read, exec_read_exec_func_t *read_exec,
- void *handle, exec_info_t *out_info);
-
-/*
- * Error codes
- */
-
-#define EX_NOT_EXECUTABLE 6000 /* not a recognized executable format */
-#define EX_WRONG_ARCH 6001 /* valid executable, but wrong arch. */
-#define EX_CORRUPT 6002 /* recognized executable, but mangled */
-#define EX_BAD_LAYOUT 6003 /* something wrong with the memory or file image layout */
-
-
-#endif /* _MACH_EXEC_H_ */
diff --git a/serverboot/minix_ffs_compat.c b/serverboot/minix_ffs_compat.c
deleted file mode 100644
index 7d493520..00000000
--- a/serverboot/minix_ffs_compat.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * BSD FFS like functions used to ease porting bootstrap to MINIX fs
- * Copyright (C) 1994 Csizmazia Balazs, University ELTE, Hungary
- *
- * This file 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.
- */
-
-#include <device/device_types.h>
-#include <device/device.h>
-
-#include <mach/mach_traps.h>
-#include <mach/mach_interface.h>
-
-#include <file_io.h>
-
-#define MINIX_BLOCK_SIZE 1024
-
-int minix_ino2blk (struct minix_super_block *fs, int ino)
-{
- int blk;
-
- blk=0 /* it's Mach */+2 /* boot+superblock */ + fs->s_imap_blocks +
- fs->s_zmap_blocks + (ino-1)/MINIX_INODES_PER_BLOCK;
- return blk;
-}
-
-int minix_fsbtodb (struct minix_super_block *fs, int b)
-{
- return (b * MINIX_BLOCK_SIZE) / DEV_BSIZE;
-}
-
-int minix_itoo (struct minix_super_block *fs, int ino)
-{
- return (ino - 1) % MINIX_INODES_PER_BLOCK;
-}
-
-int minix_blkoff (struct minix_super_block * fs, vm_offset_t offset)
-{
- return offset % MINIX_BLOCK_SIZE;
-}
-
-int minix_lblkno (struct minix_super_block * fs, vm_offset_t offset)
-{
- return offset / MINIX_BLOCK_SIZE;
-}
-
-int minix_blksize (struct minix_super_block *fs, struct file *fp, minix_daddr_t file_block)
-{
- return MINIX_BLOCK_SIZE;
-}
diff --git a/serverboot/minix_ffs_compat.h b/serverboot/minix_ffs_compat.h
deleted file mode 100644
index cc038032..00000000
--- a/serverboot/minix_ffs_compat.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * BSD FFS like declarations used to ease porting bootstrap to MINIX fs
- * Copyright (C) 1994 Csizmazia Balazs, University ELTE, Hungary
- *
- * This file 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.
- */
-
-#define MINIX_SBSIZE MINIX_BLOCK_SIZE /* Size of superblock */
-#define MINIX_SBLOCK ((minix_daddr_t) 2) /* Location of superblock */
-
-#define MINIX_NDADDR 7
-#define MINIX_NIADDR 2
-
-#define MINIX_MAXNAMLEN 14
-
-#define MINIX_ROOTINO 1 /* MINIX ROOT INODE */
-
-#define MINIX_NINDIR(fs) 512 /* DISK_ADDRESSES_PER_BLOCKS */
-
-#define IFMT 00170000
-#define IFREG 0100000
-#define IFDIR 0040000
-#define ISVTX 0001000
-
-#define f_fs u.minix.minix_fs
-#define i_ic u.minix.minix_ic
-#define f_nindir u.minix.minix_nindir
-#define f_blk u.minix.minix_blk
-#define f_blksize u.minix.minix_blksize
-#define f_blkno u.minix.minix_blkno
-
diff --git a/serverboot/minix_file_io.c b/serverboot/minix_file_io.c
deleted file mode 100644
index 17beb18c..00000000
--- a/serverboot/minix_file_io.c
+++ /dev/null
@@ -1,851 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * Stand-alone file reading package.
- */
-
-#include <device/device_types.h>
-#include <device/device.h>
-
-#include <mach/mach_traps.h>
-#include <mach/mach_interface.h>
-
-#include "file_io.h"
-#include "minix_ffs_compat.h"
-#include "minix_fs.h"
-
-void minix_close_file(); /* forward */
-
-#define MINIX_NAME_LEN 14
-#define MINIX_BLOCK_SIZE 1024
-
-/*
- * Free file buffers, but don't close file.
- */
-static void
-free_file_buffers(fp)
- register struct file *fp;
-{
- register int level;
-
- /*
- * Free the indirect blocks
- */
- for (level = 0; level < MINIX_NIADDR; level++) {
- if (fp->f_blk[level] != 0) {
- (void) vm_deallocate(mach_task_self(),
- fp->f_blk[level],
- fp->f_blksize[level]);
- fp->f_blk[level] = 0;
- }
- fp->f_blkno[level] = -1;
- }
-
- /*
- * Free the data block
- */
- if (fp->f_buf != 0) {
- (void) vm_deallocate(mach_task_self(),
- fp->f_buf,
- fp->f_buf_size);
- fp->f_buf = 0;
- }
- fp->f_buf_blkno = -1;
-}
-
-/*
- * Read a new inode into a file structure.
- */
-static int
-read_inode(inumber, fp)
- ino_t inumber;
- register struct file *fp;
-{
- vm_offset_t buf;
- mach_msg_type_number_t buf_size;
- register
- struct minix_super_block *fs;
- minix_daddr_t disk_block;
- kern_return_t rc;
-
- fs = fp->f_fs;
- disk_block = minix_ino2blk(fs, inumber);
-
- rc = device_read(fp->f_dev,
- 0,
- (recnum_t) minix_fsbtodb(fp->f_fs, disk_block),
- (int) MINIX_BLOCK_SIZE,
- (char **)&buf,
- &buf_size);
- if (rc != KERN_SUCCESS)
- return (rc);
-
- {
- register struct minix_inode *dp;
-
- dp = (struct minix_inode *)buf;
- dp += minix_itoo(fs, inumber);
- fp->i_ic = *dp;
- fp->f_size = dp->i_size;
- }
-
- (void) vm_deallocate(mach_task_self(), buf, buf_size);
-
- /*
- * Clear out the old buffers
- */
- free_file_buffers(fp);
-
- return (0);
-}
-
-/*
- * Given an offset in a file, find the disk block number that
- * contains that block.
- */
-static int
-block_map(fp, file_block, disk_block_p)
- struct file *fp;
- minix_daddr_t file_block;
- minix_daddr_t *disk_block_p; /* out */
-{
- int level;
- int idx;
- minix_daddr_t ind_block_num;
- kern_return_t rc;
-
- vm_offset_t olddata[MINIX_NIADDR+1];
- vm_size_t oldsize[MINIX_NIADDR+1];
-
- /*
- * Index structure of an inode:
- *
- * i_db[0..NDADDR-1] hold block numbers for blocks
- * 0..NDADDR-1
- *
- * i_ib[0] index block 0 is the single indirect
- * block
- * holds block numbers for blocks
- * NDADDR .. NDADDR + NINDIR(fs)-1
- *
- * i_ib[1] index block 1 is the double indirect
- * block
- * holds block numbers for INDEX blocks
- * for blocks
- * NDADDR + NINDIR(fs) ..
- * NDADDR + NINDIR(fs) + NINDIR(fs)**2 - 1
- *
- * i_ib[2] index block 2 is the triple indirect
- * block
- * holds block numbers for double-indirect
- * blocks for blocks
- * NDADDR + NINDIR(fs) + NINDIR(fs)**2 ..
- * NDADDR + NINDIR(fs) + NINDIR(fs)**2
- * + NINDIR(fs)**3 - 1
- */
-
- mutex_lock(&fp->f_lock);
-
- if (file_block < MINIX_NDADDR) {
- /* Direct block. */
- *disk_block_p = fp->i_ic.i_zone[file_block];
- mutex_unlock(&fp->f_lock);
- return (0);
- }
-
- file_block -= MINIX_NDADDR;
-
- /*
- * nindir[0] = NINDIR
- * nindir[1] = NINDIR**2
- * nindir[2] = NINDIR**3
- * etc
- */
- for (level = 0; level < MINIX_NIADDR; level++) {
- if (file_block < fp->f_nindir[level])
- break;
- file_block -= fp->f_nindir[level];
- }
- if (level == MINIX_NIADDR) {
- /* Block number too high */
- mutex_unlock(&fp->f_lock);
- return (FS_NOT_IN_FILE);
- }
-
- ind_block_num = fp->i_ic.i_zone[level + MINIX_NDADDR];
-
- /*
- * Initialize array of blocks to free.
- */
- for (idx = 0; idx < MINIX_NIADDR; idx++)
- oldsize[idx] = 0;
-
- for (; level >= 0; level--) {
-
- vm_offset_t data;
- mach_msg_type_number_t size;
-
- if (ind_block_num == 0)
- break;
-
- if (fp->f_blkno[level] == ind_block_num) {
- /*
- * Cache hit. Just pick up the data.
- */
-
- data = fp->f_blk[level];
- }
- else {
- /*
- * Drop our lock while doing the read.
- * (The f_dev and f_fs fields don`t change.)
- */
- mutex_unlock(&fp->f_lock);
-
- rc = device_read(fp->f_dev,
- 0,
- (recnum_t) minix_fsbtodb(fp->f_fs, ind_block_num),
- MINIX_BLOCK_SIZE,
- (char **)&data,
- &size);
- if (rc != KERN_SUCCESS)
- return (rc);
-
- /*
- * See if we can cache the data. Need a write lock to
- * do this. While we hold the write lock, we can`t do
- * *anything* which might block for memory. Otherwise
- * a non-privileged thread might deadlock with the
- * privileged threads. We can`t block while taking the
- * write lock. Otherwise a non-privileged thread
- * blocked in the vm_deallocate (while holding a read
- * lock) will block a privileged thread. For the same
- * reason, we can`t take a read lock and then use
- * lock_read_to_write.
- */
-
- mutex_lock(&fp->f_lock);
-
- olddata[level] = fp->f_blk[level];
- oldsize[level] = fp->f_blksize[level];
-
- fp->f_blkno[level] = ind_block_num;
- fp->f_blk[level] = data;
- fp->f_blksize[level] = size;
-
- /*
- * Return to holding a read lock, and
- * dispose of old data.
- */
-
- }
-
- if (level > 0) {
- idx = file_block / fp->f_nindir[level-1];
- file_block %= fp->f_nindir[level-1];
- }
- else
- idx = file_block;
-
- ind_block_num = ((minix_daddr_t *)data)[idx];
- }
-
- mutex_unlock(&fp->f_lock);
-
- /*
- * After unlocking the file, free any blocks that
- * we need to free.
- */
- for (idx = 0; idx < MINIX_NIADDR; idx++)
- if (oldsize[idx] != 0)
- (void) vm_deallocate(mach_task_self(),
- olddata[idx],
- oldsize[idx]);
-
- *disk_block_p = ind_block_num;
- return (0);
-}
-
-/*
- * Read a portion of a file into an internal buffer. Return
- * the location in the buffer and the amount in the buffer.
- */
-static int
-buf_read_file(fp, offset, buf_p, size_p)
- register struct file *fp;
- vm_offset_t offset;
- vm_offset_t *buf_p; /* out */
- vm_size_t *size_p; /* out */
-{
- register
- struct minix_super_block *fs;
- vm_offset_t off;
- register minix_daddr_t file_block;
- minix_daddr_t disk_block;
- int rc;
- vm_offset_t block_size;
-
- if (offset >= fp->i_ic.i_size)
- return (FS_NOT_IN_FILE);
-
- fs = fp->f_fs;
-
- off = minix_blkoff(fs, offset);
- file_block = minix_lblkno(fs, offset);
- block_size = minix_blksize(fs, fp, file_block);
-
- if (((daddr_t) file_block) != fp->f_buf_blkno) {
- rc = block_map(fp, file_block, &disk_block);
- if (rc != 0)
- return (rc);
-
- if (fp->f_buf)
- (void)vm_deallocate(mach_task_self(),
- fp->f_buf,
- fp->f_buf_size);
-
- if (disk_block == 0) {
- (void)vm_allocate(mach_task_self(),
- &fp->f_buf,
- block_size,
- TRUE);
- fp->f_buf_size = block_size;
- }
- else {
- rc = device_read(fp->f_dev,
- 0,
- (recnum_t) minix_fsbtodb(fs, disk_block),
- (int) block_size,
- (char **) &fp->f_buf,
- (mach_msg_type_number_t *)&fp->f_buf_size);
- }
- if (rc)
- return (rc);
-
- fp->f_buf_blkno = (daddr_t) file_block;
- }
-
- /*
- * Return address of byte in buffer corresponding to
- * offset, and size of remainder of buffer after that
- * byte.
- */
- *buf_p = fp->f_buf + off;
- *size_p = block_size - off;
-
- /*
- * But truncate buffer at end of file.
- */
- if (*size_p > fp->i_ic.i_size - offset)
- *size_p = fp->i_ic.i_size - offset;
-
- return (0);
-}
-
-/*
- * Search a directory for a name and return its
- * i_number.
- */
-static int
-search_directory(name, fp, inumber_p)
- char * name;
- register struct file *fp;
- ino_t *inumber_p; /* out */
-{
- vm_offset_t buf;
- vm_size_t buf_size;
- vm_offset_t offset;
- register struct minix_directory_entry *dp;
- int length;
- kern_return_t rc;
- char tmp_name[15];
-
- length = strlen(name);
-
- offset = 0;
- while (offset < fp->i_ic.i_size) {
- rc = buf_read_file(fp, offset, &buf, &buf_size);
- if (rc != KERN_SUCCESS)
- return (rc);
-
- dp = (struct minix_directory_entry *)buf;
- if (dp->inode != 0) {
- strncpy (tmp_name, dp->name, MINIX_NAME_LEN /* XXX it's 14 */);
- tmp_name[MINIX_NAME_LEN] = '\0';
- if (strlen(tmp_name) == length &&
- !strcmp(name, tmp_name))
- {
- /* found entry */
- *inumber_p = dp->inode;
- return (0);
- }
- }
- offset += 16 /* MINIX dir. entry length - MINIX FS Ver. 1. */;
- }
- return (FS_NO_ENTRY);
-}
-
-static int
-read_fs(dev, fsp)
- mach_port_t dev;
- struct minix_super_block **fsp;
-{
- register
- struct minix_super_block *fs;
- vm_offset_t buf;
- mach_msg_type_number_t buf_size;
- int error;
-
- /*
- * Read the super block
- */
- error = device_read(dev, 0, (recnum_t) MINIX_SBLOCK, MINIX_SBSIZE,
- (char **) &buf, &buf_size);
- if (error)
- return (error);
-
- /*
- * Check the superblock
- */
- fs = (struct minix_super_block *)buf;
- if (fs->s_magic != MINIX_SUPER_MAGIC) {
- (void) vm_deallocate(mach_task_self(), buf, buf_size);
- return (FS_INVALID_FS);
- }
-
-
- *fsp = fs;
-
- return 0;
-}
-
-static int
-mount_fs(fp)
- register struct file *fp;
-{
- register struct minix_super_block *fs;
- int error;
-
- error = read_fs(fp->f_dev, &fp->f_fs);
- if (error)
- return (error);
-
- fs = fp->f_fs;
-
- /*
- * Calculate indirect block levels.
- */
- {
- register int mult;
- register int level;
-
- mult = 1;
- for (level = 0; level < MINIX_NIADDR; level++) {
- mult *= MINIX_NINDIR(fs);
- fp->f_nindir[level] = mult;
- }
- }
-
- return (0);
-}
-
-static void
-unmount_fs(fp)
- register struct file *fp;
-{
- if (file_is_structured(fp)) {
- (void) vm_deallocate(mach_task_self(),
- (vm_offset_t) fp->f_fs,
- MINIX_SBSIZE);
- fp->f_fs = 0;
- }
-}
-
-/*
- * Open a file.
- */
-int
-minix_open_file(master_device_port, path, fp)
- mach_port_t master_device_port;
- char * path;
- struct file *fp;
-{
-#define RETURN(code) { rc = (code); goto exit; }
-
- register char *cp, *component;
- register int c; /* char */
- register int rc;
- ino_t inumber, parent_inumber;
- int nlinks = 0;
-
- char namebuf[MAXPATHLEN+1];
-
- if (path == 0 || *path == '\0') {
- return FS_NO_ENTRY;
- }
-
- /*
- * Copy name into buffer to allow modifying it.
- */
- strcpy(namebuf, path);
-
- /*
- * Look for '/dev/xxx' at start of path, for
- * root device.
- */
- if (!strprefix(namebuf, "/dev/")) {
- printf("no device name\n");
- return FS_NO_ENTRY;
- }
-
- cp = namebuf + 5; /* device */
- component = cp;
- while ((c = *cp) != '\0' && c != '/') {
- cp++;
- }
- *cp = '\0';
-
- bzero (fp, sizeof (struct file));
-
- rc = device_open(master_device_port,
- D_READ|D_WRITE,
- component,
- &fp->f_dev);
- if (rc)
- return rc;
-
- if (c == 0) {
- fp->f_fs = 0;
- goto out_ok;
- }
-
- *cp = c;
-
- rc = mount_fs(fp);
- if (rc)
- return rc;
-
- inumber = (ino_t) MINIX_ROOTINO;
- if ((rc = read_inode(inumber, fp)) != 0) {
- printf("can't read root inode\n");
- goto exit;
- }
-
- while (*cp) {
-
- /*
- * Check that current node is a directory.
- */
- if ((fp->i_ic.i_mode & IFMT) != IFDIR)
- RETURN (FS_NOT_DIRECTORY);
-
- /*
- * Remove extra separators
- */
- while (*cp == '/')
- cp++;
-
- /*
- * Get next component of path name.
- */
- component = cp;
- {
- register int len = 0;
-
- while ((c = *cp) != '\0' && c != '/') {
- if (len++ > MINIX_MAXNAMLEN)
- RETURN (FS_NAME_TOO_LONG);
- if (c & 0200)
- RETURN (FS_INVALID_PARAMETER);
- cp++;
- }
- *cp = 0;
- }
-
- /*
- * Look up component in current directory.
- * Save directory inumber in case we find a
- * symbolic link.
- */
- parent_inumber = inumber;
- rc = search_directory(component, fp, &inumber);
- if (rc) {
- printf("%s: not found\n", path);
- goto exit;
- }
- *cp = c;
-
- /*
- * Open next component.
- */
- if ((rc = read_inode(inumber, fp)) != 0)
- goto exit;
-
- /*
- * Check for symbolic link.
- */
- }
-
- /*
- * Found terminal component.
- */
- out_ok:
- mutex_init(&fp->f_lock);
- return 0;
-
- /*
- * At error exit, close file to free storage.
- */
- exit:
- minix_close_file(fp);
- return rc;
-}
-
-/*
- * Close file - free all storage used.
- */
-void
-minix_close_file(fp)
- register struct file *fp;
-{
- register int i;
-
- /*
- * Free the disk super-block.
- */
- unmount_fs(fp);
-
- /*
- * Free the inode and data buffers.
- */
- free_file_buffers(fp);
-}
-
-int
-minix_file_is_directory(struct file *fp)
-{
- return (fp->i_ic.i_mode & IFMT) == IFDIR;
-}
-
-int
-minix_file_is_regular(struct file *fp)
-{
- return (fp->i_ic.i_mode & IFMT) == IFREG;
-}
-
-/*
- * Copy a portion of a file into kernel memory.
- * Cross block boundaries when necessary.
- */
-int
-minix_read_file(fp, offset, start, size, resid)
- register struct file *fp;
- vm_offset_t offset;
- vm_offset_t start;
- vm_size_t size;
- vm_size_t *resid; /* out */
-{
- int rc;
- register vm_size_t csize;
- vm_offset_t buf;
- vm_size_t buf_size;
-
- while (size != 0) {
- rc = buf_read_file(fp, offset, &buf, &buf_size);
- if (rc)
- return (rc);
-
- csize = size;
- if (csize > buf_size)
- csize = buf_size;
- if (csize == 0)
- break;
-
- bcopy((char *)buf, (char *)start, csize);
-
- offset += csize;
- start += csize;
- size -= csize;
- }
- if (resid)
- *resid = size;
-
- return (0);
-}
-
-/* simple utility: only works for 2^n */
-static int
-log2(n)
- register unsigned int n;
-{
- register int i = 0;
-
- while ((n & 1) == 0) {
- i++;
- n >>= 1;
- }
- return i;
-}
-
-/*
- * Make an empty file_direct for a device.
- */
-int
-minix_open_file_direct(dev, fdp, is_structured)
- mach_port_t dev;
- register struct file_direct *fdp;
- boolean_t is_structured;
-{
- struct minix_super_block *fs;
- int rc;
-
- if (!is_structured) {
- fdp->fd_dev = dev;
- fdp->fd_blocks = (daddr_t *) 0;
- fdp->fd_bsize = vm_page_size;
- fdp->fd_bshift = log2(vm_page_size);
- fdp->fd_fsbtodb = 0; /* later */
- fdp->fd_size = 0; /* later */
- return 0;
- }
-
- rc = read_fs(dev, &fs);
- if (rc)
- return rc;
-
- fdp->fd_dev = dev;
- fdp->fd_blocks = (daddr_t *) 0;
- fdp->fd_size = 0;
- fdp->fd_bsize = MINIX_BLOCK_SIZE;
- fdp->fd_bshift = log2(fdp->fd_bsize);
- fdp->fd_fsbtodb = log2(fdp->fd_bsize / DEV_BSIZE);
-
- (void) vm_deallocate(mach_task_self(),
- (vm_offset_t) fs,
- MINIX_SBSIZE);
-
- return 0;
-}
-
-/*
- * Add blocks from a file to a file_direct.
- */
-int
-minix_add_file_direct(fdp, fp)
- register struct file_direct *fdp;
- register struct file *fp;
-{
- register struct minix_super_block *fs;
- long num_blocks, i;
- vm_offset_t buffer;
- vm_size_t size;
- int rc;
-
- /* the file must be on the same device */
-
- if (fdp->fd_dev != fp->f_dev)
- return FS_INVALID_FS;
-
- if (!file_is_structured(fp)) {
- int result[DEV_GET_SIZE_COUNT];
- natural_t count;
-
- count = DEV_GET_SIZE_COUNT;
- rc = device_get_status( fdp->fd_dev, DEV_GET_SIZE,
- result, &count);
- if (rc)
- return rc;
- fdp->fd_size = result[DEV_GET_SIZE_DEVICE_SIZE] >> fdp->fd_bshift;
- fdp->fd_fsbtodb = log2(fdp->fd_bsize/result[DEV_GET_SIZE_RECORD_SIZE]);
- return 0;
- }
-
- /* it must hold a file system */
-
- fs = fp->f_fs;
-/*
- if (fdp->fd_bsize != fs->fs_bsize ||
- fdp->fd_fsbtodb != fs->fs_fsbtodb)
-*/
- if (fdp->fd_bsize != MINIX_BLOCK_SIZE)
- return FS_INVALID_FS;
-
- /* calculate number of blocks in the file, ignoring fragments */
-
- num_blocks = minix_lblkno(fs, fp->i_ic.i_size);
-
- /* allocate memory for a bigger array */
-
- size = (num_blocks + fdp->fd_size) * sizeof(minix_daddr_t);
- rc = vm_allocate(mach_task_self(), &buffer, size, TRUE);
- if (rc != KERN_SUCCESS)
- return rc;
-
- /* lookup new block addresses */
-
- for (i = 0; i < num_blocks; i++) {
- minix_daddr_t disk_block;
-
- rc = block_map(fp, (minix_daddr_t) i, &disk_block);
- if (rc != 0) {
- (void) vm_deallocate(mach_task_self(), buffer, size);
- return rc;
- }
-
- ((minix_daddr_t *) buffer)[fdp->fd_size + i] = disk_block;
- }
-
- /* copy old addresses and install the new array */
-
- if (fdp->fd_blocks != 0) {
- bcopy((char *) fdp->fd_blocks, (char *) buffer,
- fdp->fd_size * sizeof(minix_daddr_t));
-
- (void) vm_deallocate(mach_task_self(),
- (vm_offset_t) fdp->fd_blocks,
- (vm_size_t) (fdp->fd_size * sizeof(minix_daddr_t)));
- }
- fdp->fd_blocks = (daddr_t *) buffer;
- fdp->fd_size += num_blocks;
-
- /* deallocate cached blocks */
-
- free_file_buffers(fp);
-
- return 0;
-}
-
-int
-minix_remove_file_direct(fdp)
- struct file_direct *fdp;
-{
- if (fdp->fd_blocks)
- (void) vm_deallocate(mach_task_self(),
- (vm_offset_t) fdp->fd_blocks,
- (vm_size_t) (fdp->fd_size * sizeof(minix_daddr_t)));
- fdp->fd_blocks = 0; /* sanity */
- /* xxx should lose a ref to fdp->fd_dev here (and elsewhere) xxx */
-}
diff --git a/serverboot/minix_fs.h b/serverboot/minix_fs.h
deleted file mode 100644
index 678f3a0d..00000000
--- a/serverboot/minix_fs.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * minix_fs.h
- * stolen (and slightly extended by csb) from the Linux distribution
- * Copyright (C) 1994 Linus Torvalds
- *
- * This file 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.
- */
-
-#ifndef _LINUX_MINIX_FS_H
-#define _LINUX_MINIX_FS_H
-
-/*
- * The minix filesystem constants/structures
- */
-
-/*
- * Thanks to Kees J Bot for sending me the definitions of the new
- * minix filesystem (aka V2) with bigger inodes and 32-bit block
- * pointers. It's not actually implemented yet, but I'll look into
- * it.
- */
-
-#define MINIX_ROOT_INO 1
-
-/* Not the same as the bogus LINK_MAX in <linux/limits.h>. Oh well. */
-#define MINIX_LINK_MAX 250
-
-#define MINIX_I_MAP_SLOTS 8
-#define MINIX_Z_MAP_SLOTS 8
-#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
-#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
-#define NEW_MINIX_SUPER_MAGIC 0x2468 /* minix V2 - not implemented */
-#define MINIX_VALID_FS 0x0001 /* Clean fs. */
-#define MINIX_ERROR_FS 0x0002 /* fs has errors. */
-
-#define MINIX_INODES_PER_BLOCK ((MINIX_BLOCK_SIZE)/(sizeof (struct minix_inode)))
-
-struct minix_inode {
- unsigned short i_mode;
- unsigned short i_uid;
- unsigned long i_size;
- unsigned long i_time;
- unsigned char i_gid;
- unsigned char i_nlinks;
- unsigned short i_zone[9];
-};
-
-/*
- * The new minix inode has all the time entries, as well as
- * long block numbers and a third indirect block (7+1+1+1
- * instead of 7+1+1). Also, some previously 8-bit values are
- * now 16-bit. The inode is now 64 bytes instead of 32.
- */
-struct new_minix_inode {
- unsigned short i_mode;
- unsigned short i_nlinks;
- unsigned short i_uid;
- unsigned short i_gid;
- unsigned long i_size;
- unsigned long i_atime;
- unsigned long i_mtime;
- unsigned long i_ctime;
- unsigned long i_zone[10];
-};
-
-/*
- * minix super-block data on disk
- */
-struct minix_super_block {
- unsigned short s_ninodes;
- unsigned short s_nzones;
- unsigned short s_imap_blocks;
- unsigned short s_zmap_blocks;
- unsigned short s_firstdatazone;
- unsigned short s_log_zone_size;
- unsigned long s_max_size;
- unsigned short s_magic;
- unsigned short s_state;
-};
-
-struct minix_dir_entry {
- unsigned short inode;
- char name[0];
-};
-
-struct minix_directory_entry {
- unsigned short inode;
- char name[14];
-};
-
-#define MINIX_NIADDR 2
-
-typedef unsigned short minix_daddr_t;
-
-#endif
diff --git a/serverboot/minix_super.h b/serverboot/minix_super.h
deleted file mode 100644
index 144cf064..00000000
--- a/serverboot/minix_super.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * minix_super.h
- * stolen from the Linux distribution
- * Copyright (C) 1994 Linus Torvalds
- *
- * This file 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.
- */
-
-#ifndef _LINUX_MINIX_FS_H
-#define _LINUX_MINIX_FS_H
-
-struct minix_super_block {
- unsigned short s_ninodes;
- unsigned short s_nzones;
- unsigned short s_imap_blocks;
- unsigned short s_zmap_blocks;
- unsigned short s_firstdatazone;
- unsigned short s_log_zone_size;
- unsigned long s_max_size;
- unsigned short s_magic;
- unsigned short s_state;
-};
-
-
-struct minix_inode {
- unsigned short i_mode;
- unsigned short i_uid;
- unsigned long i_size;
- unsigned long i_time;
- unsigned char i_gid;
- unsigned char i_nlinks;
- unsigned short i_zone[9];
-};
-
-#define MINIX_NIADDR 2
-
-#endif
diff --git a/serverboot/panic.c b/serverboot/panic.c
deleted file mode 100644
index 25924099..00000000
--- a/serverboot/panic.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990,1989 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-
-#include <mach/port.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <errno.h>
-
-static mach_port_t master_host_port;
-
-panic_init(port)
- mach_port_t port;
-{
- master_host_port = port;
-}
-
-/*VARARGS1*/
-panic (const char *s, ...)
-{
- va_list listp;
-
- clearerr (stdout);
- printf("%s: panic: ", program_invocation_name);
- va_start(listp, s);
- vprintf(s, listp);
- va_end(listp);
- printf("\n");
-
-#ifdef PC532
- { int l; for (l=0;l < 1000000;l++) ; }
-#endif /* PC532 */
-#define RB_DEBUGGER 0x1000 /* enter debugger NOW */
- (void) host_reboot(master_host_port, RB_DEBUGGER);
- for (;;);
-}
diff --git a/serverboot/strfcns.c b/serverboot/strfcns.c
deleted file mode 100644
index cbead7e4..00000000
--- a/serverboot/strfcns.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * Character subroutines
- */
-
-#include <stdarg.h>
-
-#define EXPORT_BOOLEAN
-#include <mach/boolean.h>
-
-/*
- * Concatenate a group of strings together into a buffer.
- * Return a pointer to the trailing '\0' character in
- * the result string.
- * The list of strings ends with a '(char *)0'.
- */
-/*VARARGS1*/
-char *
-strbuild(char *dest, ...)
-{
- va_list argptr;
- register char * src;
- register int c;
-
- va_start(argptr, dest);
- while ((src = va_arg(argptr, char *)) != (char *)0) {
-
- while ((c = *src++) != '\0')
- *dest++ = c;
- }
- *dest = '\0';
- va_end(argptr);
- return (dest);
-}
-
-/*
- * Return TRUE if string 2 is a prefix of string 1.
- */
-boolean_t
-strprefix(s1, s2)
- register char *s1, *s2;
-{
- register int c;
-
- while ((c = *s2++) != '\0') {
- if (c != *s1++)
- return (FALSE);
- }
- return (TRUE);
-}
diff --git a/storeio/dev.c b/storeio/dev.c
index a7a1dd8b..31b084f9 100644
--- a/storeio/dev.c
+++ b/storeio/dev.c
@@ -226,7 +226,7 @@ dev_sync(struct dev *dev, int wait)
}
/* Takes care of buffering I/O to/from DEV for a transfer at position OFFS,
- length LEN; the amount of I/O sucessfully done is returned in AMOUNT.
+ length LEN; the amount of I/O successfully done is returned in AMOUNT.
BUF_RW is called to do I/O that's entirely inside DEV's internal buffer,
and RAW_RW to do I/O directly to DEV's store. */
static inline error_t
@@ -312,8 +312,8 @@ dev_rw (struct dev *dev, off_t offs, size_t len, size_t *amount,
/* Some non-aligned I/O has been done, or is needed, so we need to deal
with DEV's buffer, which means getting an exclusive lock. */
{
- /* Aquire a writer lock instead of a reader lock. Note that other
- writers may have aquired the lock by the time we get it. */
+ /* Acquire a writer lock instead of a reader lock. Note that other
+ writers may have acquired the lock by the time we get it. */
rwlock_reader_unlock (&dev->io_lock);
err = buffered_rw (dev, offs, len, amount, buf_rw, raw_rw);
}
diff --git a/storeio/pager.c b/storeio/pager.c
index 0ad126c1..1fb1d07e 100644
--- a/storeio/pager.c
+++ b/storeio/pager.c
@@ -33,7 +33,7 @@
/* For pager PAGER, read one page from offset PAGE. Set *BUF to be the
address of the page, and set *WRITE_LOCK if the page must be provided
- read-only. The only permissable error returns are EIO, EDQUOT, and
+ read-only. The only permissible error returns are EIO, EDQUOT, and
ENOSPC. */
error_t
pager_read_page (struct user_pager_info *upi,
@@ -65,7 +65,7 @@ pager_read_page (struct user_pager_info *upi,
}
/* For pager PAGER, synchronously write one page from BUF to offset PAGE. In
- addition, vm_deallocate (or equivalent) BUF. The only permissable error
+ addition, vm_deallocate (or equivalent) BUF. The only permissible error
returns are EIO, EDQUOT, and ENOSPC. */
error_t
pager_write_page (struct user_pager_info *upi,
diff --git a/sutils/clookup.c b/sutils/clookup.c
index 8fe015e1..0107799c 100644
--- a/sutils/clookup.c
+++ b/sutils/clookup.c
@@ -36,7 +36,7 @@
any passive translators. If a node with an unstarted passive translator
is encountered, ENXIO is returned in ERRNO; other errors are as for
file_name_lookup. Note that checking for an active translator currently
- requires fetching the control port, which is a priveleged operation. */
+ requires fetching the control port, which is a privileged operation. */
file_t
file_name_lookup_carefully (const char *name, int flags, mode_t mode)
{
diff --git a/sutils/e2os.sh b/sutils/e2os.sh
index 10fe5087..60c9e017 100755
--- a/sutils/e2os.sh
+++ b/sutils/e2os.sh
@@ -93,7 +93,7 @@ $DD 2>"$ERRS" if="$DEVICE" of="$SB" bs=1k skip=1 count=1 \
# Extract a word of SZ bytes from byte offset POS in the superblock
# Optional arg FMT is what format to use (x = hex, d = decimal)
-function sbget
+sbget ()
{
local pos="$1" sz="$2" fmt="${3-d}"
pos=$(($pos / $sz))
@@ -103,7 +103,7 @@ function sbget
}
# Set a word of SZ bytes at byte offset POS in the superblock to VAL
-function sbset
+sbset ()
{
local pos="$1" sz="$2" val="$3"
pos=$(($pos / $sz))
diff --git a/sutils/fsck.c b/sutils/fsck.c
index 424e3f17..1ab9caa5 100644
--- a/sutils/fsck.c
+++ b/sutils/fsck.c
@@ -41,7 +41,7 @@
Although it knows something about the hurd, this fsck still uses
/etc/fstab, and is generally not very integrated. That will have to wait
- until the appropiate mechanisms for doing so are decided. */
+ until the appropriate mechanisms for doing so are decided. */
#include <stdlib.h>
#include <string.h>
diff --git a/sutils/fstab.c b/sutils/fstab.c
index e40572e2..b66e5195 100644
--- a/sutils/fstab.c
+++ b/sutils/fstab.c
@@ -497,7 +497,29 @@ fstab_find_mount (const struct fstab *fstab, const char *name)
inline struct fs *
fstab_find (const struct fstab *fstab, const char *name)
{
- return fstab_find_device (fstab, name) ?: fstab_find_mount (fstab, name);
+ struct fs *ret;
+ const char *real_name;
+
+ ret = fstab_find_device (fstab, name);
+ if (ret)
+ return ret;
+
+ ret = fstab_find_mount (fstab, name);
+ if (ret)
+ return ret;
+
+ real_name = realpath (name, NULL);
+
+ ret = fstab_find_device (fstab, real_name);
+ if (ret) {
+ free (real_name);
+ return ret;
+ }
+
+ ret = fstab_find_mount (fstab, real_name);
+ free (real_name);
+
+ return ret;
}
/* Cons FS onto the beginning of FSTAB's entry list. */
@@ -571,7 +593,7 @@ fstab_add_mntent (struct fstab *const fstab, const struct mntent *mntent,
free (fs);
}
- if (!err && mounted_fs)
+ if (!err && mounted_fs && mounted_fs != fs)
/* Get rid of the conflicting entry MOUNTED_FS. */
fs_free (mounted_fs);
diff --git a/tasks b/tasks
index 0637a880..871bde17 100644
--- a/tasks
+++ b/tasks
@@ -94,7 +94,7 @@ Please discuss proposed microkernel work with thomas@gnu.org.
can be device_open'd, as well as to get the type of a device.
* A way to have the kernel send a message on some designated port
- everytime a new task is started.
+ every time a new task is started.
* OSF has enhanced the exception_raise protocol to include thread_state
information. This code should be merged into the kernel; OSF people
diff --git a/term/Makefile b/term/Makefile
index 8b287f36..e13763a1 100644
--- a/term/Makefile
+++ b/term/Makefile
@@ -22,7 +22,7 @@ dir := term
makemode := server
target = term
-SRCS = devio.c munge.c users.c main.c ptyio.c hurdio.c
+SRCS = devio.c munge.c users.c main.c ptyio.c hurdio.c xinl.c
LCLHDRS = term.h
DIST_FILES = ourmsg.defs
diff --git a/term/main.c b/term/main.c
index 516a2dcf..405e7cd8 100644
--- a/term/main.c
+++ b/term/main.c
@@ -405,7 +405,7 @@ main (int argc, char **argv)
}
if (err)
- error (1, err, peer_name);
+ error (1, err, "%s", peer_name);
(*peercntl)->hook = peer_name;
ports_port_deref (*peercntl);
diff --git a/term/munge.c b/term/munge.c
index 74d82888..660a99bd 100644
--- a/term/munge.c
+++ b/term/munge.c
@@ -582,7 +582,7 @@ input_character (int c)
echo_char (c, 0, 0);
if (CCEQ (cc[VEOF], c) && (lflag & ECHO))
{
- /* Special bizzare echo processing for VEOF character. */
+ /* Special bizarre echo processing for VEOF character. */
int n;
n = echo_double (c, 0) ? 2 : output_width (c, output_psize);
while (n--)
@@ -642,7 +642,7 @@ input_break ()
enqueue_quote (qp, '\0');
}
-/* Called when a character is recived with a framing error. */
+/* Called when a character is received with a framing error. */
void
input_framing_error (int c)
{
diff --git a/term/term.h b/term/term.h
index 8448d78e..81d0efee 100644
--- a/term/term.h
+++ b/term/term.h
@@ -25,8 +25,15 @@
#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>
+#include <features.h>
#include <hurd/hurd_types.h>
+#ifdef TERM_DEFINE_EI
+#define TERM_EI
+#else
+#define TERM_EI __extern_inline
+#endif
+
#undef MDMBUF
#undef ECHO
#undef TOSTOP
@@ -184,34 +191,49 @@ struct queue
struct queue *create_queue (int size, int lowat, int hiwat);
+extern int qsize (struct queue *q);
+extern int qavail (struct queue *q);
+extern void clear_queue (struct queue *q);
+extern quoted_char dequeue_quote (struct queue *q);
+extern char dequeue (struct queue *q);
+extern void enqueue_internal (struct queue **qp, quoted_char c);
+extern void enqueue (struct queue **qp, char c);
+extern void enqueue_quote (struct queue **qp, char c);
+extern char unquote_char (quoted_char c);
+extern int char_quoted_p (quoted_char c);
+extern short queue_erase (struct queue *q);
+
+#if defined(__USE_EXTERN_INLINES) || defined(TERM_DEFINE_EI)
/* Return the number of characters in Q. */
-extern inline int
+TERM_EI int
qsize (struct queue *q)
{
return q->ce - q->cs;
}
/* Return nonzero if characters can be added to Q. */
-extern inline int
+TERM_EI int
qavail (struct queue *q)
{
return !q->susp;
}
/* Flush all the characters from Q. */
-extern inline void
+TERM_EI void
clear_queue (struct queue *q)
{
q->susp = 0;
q->cs = q->ce = q->array;
condition_broadcast (q->wait);
}
+#endif /* Use extern inlines. */
/* Should be below, but inlines need it. */
void call_asyncs (int dir);
+#if defined(__USE_EXTERN_INLINES) || defined(TERM_DEFINE_EI)
/* Return the next character off Q; leave the quoting bit on. */
-extern inline quoted_char
+TERM_EI quoted_char
dequeue_quote (struct queue *q)
{
int beep = 0;
@@ -234,16 +256,18 @@ dequeue_quote (struct queue *q)
}
/* Return the next character off Q. */
-extern inline char
+TERM_EI char
dequeue (struct queue *q)
{
return dequeue_quote (q) & ~QUEUE_QUOTE_MARK;
}
+#endif /* Use extern inlines. */
struct queue *reallocate_queue (struct queue *);
+#if defined(__USE_EXTERN_INLINES) || defined(TERM_DEFINE_EI)
/* Add C to *QP. */
-extern inline void
+TERM_EI void
enqueue_internal (struct queue **qp, quoted_char c)
{
struct queue *q = *qp;
@@ -265,28 +289,28 @@ enqueue_internal (struct queue **qp, quoted_char c)
}
/* Add C to *QP. */
-extern inline void
+TERM_EI void
enqueue (struct queue **qp, char c)
{
enqueue_internal (qp, c);
}
/* Add C to *QP, marking it with a quote. */
-extern inline void
+TERM_EI void
enqueue_quote (struct queue **qp, char c)
{
enqueue_internal (qp, c | QUEUE_QUOTE_MARK);
}
/* Return the unquoted version of a quoted_char. */
-extern inline char
+TERM_EI char
unquote_char (quoted_char c)
{
return c & ~QUEUE_QUOTE_MARK;
}
/* Tell if a quoted_char is actually quoted. */
-extern inline int
+TERM_EI int
char_quoted_p (quoted_char c)
{
return c & QUEUE_QUOTE_MARK;
@@ -294,7 +318,7 @@ char_quoted_p (quoted_char c)
/* Remove the most recently enqueue character from Q; leaving
the quote mark on. */
-extern inline short
+TERM_EI short
queue_erase (struct queue *q)
{
short answer;
@@ -313,6 +337,7 @@ queue_erase (struct queue *q)
condition_broadcast (q->wait);
return answer;
}
+#endif /* Use extern inlines. */
/* Functions devio is supposed to call */
diff --git a/term/users.c b/term/users.c
index a4e110b4..4ec2b810 100644
--- a/term/users.c
+++ b/term/users.c
@@ -678,7 +678,7 @@ trivfs_S_io_read (struct trivfs_protid *cred,
while (!qsize (inputq))
{
- if ((termflags & NO_CARRIER) && !(termstate.c_cflag & CLOCAL))
+ if ((termflags & NO_CARRIER) && !(termstate.c_cflag & CLOCAL) || !amount)
{
/* Return EOF, Posix.1 7.1.1.10. */
mutex_unlock (&global_lock);
diff --git a/term/xinl.c b/term/xinl.c
new file mode 100644
index 00000000..3695faa5
--- /dev/null
+++ b/term/xinl.c
@@ -0,0 +1,2 @@
+#define TERM_DEFINE_EI
+#include "term.h"
diff --git a/tmpfs/dir.c b/tmpfs/dir.c
index 65386e0a..c0ae9785 100644
--- a/tmpfs/dir.c
+++ b/tmpfs/dir.c
@@ -29,6 +29,12 @@ diskfs_init_dir (struct node *dp, struct node *pdp, struct protid *cred)
{
dp->dn->u.dir.dotdot = pdp->dn;
dp->dn->u.dir.entries = 0;
+
+ /* Increase hardlink count for parent directory */
+ pdp->dn_stat.st_nlink++;
+ /* Take '.' directory into account */
+ dp->dn_stat.st_nlink++;
+
return 0;
}
@@ -40,6 +46,12 @@ diskfs_clear_directory (struct node *dp, struct node *pdp,
return ENOTEMPTY;
assert (dp->dn_stat.st_size == 0);
assert (dp->dn->u.dir.dotdot == pdp->dn);
+
+ /* Decrease hardlink count for parent directory */
+ pdp->dn_stat.st_nlink--;
+ /* Take '.' directory into account */
+ dp->dn_stat.st_nlink--;
+
return 0;
}
@@ -138,6 +150,7 @@ diskfs_get_directs (struct node *dp, int entry, int n,
struct dirstat
{
struct tmpfs_dirent **prevp;
+ int dotdot;
};
const size_t diskfs_dirstat_size = sizeof (struct dirstat);
@@ -166,6 +179,9 @@ diskfs_lookup_hard (struct node *dp,
if (type == REMOVE || type == RENAME)
assert (np);
+ if (ds)
+ ds->dotdot = type & SPEC_DOTDOT;
+
if (namelen == 1 && name[0] == '.')
{
if (np != 0)
@@ -267,7 +283,11 @@ error_t
diskfs_dirrewrite_hard (struct node *dp, struct node *np,
struct dirstat *ds)
{
- (*ds->prevp)->dn = np->dn;
+ if (ds->dotdot)
+ dp->dn->u.dir.dotdot = np->dn;
+ else
+ (*ds->prevp)->dn = np->dn;
+
return 0;
}
diff --git a/tmpfs/node.c b/tmpfs/node.c
index 17fe8ce7..bce15370 100644
--- a/tmpfs/node.c
+++ b/tmpfs/node.c
@@ -332,6 +332,7 @@ static error_t
create_symlink_hook (struct node *np, const char *target)
{
assert (np->dn->u.lnk == 0);
+ np->dn_stat.st_size = strlen (target);
if (np->dn_stat.st_size > 0)
{
const size_t size = np->dn_stat.st_size + 1;
@@ -339,6 +340,7 @@ create_symlink_hook (struct node *np, const char *target)
if (np->dn->u.lnk == 0)
return ENOSPC;
memcpy (np->dn->u.lnk, target, size);
+ np->dn->type = DT_LNK;
adjust_used (size);
recompute_blocks (np);
}
@@ -382,9 +384,6 @@ diskfs_node_reload (struct node *node)
error_t
diskfs_truncate (struct node *np, off_t size)
{
- if (np->allocsize <= size)
- return 0;
-
if (np->dn->type == DT_LNK)
{
free (np->dn->u.lnk);
@@ -394,6 +393,9 @@ diskfs_truncate (struct node *np, off_t size)
return 0;
}
+ if (np->allocsize <= size)
+ return 0;
+
assert (np->dn->type == DT_REG);
if (default_pager == MACH_PORT_NULL)
@@ -401,13 +403,12 @@ diskfs_truncate (struct node *np, off_t size)
np->dn_stat.st_size = size;
+ off_t set_size = size;
size = round_page (size);
- if (size == np->allocsize)
- return 0;
if (np->dn->u.reg.memobj != MACH_PORT_NULL)
{
- error_t err = default_pager_object_set_size (np->dn->u.reg.memobj, size);
+ error_t err = default_pager_object_set_size (np->dn->u.reg.memobj, set_size);
if (err == MIG_BAD_ID)
/* This is an old default pager. We have no way to truncate the
memory object. Note that the behavior here will be wrong in
@@ -440,8 +441,10 @@ diskfs_grow (struct node *np, off_t size, struct protid *cred)
if (np->allocsize >= size)
return 0;
+ off_t set_size = size;
size = round_page (size);
- if (round_page (tmpfs_space_used + size) / vm_page_size > tmpfs_page_limit)
+ if (round_page (tmpfs_space_used + size - np->allocsize)
+ / vm_page_size > tmpfs_page_limit)
return ENOSPC;
if (default_pager == MACH_PORT_NULL)
@@ -450,7 +453,7 @@ diskfs_grow (struct node *np, off_t size, struct protid *cred)
if (np->dn->u.reg.memobj != MACH_PORT_NULL)
{
/* Increase the limit the memory object will allow to be accessed. */
- error_t err = default_pager_object_set_size (np->dn->u.reg.memobj, size);
+ error_t err = default_pager_object_set_size (np->dn->u.reg.memobj, set_size);
if (err == MIG_BAD_ID) /* Old default pager, never limited it. */
err = 0;
if (err)
@@ -498,17 +501,13 @@ diskfs_get_filemap (struct node *np, vm_prot_t prot)
return MACH_PORT_NULL;
}
assert (np->dn->u.reg.memobj != MACH_PORT_NULL);
- /* A new-fangled default pager lets us prevent user accesses
- past the specified size of the file. */
- err = default_pager_object_set_size (np->dn->u.reg.memobj,
- np->allocsize);
- assert_perror (err);
/* XXX we need to keep a reference to the object, or GNU Mach
will terminate it when we release the map. */
vm_map (mach_task_self (), &np->dn->u.reg.memref, 4096, 0, 1,
np->dn->u.reg.memobj, 0, 0, VM_PROT_NONE, VM_PROT_NONE,
VM_INHERIT_NONE);
+ assert_perror (err);
}
/* XXX always writable */
diff --git a/tmpfs/pager-stubs.c b/tmpfs/pager-stubs.c
index 361724a9..25d70fe2 100644
--- a/tmpfs/pager-stubs.c
+++ b/tmpfs/pager-stubs.c
@@ -24,7 +24,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* The user must define this function. For pager PAGER, read one
page from offset PAGE. Set *BUF to be the address of the page,
and set *WRITE_LOCK if the page must be provided read-only.
- The only permissable error returns are EIO, EDQUOT, and ENOSPC. */
+ The only permissible error returns are EIO, EDQUOT, and ENOSPC. */
error_t
pager_read_page (struct user_pager_info *pager,
vm_offset_t page,
@@ -37,7 +37,7 @@ pager_read_page (struct user_pager_info *pager,
/* The user must define this function. For pager PAGER, synchronously
write one page from BUF to offset PAGE. In addition, mfree
- (or equivalent) BUF. The only permissable error returns are EIO,
+ (or equivalent) BUF. The only permissible error returns are EIO,
EDQUOT, and ENOSPC. */
error_t
pager_write_page (struct user_pager_info *pager,
diff --git a/tmpfs/tmpfs.c b/tmpfs/tmpfs.c
index cd67dd74..b72459fe 100644
--- a/tmpfs/tmpfs.c
+++ b/tmpfs/tmpfs.c
@@ -255,6 +255,30 @@ diskfs_append_args (char **argz, size_t *argz_len)
return err;
}
+/* Handling of operations for the ports in diskfs_port_bucket, calling
+ * demuxer for each incoming message */
+static any_t
+diskfs_thread_function (any_t demuxer)
+{
+ error_t err;
+
+ do
+ {
+ ports_manage_port_operations_multithread (diskfs_port_bucket,
+ (ports_demuxer_type) demuxer,
+ 0,
+ 0,
+ 0);
+ err = diskfs_shutdown (0);
+ }
+ while (err);
+
+ exit (0);
+ /* NOTREACHED */
+ return (any_t) 0;
+}
+
+
/* Add our startup arguments to the standard diskfs set. */
static const struct argp_child startup_children[] =
{{&diskfs_startup_argp}, {0}};
@@ -317,7 +341,9 @@ main (int argc, char **argv)
if (err)
error (4, err, "cannot create root directory");
- diskfs_spawn_first_thread (diskfs_demuxer);
+ /* Like diskfs_spawn_first_thread. But do it manually, without timeout */
+ cthread_detach (cthread_fork ((cthread_fn_t) diskfs_thread_function,
+ (any_t) diskfs_demuxer));
/* Now that we are all set up to handle requests, and diskfs_root_node is
set properly, it is safe to export our fsys control port to the
diff --git a/trans/Makefile b/trans/Makefile
index 8eb6c78e..4e6a22dd 100644
--- a/trans/Makefile
+++ b/trans/Makefile
@@ -46,6 +46,7 @@ proxy-defpager crash password streamio: ../libthreads/libthreads.a ../libports/l
fifo new-fifo: ../libpipe/libpipe.a
fwd: ../libfshelp/libfshelp.a ../libports/libports.a
hello-mt magic null ifsock fifo new-fifo firmlink: ../libtrivfs/libtrivfs.a ../libfshelp/libfshelp.a ../libthreads/libthreads.a ../libports/libports.a ../libihash/libihash.a
+magic: ../libiohelp/libiohelp.a
hello: ../libtrivfs/libtrivfs.a ../libfshelp/libfshelp.a ../libports/libports.a ../libihash/libihash.a
fakeroot: ../libnetfs/libnetfs.a ../libfshelp/libfshelp.a ../libiohelp/libiohelp.a ../libthreads/libthreads.a ../libports/libports.a ../libihash/libihash.a
$(targets): ../libshouldbeinlibc/libshouldbeinlibc.a
diff --git a/trans/proxy-defpager.c b/trans/proxy-defpager.c
index cda79592..0a5ab65e 100644
--- a/trans/proxy-defpager.c
+++ b/trans/proxy-defpager.c
@@ -107,7 +107,6 @@ S_default_pager_paging_storage (mach_port_t default_pager,
kern_return_t
S_default_pager_object_set_size (mach_port_t memory_object,
- mach_port_t reply_port,
mach_port_seqno_t seqno,
vm_size_t object_size_limit)
{
diff --git a/trans/streamio.c b/trans/streamio.c
index 0faa8a3e..c563c03c 100644
--- a/trans/streamio.c
+++ b/trans/streamio.c
@@ -554,8 +554,7 @@ trivfs_S_io_select (struct trivfs_protid *cred,
if (!(cred->po->openmodes & O_WRITE) && (*type & SELECT_WRITE))
return EBADF;
- if (*type & ~(SELECT_READ | SELECT_WRITE))
- return EINVAL;
+ *type &= SELECT_READ | SELECT_WRITE;
if (*type == 0)
return 0;
diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c
index 5e081fe8..14705f84 100644
--- a/ufs-fsck/utilities.c
+++ b/ufs-fsck/utilities.c
@@ -270,7 +270,7 @@ retch (char *reason)
static void
punt (char *msg)
{
- problem (0, msg);
+ problem (0, "%s", msg);
flush_problems ();
exit (8);
}
diff --git a/ufs/Makefile b/ufs/Makefile
index 02cf38ba..cf5c40d7 100644
--- a/ufs/Makefile
+++ b/ufs/Makefile
@@ -21,7 +21,7 @@ makemode := server
target = ufs
SRCS = alloc.c consts.c dir.c hyper.c inode.c main.c pager.c \
- sizes.c subr.c tables.c bmap.c pokeloc.c
+ sizes.c subr.c tables.c bmap.c pokeloc.c xinl.c
LCLHDRS = ufs.h fs.h dinode.h dir.h
OBJS = $(SRCS:.c=.o)
diff --git a/ufs/alloc.c b/ufs/alloc.c
index 48ee60cc..d8f92255 100644
--- a/ufs/alloc.c
+++ b/ufs/alloc.c
@@ -215,7 +215,7 @@ release_cg (struct cg *cgp)
* 3) allocate a block in the same cylinder group.
* 4) quadradically rehash into other cylinder groups, until an
* available block is located.
- * If no block preference is given the following heirarchy is used
+ * If no block preference is given the following hierarchy is used
* to allocate a block:
* 1) allocate a block in the cylinder group that contains the
* inode for the file.
@@ -472,7 +472,7 @@ nospace:
* logical blocks to be made contiguous is given. The allocator attempts
* to find a range of sequential blocks starting as close as possible to
* an fs_rotdelay offset from the end of the allocation for the logical
- * block immediately preceeding the current range. If successful, the
+ * block immediately preceding the current range. If successful, the
* physical block numbers in the buffer pointers and in the inode are
* changed to reflect the new allocation. If unsuccessful, the allocation
* is left unchanged. The success in doing the reallocation is returned.
@@ -638,7 +638,7 @@ fail:
* 2) allocate an inode in the same cylinder group.
* 3) quadradically rehash into other cylinder groups, until an
* available inode is located.
- * If no inode preference is given the following heirarchy is used
+ * If no inode preference is given the following hierarchy is used
* to allocate an inode:
* 1) allocate an inode in cylinder group 0.
* 2) quadradically rehash into other cylinder groups, until an
diff --git a/ufs/dir.c b/ufs/dir.c
index 7a8cfa55..3c5f152a 100644
--- a/ufs/dir.c
+++ b/ufs/dir.c
@@ -664,7 +664,7 @@ diskfs_direnter_hard(struct node *dp,
/* Following a lookup call for REMOVE, this removes the link from the
directory. DP is the directory being changed and DS is the cached
information returned from lookup. This call is only valid if the
- directory has been locked continously since the call to lookup, and
+ directory has been locked continuously since the call to lookup, and
only if that call succeeded. */
error_t
diskfs_dirremove_hard(struct node *dp,
diff --git a/ufs/inode.c b/ufs/inode.c
index 1a8a7098..77a45edb 100644
--- a/ufs/inode.c
+++ b/ufs/inode.c
@@ -181,7 +181,7 @@ diskfs_lost_hardrefs (struct node *np)
spin_unlock (&_libports_portrefcntlock);
/* Right now the node is locked with no hard refs;
- this is an anomolous situation. Before messing with
+ this is an anomalous situation. Before messing with
the reference count on the file pager, we have to
give ourselves a reference back so that we are really
allowed to hold the lock. Then we can do the
diff --git a/ufs/ufs.h b/ufs/ufs.h
index 5d823ebc..f59784d5 100644
--- a/ufs/ufs.h
+++ b/ufs/ufs.h
@@ -25,9 +25,16 @@
#include <hurd/diskfs.h>
#include <sys/mman.h>
#include <assert.h>
+#include <features.h>
#include "fs.h"
#include "dinode.h"
+#ifdef UFS_DEFINE_EI
+#define UFS_EI
+#else
+#define UFS_EI __extern_inline
+#endif
+
/* Define this if memory objects should not be cached by the kernel.
Normally, don't define it, but defining it causes a much greater rate
of paging requests, which may be helpful in catching bugs. */
@@ -150,8 +157,18 @@ unsigned log2_dev_blocks_per_dev_bsize;
/* Functions for looking inside disk_image */
+extern struct dinode * dino (ino_t inum);
+extern daddr_t * indir_block (daddr_t bno);
+extern struct cg * cg_locate (int ncg);
+extern void sync_disk_blocks (daddr_t blkno, size_t nbytes, int wait);
+extern void sync_dinode (int inum, int wait);
+extern short swab_short (short arg);
+extern long swab_long (long arg);
+extern long long swab_long_long (long long arg);
+
+#if defined(__USE_EXTERN_INLINES) || defined(UFS_DEFINE_EI)
/* Convert an inode number to the dinode on disk. */
-extern inline struct dinode *
+UFS_EI struct dinode *
dino (ino_t inum)
{
return (struct dinode *)
@@ -161,28 +178,28 @@ dino (ino_t inum)
}
/* Convert a indirect block number to a daddr_t table. */
-extern inline daddr_t *
+UFS_EI daddr_t *
indir_block (daddr_t bno)
{
return (daddr_t *) (disk_image + fsaddr (sblock, bno));
}
/* Convert a cg number to the cylinder group. */
-extern inline struct cg *
+UFS_EI struct cg *
cg_locate (int ncg)
{
return (struct cg *) (disk_image + fsaddr (sblock, cgtod (sblock, ncg)));
}
/* Sync part of the disk */
-extern inline void
+UFS_EI void
sync_disk_blocks (daddr_t blkno, size_t nbytes, int wait)
{
pager_sync_some (diskfs_disk_pager, fsaddr (sblock, blkno), nbytes, wait);
}
/* Sync an disk inode */
-extern inline void
+UFS_EI void
sync_dinode (int inum, int wait)
{
sync_disk_blocks (ino_to_fsba (sblock, inum), sblock->fs_fsize, wait);
@@ -190,26 +207,27 @@ sync_dinode (int inum, int wait)
/* Functions for byte swapping */
-extern inline short
+UFS_EI short
swab_short (short arg)
{
return (((arg & 0xff) << 8)
| ((arg & 0xff00) >> 8));
}
-extern inline long
+UFS_EI long
swab_long (long arg)
{
return (((long) swab_short (arg & 0xffff) << 16)
| swab_short ((arg & 0xffff0000) >> 16));
}
-extern inline long long
+UFS_EI long long
swab_long_long (long long arg)
{
return (((long long) swab_long (arg & 0xffffffff) << 32)
| swab_long ((arg & 0xffffffff00000000LL) >> 32));
}
+#endif /* Use extern inlines. */
/* Return ENTRY, after byteswapping it if necessary */
#define read_disk_entry(entry) \
diff --git a/ufs/xinl.c b/ufs/xinl.c
new file mode 100644
index 00000000..7994a1f7
--- /dev/null
+++ b/ufs/xinl.c
@@ -0,0 +1,2 @@
+#define UFS_DEFINE_EI
+#include "ufs.h"
diff --git a/utils/devprobe.c b/utils/devprobe.c
index b5ebafe4..d7020322 100644
--- a/utils/devprobe.c
+++ b/utils/devprobe.c
@@ -35,7 +35,7 @@ static const struct argp_option options[] = {
{0}
};
static const char *args_doc = "DEVNAME...";
-static const char *doc = "Test for the existance of mach device DEVNAME..."
+static const char *doc = "Test for the existence of mach device DEVNAME..."
"\vThe exit status is 0 if any devices were found.";
int
diff --git a/utils/ftpcp.c b/utils/ftpcp.c
index 4c4c151a..67ccb1a0 100644
--- a/utils/ftpcp.c
+++ b/utils/ftpcp.c
@@ -240,7 +240,7 @@ efinish (struct epoint *e)
}
/* Give a name which refers to a directory file, and a name in that
- directory, this should return in COMPOSITE the composite name refering to
+ directory, this should return in COMPOSITE the composite name referring to
that name in that directory, in malloced storage. */
error_t
eappend (struct epoint *e,
diff --git a/utils/ftpdir.c b/utils/ftpdir.c
index 9b496add..4ccb821d 100644
--- a/utils/ftpdir.c
+++ b/utils/ftpdir.c
@@ -39,7 +39,7 @@ static struct argp_option options[] =
{"account", 'a', "ACCT",0, "Account to login as"},
{"separator",'S', "SEP", 0, "String to separate multiple listings"},
{"prefix", 'P', "PFX", 0, "String to proceed listings; the first and second"
- " occurances of %s are replace by HOST and DIR"},
+ " occurrences of %s are replace by HOST and DIR"},
{"host", 'h', "HOST",0, "Use HOST as a default host"},
{"debug", 'D', 0, 0, "Turn on debugging output for ftp connections"},
{"intepret", 'i', 0, 0, "Parse the directory output"},
diff --git a/utils/login.c b/utils/login.c
index aefc2187..cad3b1ed 100644
--- a/utils/login.c
+++ b/utils/login.c
@@ -663,7 +663,7 @@ main(int argc, char *argv[])
if (ugids.eff_uids.num + ugids.avail_uids.num == 0)
/* We're transiting from having some uids to having none, which means
this is probably a new login session. Unless specified otherwise,
- set a timer to kill this session if it hasn't aquired any ids by
+ set a timer to kill this session if it hasn't acquired any ids by
then. Note that we fork off the timer process before clearing the
process owner: because we're interested in killing unowned
processes, proc's in-same-login-session rule should apply to us
diff --git a/utils/mount.c b/utils/mount.c
index e9f64d85..8b059c23 100644
--- a/utils/mount.c
+++ b/utils/mount.c
@@ -48,7 +48,7 @@ static const struct argp_option argp_opts[] =
{"timeout", 'T', "MILLISECONDS", 0, "Timeout for translator startup"},
{"format", 'p', "mount|fstab|translator", OPTION_ARG_OPTIONAL,
"Output format for query (no filesystem arguments)"},
- {"options", 'o', "OPTIONS", 0, "A `,' seperated list of options"},
+ {"options", 'o', "OPTIONS", 0, "A `,' separated list of options"},
{"readonly", 'r', 0, 0, "Never write to disk or allow opens for writing"},
{"writable", 'w', 0, 0, "Use normal read/write behavior"},
{"update", 'u', 0, 0, "Flush any meta-data cached in core"},
diff --git a/utils/shd.c b/utils/shd.c
index 0587fa42..a1a4b26b 100644
--- a/utils/shd.c
+++ b/utils/shd.c
@@ -86,7 +86,7 @@ run (char **argv, int fd0, int fd1)
file = file_name_lookup (program, O_EXEC, 0);
if (file == MACH_PORT_NULL)
{
- error (0, errno, program);
+ error (0, errno, "%s", program);
return -1;
}
else
diff --git a/utils/storeinfo.c b/utils/storeinfo.c
index 411bf11a..a738d50d 100644
--- a/utils/storeinfo.c
+++ b/utils/storeinfo.c
@@ -204,7 +204,7 @@ main (int argc, char *argv[])
struct store *store;
if (file == MACH_PORT_NULL)
- error (3, err, source);
+ error (3, err, "%s", source);
if (print_prefix < 0)
/* By default, only print filename prefixes for multiple files. */
@@ -220,7 +220,7 @@ main (int argc, char *argv[])
of what the unknown data looked like. */
err = store_create (file, STORE_INACTIVE|STORE_NO_FILEIO, 0, &store);
if (err)
- error (4, err, source);
+ error (4, err, "%s", source);
print_store (store, 0, what);
store_free (store);
diff --git a/utils/vmstat.c b/utils/vmstat.c
index 86494dce..7d852992 100644
--- a/utils/vmstat.c
+++ b/utils/vmstat.c
@@ -111,7 +111,7 @@ print_val (val_t val, enum val_type type,
float fval = val;
char *units = " KMGT", *u = units;
- while (fval > 1024)
+ while (fval >= 10000)
{
fval /= 1024;
u++;
@@ -456,7 +456,7 @@ main (int argc, char **argv)
if (field->standard)
output_fields |= (1 << (field - fields));
- /* Returns an appropiate SIZE_UNITS for printing FIELD. */
+ /* Returns an appropriate SIZE_UNITS for printing FIELD. */
#define SIZE_UNITS(field) \
(size_units >= 0 \
? size_units \
diff --git a/utils/w.c b/utils/w.c
index 43bce025..37555088 100644
--- a/utils/w.c
+++ b/utils/w.c
@@ -253,7 +253,7 @@ static void
add_utmp_procs (struct proc_stat_list *procs, struct utmp *u)
{
/* The tty name, with space for '\0' termination and an
- appropiate prefix. */
+ appropriate prefix. */
char tty[sizeof _PATH_DEV + sizeof u->ut_line];
io_t tty_node;
error_t err;